Bitcoin ABC  0.24.7
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 <QDialog>
16 #include <QString>
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);
26 }
27 
29  delete ui;
30 }
31 
33  this->model = _model;
34 
35  if (_model) {
38  }
39 
40  // update the display unit if necessary
41  update();
42 }
43 
45  this->info = _info;
46  setWindowTitle(tr("Request payment to %1")
47  .arg(info.label.isEmpty() ? info.address : info.label));
48  QString uri = GUIUtil::formatBitcoinURI(info);
49 
50 #ifdef USE_QRCODE
51  if (ui->qr_code->setQR(uri, info.address)) {
52  connect(ui->btnSaveAs, &QPushButton::clicked, ui->qr_code,
54  } else {
55  ui->btnSaveAs->setEnabled(false);
56  }
57 #else
58  ui->btnSaveAs->hide();
59  ui->qr_code->hide();
60 #endif
61 
62  ui->uri_content->setText("<a href=\"" + uri + "\">" +
63  GUIUtil::HtmlEscape(uri) + "</a>");
64  ui->address_content->setText(info.address);
65 
66  if (info.amount == Amount::zero()) {
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  if (!model) {
96  return;
97  }
98  ui->amount_content->setText(BitcoinUnits::formatWithUnit(
100 }
101 
104 }
105 
108 }
qrimagewidget.h
WalletModel::getOptionsModel
OptionsModel * getOptionsModel()
Definition: walletmodel.cpp:315
ReceiveRequestDialog::setModel
void setModel(WalletModel *model)
Definition: receiverequestdialog.cpp:32
ReceiveRequestDialog::ui
Ui::ReceiveRequestDialog * ui
Definition: receiverequestdialog.h:34
WalletModel
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:47
SendCoinsRecipient::amount
Amount amount
Definition: sendcoinsrecipient.h:41
ReceiveRequestDialog::info
SendCoinsRecipient info
Definition: receiverequestdialog.h:36
walletmodel.h
SendCoinsRecipient::label
QString label
Definition: sendcoinsrecipient.h:40
OptionsModel::displayUnitChanged
void displayUnitChanged(int unit)
GUIUtil::formatBitcoinURI
QString formatBitcoinURI(const SendCoinsRecipient &info)
Definition: guiutil.cpp:199
ReceiveRequestDialog::model
WalletModel * model
Definition: receiverequestdialog.h:35
ReceiveRequestDialog::updateDisplayUnit
void updateDisplayUnit()
Definition: receiverequestdialog.cpp:94
ReceiveRequestDialog::on_btnCopyAddress_clicked
void on_btnCopyAddress_clicked()
Definition: receiverequestdialog.cpp:106
GUIUtil::setClipboard
void setClipboard(const QString &str)
Definition: guiutil.cpp:766
Amount::zero
static constexpr Amount zero()
Definition: amount.h:42
ReceiveRequestDialog::setInfo
void setInfo(const SendCoinsRecipient &info)
Definition: receiverequestdialog.cpp:44
SendCoinsRecipient
Definition: sendcoinsrecipient.h:23
ReceiveRequestDialog::ReceiveRequestDialog
ReceiveRequestDialog(QWidget *parent=nullptr)
Definition: receiverequestdialog.cpp:22
BitcoinUnits::formatWithUnit
static QString formatWithUnit(int unit, const Amount amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD)
Format as string (with unit)
Definition: bitcoinunits.cpp:161
guiutil.h
WalletModel::getWalletName
QString getWalletName() const
Definition: walletmodel.cpp:518
ReceiveRequestDialog
Definition: receiverequestdialog.h:18
Ui
Definition: addressbookpage.h:14
GUIUtil::HtmlEscape
QString HtmlEscape(const QString &str, bool fMultiLine)
Definition: guiutil.cpp:240
OptionsModel::getDisplayUnit
int getDisplayUnit() const
Definition: optionsmodel.h:97
ReceiveRequestDialog::on_btnCopyURI_clicked
void on_btnCopyURI_clicked()
Definition: receiverequestdialog.cpp:102
SendCoinsRecipient::address
QString address
Definition: sendcoinsrecipient.h:39
bitcoinunits.h
ReceiveRequestDialog::~ReceiveRequestDialog
~ReceiveRequestDialog()
Definition: receiverequestdialog.cpp:28
GUIUtil::handleCloseWindowShortcut
void handleCloseWindowShortcut(QWidget *w)
Definition: guiutil.cpp:396
optionsmodel.h
receiverequestdialog.h
QRImageWidget::saveImage
void saveImage()
Definition: qrimagewidget.cpp:133
SendCoinsRecipient::message
QString message
Definition: sendcoinsrecipient.h:43