Bitcoin ABC 0.30.5
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}
static QString formatWithUnit(int unit, const Amount amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD)
Format as string (with unit)
int getDisplayUnit() const
Definition: optionsmodel.h:97
void displayUnitChanged(int unit)
ReceiveRequestDialog(QWidget *parent=nullptr)
void setModel(WalletModel *model)
Ui::ReceiveRequestDialog * ui
void setInfo(const SendCoinsRecipient &info)
SendCoinsRecipient info
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:47
OptionsModel * getOptionsModel()
QString getWalletName() const
QString HtmlEscape(const QString &str, bool fMultiLine)
Definition: guiutil.cpp:251
void handleCloseWindowShortcut(QWidget *w)
Definition: guiutil.cpp:407
QString formatBitcoinURI(const SendCoinsRecipient &info)
Definition: guiutil.cpp:210
void setClipboard(const QString &str)
Definition: guiutil.cpp:776
static constexpr Amount zero() noexcept
Definition: amount.h:32