Bitcoin Core  0.20.99
P2P Digital Currency
receiverequestdialog.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2019 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
6 #include <qt/forms/ui_receiverequestdialog.h>
7 
8 #include <qt/bitcoinunits.h>
9 #include <qt/guiutil.h>
10 #include <qt/optionsmodel.h>
11 #include <qt/qrimagewidget.h>
12 #include <qt/walletmodel.h>
13 
14 #include <QDialog>
15 #include <QString>
16 
17 #if defined(HAVE_CONFIG_H)
18 #include <config/bitcoin-config.h> /* for USE_QRCODE */
19 #endif
20 
22  QDialog(parent),
23  ui(new Ui::ReceiveRequestDialog),
24  model(nullptr)
25 {
26  ui->setupUi(this);
28 }
29 
31 {
32  delete ui;
33 }
34 
36 {
37  this->model = _model;
38 
39  if (_model)
41 
42  // update the display unit if necessary
43  update();
44 }
45 
47 {
48  this->info = _info;
49  setWindowTitle(tr("Request payment to %1").arg(info.label.isEmpty() ? info.address : info.label));
50  QString uri = GUIUtil::formatBitcoinURI(info);
51 
52 #ifdef USE_QRCODE
53  if (ui->qr_code->setQR(uri, info.address)) {
54  connect(ui->btnSaveAs, &QPushButton::clicked, ui->qr_code, &QRImageWidget::saveImage);
55  } else {
56  ui->btnSaveAs->setEnabled(false);
57  }
58 #else
59  ui->btnSaveAs->hide();
60  ui->qr_code->hide();
61 #endif
62 
63  ui->uri_content->setText("<a href=\"" + uri + "\">" + GUIUtil::HtmlEscape(uri) + "</a>");
64  ui->address_content->setText(info.address);
65 
66  if (!info.amount) {
67  ui->amount_tag->hide();
68  ui->amount_content->hide();
69  } // Amount is set in updateDisplayUnit() slot.
71 
72  if (!info.label.isEmpty()) {
73  ui->label_content->setText(info.label);
74  } else {
75  ui->label_tag->hide();
76  ui->label_content->hide();
77  }
78 
79  if (!info.message.isEmpty()) {
80  ui->message_content->setText(info.message);
81  } else {
82  ui->message_tag->hide();
83  ui->message_content->hide();
84  }
85 
86  if (!model->getWalletName().isEmpty()) {
87  ui->wallet_content->setText(model->getWalletName());
88  } else {
89  ui->wallet_tag->hide();
90  ui->wallet_content->hide();
91  }
92 }
93 
95 {
96  if (!model) return;
98 }
99 
101 {
103 }
104 
106 {
108 }
Ui::ReceiveRequestDialog * ui
QString HtmlEscape(const QString &str, bool fMultiLine)
Definition: guiutil.cpp:220
SendCoinsRecipient info
QString formatBitcoinURI(const SendCoinsRecipient &info)
Definition: guiutil.cpp:182
ReceiveRequestDialog(QWidget *parent=nullptr)
int getDisplayUnit() const
Definition: optionsmodel.h:81
void setClipboard(const QString &str)
Definition: guiutil.cpp:718
void handleCloseWindowShortcut(QWidget *w)
Definition: guiutil.cpp:390
void setInfo(const SendCoinsRecipient &info)
QString getWalletName() const
void displayUnitChanged(int unit)
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:51
static QString formatWithUnit(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as string (with unit)
OptionsModel * getOptionsModel()
void setModel(WalletModel *model)