Skip to content

Commit 09bc7bf

Browse files
author
MarcoFalke
committed
Merge bitcoin-core/gui#214: qt: Disable requests context menu actions when appropriate
bb3da8f qt: Disable requests context menu actions when appropriate (Jarol Rodriguez) Pull request description: The recent requests table will allow you to copy data points even if they do not exist. This PR implements checks to disable the `copy label`, `copy message`, and `copy amount` context menu actions if the respective fields are empty. This brings the recent requests table context menu behavior closer to the behavior seen in the transaction view. On a payment request entry which does not have a value for label, message, or amount: | Master | PR | | ----------- | ----------- | |<img width="169" alt="Screen Shot 2021-02-19 at 1 22 28 AM" src="https://user-images.githubusercontent.com/23396902/108466086-167adc00-7251-11eb-8bd6-13984042bdb3.png">| <img width="169" alt="Screen Shot 2021-02-19 at 1 21 49 AM" src="https://user-images.githubusercontent.com/23396902/108466185-3e6a3f80-7251-11eb-9dd8-492ed07fd638.png">| `copy URI` never needs to be disabled as an entry in the recent requests table must have a URI even if it doesn't have a label, message, or amount. #213 will add a `copy address` context menu action. This also does not need a check as an entry must be associated with an address. Below are some more examples of how this PR will behave: **Has Label, Message, and Amount** <img width="780" alt="Screen Shot 2021-02-19 at 12 05 38 AM" src="https://user-images.githubusercontent.com/23396902/108466507-c18b9580-7251-11eb-8875-f3aeb9c4c8e9.png"> **Has Label and Amount, but no Message** <img width="780" alt="Screen Shot 2021-02-19 at 12 05 58 AM" src="https://user-images.githubusercontent.com/23396902/108466421-9b65f580-7251-11eb-97eb-a3bfaa21fa7d.png"> ACKs for top commit: hebasto: re-ACK bb3da8f Tree-SHA512: d98f1a6e05ebf6d9d056bc5754aca78ca7ecda93f497dba88187b947ca4a261eb7dc5e8c872956315acaa0008cc39320fb5806e17117e0c873090ad917ca4a3d
2 parents 434065a + bb3da8f commit 09bc7bf

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/qt/receivecoinsdialog.cpp

+13-4
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ ReceiveCoinsDialog::ReceiveCoinsDialog(const PlatformStyle *_platformStyle, QWid
4545
// context menu actions
4646
QAction *copyURIAction = new QAction(tr("Copy URI"), this);
4747
QAction* copyAddressAction = new QAction(tr("Copy address"), this);
48-
QAction *copyLabelAction = new QAction(tr("Copy label"), this);
49-
QAction *copyMessageAction = new QAction(tr("Copy message"), this);
50-
QAction *copyAmountAction = new QAction(tr("Copy amount"), this);
48+
copyLabelAction = new QAction(tr("Copy label"), this);
49+
copyMessageAction = new QAction(tr("Copy message"), this);
50+
copyAmountAction = new QAction(tr("Copy amount"), this);
5151

5252
// context menu
5353
contextMenu = new QMenu(this);
@@ -269,9 +269,18 @@ void ReceiveCoinsDialog::copyColumnToClipboard(int column)
269269
// context menu
270270
void ReceiveCoinsDialog::showMenu(const QPoint &point)
271271
{
272-
if (!selectedRow().isValid()) {
272+
const QModelIndex sel = selectedRow();
273+
if (!sel.isValid()) {
273274
return;
274275
}
276+
277+
// disable context menu actions when appropriate
278+
const RecentRequestsTableModel* const submodel = model->getRecentRequestsTableModel();
279+
const RecentRequestEntry& req = submodel->entry(sel.row());
280+
copyLabelAction->setDisabled(req.recipient.label.isEmpty());
281+
copyMessageAction->setDisabled(req.recipient.message.isEmpty());
282+
copyAmountAction->setDisabled(req.recipient.amount == 0);
283+
275284
contextMenu->exec(QCursor::pos());
276285
}
277286

src/qt/receivecoinsdialog.h

+3
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ public Q_SLOTS:
5353
Ui::ReceiveCoinsDialog *ui;
5454
WalletModel *model;
5555
QMenu *contextMenu;
56+
QAction* copyLabelAction;
57+
QAction* copyMessageAction;
58+
QAction* copyAmountAction;
5659
const PlatformStyle *platformStyle;
5760

5861
QModelIndex selectedRow();

0 commit comments

Comments
 (0)