Skip to content

Commit e348d7e

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 5bb64ac commit e348d7e

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
@@ -44,20 +44,23 @@ ReceiveCoinsDialog::ReceiveCoinsDialog(const PlatformStyle *_platformStyle, QWid
4444

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

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

5860
// context menu signals
5961
connect(ui->recentRequestsView, &QWidget::customContextMenuRequested, this, &ReceiveCoinsDialog::showMenu);
6062
connect(copyURIAction, &QAction::triggered, this, &ReceiveCoinsDialog::copyURI);
63+
connect(copyAddressAction, &QAction::triggered, this, &ReceiveCoinsDialog::copyAddress);
6164
connect(copyLabelAction, &QAction::triggered, this, &ReceiveCoinsDialog::copyLabel);
6265
connect(copyMessageAction, &QAction::triggered, this, &ReceiveCoinsDialog::copyMessage);
6366
connect(copyAmountAction, &QAction::triggered, this, &ReceiveCoinsDialog::copyAmount);
@@ -287,6 +290,19 @@ void ReceiveCoinsDialog::copyURI()
287290
GUIUtil::setClipboard(uri);
288291
}
289292

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

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)