Bitcoin Core 28.99.0
P2P Digital Currency
receiverequestdialog.cpp
Go to the documentation of this file.
1// Copyright (c) 2011-2021 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#include <bitcoin-build-config.h> // IWYU pragma: keep
18
20 : QDialog(parent, GUIUtil::dialog_flags),
22{
23 ui->setupUi(this);
25}
26
28{
29 delete ui;
30}
31
33{
34 this->model = _model;
35
36 if (_model)
38
39 // update the display unit if necessary
40 update();
41}
42
44{
45 this->info = _info;
46 setWindowTitle(tr("Request payment to %1").arg(info.label.isEmpty() ? info.address : info.label));
47 QString uri = GUIUtil::formatBitcoinURI(info);
48
49#ifdef USE_QRCODE
50 if (ui->qr_code->setQR(uri, info.address)) {
51 connect(ui->btnSaveAs, &QPushButton::clicked, ui->qr_code, &QRImageWidget::saveImage);
52 } else {
53 ui->btnSaveAs->setEnabled(false);
54 }
55#else
56 ui->btnSaveAs->hide();
57 ui->qr_code->hide();
58#endif
59
60 ui->uri_content->setText("<a href=\"" + uri + "\">" + GUIUtil::HtmlEscape(uri) + "</a>");
61 ui->address_content->setText(info.address);
62
63 if (!info.amount) {
64 ui->amount_tag->hide();
65 ui->amount_content->hide();
66 } // Amount is set in updateDisplayUnit() slot.
68
69 if (!info.label.isEmpty()) {
70 ui->label_content->setText(info.label);
71 } else {
72 ui->label_tag->hide();
73 ui->label_content->hide();
74 }
75
76 if (!info.message.isEmpty()) {
77 ui->message_content->setText(info.message);
78 } else {
79 ui->message_tag->hide();
80 ui->message_content->hide();
81 }
82
83 if (!model->getWalletName().isEmpty()) {
84 ui->wallet_content->setText(model->getWalletName());
85 } else {
86 ui->wallet_tag->hide();
87 ui->wallet_content->hide();
88 }
89
90 ui->btnVerify->setVisible(model->wallet().hasExternalSigner());
91
92 connect(ui->btnVerify, &QPushButton::clicked, [this] {
93 model->displayAddress(info.address.toStdString());
94 });
95}
96
98{
99 if (!model) return;
101}
102
104{
106}
107
109{
111}
static QString formatWithUnit(Unit unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD)
Format as string (with unit)
void displayUnitChanged(BitcoinUnit unit)
BitcoinUnit getDisplayUnit() const
Definition: optionsmodel.h:103
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:48
interfaces::Wallet & wallet() const
Definition: walletmodel.h:138
OptionsModel * getOptionsModel() const
QString getWalletName() const
virtual bool hasExternalSigner()=0
Utility functions used by the Bitcoin Qt UI.
Definition: bitcoingui.h:58
QString HtmlEscape(const QString &str, bool fMultiLine)
Definition: guiutil.cpp:249
void handleCloseWindowShortcut(QWidget *w)
Definition: guiutil.cpp:431
QString formatBitcoinURI(const SendCoinsRecipient &info)
Definition: guiutil.cpp:211
constexpr auto dialog_flags
Definition: guiutil.h:60
void setClipboard(const QString &str)
Definition: guiutil.cpp:668