2 * W.J. van der Laan 2011
4 #include "BitcoinGUI.h"
5 #include "TransactionTableModel.h"
7 #include <QApplication>
13 #include <QVBoxLayout>
20 #include <QPushButton>
24 BitcoinGUI::BitcoinGUI(QWidget *parent):
28 setWindowTitle("Bitcoin");
29 setWindowIcon(QIcon("bitcoin.png"));
31 QAction *quit = new QAction(QIcon("quit.png"), "&Quit", this);
32 QAction *sendcoins = new QAction(QIcon("send.png"), "&Send coins", this);
33 QAction *addressbook = new QAction(QIcon("address-book.png"), "&Address book", this);
34 QAction *about = new QAction(QIcon("bitcoin.png"), "&About", this);
37 QMenu *file = menuBar()->addMenu("&File");
38 file->addAction(sendcoins);
40 file->addAction(quit);
42 QMenu *settings = menuBar()->addMenu("&Settings");
43 settings->addAction(addressbook);
45 QMenu *help = menuBar()->addMenu("&Help");
46 help->addAction(about);
49 QToolBar *toolbar = addToolBar("Main toolbar");
50 toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
51 toolbar->addAction(sendcoins);
52 toolbar->addAction(addressbook);
54 /* Address: <address>: New... : Paste to clipboard */
55 QHBoxLayout *hbox_address = new QHBoxLayout();
56 hbox_address->addWidget(new QLabel(tr("Your Bitcoin Address:")));
57 QLineEdit *edit_address = new QLineEdit();
58 edit_address->setReadOnly(true);
59 hbox_address->addWidget(edit_address);
61 QPushButton *button_new = new QPushButton(trUtf8("&New\u2026"));
62 QPushButton *button_clipboard = new QPushButton(tr("&Copy to clipboard"));
63 hbox_address->addWidget(button_new);
64 hbox_address->addWidget(button_clipboard);
66 /* Balance: <balance> */
67 QHBoxLayout *hbox_balance = new QHBoxLayout();
68 hbox_balance->addWidget(new QLabel("Balance:"));
69 hbox_balance->addSpacing(5);/* Add some spacing between the label and the text */
70 QLabel *label_balance = new QLabel("1,234.54");
71 label_balance->setFont(QFont("Teletype"));
72 hbox_balance->addWidget(label_balance);
73 hbox_balance->addStretch(1);
76 QVBoxLayout *vbox = new QVBoxLayout();
77 vbox->addLayout(hbox_address);
78 vbox->addLayout(hbox_balance);
85 * QAbstractItemView::SelectItems
86 * QAbstractItemView::ExtendedSelection
88 QTableView *transaction_table = new QTableView(this);
89 TransactionTableModel *transaction_model = new TransactionTableModel(this);
90 transaction_table->setModel(transaction_model);
92 QTabBar *tabs = new QTabBar(this);
93 tabs->addTab("All transactions");
94 tabs->addTab("Sent/Received");
96 tabs->addTab("Received");
98 vbox->addWidget(tabs);
99 vbox->addWidget(transaction_table);
101 QWidget *centralwidget = new QWidget(this);
102 centralwidget->setLayout(vbox);
103 setCentralWidget(centralwidget);
108 QLabel *label_connections = new QLabel("6 connections", this);
109 label_connections->setFrameStyle(QFrame::Panel | QFrame::Sunken);
110 label_connections->setMinimumWidth(100);
112 QLabel *label_blocks = new QLabel("6 blocks", this);
113 label_blocks->setFrameStyle(QFrame::Panel | QFrame::Sunken);
114 label_blocks->setMinimumWidth(100);
116 QLabel *label_transactions = new QLabel("6 transactions", this);
117 label_transactions->setFrameStyle(QFrame::Panel | QFrame::Sunken);
118 label_transactions->setMinimumWidth(100);
121 statusBar()->addPermanentWidget(label_connections);
122 statusBar()->addPermanentWidget(label_blocks);
123 statusBar()->addPermanentWidget(label_transactions);
126 /* Action bindings */
128 connect(quit, SIGNAL(triggered()), qApp, SLOT(quit()));
129 connect(tabs, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int)));
132 void BitcoinGUI::currentChanged(int tab)
134 std::cout << "Switched to tab: " << tab << std::endl;