Skip to content

Commit 3f83f05

Browse files
committed
qt: Disable requests context menu actions when appropriate
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 action if the respective fields are empty.
1 parent 7fca189 commit 3f83f05

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/qt/receivecoinsdialog.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ ReceiveCoinsDialog::ReceiveCoinsDialog(const PlatformStyle *_platformStyle, QWid
4444

4545
// context menu actions
4646
QAction *copyURIAction = new QAction(tr("Copy URI"), this);
47-
QAction *copyLabelAction = new QAction(tr("Copy label"), this);
48-
QAction *copyMessageAction = new QAction(tr("Copy message"), this);
49-
QAction *copyAmountAction = new QAction(tr("Copy amount"), this);
47+
copyLabelAction = new QAction(tr("Copy label"), this);
48+
copyMessageAction = new QAction(tr("Copy message"), this);
49+
copyAmountAction = new QAction(tr("Copy amount"), this);
5050

5151
// context menu
5252
contextMenu = new QMenu(this);
@@ -266,9 +266,18 @@ void ReceiveCoinsDialog::copyColumnToClipboard(int column)
266266
// context menu
267267
void ReceiveCoinsDialog::showMenu(const QPoint &point)
268268
{
269-
if (!selectedRow().isValid()) {
269+
const QModelIndex sel = selectedRow();
270+
if (!sel.isValid()) {
270271
return;
271272
}
273+
274+
// disable context menu actions when appropriate
275+
const RecentRequestsTableModel* const submodel = model->getRecentRequestsTableModel();
276+
const RecentRequestEntry& req = submodel->entry(sel.row());
277+
copyLabelAction->setDisabled(req.recipient.label.isEmpty());
278+
copyMessageAction->setDisabled(req.recipient.message.isEmpty());
279+
copyAmountAction->setDisabled(req.recipient.amount == 0);
280+
272281
contextMenu->exec(QCursor::pos());
273282
}
274283

src/qt/receivecoinsdialog.h

Lines changed: 3 additions & 0 deletions
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)