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
This commit is contained in:
UdjinM6 2019-03-06 22:45:22 +03:00 committed by GitHub
parent b6177740c2
commit e63cdadc97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 168 additions and 1 deletions

View File

@ -15,7 +15,9 @@
#include "csvmodelwriter.h" #include "csvmodelwriter.h"
#include "editaddressdialog.h" #include "editaddressdialog.h"
#include "guiutil.h" #include "guiutil.h"
#include "optionsmodel.h"
#include "platformstyle.h" #include "platformstyle.h"
#include "qrdialog.h"
#include <QIcon> #include <QIcon>
#include <QMenu> #include <QMenu>
@ -42,6 +44,7 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode,
ui->deleteAddress->setIcon(QIcon(":/icons/" + theme + "/remove")); ui->deleteAddress->setIcon(QIcon(":/icons/" + theme + "/remove"));
ui->exportButton->setIcon(QIcon(":/icons/" + theme + "/export")); ui->exportButton->setIcon(QIcon(":/icons/" + theme + "/export"));
} }
ui->showAddressQRCode->setIcon(QIcon());
switch(mode) switch(mode)
{ {
@ -81,6 +84,7 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode,
QAction *copyAddressAction = new QAction(tr("&Copy Address"), this); QAction *copyAddressAction = new QAction(tr("&Copy Address"), this);
QAction *copyLabelAction = new QAction(tr("Copy &Label"), this); QAction *copyLabelAction = new QAction(tr("Copy &Label"), this);
QAction *editAction = new QAction(tr("&Edit"), this); QAction *editAction = new QAction(tr("&Edit"), this);
QAction *showAddressQRCodeAction = new QAction(tr("&Show address QR code"), this);
deleteAction = new QAction(ui->deleteAddress->text(), this); deleteAction = new QAction(ui->deleteAddress->text(), this);
// Build context menu // Build context menu
@ -91,12 +95,14 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode,
if(tab == SendingTab) if(tab == SendingTab)
contextMenu->addAction(deleteAction); contextMenu->addAction(deleteAction);
contextMenu->addSeparator(); contextMenu->addSeparator();
contextMenu->addAction(showAddressQRCodeAction);
// Connect signals for context menu actions // Connect signals for context menu actions
connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(on_copyAddress_clicked())); connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(on_copyAddress_clicked()));
connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(onCopyLabelAction())); connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(onCopyLabelAction()));
connect(editAction, SIGNAL(triggered()), this, SLOT(onEditAction())); connect(editAction, SIGNAL(triggered()), this, SLOT(onEditAction()));
connect(deleteAction, SIGNAL(triggered()), this, SLOT(on_deleteAddress_clicked())); connect(deleteAction, SIGNAL(triggered()), this, SLOT(on_deleteAddress_clicked()));
connect(showAddressQRCodeAction, SIGNAL(triggered()), this, SLOT(on_showAddressQRCode_clicked()));
connect(ui->tableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint))); connect(ui->tableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint)));
@ -213,6 +219,23 @@ void AddressBookPage::on_deleteAddress_clicked()
} }
} }
void AddressBookPage::on_showAddressQRCode_clicked()
{
QList<QModelIndex> entries = GUIUtil::getEntryData(ui->tableView, AddressTableModel::Address);
if (entries.empty()) {
return;
}
QString strAddress = entries.at(0).data(Qt::EditRole).toString();
QRDialog* dialog = new QRDialog(this);
OptionsModel *model = new OptionsModel(NULL, false);
dialog->setModel(model);
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->setInfo(tr("QR code"), "dash:"+strAddress, "", strAddress);
dialog->show();
}
void AddressBookPage::selectionChanged() void AddressBookPage::selectionChanged()
{ {
// Set button states based on selected tab and selection // Set button states based on selected tab and selection
@ -238,11 +261,13 @@ void AddressBookPage::selectionChanged()
break; break;
} }
ui->copyAddress->setEnabled(true); ui->copyAddress->setEnabled(true);
ui->showAddressQRCode->setEnabled(true);
} }
else else
{ {
ui->deleteAddress->setEnabled(false); ui->deleteAddress->setEnabled(false);
ui->copyAddress->setEnabled(false); ui->copyAddress->setEnabled(false);
ui->showAddressQRCode->setEnabled(false);
} }
} }

View File

@ -71,6 +71,8 @@ private Q_SLOTS:
void onCopyLabelAction(); void onCopyLabelAction();
/** Edit currently selected address entry (no button) */ /** Edit currently selected address entry (no button) */
void onEditAction(); void onEditAction();
/** Show QR code for the currently selected address */
void on_showAddressQRCode_clicked();
/** Export button clicked */ /** Export button clicked */
void on_exportButton_clicked(); void on_exportButton_clicked();

View File

@ -77,6 +77,19 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="showAddressQRCode">
<property name="toolTip">
<string>Show QR code for the currently selected address</string>
</property>
<property name="text">
<string>&amp;Show QR code</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="deleteAddress"> <widget class="QPushButton" name="deleteAddress">
<property name="toolTip"> <property name="toolTip">

View File

@ -8,7 +8,6 @@
#include "init.h" #include "init.h"
#include "masternode-sync.h" #include "masternode-sync.h"
#include "netbase.h" #include "netbase.h"
#include "qrdialog.h"
#include "sync.h" #include "sync.h"
#include "wallet/wallet.h" #include "wallet/wallet.h"
#include "walletmodel.h" #include "walletmodel.h"

View File

@ -136,6 +136,10 @@ void QRDialog::update()
setWindowTitle(strWindowtitle); setWindowTitle(strWindowtitle);
ui->button_saveImage->setEnabled(false); ui->button_saveImage->setEnabled(false);
if (strTextInfo.isEmpty()) {
ui->outUri->setVisible(false);
adjustSize();
}
ui->outUri->setText(strTextInfo); ui->outUri->setText(strTextInfo);
#ifdef USE_QRCODE #ifdef USE_QRCODE

View File

@ -606,6 +606,23 @@ QWidget#AddressBookPage QPushButton#copyAddress:pressed {
border:1px solid #9e9e9e; border:1px solid #9e9e9e;
} }
QWidget#AddressBookPage QPushButton#showAddressQRCode { /* Show Address QR code Button */
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);
border:1px solid #d2d2d2;
color:#616161;
padding-left:10px;
padding-right:10px;
}
QWidget#AddressBookPage QPushButton#showAddressQRCode:hover {
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);
color:#333;
}
QWidget#AddressBookPage QPushButton#showAddressQRCode:pressed {
border:1px solid #9e9e9e;
}
QWidget#AddressBookPage QPushButton#deleteAddress { /* Delete Address Button */ QWidget#AddressBookPage QPushButton#deleteAddress { /* Delete Address Button */
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); 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);
border:1px solid #d2d2d2; border:1px solid #d2d2d2;

View File

@ -601,6 +601,23 @@ QWidget#AddressBookPage QPushButton#copyAddress:pressed {
border:1px solid #9e9e9e; border:1px solid #9e9e9e;
} }
QWidget#AddressBookPage QPushButton#showAddressQRCode { /* Show Address QR code Button */
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);
border:1px solid #d2d2d2;
color:#616161;
padding-left:10px;
padding-right:10px;
}
QWidget#AddressBookPage QPushButton#showAddressQRCode:hover {
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);
color:#333;
}
QWidget#AddressBookPage QPushButton#showAddressQRCode:pressed {
border:1px solid #9e9e9e;
}
QWidget#AddressBookPage QPushButton#deleteAddress { /* Delete Address Button */ QWidget#AddressBookPage QPushButton#deleteAddress { /* Delete Address Button */
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); 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);
border:1px solid #d2d2d2; border:1px solid #d2d2d2;

View File

@ -604,6 +604,23 @@ QWidget#AddressBookPage QPushButton#copyAddress:pressed {
border:1px solid #9e9e9e; border:1px solid #9e9e9e;
} }
QWidget#AddressBookPage QPushButton#showAddressQRCode { /* Show Address QR code Button */
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);
border:1px solid #d2d2d2;
color:#616161;
padding-left:10px;
padding-right:10px;
}
QWidget#AddressBookPage QPushButton#showAddressQRCode:hover {
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);
color:#333;
}
QWidget#AddressBookPage QPushButton#showAddressQRCode:pressed {
border:1px solid #9e9e9e;
}
QWidget#AddressBookPage QPushButton#deleteAddress { /* Delete Address Button */ QWidget#AddressBookPage QPushButton#deleteAddress { /* Delete Address Button */
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); 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);
border:1px solid #d2d2d2; border:1px solid #d2d2d2;

View File

@ -604,6 +604,23 @@ QWidget#AddressBookPage QPushButton#copyAddress:pressed {
border:1px solid #9e9e9e; border:1px solid #9e9e9e;
} }
QWidget#AddressBookPage QPushButton#showAddressQRCode { /* Show Address QR code Button */
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);
border:1px solid #d2d2d2;
color:#616161;
padding-left:10px;
padding-right:10px;
}
QWidget#AddressBookPage QPushButton#showAddressQRCode:hover {
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);
color:#333;
}
QWidget#AddressBookPage QPushButton#showAddressQRCode:pressed {
border:1px solid #9e9e9e;
}
QWidget#AddressBookPage QPushButton#deleteAddress { /* Delete Address Button */ QWidget#AddressBookPage QPushButton#deleteAddress { /* Delete Address Button */
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); 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);
border:1px solid #d2d2d2; border:1px solid #d2d2d2;

View File

@ -604,6 +604,23 @@ QWidget#AddressBookPage QPushButton#copyAddress:pressed {
border:1px solid #9e9e9e; border:1px solid #9e9e9e;
} }
QWidget#AddressBookPage QPushButton#showAddressQRCode { /* Show Address QR code Button */
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);
border:1px solid #d2d2d2;
color:#616161;
padding-left:10px;
padding-right:10px;
}
QWidget#AddressBookPage QPushButton#showAddressQRCode:hover {
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);
color:#333;
}
QWidget#AddressBookPage QPushButton#showAddressQRCode:pressed {
border:1px solid #9e9e9e;
}
QWidget#AddressBookPage QPushButton#deleteAddress { /* Delete Address Button */ QWidget#AddressBookPage QPushButton#deleteAddress { /* Delete Address Button */
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); 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);
border:1px solid #d2d2d2; border:1px solid #d2d2d2;

View File

@ -604,6 +604,23 @@ QWidget#AddressBookPage QPushButton#copyAddress:pressed {
border:1px solid #9e9e9e; border:1px solid #9e9e9e;
} }
QWidget#AddressBookPage QPushButton#showAddressQRCode { /* Show Address QR code Button */
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);
border:1px solid #d2d2d2;
color:#616161;
padding-left:10px;
padding-right:10px;
}
QWidget#AddressBookPage QPushButton#showAddressQRCode:hover {
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);
color:#333;
}
QWidget#AddressBookPage QPushButton#showAddressQRCode:pressed {
border:1px solid #9e9e9e;
}
QWidget#AddressBookPage QPushButton#deleteAddress { /* Delete Address Button */ QWidget#AddressBookPage QPushButton#deleteAddress { /* Delete Address Button */
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); 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);
border:1px solid #d2d2d2; border:1px solid #d2d2d2;

View File

@ -11,6 +11,7 @@
#include "guiutil.h" #include "guiutil.h"
#include "optionsmodel.h" #include "optionsmodel.h"
#include "platformstyle.h" #include "platformstyle.h"
#include "qrdialog.h"
#include "transactiondescdialog.h" #include "transactiondescdialog.h"
#include "transactionfilterproxy.h" #include "transactionfilterproxy.h"
#include "transactionrecord.h" #include "transactionrecord.h"
@ -167,6 +168,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
QAction *copyTxPlainText = new QAction(tr("Copy full transaction details"), this); QAction *copyTxPlainText = new QAction(tr("Copy full transaction details"), this);
QAction *editLabelAction = new QAction(tr("Edit label"), this); QAction *editLabelAction = new QAction(tr("Edit label"), this);
QAction *showDetailsAction = new QAction(tr("Show transaction details"), this); QAction *showDetailsAction = new QAction(tr("Show transaction details"), this);
QAction *showAddressQRCodeAction = new QAction(tr("Show address QR code"), this);
contextMenu = new QMenu(this); contextMenu = new QMenu(this);
contextMenu->addAction(copyAddressAction); contextMenu->addAction(copyAddressAction);
@ -176,6 +178,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
contextMenu->addAction(copyTxHexAction); contextMenu->addAction(copyTxHexAction);
contextMenu->addAction(copyTxPlainText); contextMenu->addAction(copyTxPlainText);
contextMenu->addAction(showDetailsAction); contextMenu->addAction(showDetailsAction);
contextMenu->addAction(showAddressQRCodeAction);
contextMenu->addSeparator(); contextMenu->addSeparator();
contextMenu->addAction(abandonAction); contextMenu->addAction(abandonAction);
contextMenu->addAction(editLabelAction); contextMenu->addAction(editLabelAction);
@ -205,6 +208,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
connect(copyTxPlainText, SIGNAL(triggered()), this, SLOT(copyTxPlainText())); connect(copyTxPlainText, SIGNAL(triggered()), this, SLOT(copyTxPlainText()));
connect(editLabelAction, SIGNAL(triggered()), this, SLOT(editLabel())); connect(editLabelAction, SIGNAL(triggered()), this, SLOT(editLabel()));
connect(showDetailsAction, SIGNAL(triggered()), this, SLOT(showDetails())); connect(showDetailsAction, SIGNAL(triggered()), this, SLOT(showDetails()));
connect(showAddressQRCodeAction, SIGNAL(triggered()), this, SLOT(showAddressQRCode()));
} }
void TransactionView::setModel(WalletModel *_model) void TransactionView::setModel(WalletModel *_model)
@ -542,6 +546,23 @@ void TransactionView::showDetails()
} }
} }
void TransactionView::showAddressQRCode()
{
QList<QModelIndex> entries = GUIUtil::getEntryData(transactionView, 0);
if (entries.empty()) {
return;
}
QString strAddress = entries.at(0).data(TransactionTableModel::AddressRole).toString();
QRDialog* dialog = new QRDialog(this);
OptionsModel *model = new OptionsModel(NULL, false);
dialog->setModel(model);
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->setInfo(tr("QR code"), "dash:"+strAddress, "", strAddress);
dialog->show();
}
/** Compute sum of all selected transactions */ /** Compute sum of all selected transactions */
void TransactionView::computeSum() void TransactionView::computeSum()
{ {

View File

@ -91,6 +91,7 @@ private Q_SLOTS:
void contextualMenu(const QPoint &); void contextualMenu(const QPoint &);
void dateRangeChanged(); void dateRangeChanged();
void showDetails(); void showDetails();
void showAddressQRCode();
void copyAddress(); void copyAddress();
void editLabel(); void editLabel();
void copyLabel(); void copyLabel();