From 79fb0557cf3b72cac6c7db2b5389a48ac8ab4e22 Mon Sep 17 00:00:00 2001 From: Cozz Lovan Date: Sun, 26 Jan 2014 06:37:17 +0100 Subject: [PATCH 1/2] [Qt] minor receive tab improvements --- src/qt/forms/receivecoinsdialog.ui | 77 +++++++++++++++++++------- src/qt/forms/sendcoinsdialog.ui | 84 ++++++++++++++--------------- src/qt/receivecoinsdialog.cpp | 78 +++++++++++++++++++++++++++ src/qt/receivecoinsdialog.h | 12 +++++ src/qt/recentrequeststablemodel.cpp | 5 +- 5 files changed, 193 insertions(+), 63 deletions(-) diff --git a/src/qt/forms/receivecoinsdialog.ui b/src/qt/forms/receivecoinsdialog.ui index e93636ea5f..e5a8812711 100644 --- a/src/qt/forms/receivecoinsdialog.ui +++ b/src/qt/forms/receivecoinsdialog.ui @@ -10,8 +10,23 @@ 364 - + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + @@ -32,6 +47,9 @@ + + An optional message to attach to the payment request, which will be displayed when the request is opened. Note: The message will not be sent with the payment over the Bitcoin network. + &Message: @@ -46,7 +64,7 @@ - An optional label to associate with the new receiving address + An optional label to associate with the new receiving address. @@ -66,6 +84,9 @@ + + An optional label to associate with the new receiving address. + &Label: @@ -79,6 +100,9 @@ + + An optional amount to request. Leave this empty or zero to not request a specific amount. + &Amount: @@ -103,10 +127,25 @@ - - - + + + + + + 150 + 0 + + + + &Request payment + + + + :/icons/receiving_addresses:/icons/receiving_addresses + + + @@ -146,25 +185,20 @@ - - - - - 150 - 0 - - + + + + - &Request payment - - - - :/icons/receiving_addresses:/icons/receiving_addresses + + + + @@ -173,7 +207,7 @@ 20 - 40 + 10 @@ -202,12 +236,15 @@ - Requested payments + Requested payments history + + Qt::CustomContextMenu + true diff --git a/src/qt/forms/sendcoinsdialog.ui b/src/qt/forms/sendcoinsdialog.ui index db8271b016..95f3294adb 100644 --- a/src/qt/forms/sendcoinsdialog.ui +++ b/src/qt/forms/sendcoinsdialog.ui @@ -657,19 +657,25 @@ - + + + + 150 + 0 + + - Send to multiple recipients at once + Confirm the send action - Add &Recipient + S&end - :/icons/add:/icons/add + :/icons/send:/icons/send - - false + + true @@ -699,6 +705,36 @@ + + + + Send to multiple recipients at once + + + Add &Recipient + + + + :/icons/add:/icons/add + + + false + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -726,42 +762,6 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 150 - 0 - - - - Confirm the send action - - - S&end - - - - :/icons/send:/icons/send - - - true - - - diff --git a/src/qt/receivecoinsdialog.cpp b/src/qt/receivecoinsdialog.cpp index 38dc88f63b..8ef80d32ea 100644 --- a/src/qt/receivecoinsdialog.cpp +++ b/src/qt/receivecoinsdialog.cpp @@ -14,6 +14,8 @@ #include "addresstablemodel.h" #include "recentrequeststablemodel.h" +#include +#include #include #include #include @@ -31,6 +33,24 @@ ReceiveCoinsDialog::ReceiveCoinsDialog(QWidget *parent) : ui->showRequestButton->setIcon(QIcon()); ui->removeRequestButton->setIcon(QIcon()); #endif + + // context menu actions + QAction *copyLabelAction = new QAction(tr("Copy label"), this); + QAction *copyMessageAction = new QAction(tr("Copy message"), this); + QAction *copyAmountAction = new QAction(tr("Copy amount"), this); + + // context menu + contextMenu = new QMenu(); + contextMenu->addAction(copyLabelAction); + contextMenu->addAction(copyMessageAction); + contextMenu->addAction(copyAmountAction); + + // context menu signals + connect(ui->recentRequestsView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showMenu(QPoint))); + connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(copyLabel())); + connect(copyMessageAction, SIGNAL(triggered()), this, SLOT(copyMessage())); + connect(copyAmountAction, SIGNAL(triggered()), this, SLOT(copyAmount())); + connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear())); } @@ -164,3 +184,61 @@ void ReceiveCoinsDialog::on_removeRequestButton_clicked() QModelIndex firstIndex = selection.at(0); model->getRecentRequestsTableModel()->removeRows(firstIndex.row(), selection.length(), firstIndex.parent()); } + +void ReceiveCoinsDialog::keyPressEvent(QKeyEvent *event) +{ + if (event->key() == Qt::Key_Return) + { + // press return -> submit form + if (ui->reqLabel->hasFocus() || ui->reqAmount->hasFocus() || ui->reqMessage->hasFocus()) + { + event->ignore(); + on_receiveButton_clicked(); + return; + } + } + + this->QDialog::keyPressEvent(event); +} + +// copy column of selected row to clipboard +void ReceiveCoinsDialog::copyColumnToClipboard(int column) +{ + if(!model || !model->getRecentRequestsTableModel() || !ui->recentRequestsView->selectionModel()) + return; + QModelIndexList selection = ui->recentRequestsView->selectionModel()->selectedRows(); + if(selection.empty()) + return; + // correct for selection mode ContiguousSelection + QModelIndex firstIndex = selection.at(0); + GUIUtil::setClipboard(model->getRecentRequestsTableModel()->data(firstIndex.child(firstIndex.row(), column), Qt::EditRole).toString()); +} + +// context menu +void ReceiveCoinsDialog::showMenu(const QPoint &point) +{ + if(!model || !model->getRecentRequestsTableModel() || !ui->recentRequestsView->selectionModel()) + return; + QModelIndexList selection = ui->recentRequestsView->selectionModel()->selectedRows(); + if(selection.empty()) + return; + contextMenu->exec(QCursor::pos()); +} + +// context menu action: copy label +void ReceiveCoinsDialog::copyLabel() +{ + copyColumnToClipboard(RecentRequestsTableModel::Label); +} + +// context menu action: copy message +void ReceiveCoinsDialog::copyMessage() +{ + copyColumnToClipboard(RecentRequestsTableModel::Message); +} + +// context menu action: copy amount +void ReceiveCoinsDialog::copyAmount() +{ + copyColumnToClipboard(RecentRequestsTableModel::Amount); +} diff --git a/src/qt/receivecoinsdialog.h b/src/qt/receivecoinsdialog.h index ed4b04d361..2c6de0cbca 100644 --- a/src/qt/receivecoinsdialog.h +++ b/src/qt/receivecoinsdialog.h @@ -6,6 +6,9 @@ #define RECEIVECOINSDIALOG_H #include +#include +#include +#include #include namespace Ui { @@ -34,9 +37,14 @@ public slots: void reject(); void accept(); +protected: + virtual void keyPressEvent(QKeyEvent *event); + private: Ui::ReceiveCoinsDialog *ui; WalletModel *model; + QMenu *contextMenu; + void copyColumnToClipboard(int column); private slots: void on_receiveButton_clicked(); @@ -44,6 +52,10 @@ private slots: void on_removeRequestButton_clicked(); void on_recentRequestsView_doubleClicked(const QModelIndex &index); void updateDisplayUnit(); + void showMenu(const QPoint &); + void copyLabel(); + void copyMessage(); + void copyAmount(); }; #endif // RECEIVECOINSDIALOG_H diff --git a/src/qt/recentrequeststablemodel.cpp b/src/qt/recentrequeststablemodel.cpp index 74b43f1d24..64f140bc86 100644 --- a/src/qt/recentrequeststablemodel.cpp +++ b/src/qt/recentrequeststablemodel.cpp @@ -75,7 +75,10 @@ QVariant RecentRequestsTableModel::data(const QModelIndex &index, int role) cons return rec->recipient.message; } case Amount: - return BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), rec->recipient.amount); + if (rec->recipient.amount == 0 && role == Qt::DisplayRole) + return tr("(no amount)"); + else + return BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), rec->recipient.amount); } } return QVariant(); From 69d03bc6e2c97d19b4e23a36205db3fe72bb7c8a Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Wed, 29 Jan 2014 14:41:41 +0100 Subject: [PATCH 2/2] qt: Fix tab order in send and receive tab --- src/qt/bitcoinamountfield.cpp | 3 ++- src/qt/forms/receivecoinsdialog.ui | 5 ++++- src/qt/sendcoinsdialog.cpp | 7 ++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/qt/bitcoinamountfield.cpp b/src/qt/bitcoinamountfield.cpp index 1698595188..c1f2f18d45 100644 --- a/src/qt/bitcoinamountfield.cpp +++ b/src/qt/bitcoinamountfield.cpp @@ -116,7 +116,8 @@ bool BitcoinAmountField::eventFilter(QObject *object, QEvent *event) QWidget *BitcoinAmountField::setupTabChain(QWidget *prev) { QWidget::setTabOrder(prev, amount); - return amount; + QWidget::setTabOrder(amount, unit); + return unit; } qint64 BitcoinAmountField::value(bool *valid_out) const diff --git a/src/qt/forms/receivecoinsdialog.ui b/src/qt/forms/receivecoinsdialog.ui index e5a8812711..3e1a8bccc7 100644 --- a/src/qt/forms/receivecoinsdialog.ui +++ b/src/qt/forms/receivecoinsdialog.ui @@ -245,6 +245,9 @@ Qt::CustomContextMenu + + false + true @@ -312,8 +315,8 @@ reqAmount reqMessage reuseAddress - clearButton receiveButton + clearButton recentRequestsView showRequestButton removeRequestButton diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index e2d7dc9bd3..c3a4e4a0db 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -325,9 +325,10 @@ QWidget *SendCoinsDialog::setupTabChain(QWidget *prev) prev = entry->setupTabChain(prev); } } - QWidget::setTabOrder(prev, ui->addButton); - QWidget::setTabOrder(ui->addButton, ui->sendButton); - return ui->sendButton; + QWidget::setTabOrder(prev, ui->sendButton); + QWidget::setTabOrder(ui->sendButton, ui->clearButton); + QWidget::setTabOrder(ui->clearButton, ui->addButton); + return ui->addButton; } void SendCoinsDialog::setAddress(const QString &address)