Skip to content

Commit 5a67b52

Browse files
committed
merge bitcoin-core/gui#214: Disable requests context menu actions when appropriate
1 parent dc9b25e commit 5a67b52

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
@@ -34,9 +34,9 @@ ReceiveCoinsDialog::ReceiveCoinsDialog(QWidget* parent) :
3434
// context menu actions
3535
QAction *copyURIAction = new QAction(tr("Copy URI"), this);
3636
QAction* copyAddressAction = new QAction(tr("Copy address"), this);
37-
QAction *copyLabelAction = new QAction(tr("Copy label"), this);
38-
QAction *copyMessageAction = new QAction(tr("Copy message"), this);
39-
QAction *copyAmountAction = new QAction(tr("Copy amount"), this);
37+
copyLabelAction = new QAction(tr("Copy label"), this);
38+
copyMessageAction = new QAction(tr("Copy message"), this);
39+
copyAmountAction = new QAction(tr("Copy amount"), this);
4040

4141
// context menu
4242
contextMenu = new QMenu(this);
@@ -239,9 +239,18 @@ void ReceiveCoinsDialog::copyColumnToClipboard(int column)
239239
// context menu
240240
void ReceiveCoinsDialog::showMenu(const QPoint &point)
241241
{
242-
if (!selectedRow().isValid()) {
242+
const QModelIndex sel = selectedRow();
243+
if (!sel.isValid()) {
243244
return;
244245
}
246+
247+
// disable context menu actions when appropriate
248+
const RecentRequestsTableModel* const submodel = model->getRecentRequestsTableModel();
249+
const RecentRequestEntry& req = submodel->entry(sel.row());
250+
copyLabelAction->setDisabled(req.recipient.label.isEmpty());
251+
copyMessageAction->setDisabled(req.recipient.message.isEmpty());
252+
copyAmountAction->setDisabled(req.recipient.amount == 0);
253+
245254
contextMenu->exec(QCursor::pos());
246255
}
247256

src/qt/receivecoinsdialog.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public Q_SLOTS:
5252
Ui::ReceiveCoinsDialog *ui;
5353
WalletModel *model;
5454
QMenu *contextMenu;
55+
QAction* copyLabelAction;
56+
QAction* copyMessageAction;
57+
QAction* copyAmountAction;
5558

5659
QModelIndex selectedRow();
5760
void copyColumnToClipboard(int column);

0 commit comments

Comments
 (0)