@@ -43,18 +43,21 @@ ReceiveCoinsDialog::ReceiveCoinsDialog(const PlatformStyle *_platformStyle, QWid
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 ()));
@@ -228,30 +231,50 @@ void ReceiveCoinsDialog::keyPressEvent(QKeyEvent *event)
228
231
this ->QDialog ::keyPressEvent (event);
229
232
}
230
233
231
- // copy column of selected row to clipboard
232
- void ReceiveCoinsDialog::copyColumnToClipboard (int column)
234
+ QModelIndex ReceiveCoinsDialog::selectedRow ()
233
235
{
234
236
if (!model || !model->getRecentRequestsTableModel () || !ui->recentRequestsView ->selectionModel ())
235
- return ;
237
+ return QModelIndex () ;
236
238
QModelIndexList selection = ui->recentRequestsView ->selectionModel ()->selectedRows ();
237
239
if (selection.empty ())
238
- return ;
240
+ return QModelIndex () ;
239
241
// correct for selection mode ContiguousSelection
240
242
QModelIndex firstIndex = selection.at (0 );
243
+ return firstIndex;
244
+ }
245
+
246
+ // copy column of selected row to clipboard
247
+ void ReceiveCoinsDialog::copyColumnToClipboard (int column)
248
+ {
249
+ QModelIndex firstIndex = selectedRow ();
250
+ if (!firstIndex.isValid ()) {
251
+ return ;
252
+ }
241
253
GUIUtil::setClipboard (model->getRecentRequestsTableModel ()->data (firstIndex.child (firstIndex.row (), column), Qt::EditRole).toString ());
242
254
}
243
255
244
256
// context menu
245
257
void ReceiveCoinsDialog::showMenu (const QPoint &point)
246
258
{
247
- if (!model || !model->getRecentRequestsTableModel () || !ui->recentRequestsView ->selectionModel ())
248
- return ;
249
- QModelIndexList selection = ui->recentRequestsView ->selectionModel ()->selectedRows ();
250
- if (selection.empty ())
259
+ if (!selectedRow ().isValid ()) {
251
260
return ;
261
+ }
252
262
contextMenu->exec (QCursor::pos ());
253
263
}
254
264
265
+ // context menu action: copy URI
266
+ void ReceiveCoinsDialog::copyURI ()
267
+ {
268
+ QModelIndex sel = selectedRow ();
269
+ if (!sel.isValid ()) {
270
+ return ;
271
+ }
272
+
273
+ const RecentRequestsTableModel * const submodel = model->getRecentRequestsTableModel ();
274
+ const QString uri = GUIUtil::formatBitcoinURI (submodel->entry (sel.row ()).recipient );
275
+ GUIUtil::setClipboard (uri);
276
+ }
277
+
255
278
// context menu action: copy label
256
279
void ReceiveCoinsDialog::copyLabel ()
257
280
{
0 commit comments