diff --git a/src/qt/forms/receiverequestdialog.ui b/src/qt/forms/receiverequestdialog.ui index 9f896ee3b199bc..f6d47234655e5c 100644 --- a/src/qt/forms/receiverequestdialog.ui +++ b/src/qt/forms/receiverequestdialog.ui @@ -6,68 +6,233 @@ 0 0 - 487 - 597 + 413 + 229 - - - - - - 0 - 0 - - - - - 300 - 320 - - - - QR Code + + Request payment to ... + + + + QLayout::SetFixedSize + + + + + QR image + + + Qt::NoTextInteraction + + + + + + + + 75 + true + + + + Payment information + + + Qt::NoTextInteraction + + + + + + + + 75 + true + + + + URI: Qt::PlainText - - Qt::AlignCenter + + Qt::NoTextInteraction + + + + + + + bitcoin:BC1... + + + Qt::RichText true + + Qt::TextSelectableByMouse + + + + + + + + 75 + true + + + + Address: + + + Qt::NoTextInteraction + - - - - - 0 - 0 - - - - - 0 - 50 - - - - QFrame::NoFrame - - - QFrame::Plain - - + + + + bc1... + + + Qt::PlainText + + + Qt::TextSelectableByMouse + + + + + + + + 75 + true + + + + Amount: + + + Qt::NoTextInteraction + + + + + + + 0.00000000 BTC + + + Qt::PlainText + + + Qt::TextSelectableByMouse + + + + + + + + 75 + true + + + + Label: + + + Qt::NoTextInteraction + + + + + + + label content + + + Qt::PlainText + + + true + + + Qt::TextSelectableByMouse + + + + + + + + 75 + true + + + + Message: + + + Qt::NoTextInteraction + + + + + + + message content + + + Qt::PlainText + + + true + + + Qt::TextSelectableByMouse + + + + + + + + 75 + true + + + + Wallet: + + + Qt::NoTextInteraction + + + + + + + wallet name + + + Qt::PlainText + + true - Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + Qt::TextSelectableByMouse - + @@ -114,8 +279,11 @@ + + Qt::StrongFocus + - QDialogButtonBox::Close + QDialogButtonBox::Ok @@ -130,24 +298,14 @@
qt/qrimagewidget.h
+ + buttonBox + btnCopyURI + btnCopyAddress + btnSaveAs + - - buttonBox - rejected() - ReceiveRequestDialog - reject() - - - 452 - 573 - - - 243 - 298 - - - buttonBox accepted() @@ -155,12 +313,12 @@ accept() - 452 - 573 + 135 + 230 - 243 - 298 + 135 + 126 diff --git a/src/qt/receiverequestdialog.cpp b/src/qt/receiverequestdialog.cpp index be2aeb06e1e086..b4bb7cac0270e9 100644 --- a/src/qt/receiverequestdialog.cpp +++ b/src/qt/receiverequestdialog.cpp @@ -11,8 +11,8 @@ #include #include -#include -#include +#include +#include #if defined(HAVE_CONFIG_H) #include /* for USE_QRCODE */ @@ -27,13 +27,6 @@ ReceiveRequestDialog::ReceiveRequestDialog(QWidget *parent) : GUIUtil::updateFonts(); -#ifndef USE_QRCODE - ui->btnSaveAs->setVisible(false); - ui->lblQRCode->setVisible(false); -#endif - - connect(ui->btnSaveAs, &QPushButton::clicked, ui->lblQRCode, &QRImageWidget::saveImage); - GUIUtil::handleCloseWindowShortcut(this); } @@ -47,7 +40,7 @@ void ReceiveRequestDialog::setModel(WalletModel *_model) this->model = _model; if (_model) - connect(_model->getOptionsModel(), &OptionsModel::displayUnitChanged, this, &ReceiveRequestDialog::update); + connect(_model->getOptionsModel(), &OptionsModel::displayUnitChanged, this, &ReceiveRequestDialog::updateDisplayUnit); // update the display unit if necessary update(); @@ -56,43 +49,58 @@ void ReceiveRequestDialog::setModel(WalletModel *_model) void ReceiveRequestDialog::setInfo(const SendCoinsRecipient &_info) { this->info = _info; - update(); -} + setWindowTitle(tr("Request payment to %1").arg(info.label.isEmpty() ? info.address : info.label)); + QString uri = GUIUtil::formatBitcoinURI(info); -void ReceiveRequestDialog::update() -{ - if(!model) - return; - QString target = info.label; - if(target.isEmpty()) - target = info.address; - setWindowTitle(tr("Request payment to %1").arg(target)); +#ifdef USE_QRCODE + if (ui->qr_code->setQR(uri, info.address)) { + connect(ui->btnSaveAs, &QPushButton::clicked, ui->qr_code, &QRImageWidget::saveImage); + } else { + ui->btnSaveAs->setEnabled(false); + } +#else + ui->btnSaveAs->hide(); + ui->qr_code->hide(); +#endif - QString uri = GUIUtil::formatBitcoinURI(info); - ui->btnSaveAs->setEnabled(false); - QString html; - html += ""; - html += "" + tr("Payment information") + "

"; - html += ""+tr("URI")+": "; - html += QString("" + GUIUtil::HtmlEscape(uri) + "
"; - html += ""+tr("Address")+": " + GUIUtil::HtmlEscape(info.address) + "
"; - if(info.amount) - html += ""+tr("Amount")+": " + BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), info.amount) + "
"; - if(!info.label.isEmpty()) - html += ""+tr("Label")+": " + GUIUtil::HtmlEscape(info.label) + "
"; - if(!info.message.isEmpty()) - html += ""+tr("Message")+": " + GUIUtil::HtmlEscape(info.message) + "
"; - if(model->isMultiwallet()) { - html += ""+tr("Wallet")+": " + GUIUtil::HtmlEscape(model->getWalletName()) + "
"; + ui->uri_content->setText("" + GUIUtil::HtmlEscape(uri) + ""); + ui->address_content->setText(info.address); + + if (!info.amount) { + ui->amount_tag->hide(); + ui->amount_content->hide(); + } // Amount is set in updateDisplayUnit() slot. + updateDisplayUnit(); + + if (!info.label.isEmpty()) { + ui->label_content->setText(info.label); + } else { + ui->label_tag->hide(); + ui->label_content->hide(); + } + + if (!info.message.isEmpty()) { + ui->message_content->setText(info.message); + } else { + ui->message_tag->hide(); + ui->message_content->hide(); } - ui->outUri->setText(html); - if (ui->lblQRCode->setQR(uri, info.address)) { - ui->btnSaveAs->setEnabled(true); + if (!model->getWalletName().isEmpty()) { + ui->wallet_content->setText(model->getWalletName()); + } else { + ui->wallet_tag->hide(); + ui->wallet_content->hide(); } } +void ReceiveRequestDialog::updateDisplayUnit() +{ + if(!model) + return; + ui->amount_content->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), info.amount)); +} + void ReceiveRequestDialog::on_btnCopyURI_clicked() { GUIUtil::setClipboard(GUIUtil::formatBitcoinURI(info)); diff --git a/src/qt/receiverequestdialog.h b/src/qt/receiverequestdialog.h index 40e3d5ffa8ac8f..846478643d819d 100644 --- a/src/qt/receiverequestdialog.h +++ b/src/qt/receiverequestdialog.h @@ -29,8 +29,7 @@ class ReceiveRequestDialog : public QDialog private Q_SLOTS: void on_btnCopyURI_clicked(); void on_btnCopyAddress_clicked(); - - void update(); + void updateDisplayUnit(); private: Ui::ReceiveRequestDialog *ui; diff --git a/src/qt/test/wallettests.cpp b/src/qt/test/wallettests.cpp index efbb33c39b1a2f..deb3b76aa3e15c 100644 --- a/src/qt/test/wallettests.cpp +++ b/src/qt/test/wallettests.cpp @@ -192,15 +192,23 @@ void TestGUI(interfaces::Node& node) for (QWidget* widget : QApplication::topLevelWidgets()) { if (widget->inherits("ReceiveRequestDialog")) { ReceiveRequestDialog* receiveRequestDialog = qobject_cast(widget); - QTextEdit* rlist = receiveRequestDialog->QObject::findChild("outUri"); - QString paymentText = rlist->toPlainText(); - QStringList paymentTextList = paymentText.split('\n'); - QCOMPARE(paymentTextList.at(0), QString("Payment information")); - QVERIFY(paymentTextList.at(2).indexOf(QString("URI: dash:")) != -1); - QVERIFY(paymentTextList.at(3).indexOf(QString("Address:")) != -1); - QCOMPARE(paymentTextList.at(4), QString("Amount: 0.00000001 ") + BitcoinUnits::name(unit)); - QCOMPARE(paymentTextList.at(5), QString("Label: TEST_LABEL_1")); - QCOMPARE(paymentTextList.at(6), QString("Message: TEST_MESSAGE_1")); + QCOMPARE(receiveRequestDialog->QObject::findChild("payment_header")->text(), QString("Payment information")); + QCOMPARE(receiveRequestDialog->QObject::findChild("uri_tag")->text(), QString("URI:")); + QString uri = receiveRequestDialog->QObject::findChild("uri_content")->text(); + QCOMPARE(uri.count("dash:"), 2); + QCOMPARE(receiveRequestDialog->QObject::findChild("address_tag")->text(), QString("Address:")); + + QCOMPARE(uri.count("amount=0.00000001"), 2); + QCOMPARE(receiveRequestDialog->QObject::findChild("amount_tag")->text(), QString("Amount:")); + QCOMPARE(receiveRequestDialog->QObject::findChild("amount_content")->text(), QString("0.00000001 ") + BitcoinUnits::name(unit)); + + QCOMPARE(uri.count("label=TEST_LABEL_1"), 2); + QCOMPARE(receiveRequestDialog->QObject::findChild("label_tag")->text(), QString("Label:")); + QCOMPARE(receiveRequestDialog->QObject::findChild("label_content")->text(), QString("TEST_LABEL_1")); + + QCOMPARE(uri.count("message=TEST_MESSAGE_1"), 2); + QCOMPARE(receiveRequestDialog->QObject::findChild("message_tag")->text(), QString("Message:")); + QCOMPARE(receiveRequestDialog->QObject::findChild("message_content")->text(), QString("TEST_MESSAGE_1")); } }