@@ -43,18 +43,21 @@ ReceiveCoinsDialog::ReceiveCoinsDialog(const PlatformStyle *platformStyle, QWidg
43
43
}
44
44
45
45
// context menu actions
46
+ QAction *copyURIAction = new QAction (tr (" Copy URI" ), this );
46
47
QAction *copyLabelAction = new QAction (tr (" Copy label" ), this );
47
48
QAction *copyMessageAction = new QAction (tr (" Copy message" ), this );
48
49
QAction *copyAmountAction = new QAction (tr (" Copy amount" ), this );
49
50
50
51
// context menu
51
52
contextMenu = new QMenu ();
53
+ contextMenu->addAction (copyURIAction);
52
54
contextMenu->addAction (copyLabelAction);
53
55
contextMenu->addAction (copyMessageAction);
54
56
contextMenu->addAction (copyAmountAction);
55
57
56
58
// context menu signals
57
59
connect (ui->recentRequestsView , SIGNAL (customContextMenuRequested (QPoint)), this , SLOT (showMenu (QPoint)));
60
+ connect (copyURIAction, SIGNAL (triggered ()), this , SLOT (copyURI ()));
58
61
connect (copyLabelAction, SIGNAL (triggered ()), this , SLOT (copyLabel ()));
59
62
connect (copyMessageAction, SIGNAL (triggered ()), this , SLOT (copyMessage ()));
60
63
connect (copyAmountAction, SIGNAL (triggered ()), this , SLOT (copyAmount ()));
@@ -227,30 +230,50 @@ void ReceiveCoinsDialog::keyPressEvent(QKeyEvent *event)
227
230
this ->QDialog ::keyPressEvent (event);
228
231
}
229
232
230
- // copy column of selected row to clipboard
231
- void ReceiveCoinsDialog::copyColumnToClipboard (int column)
233
+ QModelIndex ReceiveCoinsDialog::selectedRow ()
232
234
{
233
235
if (!model || !model->getRecentRequestsTableModel () || !ui->recentRequestsView ->selectionModel ())
234
- return ;
236
+ return QModelIndex () ;
235
237
QModelIndexList selection = ui->recentRequestsView ->selectionModel ()->selectedRows ();
236
238
if (selection.empty ())
237
- return ;
239
+ return QModelIndex () ;
238
240
// correct for selection mode ContiguousSelection
239
241
QModelIndex firstIndex = selection.at (0 );
242
+ return firstIndex;
243
+ }
244
+
245
+ // copy column of selected row to clipboard
246
+ void ReceiveCoinsDialog::copyColumnToClipboard (int column)
247
+ {
248
+ QModelIndex firstIndex = selectedRow ();
249
+ if (!firstIndex.isValid ()) {
250
+ return ;
251
+ }
240
252
GUIUtil::setClipboard (model->getRecentRequestsTableModel ()->data (firstIndex.child (firstIndex.row (), column), Qt::EditRole).toString ());
241
253
}
242
254
243
255
// context menu
244
256
void ReceiveCoinsDialog::showMenu (const QPoint &point)
245
257
{
246
- if (!model || !model->getRecentRequestsTableModel () || !ui->recentRequestsView ->selectionModel ())
247
- return ;
248
- QModelIndexList selection = ui->recentRequestsView ->selectionModel ()->selectedRows ();
249
- if (selection.empty ())
258
+ if (!selectedRow ().isValid ()) {
250
259
return ;
260
+ }
251
261
contextMenu->exec (QCursor::pos ());
252
262
}
253
263
264
+ // context menu action: copy URI
265
+ void ReceiveCoinsDialog::copyURI ()
266
+ {
267
+ QModelIndex sel = selectedRow ();
268
+ if (!sel.isValid ()) {
269
+ return ;
270
+ }
271
+
272
+ const RecentRequestsTableModel * const submodel = model->getRecentRequestsTableModel ();
273
+ const QString uri = GUIUtil::formatBitcoinURI (submodel->entry (sel.row ()).recipient );
274
+ GUIUtil::setClipboard (uri);
275
+ }
276
+
254
277
// context menu action: copy label
255
278
void ReceiveCoinsDialog::copyLabel ()
256
279
{
0 commit comments