Skip to content

Commit

Permalink
Merge pull request #3099 from laanwj/2013_10_new_receive_flow
Browse files Browse the repository at this point in the history
qt: improve "receive coins" workflow
  • Loading branch information
laanwj committed Oct 25, 2013
2 parents 48cc4fc + 70b1463 commit 081c0cd
Show file tree
Hide file tree
Showing 29 changed files with 876 additions and 667 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
120 changes: 15 additions & 105 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 @@ -35,49 +31,47 @@ AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) :
ui->newAddress->setIcon(QIcon());
ui->copyAddress->setIcon(QIcon());
ui->deleteAddress->setIcon(QIcon());
ui->verifyMessage->setIcon(QIcon());
ui->signMessage->setIcon(QIcon());
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->closeButton->setText(tr("C&hoose"));
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)
{
case SendingTab:
ui->labelExplanation->setText(tr("These are your Bitcoin addresses for sending payments. Always check the amount and the receiving address before sending coins."));
ui->deleteAddress->setVisible(true);
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;
}

// Context menu actions
QAction *copyAddressAction = new QAction(ui->copyAddress->text(), this);
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);

// Build context menu
Expand All @@ -88,30 +82,16 @@ AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) :
if(tab == SendingTab)
contextMenu->addAction(deleteAction);
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)
contextMenu->addAction(verifyMessageAction);

// Connect signals for context menu actions
connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(on_copyAddress_clicked()));
connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(onCopyLabelAction()));
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()));

connect(ui->tableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint)));

// Pass through accept action from button box
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(accept()));
}

AddressBookPage::~AddressBookPage()
Expand Down Expand Up @@ -197,42 +177,6 @@ void AddressBookPage::onEditAction()
dlg.exec();
}

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

foreach (QModelIndex index, indexes)
{
QString address = index.data().toString();
emit signMessage(address);
}
}

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

foreach (QModelIndex index, indexes)
{
QString address = index.data().toString();
emit verifyMessage(address);
}
}

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

foreach (QModelIndex index, indexes)
{
QString address = index.data().toString();
emit sendCoins(address);
}
}

void AddressBookPage::on_newAddress_clicked()
{
if(!model)
Expand Down Expand Up @@ -278,32 +222,20 @@ void AddressBookPage::selectionChanged()
ui->deleteAddress->setEnabled(true);
ui->deleteAddress->setVisible(true);
deleteAction->setEnabled(true);
ui->signMessage->setEnabled(false);
ui->signMessage->setVisible(false);
ui->verifyMessage->setEnabled(true);
ui->verifyMessage->setVisible(true);
break;
case ReceivingTab:
// Deleting receiving addresses, however, is not allowed
ui->deleteAddress->setEnabled(false);
ui->deleteAddress->setVisible(false);
deleteAction->setEnabled(false);
ui->signMessage->setEnabled(true);
ui->signMessage->setVisible(true);
ui->verifyMessage->setEnabled(false);
ui->verifyMessage->setVisible(false);
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 +244,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 All @@ -339,7 +268,7 @@ void AddressBookPage::on_exportButton_clicked()
// CSV is currently the only supported format
QString filename = GUIUtil::getSaveFileName(
this,
tr("Export Address Book Data"), QString(),
tr("Export Address List"), QString(),
tr("Comma separated file (*.csv)"));

if (filename.isNull()) return;
Expand All @@ -358,25 +287,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
12 changes: 1 addition & 11 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 @@ -63,14 +63,6 @@ private slots:
void on_newAddress_clicked();
/** Copy address of currently selected address entry to clipboard */
void on_copyAddress_clicked();
/** Open the sign message tab in the Sign/Verify Message dialog with currently selected address */
void on_signMessage_clicked();
/** Open the verify message tab in the Sign/Verify Message dialog with currently selected address */
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 All @@ -86,8 +78,6 @@ private slots:
void selectNewAddress(const QModelIndex &parent, int begin, int /*end*/);

signals:
void signMessage(QString addr);
void verifyMessage(QString addr);
void sendCoins(QString addr);
};

Expand Down
Loading

0 comments on commit 081c0cd

Please sign in to comment.