Bitcoin ABC  0.22.13
P2P Digital Currency
receiverequestdialog.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2016 The Bitcoin Core developers
2 // Copyright (c) 2017-2019 The Bitcoin developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #include <qt/forms/ui_receiverequestdialog.h>
8 
9 #include <qt/bitcoinunits.h>
10 #include <qt/guiutil.h>
11 #include <qt/optionsmodel.h>
12 #include <qt/qrimagewidget.h>
13 #include <qt/walletmodel.h>
14 
15 #include <QClipboard>
16 #include <QPixmap>
17 
18 #if defined(HAVE_CONFIG_H)
19 #include <config/bitcoin-config.h> /* for USE_QRCODE */
20 #endif
21 
23  : QDialog(parent), ui(new Ui::ReceiveRequestDialog), model(nullptr) {
24  ui->setupUi(this);
25 
26 #ifndef USE_QRCODE
27  ui->btnSaveAs->setVisible(false);
28  ui->lblQRCode->setVisible(false);
29 #endif
30 
31  connect(ui->btnSaveAs, &QPushButton::clicked, ui->lblQRCode,
33 }
34 
36  delete ui;
37 }
38 
40  this->model = _model;
41 
42  if (_model) {
45  }
46 
47  // update the display unit if necessary
48  update();
49 }
50 
52  this->info = _info;
53  update();
54 }
55 
57  if (!model) {
58  return;
59  }
60  QString target = info.label;
61  if (target.isEmpty()) {
62  target = info.address;
63  }
64  setWindowTitle(tr("Request payment to %1").arg(target));
65 
66  QString uri = GUIUtil::formatBitcoinURI(info);
67  ui->btnSaveAs->setEnabled(false);
68  QString html;
69  html += "<html><font face='verdana, arial, helvetica, sans-serif'>";
70  html += "<b>" + tr("Payment information") + "</b><br>";
71  html += "<b>" + tr("URI") + "</b>: ";
72  html += "<a href=\"" + uri + "\">" + GUIUtil::HtmlEscape(uri) + "</a><br>";
73  html += "<b>" + tr("Address") +
74  "</b>: " + GUIUtil::HtmlEscape(info.address) + "<br>";
75  if (info.amount != Amount::zero()) {
76  html += "<b>" + tr("Amount") + "</b>: " +
79  "<br>";
80  }
81  if (!info.label.isEmpty()) {
82  html += "<b>" + tr("Label") +
83  "</b>: " + GUIUtil::HtmlEscape(info.label) + "<br>";
84  }
85  if (!info.message.isEmpty()) {
86  html += "<b>" + tr("Message") +
87  "</b>: " + GUIUtil::HtmlEscape(info.message) + "<br>";
88  }
89  if (model->isMultiwallet()) {
90  html += "<b>" + tr("Wallet") +
91  "</b>: " + GUIUtil::HtmlEscape(model->getWalletName()) + "<br>";
92  }
93  ui->outUri->setText(html);
94 
95  if (ui->lblQRCode->setQR(uri, info.address)) {
96  ui->btnSaveAs->setEnabled(true);
97  }
98 }
99 
102 }
103 
106 }
static constexpr Amount zero()
Definition: amount.h:35
Ui::ReceiveRequestDialog * ui
QString HtmlEscape(const QString &str, bool fMultiLine)
Definition: guiutil.cpp:238
SendCoinsRecipient info
QString formatBitcoinURI(const SendCoinsRecipient &info)
Definition: guiutil.cpp:197
ReceiveRequestDialog(QWidget *parent=nullptr)
int getDisplayUnit() const
Definition: optionsmodel.h:96
void setClipboard(const QString &str)
Definition: guiutil.cpp:732
void setInfo(const SendCoinsRecipient &info)
QString getWalletName() const
void displayUnitChanged(int unit)
static QString formatHtmlWithUnit(int unit, const Amount amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as HTML string (with unit)
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:47
bool isMultiwallet()
OptionsModel * getOptionsModel()
void setModel(WalletModel *model)