Skip to content

Commit bb3da8f

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 78effb3 commit bb3da8f

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
@@ -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

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)