Browse Source

convert to full tab-based ui

pull/1/head
Wladimir J. van der Laan 11 years ago
parent
commit
3479849dc4
  1. 6
      bitcoin-qt.pro
  2. 177
      src/qt/addressbookdialog.cpp
  3. 181
      src/qt/addressbookpage.cpp
  4. 20
      src/qt/addressbookpage.h
  5. 5
      src/qt/bitcoinamountfield.cpp
  6. 151
      src/qt/bitcoingui.cpp
  7. 34
      src/qt/bitcoingui.h
  8. 115
      src/qt/forms/addressbookpage.ui
  9. BIN
      src/qt/res/icons/export.png
  10. 34
      src/qt/sendcoinsdialog.cpp
  11. 5
      src/qt/sendcoinsdialog.h

6
bitcoin-qt.pro

@ -22,7 +22,7 @@ HEADERS += src/qt/bitcoingui.h \ @@ -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 \ @@ -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 += \ @@ -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 \

177
src/qt/addressbookdialog.cpp

@ -1,177 +0,0 @@ @@ -1,177 +0,0 @@
#include "addressbookdialog.h"
#include "ui_addressbookdialog.h"
#include "addresstablemodel.h"
#include "editaddressdialog.h"
#include <QSortFilterProxyModel>
#include <QClipboard>
#include <QDebug>
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);
}
}

181
src/qt/addressbookpage.cpp

@ -0,0 +1,181 @@ @@ -0,0 +1,181 @@
#include "addressbookpage.h"
#include "ui_addressbookpage.h"
#include "addresstablemodel.h"
#include "editaddressdialog.h"
#include <QSortFilterProxyModel>
#include <QClipboard>
#include <QDebug>
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);
}

20
src/qt/addressbookdialog.h → src/qt/addressbookpage.h

@ -1,10 +1,10 @@ @@ -1,10 +1,10 @@
#ifndef ADDRESSBOOKDIALOG_H
#define ADDRESSBOOKDIALOG_H
#ifndef ADDRESSBOOKPAGE_H
#define ADDRESSBOOKPAGE_H
#include <QDialog>
namespace Ui {
class AddressBookDialog;
class AddressBookPage;
}
class AddressTableModel;
@ -13,7 +13,7 @@ class QTableView; @@ -13,7 +13,7 @@ class QTableView;
class QItemSelection;
QT_END_NAMESPACE
class AddressBookDialog : public QDialog
class AddressBookPage : public QDialog
{
Q_OBJECT
@ -28,16 +28,20 @@ public: @@ -28,16 +28,20 @@ public:
ForEditing // Open address book for editing
};
explicit AddressBookDialog(Mode mode, QWidget *parent = 0);
~AddressBookDialog();
explicit AddressBookPage(Mode mode, Tabs tab, QWidget *parent = 0);
~AddressBookPage();
void setModel(AddressTableModel *model);
void setTab(int tab);
const QString &getReturnValue() const { return returnValue; }
public slots:
void done(int retval);
private:
Ui::AddressBookDialog *ui;
Ui::AddressBookPage *ui;
AddressTableModel *model;
Mode mode;
Tabs tab;
QString returnValue;
QTableView *getCurrentTable();

5
src/qt/bitcoinamountfield.cpp

@ -46,6 +46,11 @@ void BitcoinAmountField::setText(const QString &text) @@ -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

151
src/qt/bitcoingui.cpp

@ -5,7 +5,7 @@ @@ -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): @@ -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): @@ -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): @@ -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) @@ -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) @@ -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) @@ -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 @@ -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

34
src/qt/bitcoingui.h

@ -9,6 +9,8 @@ class ClientModel; @@ -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: @@ -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: @@ -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: @@ -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

115
src/qt/forms/addressbookdialog.ui → src/qt/forms/addressbookpage.ui

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AddressBookDialog</class>
<widget class="QDialog" name="AddressBookDialog">
<class>AddressBookPage</class>
<widget class="QWidget" name="AddressBookPage">
<property name="geometry">
<rect>
<x>0</x>
@ -15,87 +15,38 @@ @@ -15,87 +15,38 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>1</number>
<widget class="QLabel" name="labelExplanation">
<property name="text">
<string>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.</string>
</property>
<widget class="QWidget" name="sendTab">
<property name="toolTip">
<string/>
</property>
<attribute name="title">
<string>Sending</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTableView" name="sendTableView">
<property name="toolTip">
<string>Double-click to edit address or label</string>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="receiveTab">
<property name="toolTip">
<string/>
</property>
<attribute name="title">
<string>Receiving</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>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.</string>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QTableView" name="receiveTableView">
<property name="toolTip">
<string>Double-click to edit address or label</string>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QTableView" name="tableView">
<property name="toolTip">
<string>Double-click to edit address or label</string>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
<item>

BIN
src/qt/res/icons/export.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

34
src/qt/sendcoinsdialog.cpp

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
#include "walletmodel.h"
#include "guiutil.h"
#include "addressbookdialog.h"
#include "addressbookpage.h"
#include "optionsmodel.h"
#include <QApplication>
@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
#include <QMessageBox>
#include <QLocale>
#include <QDebug>
#include <QMessageBox>
SendCoinsDialog::SendCoinsDialog(QWidget *parent, const QString &address) :
QDialog(parent),
@ -61,6 +62,16 @@ void SendCoinsDialog::on_sendButton_clicked() @@ -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() @@ -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) @@ -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();
}

5
src/qt/sendcoinsdialog.h

@ -18,6 +18,11 @@ public: @@ -18,6 +18,11 @@ public:
void setModel(WalletModel *model);
public slots:
void clear();
void reject();
void accept();
private:
Ui::SendCoinsDialog *ui;
WalletModel *model;

Loading…
Cancel
Save