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:
parent
b6177740c2
commit
e63cdadc97
@ -15,7 +15,9 @@
|
||||
#include "csvmodelwriter.h"
|
||||
#include "editaddressdialog.h"
|
||||
#include "guiutil.h"
|
||||
#include "optionsmodel.h"
|
||||
#include "platformstyle.h"
|
||||
#include "qrdialog.h"
|
||||
|
||||
#include <QIcon>
|
||||
#include <QMenu>
|
||||
@ -42,6 +44,7 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode,
|
||||
ui->deleteAddress->setIcon(QIcon(":/icons/" + theme + "/remove"));
|
||||
ui->exportButton->setIcon(QIcon(":/icons/" + theme + "/export"));
|
||||
}
|
||||
ui->showAddressQRCode->setIcon(QIcon());
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
@ -81,6 +84,7 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode,
|
||||
QAction *copyAddressAction = new QAction(tr("&Copy Address"), this);
|
||||
QAction *copyLabelAction = new QAction(tr("Copy &Label"), 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);
|
||||
|
||||
// Build context menu
|
||||
@ -91,12 +95,14 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode,
|
||||
if(tab == SendingTab)
|
||||
contextMenu->addAction(deleteAction);
|
||||
contextMenu->addSeparator();
|
||||
contextMenu->addAction(showAddressQRCodeAction);
|
||||
|
||||
// Connect signals for context menu actions
|
||||
connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(on_copyAddress_clicked()));
|
||||
connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(onCopyLabelAction()));
|
||||
connect(editAction, SIGNAL(triggered()), this, SLOT(onEditAction()));
|
||||
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)));
|
||||
|
||||
@ -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()
|
||||
{
|
||||
// Set button states based on selected tab and selection
|
||||
@ -238,11 +261,13 @@ void AddressBookPage::selectionChanged()
|
||||
break;
|
||||
}
|
||||
ui->copyAddress->setEnabled(true);
|
||||
ui->showAddressQRCode->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->deleteAddress->setEnabled(false);
|
||||
ui->copyAddress->setEnabled(false);
|
||||
ui->showAddressQRCode->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,6 +71,8 @@ private Q_SLOTS:
|
||||
void onCopyLabelAction();
|
||||
/** Edit currently selected address entry (no button) */
|
||||
void onEditAction();
|
||||
/** Show QR code for the currently selected address */
|
||||
void on_showAddressQRCode_clicked();
|
||||
/** Export button clicked */
|
||||
void on_exportButton_clicked();
|
||||
|
||||
|
@ -77,6 +77,19 @@
|
||||
</property>
|
||||
</widget>
|
||||
</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>&Show QR code</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="deleteAddress">
|
||||
<property name="toolTip">
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "init.h"
|
||||
#include "masternode-sync.h"
|
||||
#include "netbase.h"
|
||||
#include "qrdialog.h"
|
||||
#include "sync.h"
|
||||
#include "wallet/wallet.h"
|
||||
#include "walletmodel.h"
|
||||
|
@ -136,6 +136,10 @@ void QRDialog::update()
|
||||
|
||||
setWindowTitle(strWindowtitle);
|
||||
ui->button_saveImage->setEnabled(false);
|
||||
if (strTextInfo.isEmpty()) {
|
||||
ui->outUri->setVisible(false);
|
||||
adjustSize();
|
||||
}
|
||||
ui->outUri->setText(strTextInfo);
|
||||
|
||||
#ifdef USE_QRCODE
|
||||
|
@ -606,6 +606,23 @@ QWidget#AddressBookPage QPushButton#copyAddress:pressed {
|
||||
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 */
|
||||
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;
|
||||
|
@ -601,6 +601,23 @@ QWidget#AddressBookPage QPushButton#copyAddress:pressed {
|
||||
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 */
|
||||
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;
|
||||
|
@ -604,6 +604,23 @@ QWidget#AddressBookPage QPushButton#copyAddress:pressed {
|
||||
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 */
|
||||
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;
|
||||
|
@ -604,6 +604,23 @@ QWidget#AddressBookPage QPushButton#copyAddress:pressed {
|
||||
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 */
|
||||
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;
|
||||
|
@ -604,6 +604,23 @@ QWidget#AddressBookPage QPushButton#copyAddress:pressed {
|
||||
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 */
|
||||
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;
|
||||
|
@ -604,6 +604,23 @@ QWidget#AddressBookPage QPushButton#copyAddress:pressed {
|
||||
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 */
|
||||
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;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "guiutil.h"
|
||||
#include "optionsmodel.h"
|
||||
#include "platformstyle.h"
|
||||
#include "qrdialog.h"
|
||||
#include "transactiondescdialog.h"
|
||||
#include "transactionfilterproxy.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 *editLabelAction = new QAction(tr("Edit label"), 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->addAction(copyAddressAction);
|
||||
@ -176,6 +178,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
|
||||
contextMenu->addAction(copyTxHexAction);
|
||||
contextMenu->addAction(copyTxPlainText);
|
||||
contextMenu->addAction(showDetailsAction);
|
||||
contextMenu->addAction(showAddressQRCodeAction);
|
||||
contextMenu->addSeparator();
|
||||
contextMenu->addAction(abandonAction);
|
||||
contextMenu->addAction(editLabelAction);
|
||||
@ -205,6 +208,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
|
||||
connect(copyTxPlainText, SIGNAL(triggered()), this, SLOT(copyTxPlainText()));
|
||||
connect(editLabelAction, SIGNAL(triggered()), this, SLOT(editLabel()));
|
||||
connect(showDetailsAction, SIGNAL(triggered()), this, SLOT(showDetails()));
|
||||
connect(showAddressQRCodeAction, SIGNAL(triggered()), this, SLOT(showAddressQRCode()));
|
||||
}
|
||||
|
||||
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 */
|
||||
void TransactionView::computeSum()
|
||||
{
|
||||
|
@ -91,6 +91,7 @@ private Q_SLOTS:
|
||||
void contextualMenu(const QPoint &);
|
||||
void dateRangeChanged();
|
||||
void showDetails();
|
||||
void showAddressQRCode();
|
||||
void copyAddress();
|
||||
void editLabel();
|
||||
void copyLabel();
|
||||
|
Loading…
Reference in New Issue
Block a user