Skip to content

Commit 24fcd97

Browse files
committed
qt: Add Copy Address Action to Payment Requests
Currently, the only way to copy the address of a payment request is to double-click on the payment request and then click on the copy address button. This commit adds a convenient context menu action to copy the address of a payment request.
1 parent f5cdc29 commit 24fcd97

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/qt/receivecoinsdialog.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,23 @@ ReceiveCoinsDialog::ReceiveCoinsDialog(const PlatformStyle *_platformStyle, QWid
4343

4444
// context menu actions
4545
QAction *copyURIAction = new QAction(tr("Copy URI"), this);
46+
QAction *copyAddressAction = new QAction(tr("Copy address"), this);
4647
QAction *copyLabelAction = new QAction(tr("Copy label"), this);
4748
QAction *copyMessageAction = new QAction(tr("Copy message"), this);
4849
QAction *copyAmountAction = new QAction(tr("Copy amount"), this);
4950

5051
// context menu
5152
contextMenu = new QMenu(this);
5253
contextMenu->addAction(copyURIAction);
54+
contextMenu->addAction(copyAddressAction);
5355
contextMenu->addAction(copyLabelAction);
5456
contextMenu->addAction(copyMessageAction);
5557
contextMenu->addAction(copyAmountAction);
5658

5759
// context menu signals
5860
connect(ui->recentRequestsView, &QWidget::customContextMenuRequested, this, &ReceiveCoinsDialog::showMenu);
5961
connect(copyURIAction, &QAction::triggered, this, &ReceiveCoinsDialog::copyURI);
62+
connect(copyAddressAction, &QAction::triggered, this, &ReceiveCoinsDialog::copyAddress);
6063
connect(copyLabelAction, &QAction::triggered, this, &ReceiveCoinsDialog::copyLabel);
6164
connect(copyMessageAction, &QAction::triggered, this, &ReceiveCoinsDialog::copyMessage);
6265
connect(copyAmountAction, &QAction::triggered, this, &ReceiveCoinsDialog::copyAmount);
@@ -286,6 +289,19 @@ void ReceiveCoinsDialog::copyURI()
286289
GUIUtil::setClipboard(uri);
287290
}
288291

292+
// context menu action: copy address
293+
void ReceiveCoinsDialog::copyAddress()
294+
{
295+
const QModelIndex sel = selectedRow();
296+
if (!sel.isValid()) {
297+
return;
298+
}
299+
300+
const RecentRequestsTableModel * const submodel = model->getRecentRequestsTableModel();
301+
const QString address = submodel->entry(sel.row()).recipient.address;
302+
GUIUtil::setClipboard(address);
303+
}
304+
289305
// context menu action: copy label
290306
void ReceiveCoinsDialog::copyLabel()
291307
{

src/qt/receivecoinsdialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ private Q_SLOTS:
6969
void updateDisplayUnit();
7070
void showMenu(const QPoint &point);
7171
void copyURI();
72+
void copyAddress();
7273
void copyLabel();
7374
void copyMessage();
7475
void copyAmount();

0 commit comments

Comments
 (0)