LCOV - code coverage report
Current view: top level - src/qt - receiverequestdialog.cpp (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 0 56 0.0 %
Date: 2020-09-26 01:30:44 Functions: 0 10 0.0 %

          Line data    Source code
       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             : 
       5             : #include <qt/receiverequestdialog.h>
       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             : 
      21           0 : ReceiveRequestDialog::ReceiveRequestDialog(QWidget *parent) :
      22           0 :     QDialog(parent),
      23           0 :     ui(new Ui::ReceiveRequestDialog),
      24           0 :     model(nullptr)
      25           0 : {
      26           0 :     ui->setupUi(this);
      27           0 :     GUIUtil::handleCloseWindowShortcut(this);
      28           0 : }
      29             : 
      30           0 : ReceiveRequestDialog::~ReceiveRequestDialog()
      31           0 : {
      32           0 :     delete ui;
      33           0 : }
      34             : 
      35           0 : void ReceiveRequestDialog::setModel(WalletModel *_model)
      36             : {
      37           0 :     this->model = _model;
      38             : 
      39           0 :     if (_model)
      40           0 :         connect(_model->getOptionsModel(), &OptionsModel::displayUnitChanged, this, &ReceiveRequestDialog::updateDisplayUnit);
      41             : 
      42             :     // update the display unit if necessary
      43           0 :     update();
      44           0 : }
      45             : 
      46           0 : void ReceiveRequestDialog::setInfo(const SendCoinsRecipient &_info)
      47             : {
      48           0 :     this->info = _info;
      49           0 :     setWindowTitle(tr("Request payment to %1").arg(info.label.isEmpty() ? info.address : info.label));
      50           0 :     QString uri = GUIUtil::formatBitcoinURI(info);
      51             : 
      52             : #ifdef USE_QRCODE
      53           0 :     if (ui->qr_code->setQR(uri, info.address)) {
      54           0 :         connect(ui->btnSaveAs, &QPushButton::clicked, ui->qr_code, &QRImageWidget::saveImage);
      55           0 :     } else {
      56           0 :         ui->btnSaveAs->setEnabled(false);
      57             :     }
      58             : #else
      59             :     ui->btnSaveAs->hide();
      60             :     ui->qr_code->hide();
      61             : #endif
      62             : 
      63           0 :     ui->uri_content->setText("<a href=\"" + uri + "\">" + GUIUtil::HtmlEscape(uri) + "</a>");
      64           0 :     ui->address_content->setText(info.address);
      65             : 
      66           0 :     if (!info.amount) {
      67           0 :         ui->amount_tag->hide();
      68           0 :         ui->amount_content->hide();
      69             :     } // Amount is set in updateDisplayUnit() slot.
      70           0 :     updateDisplayUnit();
      71             : 
      72           0 :     if (!info.label.isEmpty()) {
      73           0 :         ui->label_content->setText(info.label);
      74             :     } else {
      75           0 :         ui->label_tag->hide();
      76           0 :         ui->label_content->hide();
      77             :     }
      78             : 
      79           0 :     if (!info.message.isEmpty()) {
      80           0 :         ui->message_content->setText(info.message);
      81             :     } else {
      82           0 :         ui->message_tag->hide();
      83           0 :         ui->message_content->hide();
      84             :     }
      85             : 
      86           0 :     if (!model->getWalletName().isEmpty()) {
      87           0 :         ui->wallet_content->setText(model->getWalletName());
      88           0 :     } else {
      89           0 :         ui->wallet_tag->hide();
      90           0 :         ui->wallet_content->hide();
      91             :     }
      92           0 : }
      93             : 
      94           0 : void ReceiveRequestDialog::updateDisplayUnit()
      95             : {
      96           0 :     if (!model) return;
      97           0 :     ui->amount_content->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), info.amount));
      98           0 : }
      99             : 
     100           0 : void ReceiveRequestDialog::on_btnCopyURI_clicked()
     101             : {
     102           0 :     GUIUtil::setClipboard(GUIUtil::formatBitcoinURI(info));
     103           0 : }
     104             : 
     105           0 : void ReceiveRequestDialog::on_btnCopyAddress_clicked()
     106             : {
     107           0 :     GUIUtil::setClipboard(info.address);
     108           0 : }

Generated by: LCOV version 1.15