diff --git a/bitcoin-qt.pro b/bitcoin-qt.pro index 40c0ded6..a8705c36 100644 --- a/bitcoin-qt.pro +++ b/bitcoin-qt.pro @@ -76,7 +76,8 @@ HEADERS += src/qt/bitcoingui.h \ src/qt/transactionfilterproxy.h \ src/qt/transactionview.h \ src/qt/walletmodel.h \ - src/bitcoinrpc.h + src/bitcoinrpc.h \ + src/qt/overviewpage.h SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \ src/qt/transactiontablemodel.cpp \ src/qt/addresstablemodel.cpp \ @@ -112,7 +113,8 @@ SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \ src/qt/transactionfilterproxy.cpp \ src/qt/transactionview.cpp \ src/qt/walletmodel.cpp \ - src/bitcoinrpc.cpp + src/bitcoinrpc.cpp \ + src/qt/overviewpage.cpp RESOURCES += \ src/qt/bitcoin.qrc @@ -122,7 +124,8 @@ FORMS += \ src/qt/forms/addressbookdialog.ui \ src/qt/forms/aboutdialog.ui \ src/qt/forms/editaddressdialog.ui \ - src/qt/forms/transactiondescdialog.ui + src/qt/forms/transactiondescdialog.ui \ + src/qt/forms/overviewpage.ui CODECFORTR = UTF-8 TRANSLATIONS = src/qt/locale/bitcoin_nl.ts diff --git a/doc/assets-attribution.txt b/doc/assets-attribution.txt index f34c2c91..d4eb8488 100644 --- a/doc/assets-attribution.txt +++ b/doc/assets-attribution.txt @@ -34,7 +34,7 @@ Designer: http://www.everaldo.com Icon Pack: Crystal SVG License: LGPL -Icon: src/qt/res/icons/receive.png +Icon: src/qt/res/icons/receive.png, src/qt/res/icons/history.png Designer: Oxygen team Icon Pack: Oxygen License: Creative Common Attribution-ShareAlike 3.0 License or LGPL @@ -45,3 +45,9 @@ Designer: Bitboy (optimized for 16x16 by Wladimir van der Laan) License: Public Domain Site: http://forum.bitcoin.org/?topic=1756.0 +Icon: src/qt/res/icons/overview.png +Icon Pack: Primo +Designer: Jack Cai +License: Creative Commons Attribution No Derivatives (by-nd) +Site: http://findicons.com/icon/175944/home?id=176221# + diff --git a/src/qt/bitcoin.qrc b/src/qt/bitcoin.qrc index 2dfc7dd9..20ecd9f3 100644 --- a/src/qt/bitcoin.qrc +++ b/src/qt/bitcoin.qrc @@ -26,6 +26,8 @@ res/icons/toolbar_testnet.png res/icons/edit.png res/icons/editdelete.png + res/icons/history.png + res/icons/overview.png res/images/about.png diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index cd9291ac..bf4aa320 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -17,6 +17,7 @@ #include "transactiondescdialog.h" #include "addresstablemodel.h" #include "transactionview.h" +#include "overviewpage.h" #include #include @@ -33,6 +34,7 @@ #include #include #include +#include #include @@ -66,32 +68,28 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): // Toolbar QToolBar *toolbar = addToolBar("Main toolbar"); toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + toolbar->addAction(overviewAction); + toolbar->addAction(historyAction); + toolbar->addSeparator(); toolbar->addAction(sendCoins); toolbar->addAction(receiveCoins); toolbar->addAction(addressbook); - // Balance: - QHBoxLayout *hbox_balance = new QHBoxLayout(); - hbox_balance->addWidget(new QLabel(tr("Balance:"))); - hbox_balance->addSpacing(5);/* Add some spacing between the label and the text */ - - labelBalance = new QLabel(); - labelBalance->setFont(QFont("Monospace", -1, QFont::Bold)); - labelBalance->setToolTip(tr("Your current balance")); - labelBalance->setTextInteractionFlags(Qt::TextSelectableByMouse|Qt::TextSelectableByKeyboard); - hbox_balance->addWidget(labelBalance); - hbox_balance->addStretch(1); - + overviewPage = new OverviewPage(); + QVBoxLayout *vbox = new QVBoxLayout(); - vbox->addLayout(hbox_balance); transactionView = new TransactionView(this); connect(transactionView, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(transactionDetails(const QModelIndex&))); vbox->addWidget(transactionView); - QWidget *centralwidget = new QWidget(this); - centralwidget->setLayout(vbox); - setCentralWidget(centralwidget); + transactionsPage = new QWidget(this); + transactionsPage->setLayout(vbox); + + centralWidget = new QStackedWidget(this); + centralWidget->addWidget(overviewPage); + centralWidget->addWidget(transactionsPage); + setCentralWidget(centralWidget); // Create status bar statusBar(); @@ -125,10 +123,23 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): statusBar()->addPermanentWidget(labelTransactions); createTrayIcon(); + + gotoOverviewTab(); } void BitcoinGUI::createActions() { + QActionGroup *tabGroup = new QActionGroup(this); + overviewAction = new QAction(QIcon(":/icons/overview"), tr("&Overview"), this); + overviewAction->setCheckable(true); + tabGroup->addAction(overviewAction); + historyAction = new QAction(QIcon(":/icons/history"), tr("&History"), this); + historyAction->setCheckable(true); + tabGroup->addAction(historyAction); + + connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewTab())); + connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryTab())); + quit = new QAction(QIcon(":/icons/quit"), tr("&Exit"), this); quit->setToolTip(tr("Quit application")); sendCoins = new QAction(QIcon(":/icons/send"), tr("&Send coins"), this); @@ -267,7 +278,7 @@ void BitcoinGUI::aboutClicked() void BitcoinGUI::setBalance(qint64 balance) { - labelBalance->setText(GUIUtil::formatMoney(balance) + QString(" BTC")); + overviewPage->setBalance(balance); } void BitcoinGUI::setNumConnections(int count) @@ -399,3 +410,15 @@ void BitcoinGUI::incomingTransaction(const QModelIndex & parent, int start, int QSystemTrayIcon::Information); } } + +void BitcoinGUI::gotoOverviewTab() +{ + overviewAction->setChecked(true); + centralWidget->setCurrentWidget(overviewPage); +} + +void BitcoinGUI::gotoHistoryTab() +{ + historyAction->setChecked(true); + centralWidget->setCurrentWidget(transactionsPage); +} diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 046186c5..432a9e3b 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -8,6 +8,7 @@ class TransactionTableModel; class ClientModel; class WalletModel; class TransactionView; +class OverviewPage; QT_BEGIN_NAMESPACE class QLabel; @@ -16,6 +17,7 @@ class QTableView; class QAbstractItemModel; class QModelIndex; class QProgressBar; +class QStackedWidget; QT_END_NAMESPACE class BitcoinGUI : public QMainWindow @@ -42,7 +44,10 @@ private: ClientModel *clientModel; WalletModel *walletModel; - QLabel *labelBalance; + QStackedWidget *centralWidget; + OverviewPage *overviewPage; + QWidget *transactionsPage; + QLabel *labelConnections; QLabel *labelConnectionsIcon; QLabel *labelBlocks; @@ -50,6 +55,8 @@ private: QLabel *progressBarLabel; QProgressBar *progressBar; + QAction *overviewAction; + QAction *historyAction; QAction *quit; QAction *sendCoins; QAction *addressbook; @@ -86,6 +93,9 @@ private slots: void trayIconActivated(QSystemTrayIcon::ActivationReason reason); void transactionDetails(const QModelIndex& idx); void incomingTransaction(const QModelIndex & parent, int start, int end); + + void gotoOverviewTab(); + void gotoHistoryTab(); }; #endif diff --git a/src/qt/forms/overviewpage.ui b/src/qt/forms/overviewpage.ui new file mode 100644 index 00000000..ef9c0730 --- /dev/null +++ b/src/qt/forms/overviewpage.ui @@ -0,0 +1,63 @@ + + + OverviewPage + + + + 0 + 0 + 552 + 342 + + + + Form + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + Balance + + + + + + + 123.456 BTC + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp new file mode 100644 index 00000000..faed2986 --- /dev/null +++ b/src/qt/overviewpage.cpp @@ -0,0 +1,32 @@ +#include "overviewpage.h" +#include "ui_overviewpage.h" + +#include "guiutil.h" + +OverviewPage::OverviewPage(QWidget *parent) : + QWidget(parent), + ui(new Ui::OverviewPage) +{ + ui->setupUi(this); + + // Balance: + ui->labelBalance->setFont(QFont("Monospace", -1, QFont::Bold)); + ui->labelBalance->setToolTip(tr("Your current balance")); + ui->labelBalance->setTextInteractionFlags(Qt::TextSelectableByMouse|Qt::TextSelectableByKeyboard); + + // Overview page should show: + // Balance + // Unconfirmed balance + // Last received transaction(s) + // Last sent transaction(s) +} + +OverviewPage::~OverviewPage() +{ + delete ui; +} + +void OverviewPage::setBalance(qint64 balance) +{ + ui->labelBalance->setText(GUIUtil::formatMoney(balance) + QString(" BTC")); +} diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h new file mode 100644 index 00000000..85b927b8 --- /dev/null +++ b/src/qt/overviewpage.h @@ -0,0 +1,26 @@ +#ifndef OVERVIEWPAGE_H +#define OVERVIEWPAGE_H + +#include + +namespace Ui { + class OverviewPage; +} + +class OverviewPage : public QWidget +{ + Q_OBJECT + +public: + explicit OverviewPage(QWidget *parent = 0); + ~OverviewPage(); + +public slots: + void setBalance(qint64 balance); + +private: + Ui::OverviewPage *ui; + +}; + +#endif // OVERVIEWPAGE_H diff --git a/src/qt/res/icons/history.png b/src/qt/res/icons/history.png new file mode 100644 index 00000000..60f13517 Binary files /dev/null and b/src/qt/res/icons/history.png differ diff --git a/src/qt/res/icons/overview.png b/src/qt/res/icons/overview.png new file mode 100644 index 00000000..6b94b43a Binary files /dev/null and b/src/qt/res/icons/overview.png differ