Skip to content

Commit

Permalink
qt: rework "receive coins" workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
laanwj committed Oct 23, 2013
1 parent 58daa01 commit 74fb765
Show file tree
Hide file tree
Showing 19 changed files with 533 additions and 235 deletions.
4 changes: 3 additions & 1 deletion contrib/bitcoin-qt.pro
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ FORMS += \
../src/qt/forms/editaddressdialog.ui \
../src/qt/forms/askpassphrasedialog.ui \
../src/qt/forms/addressbookpage.ui \
../src/qt/forms/aboutdialog.ui
../src/qt/forms/aboutdialog.ui \
../src/qt/forms/receivecoinsdialog.ui \
../src/qt/forms/receiverequestdialog.ui

RESOURCES += \
../src/qt/bitcoin.qrc
16 changes: 8 additions & 8 deletions src/qt/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ QT_TS = locale/bitcoin_ach.ts locale/bitcoin_af_ZA.ts locale/bitcoin_ar.ts \

QT_FORMS_UI = forms/aboutdialog.ui forms/addressbookpage.ui \
forms/askpassphrasedialog.ui forms/editaddressdialog.ui forms/intro.ui \
forms/optionsdialog.ui forms/overviewpage.ui forms/qrcodedialog.ui \
forms/optionsdialog.ui forms/overviewpage.ui forms/receiverequestdialog.ui \
forms/receivecoinsdialog.ui \
forms/rpcconsole.ui forms/sendcoinsdialog.ui forms/sendcoinsentry.ui \
forms/signverifymessagedialog.ui forms/transactiondescdialog.ui

Expand All @@ -46,15 +47,15 @@ QT_MOC_CPP = moc_aboutdialog.cpp moc_addressbookpage.cpp \
moc_intro.cpp moc_macdockiconhandler.cpp moc_macnotificationhandler.cpp \
moc_monitoreddatamapper.cpp moc_notificator.cpp moc_optionsdialog.cpp \
moc_optionsmodel.cpp moc_overviewpage.cpp moc_paymentserver.cpp \
moc_qrcodedialog.cpp moc_qvalidatedlineedit.cpp moc_qvaluecombobox.cpp \
moc_receiverequestdialog.cpp moc_qvalidatedlineedit.cpp moc_qvaluecombobox.cpp \
moc_receivecoinsdialog.cpp \
moc_rpcconsole.cpp moc_sendcoinsdialog.cpp moc_sendcoinsentry.cpp \
moc_signverifymessagedialog.cpp moc_splashscreen.cpp moc_trafficgraphwidget.cpp moc_transactiondesc.cpp \
moc_transactiondescdialog.cpp moc_transactionfilterproxy.cpp \
moc_transactiontablemodel.cpp moc_transactionview.cpp moc_walletframe.cpp \
moc_walletmodel.cpp moc_walletview.cpp

BITCOIN_MM = macdockiconhandler.mm macnotificationhandler.mm
QR_CPP = qrcodedialog.cpp

QT_MOC = intro.moc overviewpage.moc rpcconsole.moc

Expand All @@ -71,7 +72,8 @@ BITCOIN_QT_H = aboutdialog.h addressbookpage.h addresstablemodel.h \
editaddressdialog.h guiconstants.h guiutil.h intro.h macdockiconhandler.h \
macnotificationhandler.h monitoreddatamapper.h notificator.h optionsdialog.h \
optionsmodel.h overviewpage.h paymentrequestplus.h paymentserver.h \
qrcodedialog.h qvalidatedlineedit.h qvaluecombobox.h rpcconsole.h \
receivecoinsdialog.h \
receiverequestdialog.h qvalidatedlineedit.h qvaluecombobox.h rpcconsole.h \
sendcoinsdialog.h sendcoinsentry.h signverifymessagedialog.h splashscreen.h \
trafficgraphwidget.h transactiondescdialog.h transactiondesc.h transactionfilterproxy.h \
transactionrecord.h transactiontablemodel.h transactionview.h walletframe.h \
Expand Down Expand Up @@ -101,6 +103,7 @@ BITCOIN_QT_CPP = aboutdialog.cpp addressbookpage.cpp \
guiutil.cpp intro.cpp monitoreddatamapper.cpp notificator.cpp \
optionsdialog.cpp optionsmodel.cpp overviewpage.cpp paymentrequestplus.cpp \
paymentserver.cpp qvalidatedlineedit.cpp qvaluecombobox.cpp \
receivecoinsdialog.cpp receiverequestdialog.cpp \
rpcconsole.cpp sendcoinsdialog.cpp sendcoinsentry.cpp \
signverifymessagedialog.cpp splashscreen.cpp trafficgraphwidget.cpp transactiondesc.cpp \
transactiondescdialog.cpp transactionfilterproxy.cpp transactionrecord.cpp \
Expand Down Expand Up @@ -135,9 +138,6 @@ endif
if TARGET_WINDOWS
libbitcoinqt_a_SOURCES += $(BITCOIN_RC)
endif
if USE_QRCODE
libbitcoinqt_a_SOURCES += $(QR_CPP)
endif
#

# bitcoin-qt binary #
Expand All @@ -159,7 +159,7 @@ QT_QM=$(QT_TS:.ts=.qm)
bitcoinstrings.cpp: FORCE
$(MAKE) -C $(top_srcdir)/src qt/bitcoinstrings.cpp

translate: bitcoinstrings.cpp $(QT_FORMS_UI) $(QT_FORMS_UI) $(BITCOIN_QT_CPP) $(BITCOIN_QT_H) $(BITCOIN_MM) $(QR_CPP)
translate: bitcoinstrings.cpp $(QT_FORMS_UI) $(QT_FORMS_UI) $(BITCOIN_QT_CPP) $(BITCOIN_QT_H) $(BITCOIN_MM)
@test -n $(LUPDATE) || echo "lupdate is required for updating translations"
@$(LUPDATE) $^ -locations relative -no-obsolete -ts locale/bitcoin_en.ts

Expand Down
52 changes: 12 additions & 40 deletions src/qt/addressbookpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
#include "csvmodelwriter.h"
#include "guiutil.h"

#ifdef USE_QRCODE
#include "qrcodedialog.h"
#endif

#include <QSortFilterProxyModel>
#include <QClipboard>
#include <QMessageBox>
Expand All @@ -40,20 +36,25 @@ AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) :
ui->exportButton->setIcon(QIcon());
#endif

#ifndef USE_QRCODE
ui->showQRCode->setVisible(false);
#endif

switch(mode)
{
case ForSending:
case ForSelection:
switch(tab)
{
case SendingTab: setWindowTitle(tr("Choose the address to send coins to")); break;
case ReceivingTab: setWindowTitle(tr("Choose the address to receive coins with")); break;
}
connect(ui->tableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(accept()));
ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->tableView->setFocus();
ui->exportButton->hide();
break;
case ForEditing:
ui->buttonBox->setVisible(false);
switch(tab)
{
case SendingTab: setWindowTitle(tr("Sending addresses")); break;
case ReceivingTab: setWindowTitle(tr("Receiving addresses")); break;
}
break;
}
switch(tab)
Expand All @@ -64,7 +65,7 @@ AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) :
ui->signMessage->setVisible(false);
break;
case ReceivingTab:
ui->labelExplanation->setText(tr("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."));
ui->labelExplanation->setText(tr("These are your Bitcoin addresses for receiving payments. It is recommended to use a new receiving address for each transaction."));
ui->deleteAddress->setVisible(false);
ui->signMessage->setVisible(true);
break;
Expand All @@ -75,7 +76,6 @@ AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) :
QAction *copyLabelAction = new QAction(tr("Copy &Label"), this);
QAction *editAction = new QAction(tr("&Edit"), this);
QAction *sendCoinsAction = new QAction(tr("Send &Coins"), this);
QAction *showQRCodeAction = new QAction(ui->showQRCode->text(), this);
QAction *signMessageAction = new QAction(ui->signMessage->text(), this);
QAction *verifyMessageAction = new QAction(ui->verifyMessage->text(), this);
deleteAction = new QAction(ui->deleteAddress->text(), this);
Expand All @@ -90,9 +90,6 @@ AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) :
contextMenu->addSeparator();
if(tab == SendingTab)
contextMenu->addAction(sendCoinsAction);
#ifdef USE_QRCODE
contextMenu->addAction(showQRCodeAction);
#endif
if(tab == ReceivingTab)
contextMenu->addAction(signMessageAction);
else if(tab == SendingTab)
Expand All @@ -104,7 +101,6 @@ AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) :
connect(editAction, SIGNAL(triggered()), this, SLOT(onEditAction()));
connect(deleteAction, SIGNAL(triggered()), this, SLOT(on_deleteAddress_clicked()));
connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(onSendCoinsAction()));
connect(showQRCodeAction, SIGNAL(triggered()), this, SLOT(on_showQRCode_clicked()));
connect(signMessageAction, SIGNAL(triggered()), this, SLOT(on_signMessage_clicked()));
connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(on_verifyMessage_clicked()));

Expand Down Expand Up @@ -295,12 +291,10 @@ void AddressBookPage::selectionChanged()
break;
}
ui->copyAddress->setEnabled(true);
ui->showQRCode->setEnabled(true);
}
else
{
ui->deleteAddress->setEnabled(false);
ui->showQRCode->setEnabled(false);
ui->copyAddress->setEnabled(false);
ui->signMessage->setEnabled(false);
ui->verifyMessage->setEnabled(false);
Expand All @@ -312,9 +306,6 @@ void AddressBookPage::done(int retval)
QTableView *table = ui->tableView;
if(!table->selectionModel() || !table->model())
return;
// When this is a tab/widget and not a model dialog, ignore "done"
if(mode == ForEditing)
return;

// Figure out which address was selected, and return it
QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);
Expand Down Expand Up @@ -358,25 +349,6 @@ void AddressBookPage::on_exportButton_clicked()
}
}

void AddressBookPage::on_showQRCode_clicked()
{
#ifdef USE_QRCODE
QTableView *table = ui->tableView;
QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);

foreach (QModelIndex index, indexes)
{
QString address = index.data().toString();
QString label = index.sibling(index.row(), 0).data(Qt::EditRole).toString();

QRCodeDialog *dialog = new QRCodeDialog(address, label, tab == ReceivingTab, this);
dialog->setModel(optionsModel);
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
}
#endif
}

void AddressBookPage::contextualMenu(const QPoint &point)
{
QModelIndex index = ui->tableView->indexAt(point);
Expand Down
4 changes: 1 addition & 3 deletions src/qt/addressbookpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AddressBookPage : public QDialog
};

enum Mode {
ForSending, /**< Open address book to pick address for sending */
ForSelection, /**< Open address book to pick address */
ForEditing /**< Open address book for editing */
};

Expand Down Expand Up @@ -69,8 +69,6 @@ private slots:
void on_verifyMessage_clicked();
/** Open send coins dialog for currently selected address (no button) */
void onSendCoinsAction();
/** Generate a QR Code from the currently selected address */
void on_showQRCode_clicked();
/** Copy label of currently selected address entry to clipboard (no button) */
void onCopyLabelAction();
/** Edit currently selected address entry (no button) */
Expand Down
26 changes: 10 additions & 16 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,6 @@ void BitcoinGUI::createActions(bool fIsTestnet)
historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
tabGroup->addAction(historyAction);

addressBookAction = new QAction(QIcon(":/icons/address-book"), tr("&Addresses"), this);
addressBookAction->setStatusTip(tr("Edit the list of stored addresses and labels"));
addressBookAction->setToolTip(addressBookAction->statusTip());
addressBookAction->setCheckable(true);
addressBookAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5));
tabGroup->addAction(addressBookAction);

connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage()));
connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
Expand All @@ -222,8 +215,6 @@ void BitcoinGUI::createActions(bool fIsTestnet)
connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
connect(addressBookAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(addressBookAction, SIGNAL(triggered()), this, SLOT(gotoAddressBookPage()));

quitAction = new QAction(QIcon(":/icons/quit"), tr("E&xit"), this);
quitAction->setStatusTip(tr("Quit application"));
Expand Down Expand Up @@ -266,6 +257,11 @@ void BitcoinGUI::createActions(bool fIsTestnet)
openRPCConsoleAction = new QAction(QIcon(":/icons/debugwindow"), tr("&Debug window"), this);
openRPCConsoleAction->setStatusTip(tr("Open debugging and diagnostic console"));

usedSendingAddressesAction = new QAction(QIcon(":/icons/address-book"), tr("&Used sending addresses..."), this);
usedSendingAddressesAction->setStatusTip(tr("Edit the list of used sending addresses and labels"));
usedReceivingAddressesAction = new QAction(QIcon(":/icons/address-book"), tr("Used &receiving addresses..."), this);
usedReceivingAddressesAction->setStatusTip(tr("Edit the list of used receiving addresses and labels"));

connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked()));
connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
Expand All @@ -276,6 +272,8 @@ void BitcoinGUI::createActions(bool fIsTestnet)
connect(changePassphraseAction, SIGNAL(triggered()), walletFrame, SLOT(changePassphrase()));
connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab()));
connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab()));
connect(usedSendingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedSendingAddresses()));
connect(usedReceivingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedReceivingAddresses()));
}

void BitcoinGUI::createMenuBar()
Expand All @@ -294,6 +292,9 @@ void BitcoinGUI::createMenuBar()
file->addAction(signMessageAction);
file->addAction(verifyMessageAction);
file->addSeparator();
file->addAction(usedSendingAddressesAction);
file->addAction(usedReceivingAddressesAction);
file->addSeparator();
file->addAction(quitAction);

QMenu *settings = appMenuBar->addMenu(tr("&Settings"));
Expand All @@ -317,7 +318,6 @@ void BitcoinGUI::createToolBars()
toolbar->addAction(sendCoinsAction);
toolbar->addAction(receiveCoinsAction);
toolbar->addAction(historyAction);
toolbar->addAction(addressBookAction);
}

void BitcoinGUI::setClientModel(ClientModel *clientModel)
Expand Down Expand Up @@ -457,12 +457,6 @@ void BitcoinGUI::gotoHistoryPage()
if (walletFrame) walletFrame->gotoHistoryPage();
}

void BitcoinGUI::gotoAddressBookPage()
{
addressBookAction->setChecked(true);
if (walletFrame) walletFrame->gotoAddressBookPage();
}

void BitcoinGUI::gotoReceiveCoinsPage()
{
receiveCoinsAction->setChecked(true);
Expand Down
6 changes: 2 additions & 4 deletions src/qt/bitcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class WalletModel;
class WalletStack;
class TransactionView;
class OverviewPage;
class AddressBookPage;
class SendCoinsDialog;
class SendCoinsRecipient;
class SignVerifyMessageDialog;
Expand Down Expand Up @@ -83,7 +82,8 @@ class BitcoinGUI : public QMainWindow
QAction *historyAction;
QAction *quitAction;
QAction *sendCoinsAction;
QAction *addressBookAction;
QAction *usedSendingAddressesAction;
QAction *usedReceivingAddressesAction;
QAction *signMessageAction;
QAction *verifyMessageAction;
QAction *aboutAction;
Expand Down Expand Up @@ -156,8 +156,6 @@ private slots:
void gotoOverviewPage();
/** Switch to history (transactions) page */
void gotoHistoryPage();
/** Switch to address book page */
void gotoAddressBookPage();
/** Switch to receive coins page */
void gotoReceiveCoinsPage();
/** Switch to send coins page */
Expand Down
13 changes: 1 addition & 12 deletions src/qt/forms/addressbookpage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Address Book</string>
<string></string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
Expand Down Expand Up @@ -82,17 +82,6 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="showQRCode">
<property name="text">
<string>Show &amp;QR Code</string>
</property>
<property name="icon">
<iconset resource="../bitcoin.qrc">
<normaloff>:/icons/qrcode</normaloff>:/icons/qrcode</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="signMessage">
<property name="toolTip">
Expand Down
Loading

0 comments on commit 74fb765

Please sign in to comment.