From 3479849dc47acd2fb1e191ea690a0c507a97bb73 Mon Sep 17 00:00:00 2001 From: Wladimir J. van der Laan Date: Thu, 7 Jul 2011 17:33:15 +0200 Subject: [PATCH] convert to full tab-based ui --- bitcoin-qt.pro | 6 +- src/qt/addressbookdialog.cpp | 177 ------------------------------------ src/qt/addressbookdialog.h | 53 ----------- src/qt/addressbookpage.cpp | 181 +++++++++++++++++++++++++++++++++++++ src/qt/addressbookpage.h | 57 ++++++++++++ src/qt/bitcoinamountfield.cpp | 5 + src/qt/bitcoingui.cpp | 151 ++++++++++++++++++------------- src/qt/bitcoingui.h | 34 +++++--- src/qt/forms/addressbookdialog.ui | 179 ------------------------------------ src/qt/forms/addressbookpage.ui | 130 ++++++++++++++++++++++++++ src/qt/res/icons/export.png | Bin 0 -> 1339 bytes src/qt/sendcoinsdialog.cpp | 34 +++++++- src/qt/sendcoinsdialog.h | 5 + 13 files changed, 519 insertions(+), 493 deletions(-) delete mode 100644 src/qt/addressbookdialog.cpp delete mode 100644 src/qt/addressbookdialog.h create mode 100644 src/qt/addressbookpage.cpp create mode 100644 src/qt/addressbookpage.h delete mode 100644 src/qt/forms/addressbookdialog.ui create mode 100644 src/qt/forms/addressbookpage.ui create mode 100644 src/qt/res/icons/export.png diff --git a/bitcoin-qt.pro b/bitcoin-qt.pro index 77d70b7..5e2646f 100644 --- a/bitcoin-qt.pro +++ b/bitcoin-qt.pro @@ -22,7 +22,7 @@ HEADERS += src/qt/bitcoingui.h \ src/qt/addresstablemodel.h \ src/qt/optionsdialog.h \ src/qt/sendcoinsdialog.h \ - src/qt/addressbookdialog.h \ + src/qt/addressbookpage.h \ src/qt/aboutdialog.h \ src/qt/editaddressdialog.h \ src/qt/bitcoinaddressvalidator.h \ @@ -84,7 +84,7 @@ SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \ src/qt/addresstablemodel.cpp \ src/qt/optionsdialog.cpp \ src/qt/sendcoinsdialog.cpp \ - src/qt/addressbookdialog.cpp \ + src/qt/addressbookpage.cpp \ src/qt/aboutdialog.cpp \ src/qt/editaddressdialog.cpp \ src/qt/bitcoinaddressvalidator.cpp \ @@ -123,7 +123,7 @@ RESOURCES += \ FORMS += \ src/qt/forms/sendcoinsdialog.ui \ - src/qt/forms/addressbookdialog.ui \ + src/qt/forms/addressbookpage.ui \ src/qt/forms/aboutdialog.ui \ src/qt/forms/editaddressdialog.ui \ src/qt/forms/transactiondescdialog.ui \ diff --git a/src/qt/addressbookdialog.cpp b/src/qt/addressbookdialog.cpp deleted file mode 100644 index 6d53ee8..0000000 --- a/src/qt/addressbookdialog.cpp +++ /dev/null @@ -1,177 +0,0 @@ -#include "addressbookdialog.h" -#include "ui_addressbookdialog.h" - -#include "addresstablemodel.h" -#include "editaddressdialog.h" - -#include -#include -#include - -AddressBookDialog::AddressBookDialog(Mode mode, QWidget *parent) : - QDialog(parent), - ui(new Ui::AddressBookDialog), - model(0), - mode(mode) -{ - ui->setupUi(this); - switch(mode) - { - case ForSending: - connect(ui->receiveTableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(on_buttonBox_accepted())); - connect(ui->sendTableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(on_buttonBox_accepted())); - ui->sendTableView->setFocus(); - break; - } - - connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(selectionChanged())); -} - -AddressBookDialog::~AddressBookDialog() -{ - delete ui; -} - -void AddressBookDialog::setModel(AddressTableModel *model) -{ - this->model = model; - // Refresh list from core - model->updateList(); - - // Receive filter - QSortFilterProxyModel *receive_model = new QSortFilterProxyModel(this); - receive_model->setSourceModel(model); - receive_model->setDynamicSortFilter(true); - receive_model->setFilterRole(AddressTableModel::TypeRole); - receive_model->setFilterFixedString(AddressTableModel::Receive); - ui->receiveTableView->setModel(receive_model); - ui->receiveTableView->sortByColumn(0, Qt::AscendingOrder); - - // Send filter - QSortFilterProxyModel *send_model = new QSortFilterProxyModel(this); - send_model->setSourceModel(model); - send_model->setDynamicSortFilter(true); - send_model->setFilterRole(AddressTableModel::TypeRole); - send_model->setFilterFixedString(AddressTableModel::Send); - ui->sendTableView->setModel(send_model); - ui->sendTableView->sortByColumn(0, Qt::AscendingOrder); - - // Set column widths - ui->receiveTableView->horizontalHeader()->resizeSection( - AddressTableModel::Address, 320); - ui->receiveTableView->horizontalHeader()->setResizeMode( - AddressTableModel::Label, QHeaderView::Stretch); - ui->sendTableView->horizontalHeader()->resizeSection( - AddressTableModel::Address, 320); - ui->sendTableView->horizontalHeader()->setResizeMode( - AddressTableModel::Label, QHeaderView::Stretch); - - connect(ui->receiveTableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), - this, SLOT(selectionChanged())); - connect(ui->sendTableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), - this, SLOT(selectionChanged())); - - if(mode == ForSending) - { - // Auto-select first row when in sending mode - ui->sendTableView->selectRow(0); - } -} - -void AddressBookDialog::setTab(int tab) -{ - ui->tabWidget->setCurrentIndex(tab); - selectionChanged(); -} - -QTableView *AddressBookDialog::getCurrentTable() -{ - switch(ui->tabWidget->currentIndex()) - { - case SendingTab: - return ui->sendTableView; - case ReceivingTab: - return ui->receiveTableView; - default: - return 0; - } -} - -void AddressBookDialog::on_copyToClipboard_clicked() -{ - // Copy currently selected address to clipboard - // (or nothing, if nothing selected) - QTableView *table = getCurrentTable(); - QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address); - - foreach (QModelIndex index, indexes) - { - QVariant address = index.data(); - QApplication::clipboard()->setText(address.toString()); - } -} - -void AddressBookDialog::on_newAddressButton_clicked() -{ - EditAddressDialog dlg( - ui->tabWidget->currentIndex() == SendingTab ? - EditAddressDialog::NewSendingAddress : - EditAddressDialog::NewReceivingAddress); - dlg.setModel(model); - dlg.exec(); -} - -void AddressBookDialog::on_deleteButton_clicked() -{ - QTableView *table = getCurrentTable(); - QModelIndexList indexes = table->selectionModel()->selectedRows(); - if(!indexes.isEmpty()) - { - table->model()->removeRow(indexes.at(0).row()); - } -} - -void AddressBookDialog::on_buttonBox_accepted() -{ - QTableView *table = getCurrentTable(); - QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address); - - foreach (QModelIndex index, indexes) - { - QVariant address = table->model()->data(index); - returnValue = address.toString(); - } - if(!returnValue.isEmpty()) - { - accept(); - } - else - { - reject(); - } -} - -void AddressBookDialog::selectionChanged() -{ - // Set button states based on selected tab and selection - QTableView *table = getCurrentTable(); - - if(table->selectionModel()->hasSelection()) - { - switch(ui->tabWidget->currentIndex()) - { - case SendingTab: - ui->deleteButton->setEnabled(true); - break; - case ReceivingTab: - ui->deleteButton->setEnabled(false); - break; - } - ui->copyToClipboard->setEnabled(true); - } - else - { - ui->deleteButton->setEnabled(false); - ui->copyToClipboard->setEnabled(false); - } -} diff --git a/src/qt/addressbookdialog.h b/src/qt/addressbookdialog.h deleted file mode 100644 index befa8b7..0000000 --- a/src/qt/addressbookdialog.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef ADDRESSBOOKDIALOG_H -#define ADDRESSBOOKDIALOG_H - -#include - -namespace Ui { - class AddressBookDialog; -} -class AddressTableModel; - -QT_BEGIN_NAMESPACE -class QTableView; -class QItemSelection; -QT_END_NAMESPACE - -class AddressBookDialog : public QDialog -{ - Q_OBJECT - -public: - enum Tabs { - SendingTab = 0, - ReceivingTab = 1 - }; - - enum Mode { - ForSending, // Pick address for sending - ForEditing // Open address book for editing - }; - - explicit AddressBookDialog(Mode mode, QWidget *parent = 0); - ~AddressBookDialog(); - - void setModel(AddressTableModel *model); - void setTab(int tab); - const QString &getReturnValue() const { return returnValue; } -private: - Ui::AddressBookDialog *ui; - AddressTableModel *model; - Mode mode; - QString returnValue; - - QTableView *getCurrentTable(); - -private slots: - void on_buttonBox_accepted(); - void on_deleteButton_clicked(); - void on_newAddressButton_clicked(); - void on_copyToClipboard_clicked(); - void selectionChanged(); -}; - -#endif // ADDRESSBOOKDIALOG_H diff --git a/src/qt/addressbookpage.cpp b/src/qt/addressbookpage.cpp new file mode 100644 index 0000000..67ed0fe --- /dev/null +++ b/src/qt/addressbookpage.cpp @@ -0,0 +1,181 @@ +#include "addressbookpage.h" +#include "ui_addressbookpage.h" + +#include "addresstablemodel.h" +#include "editaddressdialog.h" + +#include +#include +#include + +AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) : + QDialog(parent), + ui(new Ui::AddressBookPage), + model(0), + mode(mode), + tab(tab) +{ + ui->setupUi(this); + switch(mode) + { + case ForSending: + connect(ui->tableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(on_buttonBox_accepted())); + ui->tableView->setFocus(); + break; + case ForEditing: + ui->buttonBox->hide(); + break; + } + switch(tab) + { + case SendingTab: + ui->labelExplanation->hide(); + break; + case ReceivingTab: + break; + } +} + +AddressBookPage::~AddressBookPage() +{ + delete ui; +} + +void AddressBookPage::setModel(AddressTableModel *model) +{ + this->model = model; + // Refresh list from core + model->updateList(); + + switch(tab) + { + case ReceivingTab: { + // Receive filter + QSortFilterProxyModel *receive_model = new QSortFilterProxyModel(this); + receive_model->setSourceModel(model); + receive_model->setDynamicSortFilter(true); + receive_model->setFilterRole(AddressTableModel::TypeRole); + receive_model->setFilterFixedString(AddressTableModel::Receive); + ui->tableView->setModel(receive_model); + ui->tableView->sortByColumn(0, Qt::AscendingOrder); + } break; + case SendingTab: { + // Send filter + QSortFilterProxyModel *send_model = new QSortFilterProxyModel(this); + send_model->setSourceModel(model); + send_model->setDynamicSortFilter(true); + send_model->setFilterRole(AddressTableModel::TypeRole); + send_model->setFilterFixedString(AddressTableModel::Send); + ui->tableView->setModel(send_model); + ui->tableView->sortByColumn(0, Qt::AscendingOrder); + } break; + } + + // Set column widths + ui->tableView->horizontalHeader()->resizeSection( + AddressTableModel::Address, 320); + ui->tableView->horizontalHeader()->setResizeMode( + AddressTableModel::Label, QHeaderView::Stretch); + + connect(ui->tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), + this, SLOT(selectionChanged())); + + if(mode == ForSending) + { + // Auto-select first row when in sending mode + ui->tableView->selectRow(0); + } + selectionChanged(); +} + +QTableView *AddressBookPage::getCurrentTable() +{ + return ui->tableView; +} + +void AddressBookPage::on_copyToClipboard_clicked() +{ + // Copy currently selected address to clipboard + // (or nothing, if nothing selected) + QTableView *table = getCurrentTable(); + QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address); + + foreach (QModelIndex index, indexes) + { + QVariant address = index.data(); + QApplication::clipboard()->setText(address.toString()); + } +} + +void AddressBookPage::on_newAddressButton_clicked() +{ + EditAddressDialog dlg( + tab == SendingTab ? + EditAddressDialog::NewSendingAddress : + EditAddressDialog::NewReceivingAddress); + dlg.setModel(model); + dlg.exec(); +} + +void AddressBookPage::on_deleteButton_clicked() +{ + QTableView *table = getCurrentTable(); + QModelIndexList indexes = table->selectionModel()->selectedRows(); + if(!indexes.isEmpty()) + { + table->model()->removeRow(indexes.at(0).row()); + } +} + +void AddressBookPage::on_buttonBox_accepted() +{ + QTableView *table = getCurrentTable(); + QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address); + + foreach (QModelIndex index, indexes) + { + QVariant address = table->model()->data(index); + returnValue = address.toString(); + } + if(!returnValue.isEmpty()) + { + accept(); + } + else + { + reject(); + } +} + +void AddressBookPage::selectionChanged() +{ + // Set button states based on selected tab and selection + QTableView *table = getCurrentTable(); + + if(table->selectionModel()->hasSelection()) + { + switch(tab) + { + case SendingTab: + ui->deleteButton->setEnabled(true); + break; + case ReceivingTab: + ui->deleteButton->setEnabled(false); + break; + } + ui->copyToClipboard->setEnabled(true); + } + else + { + ui->deleteButton->setEnabled(false); + ui->copyToClipboard->setEnabled(false); + } +} + +void AddressBookPage::done(int retval) +{ + // When this is a tab/widget and not a model dialog, ignore "done" + if(mode == ForEditing) + return; + QDialog::done(retval); +} diff --git a/src/qt/addressbookpage.h b/src/qt/addressbookpage.h new file mode 100644 index 0000000..f25bbc9 --- /dev/null +++ b/src/qt/addressbookpage.h @@ -0,0 +1,57 @@ +#ifndef ADDRESSBOOKPAGE_H +#define ADDRESSBOOKPAGE_H + +#include + +namespace Ui { + class AddressBookPage; +} +class AddressTableModel; + +QT_BEGIN_NAMESPACE +class QTableView; +class QItemSelection; +QT_END_NAMESPACE + +class AddressBookPage : public QDialog +{ + Q_OBJECT + +public: + enum Tabs { + SendingTab = 0, + ReceivingTab = 1 + }; + + enum Mode { + ForSending, // Pick address for sending + ForEditing // Open address book for editing + }; + + explicit AddressBookPage(Mode mode, Tabs tab, QWidget *parent = 0); + ~AddressBookPage(); + + void setModel(AddressTableModel *model); + const QString &getReturnValue() const { return returnValue; } + +public slots: + void done(int retval); + +private: + Ui::AddressBookPage *ui; + AddressTableModel *model; + Mode mode; + Tabs tab; + QString returnValue; + + QTableView *getCurrentTable(); + +private slots: + void on_buttonBox_accepted(); + void on_deleteButton_clicked(); + void on_newAddressButton_clicked(); + void on_copyToClipboard_clicked(); + void selectionChanged(); +}; + +#endif // ADDRESSBOOKDIALOG_H diff --git a/src/qt/bitcoinamountfield.cpp b/src/qt/bitcoinamountfield.cpp index f16c0c5..1359a32 100644 --- a/src/qt/bitcoinamountfield.cpp +++ b/src/qt/bitcoinamountfield.cpp @@ -46,6 +46,11 @@ void BitcoinAmountField::setText(const QString &text) amount->setText(parts[0]); decimals->setText(parts[1]); } + else + { + amount->setText(QString()); + decimals->setText(QString()); + } } QString BitcoinAmountField::text() const diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 34da135..99dbbc1 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -5,7 +5,7 @@ */ #include "bitcoingui.h" #include "transactiontablemodel.h" -#include "addressbookdialog.h" +#include "addressbookpage.h" #include "sendcoinsdialog.h" #include "optionsdialog.h" #include "aboutdialog.h" @@ -54,26 +54,25 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): // Menus QMenu *file = menuBar()->addMenu("&File"); - file->addAction(sendCoins); - file->addAction(receiveCoins); + file->addAction(sendCoinsAction); + file->addAction(receiveCoinsAction); file->addSeparator(); - file->addAction(quit); + file->addAction(quitAction); QMenu *settings = menuBar()->addMenu("&Settings"); - settings->addAction(options); + settings->addAction(optionsAction); QMenu *help = menuBar()->addMenu("&Help"); - help->addAction(about); + help->addAction(aboutAction); // Toolbar QToolBar *toolbar = addToolBar("Main toolbar"); toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); toolbar->addAction(overviewAction); + toolbar->addAction(sendCoinsAction); + toolbar->addAction(receiveCoinsAction); toolbar->addAction(historyAction); - toolbar->addSeparator(); - toolbar->addAction(sendCoins); - toolbar->addAction(receiveCoins); - toolbar->addAction(addressbook); + toolbar->addAction(addressBookAction); QToolBar *toolbar2 = addToolBar("Transactions toolbar"); toolbar2->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); @@ -90,9 +89,18 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): transactionsPage = new QWidget(this); transactionsPage->setLayout(vbox); + addressBookPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::SendingTab); + + receiveCoinsPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::ReceivingTab); + + sendCoinsPage = new SendCoinsDialog(this); + centralWidget = new QStackedWidget(this); centralWidget->addWidget(overviewPage); centralWidget->addWidget(transactionsPage); + centralWidget->addWidget(addressBookPage); + centralWidget->addWidget(receiveCoinsPage); + centralWidget->addWidget(sendCoinsPage); setCentralWidget(centralWidget); // Create status bar @@ -122,46 +130,57 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): createTrayIcon(); - gotoOverviewTab(); + gotoOverviewPage(); } 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("&Transactions"), 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); - sendCoins->setToolTip(tr("Send coins to a bitcoin address")); - addressbook = new QAction(QIcon(":/icons/address-book"), tr("&Address Book"), this); - addressbook->setToolTip(tr("Edit the list of stored addresses and labels")); - about = new QAction(QIcon(":/icons/bitcoin"), tr("&About"), this); - about->setToolTip(tr("Show information about Bitcoin")); - receiveCoins = new QAction(QIcon(":/icons/receiving_addresses"), tr("&Receive coins"), this); - receiveCoins->setToolTip(tr("Show the list of addresses for receiving payments")); - options = new QAction(QIcon(":/icons/options"), tr("&Options..."), this); - options->setToolTip(tr("Modify configuration options for bitcoin")); - openBitcoin = new QAction(QIcon(":/icons/bitcoin"), tr("Open &Bitcoin"), this); - openBitcoin->setToolTip(tr("Show the Bitcoin window")); + addressBookAction = new QAction(QIcon(":/icons/address-book"), tr("&Address Book"), this); + addressBookAction->setToolTip(tr("Edit the list of stored addresses and labels")); + addressBookAction->setCheckable(true); + tabGroup->addAction(addressBookAction); + + receiveCoinsAction = new QAction(QIcon(":/icons/receiving_addresses"), tr("&Receive coins"), this); + receiveCoinsAction->setToolTip(tr("Show the list of addresses for receiving payments")); + receiveCoinsAction->setCheckable(true); + tabGroup->addAction(receiveCoinsAction); + + sendCoinsAction = new QAction(QIcon(":/icons/send"), tr("&Send coins"), this); + sendCoinsAction->setToolTip(tr("Send coins to a bitcoin address")); + sendCoinsAction->setCheckable(true); + tabGroup->addAction(sendCoinsAction); + + connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage())); + connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage())); + connect(addressBookAction, SIGNAL(triggered()), this, SLOT(gotoAddressBookPage())); + connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage())); + connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage())); + + quitAction = new QAction(QIcon(":/icons/quit"), tr("&Exit"), this); + quitAction->setToolTip(tr("Quit application")); + aboutAction = new QAction(QIcon(":/icons/bitcoin"), tr("&About"), this); + aboutAction->setToolTip(tr("Show information about Bitcoin")); + optionsAction = new QAction(QIcon(":/icons/options"), tr("&Options..."), this); + optionsAction->setToolTip(tr("Modify configuration options for bitcoin")); + openBitcoinAction = new QAction(QIcon(":/icons/bitcoin"), tr("Open &Bitcoin"), this); + openBitcoinAction->setToolTip(tr("Show the Bitcoin window")); exportAction = new QAction(QIcon(":/icons/export"), tr("&Export..."), this); exportAction->setToolTip(tr("Export data in current view to a file")); - connect(quit, SIGNAL(triggered()), qApp, SLOT(quit())); - connect(sendCoins, SIGNAL(triggered()), this, SLOT(sendCoinsClicked())); - connect(addressbook, SIGNAL(triggered()), this, SLOT(addressbookClicked())); - connect(receiveCoins, SIGNAL(triggered()), this, SLOT(receiveCoinsClicked())); - connect(options, SIGNAL(triggered()), this, SLOT(optionsClicked())); - connect(about, SIGNAL(triggered()), this, SLOT(aboutClicked())); - connect(openBitcoin, SIGNAL(triggered()), this, SLOT(show())); + connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); + connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked())); + connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked())); + connect(openBitcoinAction, SIGNAL(triggered()), this, SLOT(show())); connect(exportAction, SIGNAL(triggered()), this, SLOT(exportClicked())); } @@ -209,6 +228,10 @@ void BitcoinGUI::setWalletModel(WalletModel *walletModel) // Put transaction list in tabs transactionView->setModel(walletModel->getTransactionTableModel()); + addressBookPage->setModel(walletModel->getAddressTableModel()); + receiveCoinsPage->setModel(walletModel->getAddressTableModel()); + sendCoinsPage->setModel(walletModel); + // Balloon popup for new transaction connect(walletModel->getTransactionTableModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(incomingTransaction(const QModelIndex &, int, int))); @@ -217,11 +240,11 @@ void BitcoinGUI::setWalletModel(WalletModel *walletModel) void BitcoinGUI::createTrayIcon() { QMenu *trayIconMenu = new QMenu(this); - trayIconMenu->addAction(openBitcoin); - trayIconMenu->addAction(sendCoins); - trayIconMenu->addAction(options); + trayIconMenu->addAction(openBitcoinAction); + trayIconMenu->addAction(sendCoinsAction); + trayIconMenu->addAction(optionsAction); trayIconMenu->addSeparator(); - trayIconMenu->addAction(quit); + trayIconMenu->addAction(quitAction); trayIcon = new QSystemTrayIcon(this); trayIcon->setContextMenu(trayIconMenu); @@ -237,33 +260,10 @@ void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason) if(reason == QSystemTrayIcon::DoubleClick) { // Doubleclick on system tray icon triggers "open bitcoin" - openBitcoin->trigger(); + openBitcoinAction->trigger(); } } -void BitcoinGUI::sendCoinsClicked() -{ - SendCoinsDialog dlg; - dlg.setModel(walletModel); - dlg.exec(); -} - -void BitcoinGUI::addressbookClicked() -{ - AddressBookDialog dlg(AddressBookDialog::ForEditing); - dlg.setModel(walletModel->getAddressTableModel()); - dlg.setTab(AddressBookDialog::SendingTab); - dlg.exec(); -} - -void BitcoinGUI::receiveCoinsClicked() -{ - AddressBookDialog dlg(AddressBookDialog::ForEditing); - dlg.setModel(walletModel->getAddressTableModel()); - dlg.setTab(AddressBookDialog::ReceivingTab); - dlg.exec(); -} - void BitcoinGUI::optionsClicked() { OptionsDialog dlg; @@ -413,20 +413,41 @@ void BitcoinGUI::incomingTransaction(const QModelIndex & parent, int start, int } } -void BitcoinGUI::gotoOverviewTab() +void BitcoinGUI::gotoOverviewPage() { overviewAction->setChecked(true); centralWidget->setCurrentWidget(overviewPage); exportAction->setEnabled(false); } -void BitcoinGUI::gotoHistoryTab() +void BitcoinGUI::gotoHistoryPage() { historyAction->setChecked(true); centralWidget->setCurrentWidget(transactionsPage); exportAction->setEnabled(true); } +void BitcoinGUI::gotoAddressBookPage() +{ + addressBookAction->setChecked(true); + centralWidget->setCurrentWidget(addressBookPage); + exportAction->setEnabled(false); // TODO +} + +void BitcoinGUI::gotoReceiveCoinsPage() +{ + receiveCoinsAction->setChecked(true); + centralWidget->setCurrentWidget(receiveCoinsPage); + exportAction->setEnabled(false); // TODO +} + +void BitcoinGUI::gotoSendCoinsPage() +{ + sendCoinsAction->setChecked(true); + centralWidget->setCurrentWidget(sendCoinsPage); + exportAction->setEnabled(false); +} + void BitcoinGUI::exportClicked() { // Redirect to the right view, as soon as export for other views diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index a5fcc8a..8c3632a 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -9,6 +9,8 @@ class ClientModel; class WalletModel; class TransactionView; class OverviewPage; +class AddressBookPage; +class SendCoinsDialog; QT_BEGIN_NAMESPACE class QLabel; @@ -45,8 +47,12 @@ private: WalletModel *walletModel; QStackedWidget *centralWidget; + OverviewPage *overviewPage; QWidget *transactionsPage; + AddressBookPage *addressBookPage; + AddressBookPage *receiveCoinsPage; + SendCoinsDialog *sendCoinsPage; QLabel *labelConnections; QLabel *labelConnectionsIcon; @@ -56,13 +62,13 @@ private: QAction *overviewAction; QAction *historyAction; - QAction *quit; - QAction *sendCoins; - QAction *addressbook; - QAction *about; - QAction *receiveCoins; - QAction *options; - QAction *openBitcoin; + QAction *quitAction; + QAction *sendCoinsAction; + QAction *addressBookAction; + QAction *aboutAction; + QAction *receiveCoinsAction; + QAction *optionsAction; + QAction *openBitcoinAction; QAction *exportAction; QSystemTrayIcon *trayIcon; @@ -85,18 +91,20 @@ public slots: void askFee(qint64 nFeeRequired, bool *payFee); private slots: - void sendCoinsClicked(); - void addressbookClicked(); + // UI pages + void gotoOverviewPage(); + void gotoHistoryPage(); + void gotoAddressBookPage(); + void gotoReceiveCoinsPage(); + void gotoSendCoinsPage(); + + // Misc actions void optionsClicked(); - void receiveCoinsClicked(); void aboutClicked(); void trayIconActivated(QSystemTrayIcon::ActivationReason reason); void transactionDetails(const QModelIndex& idx); void incomingTransaction(const QModelIndex & parent, int start, int end); void exportClicked(); - - void gotoOverviewTab(); - void gotoHistoryTab(); }; #endif diff --git a/src/qt/forms/addressbookdialog.ui b/src/qt/forms/addressbookdialog.ui deleted file mode 100644 index 66f1076..0000000 --- a/src/qt/forms/addressbookdialog.ui +++ /dev/null @@ -1,179 +0,0 @@ - - - AddressBookDialog - - - - 0 - 0 - 627 - 347 - - - - Address Book - - - - - - 1 - - - - - - - Sending - - - - - - Double-click to edit address or label - - - true - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - true - - - false - - - - - - - - - - - Receiving - - - - - - These are your Bitcoin addresses for receiving payments. You may want to give a different one to each sender so you can keep track of who is paying you. - - - Qt::AutoText - - - true - - - - - - - Double-click to edit address or label - - - true - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - true - - - false - - - - - - - - - - - - - Create a new address - - - &New Address... - - - - :/icons/add:/icons/add - - - - - - - Copy the currently selected address to the system clipboard - - - &Copy to Clipboard - - - - :/icons/editcopy:/icons/editcopy - - - - - - - Delete the currently selected address from the list. Only sending addresses can be deleted. - - - &Delete - - - - :/icons/editdelete:/icons/editdelete - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - QDialogButtonBox::Ok - - - - - - - - - - - - diff --git a/src/qt/forms/addressbookpage.ui b/src/qt/forms/addressbookpage.ui new file mode 100644 index 0000000..d3feedb --- /dev/null +++ b/src/qt/forms/addressbookpage.ui @@ -0,0 +1,130 @@ + + + AddressBookPage + + + + 0 + 0 + 627 + 347 + + + + Address Book + + + + + + These are your Bitcoin addresses for receiving payments. You may want to give a different one to each sender so you can keep track of who is paying you. + + + Qt::AutoText + + + true + + + + + + + Double-click to edit address or label + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + false + + + + + + + + + Create a new address + + + &New Address... + + + + :/icons/add:/icons/add + + + + + + + Copy the currently selected address to the system clipboard + + + &Copy to Clipboard + + + + :/icons/editcopy:/icons/editcopy + + + + + + + Delete the currently selected address from the list. Only sending addresses can be deleted. + + + &Delete + + + + :/icons/editdelete:/icons/editdelete + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + QDialogButtonBox::Ok + + + + + + + + + + + + diff --git a/src/qt/res/icons/export.png b/src/qt/res/icons/export.png new file mode 100644 index 0000000000000000000000000000000000000000..69d59a38d20e0e3f1265b9cbc0937d1d3f847451 GIT binary patch literal 1339 zcmV-B1;qM^P)uqfx0f-a;ZgbdN?326Dw0$C9P+*KAXMr)w;$B3W#tsQ! zN~A0hH47p4$Qq3Xip3(Nl(=~DVsime#JB!n&PoInu zpm{IvrCf^^as)JQu4yQhO1N<00?wQ{gYNEb3=9k)olbu-K0Y2QLfbDv1i7XiAke}_ zbq=7dt<5Ls>+8eN(9jzIrgdG9hYIk?fn!B{h@3GD4h~{|ejc`M`y`{Iqwgh?$xZ;@ zXR}!?yaZkunx$DG4g2lXsZ$sn97H~!2NAgmX0c0`E`50J+_`rF+&EkUubEslt+kp3 zRfs$9?CeBWR~HI}g35JrY;5fP-rnA!OeXWKPYYnQW}0^$$2syO_(#!Qudc4bFbp`3 z1I{^w5C=vNsZl|o-%pGsbvnwr|IR;#ykU7z&71 zJ2Nv=HVosTuIm#($UP7yB1q7z2P%~cR##UsJUpzr8+Y#9SzK9JDeAiZmFM&`;5VG| zMp#{s5&{4_J3AJ0$esM1Y6cT-K^JYE(c>MS=QmGUY ziG=UFckkYxOG`_C1NbbP%}Vuo|6`;^AC~%7$fcAZBGl`3-?zNHjAF643m~1zWCQ}X zp8+&Am%>y5De4jjWMlB2RArG(=+ zuq+FfWuaCxarW$4JbE;Tcp^dh*@x2`8ymkx1*8QX$GlJ=r9{16$J*K&o;_Q}*48H4 z+dGg-4decU2S44;-O3Qr=282M*6Ve8_39N_mPL(5gKXO-+qQ{wPMmWRLXZ%G9LFIk zr4P3VsHnB9Ce~B7);Mux%Ub8ykox z;&2>+O64W=>(>jnf5=?{@WT5~5M}-;h$4&hVKnH*i0KE2J zvH@TRz>{W2Ey|dhEykDzAmJjej2>bxG#6^a5CG}IaUm3NW#nFu#9djZ$4?)*f+4~5Kj!Iilk5Gnyk#u$i5{tLgLs*$b}ue1OF002ovPDHLkV1hpwS84zN literal 0 HcmV?d00001 diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 4b97437..8050baf 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -3,7 +3,7 @@ #include "walletmodel.h" #include "guiutil.h" -#include "addressbookdialog.h" +#include "addressbookpage.h" #include "optionsmodel.h" #include @@ -11,6 +11,7 @@ #include #include #include +#include SendCoinsDialog::SendCoinsDialog(QWidget *parent, const QString &address) : QDialog(parent), @@ -61,6 +62,16 @@ void SendCoinsDialog::on_sendButton_clicked() // Add address to address book under label, if specified label = ui->addAsLabel->text(); + QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm send coins"), + tr("Are you sure you want to send %1 BTC to %2 (%3)?").arg(GUIUtil::formatMoney(payAmountParsed), label, ui->payTo->text()), + QMessageBox::Yes|QMessageBox::Cancel, + QMessageBox::Cancel); + + if(retval != QMessageBox::Yes) + { + return; + } + switch(model->sendCoins(ui->payTo->text(), payAmountParsed, label)) { case WalletModel::InvalidAddress: @@ -102,9 +113,8 @@ void SendCoinsDialog::on_pasteButton_clicked() void SendCoinsDialog::on_addressBookButton_clicked() { - AddressBookDialog dlg(AddressBookDialog::ForSending); + AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::SendingTab); dlg.setModel(model->getAddressTableModel()); - dlg.setTab(AddressBookDialog::SendingTab); dlg.exec(); ui->payTo->setText(dlg.getReturnValue()); ui->payAmount->setFocus(); @@ -119,3 +129,21 @@ void SendCoinsDialog::on_payTo_textChanged(const QString &address) { ui->addAsLabel->setText(model->labelForAddress(address)); } + +void SendCoinsDialog::clear() +{ + ui->payTo->setText(QString()); + ui->addAsLabel->setText(QString()); + ui->payAmount->setText(QString()); + ui->payTo->setFocus(); +} + +void SendCoinsDialog::reject() +{ + clear(); +} + +void SendCoinsDialog::accept() +{ + clear(); +} diff --git a/src/qt/sendcoinsdialog.h b/src/qt/sendcoinsdialog.h index 968cbe7..4e019b7 100644 --- a/src/qt/sendcoinsdialog.h +++ b/src/qt/sendcoinsdialog.h @@ -18,6 +18,11 @@ public: void setModel(WalletModel *model); +public slots: + void clear(); + void reject(); + void accept(); + private: Ui::SendCoinsDialog *ui; WalletModel *model; -- 1.7.1