Changeset View
Changeset View
Standalone View
Standalone View
src/qt/receiverequestdialog.cpp
// Copyright (c) 2011-2016 The Bitcoin Core developers | // Copyright (c) 2011-2016 The Bitcoin Core developers | ||||
// Copyright (c) 2017 The Bitcoin developers | // Copyright (c) 2017 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <qt/forms/ui_receiverequestdialog.h> | #include <qt/forms/ui_receiverequestdialog.h> | ||||
#include <qt/receiverequestdialog.h> | #include <qt/receiverequestdialog.h> | ||||
#include <config.h> | |||||
#include <qt/bitcoinunits.h> | #include <qt/bitcoinunits.h> | ||||
#include <qt/guiconstants.h> | #include <qt/guiconstants.h> | ||||
#include <qt/guiutil.h> | #include <qt/guiutil.h> | ||||
#include <qt/optionsmodel.h> | #include <qt/optionsmodel.h> | ||||
#include <qt/walletmodel.h> | #include <qt/walletmodel.h> | ||||
#include <QClipboard> | #include <QClipboard> | ||||
#include <QDrag> | #include <QDrag> | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | void QRImageWidget::copyImage() { | ||||
QApplication::clipboard()->setImage(exportImage()); | QApplication::clipboard()->setImage(exportImage()); | ||||
} | } | ||||
void QRImageWidget::contextMenuEvent(QContextMenuEvent *event) { | void QRImageWidget::contextMenuEvent(QContextMenuEvent *event) { | ||||
if (!pixmap()) return; | if (!pixmap()) return; | ||||
contextMenu->exec(event->globalPos()); | contextMenu->exec(event->globalPos()); | ||||
} | } | ||||
ReceiveRequestDialog::ReceiveRequestDialog(const Config *configIn, | ReceiveRequestDialog::ReceiveRequestDialog(QWidget *parent) | ||||
QWidget *parent) | : QDialog(parent), ui(new Ui::ReceiveRequestDialog), model(0) { | ||||
: QDialog(parent), ui(new Ui::ReceiveRequestDialog), model(0), | |||||
config(configIn) { | |||||
ui->setupUi(this); | ui->setupUi(this); | ||||
#ifndef USE_QRCODE | #ifndef USE_QRCODE | ||||
ui->btnSaveAs->setVisible(false); | ui->btnSaveAs->setVisible(false); | ||||
ui->lblQRCode->setVisible(false); | ui->lblQRCode->setVisible(false); | ||||
#endif | #endif | ||||
connect(ui->btnSaveAs, SIGNAL(clicked()), ui->lblQRCode, SLOT(saveImage())); | connect(ui->btnSaveAs, SIGNAL(clicked()), ui->lblQRCode, SLOT(saveImage())); | ||||
Show All 11 Lines | if (_model) | ||||
this, SLOT(update())); | this, SLOT(update())); | ||||
// update the display unit if necessary | // update the display unit if necessary | ||||
update(); | update(); | ||||
} | } | ||||
void ReceiveRequestDialog::setInfo(const SendCoinsRecipient &_info) { | void ReceiveRequestDialog::setInfo(const SendCoinsRecipient &_info) { | ||||
this->info = _info; | this->info = _info; | ||||
// Display addresses with currently configured encoding. | |||||
this->info.address = | |||||
GUIUtil::convertToConfiguredAddressFormat(*config, this->info.address); | |||||
update(); | update(); | ||||
} | } | ||||
void ReceiveRequestDialog::update() { | void ReceiveRequestDialog::update() { | ||||
if (!model) return; | if (!model) return; | ||||
QString target = info.label; | QString target = info.label; | ||||
if (target.isEmpty()) target = info.address; | if (target.isEmpty()) target = info.address; | ||||
setWindowTitle(tr("Request payment to %1").arg(target)); | setWindowTitle(tr("Request payment to %1").arg(target)); | ||||
QString uri = GUIUtil::formatBitcoinURI(*config, info); | QString uri = GUIUtil::formatBitcoinURI(info); | ||||
ui->btnSaveAs->setEnabled(false); | ui->btnSaveAs->setEnabled(false); | ||||
QString html; | QString html; | ||||
html += "<html><font face='verdana, arial, helvetica, sans-serif'>"; | html += "<html><font face='verdana, arial, helvetica, sans-serif'>"; | ||||
html += "<b>" + tr("Payment information") + "</b><br>"; | html += "<b>" + tr("Payment information") + "</b><br>"; | ||||
html += "<b>" + tr("URI") + "</b>: "; | html += "<b>" + tr("URI") + "</b>: "; | ||||
html += "<a href=\"" + uri + "\">" + GUIUtil::HtmlEscape(uri) + "</a><br>"; | html += "<a href=\"" + uri + "\">" + GUIUtil::HtmlEscape(uri) + "</a><br>"; | ||||
html += "<b>" + tr("Address") + | html += "<b>" + tr("Address") + | ||||
"</b>: " + GUIUtil::HtmlEscape(info.address) + "<br>"; | "</b>: " + GUIUtil::HtmlEscape(info.address) + "<br>"; | ||||
Show All 10 Lines | if (!info.message.isEmpty()) | ||||
"</b>: " + GUIUtil::HtmlEscape(info.message) + "<br>"; | "</b>: " + GUIUtil::HtmlEscape(info.message) + "<br>"; | ||||
if (model->isMultiwallet()) { | if (model->isMultiwallet()) { | ||||
html += "<b>" + tr("Wallet") + | html += "<b>" + tr("Wallet") + | ||||
"</b>: " + GUIUtil::HtmlEscape(model->getWalletName()) + "<br>"; | "</b>: " + GUIUtil::HtmlEscape(model->getWalletName()) + "<br>"; | ||||
} | } | ||||
ui->outUri->setText(html); | ui->outUri->setText(html); | ||||
#ifdef USE_QRCODE | #ifdef USE_QRCODE | ||||
int fontSize = config->UseCashAddrEncoding() ? 10 : 12; | int fontSize = 10; | ||||
ui->lblQRCode->setText(""); | ui->lblQRCode->setText(""); | ||||
if (!uri.isEmpty()) { | if (!uri.isEmpty()) { | ||||
// limit URI length | // limit URI length | ||||
if (uri.length() > MAX_URI_LENGTH) { | if (uri.length() > MAX_URI_LENGTH) { | ||||
ui->lblQRCode->setText(tr("Resulting URI too long, try to reduce " | ui->lblQRCode->setText(tr("Resulting URI too long, try to reduce " | ||||
"the text for label / message.")); | "the text for label / message.")); | ||||
} else { | } else { | ||||
Show All 33 Lines | if (!uri.isEmpty()) { | ||||
ui->lblQRCode->setPixmap(QPixmap::fromImage(qrAddrImage)); | ui->lblQRCode->setPixmap(QPixmap::fromImage(qrAddrImage)); | ||||
ui->btnSaveAs->setEnabled(true); | ui->btnSaveAs->setEnabled(true); | ||||
} | } | ||||
} | } | ||||
#endif | #endif | ||||
} | } | ||||
void ReceiveRequestDialog::on_btnCopyURI_clicked() { | void ReceiveRequestDialog::on_btnCopyURI_clicked() { | ||||
GUIUtil::setClipboard(GUIUtil::formatBitcoinURI(*config, info)); | GUIUtil::setClipboard(GUIUtil::formatBitcoinURI(info)); | ||||
} | } | ||||
void ReceiveRequestDialog::on_btnCopyAddress_clicked() { | void ReceiveRequestDialog::on_btnCopyAddress_clicked() { | ||||
GUIUtil::setClipboard(info.address); | GUIUtil::setClipboard(info.address); | ||||
} | } |