Skip to content

Commit e63cdad

Browse files
authored
Add a button/context menu items to show QR codes for addresses (#2741)
* Add a button/context menu item to show qr codes for addresses in address book * Add a context menu item to show qr code for addresses in transaction list
1 parent b617774 commit e63cdad

13 files changed

+168
-1
lines changed

src/qt/addressbookpage.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
#include "csvmodelwriter.h"
1616
#include "editaddressdialog.h"
1717
#include "guiutil.h"
18+
#include "optionsmodel.h"
1819
#include "platformstyle.h"
20+
#include "qrdialog.h"
1921

2022
#include <QIcon>
2123
#include <QMenu>
@@ -42,6 +44,7 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode,
4244
ui->deleteAddress->setIcon(QIcon(":/icons/" + theme + "/remove"));
4345
ui->exportButton->setIcon(QIcon(":/icons/" + theme + "/export"));
4446
}
47+
ui->showAddressQRCode->setIcon(QIcon());
4548

4649
switch(mode)
4750
{
@@ -81,6 +84,7 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode,
8184
QAction *copyAddressAction = new QAction(tr("&Copy Address"), this);
8285
QAction *copyLabelAction = new QAction(tr("Copy &Label"), this);
8386
QAction *editAction = new QAction(tr("&Edit"), this);
87+
QAction *showAddressQRCodeAction = new QAction(tr("&Show address QR code"), this);
8488
deleteAction = new QAction(ui->deleteAddress->text(), this);
8589

8690
// Build context menu
@@ -91,12 +95,14 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode,
9195
if(tab == SendingTab)
9296
contextMenu->addAction(deleteAction);
9397
contextMenu->addSeparator();
98+
contextMenu->addAction(showAddressQRCodeAction);
9499

95100
// Connect signals for context menu actions
96101
connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(on_copyAddress_clicked()));
97102
connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(onCopyLabelAction()));
98103
connect(editAction, SIGNAL(triggered()), this, SLOT(onEditAction()));
99104
connect(deleteAction, SIGNAL(triggered()), this, SLOT(on_deleteAddress_clicked()));
105+
connect(showAddressQRCodeAction, SIGNAL(triggered()), this, SLOT(on_showAddressQRCode_clicked()));
100106

101107
connect(ui->tableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint)));
102108

@@ -213,6 +219,23 @@ void AddressBookPage::on_deleteAddress_clicked()
213219
}
214220
}
215221

222+
void AddressBookPage::on_showAddressQRCode_clicked()
223+
{
224+
QList<QModelIndex> entries = GUIUtil::getEntryData(ui->tableView, AddressTableModel::Address);
225+
if (entries.empty()) {
226+
return;
227+
}
228+
229+
QString strAddress = entries.at(0).data(Qt::EditRole).toString();
230+
QRDialog* dialog = new QRDialog(this);
231+
OptionsModel *model = new OptionsModel(NULL, false);
232+
233+
dialog->setModel(model);
234+
dialog->setAttribute(Qt::WA_DeleteOnClose);
235+
dialog->setInfo(tr("QR code"), "dash:"+strAddress, "", strAddress);
236+
dialog->show();
237+
}
238+
216239
void AddressBookPage::selectionChanged()
217240
{
218241
// Set button states based on selected tab and selection
@@ -238,11 +261,13 @@ void AddressBookPage::selectionChanged()
238261
break;
239262
}
240263
ui->copyAddress->setEnabled(true);
264+
ui->showAddressQRCode->setEnabled(true);
241265
}
242266
else
243267
{
244268
ui->deleteAddress->setEnabled(false);
245269
ui->copyAddress->setEnabled(false);
270+
ui->showAddressQRCode->setEnabled(false);
246271
}
247272
}
248273

src/qt/addressbookpage.h

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ private Q_SLOTS:
7171
void onCopyLabelAction();
7272
/** Edit currently selected address entry (no button) */
7373
void onEditAction();
74+
/** Show QR code for the currently selected address */
75+
void on_showAddressQRCode_clicked();
7476
/** Export button clicked */
7577
void on_exportButton_clicked();
7678

src/qt/forms/addressbookpage.ui

+13
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,19 @@
7777
</property>
7878
</widget>
7979
</item>
80+
<item>
81+
<widget class="QPushButton" name="showAddressQRCode">
82+
<property name="toolTip">
83+
<string>Show QR code for the currently selected address</string>
84+
</property>
85+
<property name="text">
86+
<string>&amp;Show QR code</string>
87+
</property>
88+
<property name="autoDefault">
89+
<bool>false</bool>
90+
</property>
91+
</widget>
92+
</item>
8093
<item>
8194
<widget class="QPushButton" name="deleteAddress">
8295
<property name="toolTip">

src/qt/masternodelist.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include "init.h"
99
#include "masternode-sync.h"
1010
#include "netbase.h"
11-
#include "qrdialog.h"
1211
#include "sync.h"
1312
#include "wallet/wallet.h"
1413
#include "walletmodel.h"

src/qt/qrdialog.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ void QRDialog::update()
136136

137137
setWindowTitle(strWindowtitle);
138138
ui->button_saveImage->setEnabled(false);
139+
if (strTextInfo.isEmpty()) {
140+
ui->outUri->setVisible(false);
141+
adjustSize();
142+
}
139143
ui->outUri->setText(strTextInfo);
140144

141145
#ifdef USE_QRCODE

src/qt/res/css/crownium.css

+17
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,23 @@ QWidget#AddressBookPage QPushButton#copyAddress:pressed {
606606
border:1px solid #9e9e9e;
607607
}
608608

609+
QWidget#AddressBookPage QPushButton#showAddressQRCode { /* Show Address QR code Button */
610+
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: .01 #f6f6f6, stop: .1 rgba(250, 250, 250, 128), stop: .95 rgba(250, 250, 250, 255), stop: 1 #ebebeb);
611+
border:1px solid #d2d2d2;
612+
color:#616161;
613+
padding-left:10px;
614+
padding-right:10px;
615+
}
616+
617+
QWidget#AddressBookPage QPushButton#showAddressQRCode:hover {
618+
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: .01 #f6f6f6, stop: .1 rgba(240, 240, 240, 255), stop: .95 rgba(240, 240, 240, 255), stop: 1 #ebebeb);
619+
color:#333;
620+
}
621+
622+
QWidget#AddressBookPage QPushButton#showAddressQRCode:pressed {
623+
border:1px solid #9e9e9e;
624+
}
625+
609626
QWidget#AddressBookPage QPushButton#deleteAddress { /* Delete Address Button */
610627
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: .01 #f6f6f6, stop: .1 rgba(250, 250, 250, 128), stop: .95 rgba(250, 250, 250, 255), stop: 1 #ebebeb);
611628
border:1px solid #d2d2d2;

src/qt/res/css/drkblue.css

+17
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,23 @@ QWidget#AddressBookPage QPushButton#copyAddress:pressed {
601601
border:1px solid #9e9e9e;
602602
}
603603

604+
QWidget#AddressBookPage QPushButton#showAddressQRCode { /* Show Address QR code Button */
605+
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: .01 #f6f6f6, stop: .1 rgba(250, 250, 250, 128), stop: .95 rgba(250, 250, 250, 255), stop: 1 #ebebeb);
606+
border:1px solid #d2d2d2;
607+
color:#616161;
608+
padding-left:10px;
609+
padding-right:10px;
610+
}
611+
612+
QWidget#AddressBookPage QPushButton#showAddressQRCode:hover {
613+
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: .01 #f6f6f6, stop: .1 rgba(240, 240, 240, 255), stop: .95 rgba(240, 240, 240, 255), stop: 1 #ebebeb);
614+
color:#333;
615+
}
616+
617+
QWidget#AddressBookPage QPushButton#showAddressQRCode:pressed {
618+
border:1px solid #9e9e9e;
619+
}
620+
604621
QWidget#AddressBookPage QPushButton#deleteAddress { /* Delete Address Button */
605622
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: .01 #f6f6f6, stop: .1 rgba(250, 250, 250, 128), stop: .95 rgba(250, 250, 250, 255), stop: 1 #ebebeb);
606623
border:1px solid #d2d2d2;

src/qt/res/css/light-hires-retro.css

+17
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,23 @@ QWidget#AddressBookPage QPushButton#copyAddress:pressed {
604604
border:1px solid #9e9e9e;
605605
}
606606

607+
QWidget#AddressBookPage QPushButton#showAddressQRCode { /* Show Address QR code Button */
608+
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: .01 #f6f6f6, stop: .1 rgba(250, 250, 250, 128), stop: .95 rgba(250, 250, 250, 255), stop: 1 #ebebeb);
609+
border:1px solid #d2d2d2;
610+
color:#616161;
611+
padding-left:10px;
612+
padding-right:10px;
613+
}
614+
615+
QWidget#AddressBookPage QPushButton#showAddressQRCode:hover {
616+
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: .01 #f6f6f6, stop: .1 rgba(240, 240, 240, 255), stop: .95 rgba(240, 240, 240, 255), stop: 1 #ebebeb);
617+
color:#333;
618+
}
619+
620+
QWidget#AddressBookPage QPushButton#showAddressQRCode:pressed {
621+
border:1px solid #9e9e9e;
622+
}
623+
607624
QWidget#AddressBookPage QPushButton#deleteAddress { /* Delete Address Button */
608625
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: .01 #f6f6f6, stop: .1 rgba(250, 250, 250, 128), stop: .95 rgba(250, 250, 250, 255), stop: 1 #ebebeb);
609626
border:1px solid #d2d2d2;

src/qt/res/css/light-hires.css

+17
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,23 @@ QWidget#AddressBookPage QPushButton#copyAddress:pressed {
604604
border:1px solid #9e9e9e;
605605
}
606606

607+
QWidget#AddressBookPage QPushButton#showAddressQRCode { /* Show Address QR code Button */
608+
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: .01 #f6f6f6, stop: .1 rgba(250, 250, 250, 128), stop: .95 rgba(250, 250, 250, 255), stop: 1 #ebebeb);
609+
border:1px solid #d2d2d2;
610+
color:#616161;
611+
padding-left:10px;
612+
padding-right:10px;
613+
}
614+
615+
QWidget#AddressBookPage QPushButton#showAddressQRCode:hover {
616+
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: .01 #f6f6f6, stop: .1 rgba(240, 240, 240, 255), stop: .95 rgba(240, 240, 240, 255), stop: 1 #ebebeb);
617+
color:#333;
618+
}
619+
620+
QWidget#AddressBookPage QPushButton#showAddressQRCode:pressed {
621+
border:1px solid #9e9e9e;
622+
}
623+
607624
QWidget#AddressBookPage QPushButton#deleteAddress { /* Delete Address Button */
608625
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: .01 #f6f6f6, stop: .1 rgba(250, 250, 250, 128), stop: .95 rgba(250, 250, 250, 255), stop: 1 #ebebeb);
609626
border:1px solid #d2d2d2;

src/qt/res/css/light-retro.css

+17
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,23 @@ QWidget#AddressBookPage QPushButton#copyAddress:pressed {
604604
border:1px solid #9e9e9e;
605605
}
606606

607+
QWidget#AddressBookPage QPushButton#showAddressQRCode { /* Show Address QR code Button */
608+
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: .01 #f6f6f6, stop: .1 rgba(250, 250, 250, 128), stop: .95 rgba(250, 250, 250, 255), stop: 1 #ebebeb);
609+
border:1px solid #d2d2d2;
610+
color:#616161;
611+
padding-left:10px;
612+
padding-right:10px;
613+
}
614+
615+
QWidget#AddressBookPage QPushButton#showAddressQRCode:hover {
616+
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: .01 #f6f6f6, stop: .1 rgba(240, 240, 240, 255), stop: .95 rgba(240, 240, 240, 255), stop: 1 #ebebeb);
617+
color:#333;
618+
}
619+
620+
QWidget#AddressBookPage QPushButton#showAddressQRCode:pressed {
621+
border:1px solid #9e9e9e;
622+
}
623+
607624
QWidget#AddressBookPage QPushButton#deleteAddress { /* Delete Address Button */
608625
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: .01 #f6f6f6, stop: .1 rgba(250, 250, 250, 128), stop: .95 rgba(250, 250, 250, 255), stop: 1 #ebebeb);
609626
border:1px solid #d2d2d2;

src/qt/res/css/light.css

+17
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,23 @@ QWidget#AddressBookPage QPushButton#copyAddress:pressed {
604604
border:1px solid #9e9e9e;
605605
}
606606

607+
QWidget#AddressBookPage QPushButton#showAddressQRCode { /* Show Address QR code Button */
608+
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: .01 #f6f6f6, stop: .1 rgba(250, 250, 250, 128), stop: .95 rgba(250, 250, 250, 255), stop: 1 #ebebeb);
609+
border:1px solid #d2d2d2;
610+
color:#616161;
611+
padding-left:10px;
612+
padding-right:10px;
613+
}
614+
615+
QWidget#AddressBookPage QPushButton#showAddressQRCode:hover {
616+
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: .01 #f6f6f6, stop: .1 rgba(240, 240, 240, 255), stop: .95 rgba(240, 240, 240, 255), stop: 1 #ebebeb);
617+
color:#333;
618+
}
619+
620+
QWidget#AddressBookPage QPushButton#showAddressQRCode:pressed {
621+
border:1px solid #9e9e9e;
622+
}
623+
607624
QWidget#AddressBookPage QPushButton#deleteAddress { /* Delete Address Button */
608625
background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: .01 #f6f6f6, stop: .1 rgba(250, 250, 250, 128), stop: .95 rgba(250, 250, 250, 255), stop: 1 #ebebeb);
609626
border:1px solid #d2d2d2;

src/qt/transactionview.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "guiutil.h"
1212
#include "optionsmodel.h"
1313
#include "platformstyle.h"
14+
#include "qrdialog.h"
1415
#include "transactiondescdialog.h"
1516
#include "transactionfilterproxy.h"
1617
#include "transactionrecord.h"
@@ -167,6 +168,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
167168
QAction *copyTxPlainText = new QAction(tr("Copy full transaction details"), this);
168169
QAction *editLabelAction = new QAction(tr("Edit label"), this);
169170
QAction *showDetailsAction = new QAction(tr("Show transaction details"), this);
171+
QAction *showAddressQRCodeAction = new QAction(tr("Show address QR code"), this);
170172

171173
contextMenu = new QMenu(this);
172174
contextMenu->addAction(copyAddressAction);
@@ -176,6 +178,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
176178
contextMenu->addAction(copyTxHexAction);
177179
contextMenu->addAction(copyTxPlainText);
178180
contextMenu->addAction(showDetailsAction);
181+
contextMenu->addAction(showAddressQRCodeAction);
179182
contextMenu->addSeparator();
180183
contextMenu->addAction(abandonAction);
181184
contextMenu->addAction(editLabelAction);
@@ -205,6 +208,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
205208
connect(copyTxPlainText, SIGNAL(triggered()), this, SLOT(copyTxPlainText()));
206209
connect(editLabelAction, SIGNAL(triggered()), this, SLOT(editLabel()));
207210
connect(showDetailsAction, SIGNAL(triggered()), this, SLOT(showDetails()));
211+
connect(showAddressQRCodeAction, SIGNAL(triggered()), this, SLOT(showAddressQRCode()));
208212
}
209213

210214
void TransactionView::setModel(WalletModel *_model)
@@ -542,6 +546,23 @@ void TransactionView::showDetails()
542546
}
543547
}
544548

549+
void TransactionView::showAddressQRCode()
550+
{
551+
QList<QModelIndex> entries = GUIUtil::getEntryData(transactionView, 0);
552+
if (entries.empty()) {
553+
return;
554+
}
555+
556+
QString strAddress = entries.at(0).data(TransactionTableModel::AddressRole).toString();
557+
QRDialog* dialog = new QRDialog(this);
558+
OptionsModel *model = new OptionsModel(NULL, false);
559+
560+
dialog->setModel(model);
561+
dialog->setAttribute(Qt::WA_DeleteOnClose);
562+
dialog->setInfo(tr("QR code"), "dash:"+strAddress, "", strAddress);
563+
dialog->show();
564+
}
565+
545566
/** Compute sum of all selected transactions */
546567
void TransactionView::computeSum()
547568
{

src/qt/transactionview.h

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ private Q_SLOTS:
9191
void contextualMenu(const QPoint &);
9292
void dateRangeChanged();
9393
void showDetails();
94+
void showAddressQRCode();
9495
void copyAddress();
9596
void editLabel();
9697
void copyLabel();

0 commit comments

Comments
 (0)