From 00fcc0f76a263e52cbba09cb14f4affcb8de8dea Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Fri, 5 Jun 2020 09:18:38 +0200 Subject: [PATCH 1/4] Merge #15202: gui: Add Close All Wallets action MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit c4b574899abfa27f83c6948593838ed418c78f9c gui: Add Close All Wallets action (João Barbosa) f30960adc02877267cb6efeb378962ed96628741 gui: Add closeAllWallets to WalletController (João Barbosa) Pull request description: This PR adds the action to close all wallets. Screenshot 2020-06-01 at 01 06 12 ACKs for top commit: jonasschnelli: Tested ACK c4b574899abfa27f83c6948593838ed418c78f9c Tree-SHA512: 049ad77ac79949fb55f6bde47b583fbf946f4bfaf3d56d768e85f813d814cff0fe326b700f7b5e383cda4af7b5666e13043a6aaeee3798a69fc94385d88ce809 --- src/qt/bitcoingui.cpp | 8 ++++++++ src/qt/bitcoingui.h | 1 + src/qt/walletcontroller.cpp | 17 +++++++++++++++++ src/qt/walletcontroller.h | 1 + 4 files changed, 27 insertions(+) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 6a0a1e2d38ce4..add8af9554232 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -445,6 +445,9 @@ void BitcoinGUI::createActions() m_create_wallet_action->setEnabled(false); m_create_wallet_action->setStatusTip(tr("Create a new wallet")); + m_close_all_wallets_action = new QAction(tr("Close All Wallets..."), this); + m_close_all_wallets_action->setStatusTip(tr("Close all wallets")); + showHelpMessageAction = new QAction(tr("&Command-line options"), this); showHelpMessageAction->setMenuRole(QAction::NoRole); showHelpMessageAction->setStatusTip(tr("Show the %1 help message to get a list with possible Dash command-line options").arg(PACKAGE_NAME)); @@ -532,6 +535,9 @@ void BitcoinGUI::createActions() connect(activity, &CreateWalletActivity::finished, activity, &QObject::deleteLater); activity->create(); }); + connect(m_close_all_wallets_action, &QAction::triggered, [this] { + m_wallet_controller->closeAllWallets(this); + }); } #endif // ENABLE_WALLET } @@ -553,6 +559,7 @@ void BitcoinGUI::createMenuBar() file->addAction(m_create_wallet_action); file->addAction(m_open_wallet_action); file->addAction(m_close_wallet_action); + file->addAction(m_close_all_wallets_action); file->addSeparator(); file->addAction(openAction); file->addAction(backupWalletAction); @@ -972,6 +979,7 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled) usedReceivingAddressesAction->setEnabled(enabled); openAction->setEnabled(enabled); m_close_wallet_action->setEnabled(enabled); + m_close_all_wallets_action->setEnabled(enabled); } void BitcoinGUI::createTrayIcon() diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index adb584b34c577..8b9cf7928d9cc 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -171,6 +171,7 @@ class BitcoinGUI : public QMainWindow QMenu* m_open_wallet_menu{nullptr}; QAction* m_close_wallet_action{nullptr}; QAction* showCoinJoinHelpAction = nullptr; + QAction* m_close_all_wallets_action{nullptr}; QAction* m_wallet_selector_action = nullptr; QComboBox* m_wallet_selector = nullptr; diff --git a/src/qt/walletcontroller.cpp b/src/qt/walletcontroller.cpp index 9b6aed8fbfde2..c49989e7fc478 100644 --- a/src/qt/walletcontroller.cpp +++ b/src/qt/walletcontroller.cpp @@ -93,6 +93,23 @@ void WalletController::closeWallet(WalletModel* wallet_model, QWidget* parent) removeAndDeleteWallet(wallet_model); } +void WalletController::closeAllWallets(QWidget* parent) +{ + QMessageBox::StandardButton button = QMessageBox::question(parent, tr("Close all wallets"), + tr("Are you sure you wish to close all wallets?"), + QMessageBox::Yes|QMessageBox::Cancel, + QMessageBox::Yes); + if (button != QMessageBox::Yes) return; + + QMutexLocker locker(&m_mutex); + for (WalletModel* wallet_model : m_wallets) { + wallet_model->wallet().remove(); + Q_EMIT walletRemoved(wallet_model); + delete wallet_model; + } + m_wallets.clear(); +} + WalletModel* WalletController::getOrCreateWallet(std::unique_ptr wallet) { QMutexLocker locker(&m_mutex); diff --git a/src/qt/walletcontroller.h b/src/qt/walletcontroller.h index a61af4e318670..07c781791f2b3 100644 --- a/src/qt/walletcontroller.h +++ b/src/qt/walletcontroller.h @@ -62,6 +62,7 @@ class WalletController : public QObject std::map listWalletDir() const; void closeWallet(WalletModel* wallet_model, QWidget* parent = nullptr); + void closeAllWallets(QWidget* parent = nullptr); Q_SIGNALS: void walletAdded(WalletModel* wallet_model); From 5564cf6906c4dea0a9536ef4e00131bbbd8c1842 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Fri, 29 May 2020 08:54:32 +0200 Subject: [PATCH 2/4] Merge #16432: qt: Add privacy to the Overview page 8d75115844baefe5cad4d82ec8dce001dd16eb9c qt: Add privacy feature to Overview page (Hennadii Stepanov) 73d8ef72742ab9193e9e95158b26176bfaab3f66 qt: Add BitcoinUnits::formatWithPrivacy() function (Hennadii Stepanov) Pull request description: This PR allows to hide/reveal values on the Overviewpage by checking/unchecking Menu->Settings-> Mask Values Closes #16407 Privacy mode is OFF (the default behavior): ![Screenshot from 2020-01-02 15-08-28](https://user-images.githubusercontent.com/32963518/71669074-28ab6980-2d74-11ea-8e54-4973aa307192.png) Privacy mode is ON: ![Screenshot from 2020-01-02 15-10-23 cropped](https://user-images.githubusercontent.com/32963518/71669082-2d701d80-2d74-11ea-9df5-d4acc4982dbe.png) ACKs for top commit: jonatack: Tested ACK 8d75115 jonasschnelli: Tested ACK 8d75115844baefe5cad4d82ec8dce001dd16eb9c Tree-SHA512: 42f396d5bf0d343b306fb7e925f86f66b3fc3a257af370a812f4be181b5269298f9b23bd8a3ce25ab61de92908c4018d8c2dc8591d11bc58d79c4eb7206fc6ec --- src/qt/bitcoingui.cpp | 15 +++++++++++++ src/qt/bitcoingui.h | 4 ++++ src/qt/bitcoinunits.cpp | 25 ++++++++++++++++++--- src/qt/bitcoinunits.h | 6 +++-- src/qt/forms/overviewpage.ui | 20 ++++++++--------- src/qt/overviewpage.cpp | 43 +++++++++++++++++++++++++----------- src/qt/overviewpage.h | 2 ++ src/qt/test/wallettests.cpp | 4 ++-- src/qt/walletframe.cpp | 2 ++ src/qt/walletview.cpp | 2 ++ src/qt/walletview.h | 1 + 11 files changed, 94 insertions(+), 30 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index add8af9554232..80d0fae7ed7f3 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -456,6 +456,11 @@ void BitcoinGUI::createActions() showCoinJoinHelpAction->setMenuRole(QAction::NoRole); showCoinJoinHelpAction->setStatusTip(tr("Show the %1 basic information").arg(strCoinJoinName)); + m_mask_values_action = new QAction(tr("&Mask values"), this); + m_mask_values_action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_M)); + m_mask_values_action->setStatusTip(tr("Mask the values in the Overview tab")); + m_mask_values_action->setCheckable(true); + connect(quitAction, &QAction::triggered, qApp, QApplication::quit); connect(aboutAction, &QAction::triggered, this, &BitcoinGUI::aboutClicked); connect(aboutQtAction, &QAction::triggered, qApp, QApplication::aboutQt); @@ -538,6 +543,8 @@ void BitcoinGUI::createActions() connect(m_close_all_wallets_action, &QAction::triggered, [this] { m_wallet_controller->closeAllWallets(this); }); + + connect(m_mask_values_action, &QAction::toggled, this, &BitcoinGUI::setPrivacy); } #endif // ENABLE_WALLET } @@ -583,6 +590,8 @@ void BitcoinGUI::createMenuBar() settings->addAction(unlockWalletAction); settings->addAction(lockWalletAction); settings->addSeparator(); + settings->addAction(m_mask_values_action); + settings->addSeparator(); } settings->addAction(optionsAction); @@ -2007,6 +2016,12 @@ void BitcoinGUI::handleRestart(QStringList args) Q_EMIT requestedRestart(args); } +bool BitcoinGUI::isPrivacyModeActivated() const +{ + assert(m_mask_values_action); + return m_mask_values_action->isChecked(); +} + UnitDisplayStatusBarControl::UnitDisplayStatusBarControl() : optionsModel(nullptr), menu(nullptr) diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 8b9cf7928d9cc..ad0d81206eda1 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -103,6 +103,8 @@ class BitcoinGUI : public QMainWindow /** Disconnect core signals from GUI client */ void unsubscribeFromCoreSignals(); + bool isPrivacyModeActivated() const; + protected: void changeEvent(QEvent *e) override; void closeEvent(QCloseEvent *event) override; @@ -173,6 +175,7 @@ class BitcoinGUI : public QMainWindow QAction* showCoinJoinHelpAction = nullptr; QAction* m_close_all_wallets_action{nullptr}; QAction* m_wallet_selector_action = nullptr; + QAction* m_mask_values_action{nullptr}; QComboBox* m_wallet_selector = nullptr; @@ -253,6 +256,7 @@ class BitcoinGUI : public QMainWindow void consoleShown(RPCConsole* console); /** Restart handling */ void requestedRestart(QStringList args); + void setPrivacy(bool privacy); public Q_SLOTS: /** Set number of connections shown in the UI */ diff --git a/src/qt/bitcoinunits.cpp b/src/qt/bitcoinunits.cpp index d3de867aae555..c8a7eeec94184 100644 --- a/src/qt/bitcoinunits.cpp +++ b/src/qt/bitcoinunits.cpp @@ -9,6 +9,8 @@ #include #include +#include + BitcoinUnits::BitcoinUnits(QObject *parent): QAbstractListModel(parent), unitlist(availableUnits()) @@ -115,7 +117,7 @@ int BitcoinUnits::decimals(int unit) } } -QString BitcoinUnits::format(int unit, const CAmount& nIn, bool fPlus, SeparatorStyle separators) +QString BitcoinUnits::format(int unit, const CAmount& nIn, bool fPlus, SeparatorStyle separators, bool justify) { // Note: not using straight sprintf here because we do NOT want // localized number formatting. @@ -127,6 +129,7 @@ QString BitcoinUnits::format(int unit, const CAmount& nIn, bool fPlus, Separator qint64 n_abs = (n > 0 ? n : -n); qint64 quotient = n_abs / coin; QString quotient_str = QString::number(quotient); + if (justify) quotient_str = quotient_str.rightJustified(16 - num_decimals, ' '); // Use SI-style thin space separators as these are locale independent and can't be // confused with the decimal marker. @@ -171,6 +174,18 @@ QString BitcoinUnits::formatHtmlWithUnit(int unit, const CAmount& amount, bool p return QString("%1").arg(str); } +QString BitcoinUnits::formatWithPrivacy(int unit, const CAmount& amount, SeparatorStyle separators, bool privacy) +{ + assert(amount >= 0); + QString value; + if (privacy) { + value = format(unit, 0, false, separators, true).replace('0', '#'); + } else { + value = format(unit, amount, false, separators, true); + } + return value + QString(" ") + name(unit); +} + QString BitcoinUnits::floorWithUnit(int unit, const CAmount& amount, bool plussign, SeparatorStyle separators) { QSettings settings; @@ -182,9 +197,13 @@ QString BitcoinUnits::floorWithUnit(int unit, const CAmount& amount, bool plussi return result + QString(" ") + name(unit); } -QString BitcoinUnits::floorHtmlWithUnit(int unit, const CAmount& amount, bool plussign, SeparatorStyle separators) +QString BitcoinUnits::floorHtmlWithPrivacy(int unit, const CAmount& amount, SeparatorStyle separators, bool privacy) { - QString str(floorWithUnit(unit, amount, plussign, separators)); + assert(amount >= 0); + QString str = privacy + ? floorWithUnit(unit, 0, false, separators).replace('0', '#') + : floorWithUnit(unit, amount, false, separators); + str.replace(QChar(THIN_SP_CP), QString(THIN_SP_HTML)); return QString("%1").arg(str); } diff --git a/src/qt/bitcoinunits.h b/src/qt/bitcoinunits.h index e249420a4d614..e3e727881f64d 100644 --- a/src/qt/bitcoinunits.h +++ b/src/qt/bitcoinunits.h @@ -71,15 +71,17 @@ class BitcoinUnits: public QAbstractListModel //! Number of decimals left static int decimals(int unit); //! Format as string - static QString format(int unit, const CAmount& amount, bool plussign=false, SeparatorStyle separators=separatorStandard); + static QString format(int unit, const CAmount& amount, bool plussign = false, SeparatorStyle separators = separatorStandard, bool justify = false); static QString simpleFormat(int unit, const CAmount& amount, bool plussign=false, SeparatorStyle separators=separatorStandard); //! Format as string (with unit) static QString formatWithUnit(int unit, const CAmount& amount, bool plussign=false, SeparatorStyle separators=separatorStandard); //! Format as HTML string (with unit) static QString formatHtmlWithUnit(int unit, const CAmount& amount, bool plussign=false, SeparatorStyle separators=separatorStandard); + //! Format as string (with unit) of fixed length to preserve privacy, if it is set. + static QString formatWithPrivacy(int unit, const CAmount& amount, SeparatorStyle separators, bool privacy); //! Format as string (with unit) but floor value up to "digits" settings static QString floorWithUnit(int unit, const CAmount& amount, bool plussign=false, SeparatorStyle separators=separatorStandard); - static QString floorHtmlWithUnit(int unit, const CAmount& amount, bool plussign=false, SeparatorStyle separators=separatorStandard); + static QString floorHtmlWithPrivacy(int unit, const CAmount& amount, SeparatorStyle separators, bool privacy); //! Parse string to coin amount static bool parse(int unit, const QString &value, CAmount *val_out); //! Gets title for amount column including current display unit if optionsModel reference available */ diff --git a/src/qt/forms/overviewpage.ui b/src/qt/forms/overviewpage.ui index 7e3d5c0a0455c..947edb70a2e41 100644 --- a/src/qt/forms/overviewpage.ui +++ b/src/qt/forms/overviewpage.ui @@ -6,8 +6,8 @@ 0 0 - 960 - 585 + 798 + 318 @@ -116,7 +116,7 @@ Unconfirmed transactions to watch-only addresses - 0.000 000 00 BTC + 0.00000000 BTC Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -135,7 +135,7 @@ Total of transactions that have yet to be confirmed, and do not yet count toward the spendable balance - 0.000 000 00 BTC + 0.00000000 BTC Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -154,7 +154,7 @@ Mined balance in watch-only addresses that has not yet matured - 0.000 000 00 BTC + 0.00000000 BTC Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -206,7 +206,7 @@ Mined balance that has not yet matured - 0.000 000 00 BTC + 0.00000000 BTC Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -245,7 +245,7 @@ Your current total balance - 0.000 000 00 BTC + 21 000 000.00000000 BTC Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -264,7 +264,7 @@ Current total balance in watch-only addresses - 0.000 000 00 BTC + 21 000 000.00000000 BTC Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -300,7 +300,7 @@ Your current spendable balance - 0.000 000 00 BTC + 21 000 000.00000000 BTC Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -319,7 +319,7 @@ Your current balance in watch-only addresses - 0.000 000 00 BTC + 21 000 000.00000000 BTC Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index fa7aa54572867..40bb4adcac36e 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -20,9 +20,11 @@ #include #include +#include #include #include #include +#include #include #define ITEM_HEIGHT 54 @@ -181,6 +183,21 @@ void OverviewPage::handleOutOfSyncWarningClicks() Q_EMIT outOfSyncWarningClicked(); } +void OverviewPage::setPrivacy(bool privacy) +{ + m_privacy = privacy; + if (m_balances.balance != -1) { + setBalance(m_balances); + } + + ui->listTransactions->setVisible(!m_privacy); + + const QString status_tip = m_privacy ? tr("Privacy mode activated for the Overview tab. To unmask the values, uncheck Settings->Mask values.") : ""; + setStatusTip(status_tip); + QStatusTipEvent event(status_tip); + QApplication::sendEvent(this, &event); +} + OverviewPage::~OverviewPage() { delete ui; @@ -191,20 +208,20 @@ void OverviewPage::setBalance(const interfaces::WalletBalances& balances) int unit = walletModel->getOptionsModel()->getDisplayUnit(); m_balances = balances; if (walletModel->wallet().privateKeysDisabled()) { - ui->labelBalance->setText(BitcoinUnits::floorHtmlWithUnit(unit, balances.watch_only_balance, false, BitcoinUnits::separatorAlways)); - ui->labelUnconfirmed->setText(BitcoinUnits::floorHtmlWithUnit(unit, balances.unconfirmed_watch_only_balance, false, BitcoinUnits::separatorAlways)); - ui->labelImmature->setText(BitcoinUnits::floorHtmlWithUnit(unit, balances.immature_watch_only_balance, false, BitcoinUnits::separatorAlways)); - ui->labelTotal->setText(BitcoinUnits::floorHtmlWithUnit(unit, balances.watch_only_balance + balances.unconfirmed_watch_only_balance + balances.immature_watch_only_balance, false, BitcoinUnits::separatorAlways)); + ui->labelBalance->setText(BitcoinUnits::floorHtmlWithPrivacy(unit, balances.watch_only_balance, BitcoinUnits::separatorAlways, m_privacy)); + ui->labelUnconfirmed->setText(BitcoinUnits::floorHtmlWithPrivacy(unit, balances.unconfirmed_watch_only_balance, BitcoinUnits::separatorAlways, m_privacy)); + ui->labelImmature->setText(BitcoinUnits::floorHtmlWithPrivacy(unit, balances.immature_watch_only_balance, BitcoinUnits::separatorAlways, m_privacy)); + ui->labelTotal->setText(BitcoinUnits::floorHtmlWithPrivacy(unit, balances.watch_only_balance + balances.unconfirmed_watch_only_balance + balances.immature_watch_only_balance, BitcoinUnits::separatorAlways, m_privacy)); } else { - ui->labelBalance->setText(BitcoinUnits::floorHtmlWithUnit(unit, balances.balance, false, BitcoinUnits::separatorAlways)); - ui->labelUnconfirmed->setText(BitcoinUnits::floorHtmlWithUnit(unit, balances.unconfirmed_balance, false, BitcoinUnits::separatorAlways)); - ui->labelImmature->setText(BitcoinUnits::floorHtmlWithUnit(unit, balances.immature_balance, false, BitcoinUnits::separatorAlways)); - ui->labelAnonymized->setText(BitcoinUnits::floorHtmlWithUnit(unit, balances.anonymized_balance, false, BitcoinUnits::separatorAlways)); - ui->labelTotal->setText(BitcoinUnits::floorHtmlWithUnit(unit, balances.balance + balances.unconfirmed_balance + balances.immature_balance, false, BitcoinUnits::separatorAlways)); - ui->labelWatchAvailable->setText(BitcoinUnits::floorHtmlWithUnit(unit, balances.watch_only_balance, false, BitcoinUnits::separatorAlways)); - ui->labelWatchPending->setText(BitcoinUnits::floorHtmlWithUnit(unit, balances.unconfirmed_watch_only_balance, false, BitcoinUnits::separatorAlways)); - ui->labelWatchImmature->setText(BitcoinUnits::floorHtmlWithUnit(unit, balances.immature_watch_only_balance, false, BitcoinUnits::separatorAlways)); - ui->labelWatchTotal->setText(BitcoinUnits::floorHtmlWithUnit(unit, balances.watch_only_balance + balances.unconfirmed_watch_only_balance + balances.immature_watch_only_balance, false, BitcoinUnits::separatorAlways)); + ui->labelBalance->setText(BitcoinUnits::floorHtmlWithPrivacy(unit, balances.balance, BitcoinUnits::separatorAlways, m_privacy)); + ui->labelUnconfirmed->setText(BitcoinUnits::floorHtmlWithPrivacy(unit, balances.unconfirmed_balance, BitcoinUnits::separatorAlways, m_privacy)); + ui->labelImmature->setText(BitcoinUnits::floorHtmlWithPrivacy(unit, balances.immature_balance, BitcoinUnits::separatorAlways, m_privacy)); + ui->labelAnonymized->setText(BitcoinUnits::floorHtmlWithPrivacy(unit, balances.anonymized_balance, BitcoinUnits::separatorAlways, m_privacy)); + ui->labelTotal->setText(BitcoinUnits::floorHtmlWithPrivacy(unit, balances.balance + balances.unconfirmed_balance + balances.immature_balance, BitcoinUnits::separatorAlways, m_privacy)); + ui->labelWatchAvailable->setText(BitcoinUnits::floorHtmlWithPrivacy(unit, balances.watch_only_balance, BitcoinUnits::separatorAlways, m_privacy)); + ui->labelWatchPending->setText(BitcoinUnits::floorHtmlWithPrivacy(unit, balances.unconfirmed_watch_only_balance, BitcoinUnits::separatorAlways, m_privacy)); + ui->labelWatchImmature->setText(BitcoinUnits::floorHtmlWithPrivacy(unit, balances.immature_watch_only_balance, BitcoinUnits::separatorAlways, m_privacy)); + ui->labelWatchTotal->setText(BitcoinUnits::floorHtmlWithPrivacy(unit, balances.watch_only_balance + balances.unconfirmed_watch_only_balance + balances.immature_watch_only_balance, BitcoinUnits::separatorAlways, m_privacy)); } // only show immature (newly mined) balance if it's non-zero, so as not to complicate things // for the non-mining users diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index 8b0f12dfd14cd..af7e9006a5aa8 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -39,6 +39,7 @@ class OverviewPage : public QWidget public Q_SLOTS: void coinJoinStatus(bool fForce = false); void setBalance(const interfaces::WalletBalances& balances); + void setPrivacy(bool privacy); Q_SIGNALS: void transactionClicked(const QModelIndex &index); @@ -50,6 +51,7 @@ public Q_SLOTS: ClientModel *clientModel; WalletModel *walletModel; interfaces::WalletBalances m_balances; + bool m_privacy{false}; int nDisplayUnit; bool fShowAdvancedCJUI; int cachedNumISLocks; diff --git a/src/qt/test/wallettests.cpp b/src/qt/test/wallettests.cpp index 23c58c9eede28..efbb33c39b1a2 100644 --- a/src/qt/test/wallettests.cpp +++ b/src/qt/test/wallettests.cpp @@ -164,10 +164,10 @@ void TestGUI(interfaces::Node& node) overviewPage.setClientModel(&clientModel); overviewPage.setWalletModel(&walletModel); QLabel* balanceLabel = overviewPage.findChild("labelBalance"); - QString balanceText = balanceLabel->text(); + QString balanceText = balanceLabel->text().trimmed(); int unit = walletModel.getOptionsModel()->getDisplayUnit(); CAmount balance = walletModel.wallet().getBalance(); - QString balanceComparison = BitcoinUnits::floorHtmlWithUnit(unit, balance, false, BitcoinUnits::separatorAlways); + QString balanceComparison = BitcoinUnits::floorHtmlWithPrivacy(unit, balance, BitcoinUnits::separatorAlways, false); QCOMPARE(balanceText, balanceComparison); // Check Request Payment button diff --git a/src/qt/walletframe.cpp b/src/qt/walletframe.cpp index a3030862d4a93..77ca7b5df4f85 100644 --- a/src/qt/walletframe.cpp +++ b/src/qt/walletframe.cpp @@ -84,6 +84,7 @@ bool WalletFrame::addWallet(WalletModel *walletModel) walletView->setClientModel(clientModel); walletView->setWalletModel(walletModel); walletView->showOutOfSyncWarning(bOutOfSync); + walletView->setPrivacy(gui->isPrivacyModeActivated()); WalletView* current_wallet_view = currentWalletView(); if (current_wallet_view) { @@ -104,6 +105,7 @@ bool WalletFrame::addWallet(WalletModel *walletModel) connect(walletView, &WalletView::encryptionStatusChanged, gui, &BitcoinGUI::updateWalletStatus); connect(walletView, &WalletView::incomingTransaction, gui, &BitcoinGUI::incomingTransaction); connect(walletView, &WalletView::hdEnabledStatusChanged, gui, &BitcoinGUI::updateWalletStatus); + connect(gui, &BitcoinGUI::setPrivacy, walletView, &WalletView::setPrivacy); return true; } diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index 2862b46fa66c8..389e8e5d8f0b8 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -121,6 +121,8 @@ WalletView::WalletView(QWidget* parent) : // Pass through messages from transactionView connect(transactionView, &TransactionView::message, this, &WalletView::message); + connect(this, &WalletView::setPrivacy, overviewPage, &OverviewPage::setPrivacy); + GUIUtil::disableMacFocusRect(this); } diff --git a/src/qt/walletview.h b/src/qt/walletview.h index c1a7d5874f9f1..b0c283c7b9086 100644 --- a/src/qt/walletview.h +++ b/src/qt/walletview.h @@ -131,6 +131,7 @@ public Q_SLOTS: /** Update selected DASH amount from transactionview */ void trxAmount(QString amount); Q_SIGNALS: + void setPrivacy(bool privacy); void transactionClicked(); void coinsSent(); /** Fired when a message should be reported to the user */ From 41dddafa8fc97556c9897d0f6b45efa74741d0bf Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Mon, 4 May 2020 11:53:21 +0200 Subject: [PATCH 3/4] Merge #15768: gui: Add close window shortcut f5a3a5b9ab362c58fa424261f313aa9cf46d2a98 gui: Add close window shortcut (Miguel Herranz) Pull request description: CMD+W is the standard shortcut in macOS to close a window without exiting the program. This adds support to use the shortcut in both main and debug windows. ACKs for top commit: jonasschnelli: Tested ACK f5a3a5b9ab362c58fa424261f313aa9cf46d2a98 hebasto: ACK f5a3a5b9ab362c58fa424261f313aa9cf46d2a98, tested on Linux Mint 19.3 by manually opening available dialogs and sub-windows, and applying the `Ctrl+W` shortcut. Also tested with "Minimize on close" option enabled / disabled. Tree-SHA512: 39851f6680cf97c334d5759c6f8597cb45685359417493ff8b0566672edbd32303fa15ac4260ec8ab5ea1458a600a329153014f25609e1db9cf399aa851ae2f9 --- src/qt/addressbookpage.cpp | 2 ++ src/qt/askpassphrasedialog.cpp | 2 ++ src/qt/bitcoingui.cpp | 2 ++ src/qt/coincontroldialog.cpp | 2 ++ src/qt/editaddressdialog.cpp | 2 ++ src/qt/guiutil.cpp | 6 ++++++ src/qt/guiutil.h | 3 +++ src/qt/openuridialog.cpp | 2 ++ src/qt/optionsdialog.cpp | 2 ++ src/qt/receiverequestdialog.cpp | 2 ++ src/qt/rpcconsole.cpp | 2 ++ src/qt/signverifymessagedialog.cpp | 2 ++ src/qt/splashscreen.cpp | 2 ++ src/qt/transactiondescdialog.cpp | 4 +++- src/qt/utilitydialog.cpp | 4 ++++ 15 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/qt/addressbookpage.cpp b/src/qt/addressbookpage.cpp index e8abbef54c144..be2d214721d98 100644 --- a/src/qt/addressbookpage.cpp +++ b/src/qt/addressbookpage.cpp @@ -139,6 +139,8 @@ AddressBookPage::AddressBookPage(Mode _mode, Tabs _tab, QWidget* parent) : GUIUtil::updateFonts(); GUIUtil::disableMacFocusRect(this); + + GUIUtil::handleCloseWindowShortcut(this); } AddressBookPage::~AddressBookPage() diff --git a/src/qt/askpassphrasedialog.cpp b/src/qt/askpassphrasedialog.cpp index 493c9fae60066..27ba8e4135a74 100644 --- a/src/qt/askpassphrasedialog.cpp +++ b/src/qt/askpassphrasedialog.cpp @@ -91,6 +91,8 @@ AskPassphraseDialog::AskPassphraseDialog(Mode _mode, QWidget *parent, SecureStri connect(ui->passEdit1, &QLineEdit::textChanged, this, &AskPassphraseDialog::textChanged); connect(ui->passEdit2, &QLineEdit::textChanged, this, &AskPassphraseDialog::textChanged); connect(ui->passEdit3, &QLineEdit::textChanged, this, &AskPassphraseDialog::textChanged); + + GUIUtil::handleCloseWindowShortcut(this); } AskPassphraseDialog::~AskPassphraseDialog() diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 80d0fae7ed7f3..890df6c032379 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -238,6 +238,8 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const NetworkStyle* networkStyle, }); timerCustomCss->start(200); } + + GUIUtil::handleCloseWindowShortcut(this); } BitcoinGUI::~BitcoinGUI() diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index fd3b37f72d0f2..8d5458a57b2ef 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -160,6 +160,8 @@ CoinControlDialog::CoinControlDialog(CCoinControl& coin_control, WalletModel* _m updateLabelLocked(); CoinControlDialog::updateLabels(m_coin_control, _model, this); } + + GUIUtil::handleCloseWindowShortcut(this); } CoinControlDialog::~CoinControlDialog() diff --git a/src/qt/editaddressdialog.cpp b/src/qt/editaddressdialog.cpp index b6ab268707775..574c374550a88 100644 --- a/src/qt/editaddressdialog.cpp +++ b/src/qt/editaddressdialog.cpp @@ -45,6 +45,8 @@ EditAddressDialog::EditAddressDialog(Mode _mode, QWidget *parent) : GUIUtil::ItemDelegate* delegate = new GUIUtil::ItemDelegate(mapper); connect(delegate, &GUIUtil::ItemDelegate::keyEscapePressed, this, &EditAddressDialog::reject); mapper->setItemDelegate(delegate); + + GUIUtil::handleCloseWindowShortcut(this); } EditAddressDialog::~EditAddressDialog() diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 3a95c9a336aa6..e90b9b4f1daf2 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -67,6 +67,7 @@ #include #include #include +#include #include // for Qt::mightBeRichText #include #include @@ -602,6 +603,11 @@ void bringToFront(QWidget* w) } } +void handleCloseWindowShortcut(QWidget* w) +{ + QObject::connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), w), &QShortcut::activated, w, &QWidget::close); +} + void openDebugLogfile() { fs::path pathDebug = GetDataDir() / "debug.log"; diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 286d37c098c49..54e9494b34419 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -193,6 +193,9 @@ namespace GUIUtil // Activate, show and raise the widget void bringToFront(QWidget* w); + // Set shortcut to close window + void handleCloseWindowShortcut(QWidget* w); + // Open debug.log void openDebugLogfile(); diff --git a/src/qt/openuridialog.cpp b/src/qt/openuridialog.cpp index 1a6d7cc175049..eb7c34ae210bd 100644 --- a/src/qt/openuridialog.cpp +++ b/src/qt/openuridialog.cpp @@ -18,6 +18,8 @@ OpenURIDialog::OpenURIDialog(QWidget *parent) : ui->setupUi(this); GUIUtil::updateFonts(); GUIUtil::disableMacFocusRect(this); + + GUIUtil::handleCloseWindowShortcut(this); } OpenURIDialog::~OpenURIDialog() diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index 6047e2b75b969..e52d650bde9ba 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -202,6 +202,8 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) : ui->minimizeToTray->setChecked(false); ui->minimizeToTray->setEnabled(false); } + + GUIUtil::handleCloseWindowShortcut(this); } OptionsDialog::~OptionsDialog() diff --git a/src/qt/receiverequestdialog.cpp b/src/qt/receiverequestdialog.cpp index 96c7584494eb9..be2aeb06e1e08 100644 --- a/src/qt/receiverequestdialog.cpp +++ b/src/qt/receiverequestdialog.cpp @@ -33,6 +33,8 @@ ReceiveRequestDialog::ReceiveRequestDialog(QWidget *parent) : #endif connect(ui->btnSaveAs, &QPushButton::clicked, ui->lblQRCode, &QRImageWidget::saveImage); + + GUIUtil::handleCloseWindowShortcut(this); } ReceiveRequestDialog::~ReceiveRequestDialog() diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index d98a03a633d67..c7acccdae8645 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -528,6 +528,8 @@ RPCConsole::RPCConsole(interfaces::Node& node, QWidget* parent, Qt::WindowFlags showPage(ToUnderlying(TabTypes::INFO)); reloadThemedWidgets(); + + GUIUtil::handleCloseWindowShortcut(this); } RPCConsole::~RPCConsole() diff --git a/src/qt/signverifymessagedialog.cpp b/src/qt/signverifymessagedialog.cpp index 3b7d0ef801471..edd5b71b61105 100644 --- a/src/qt/signverifymessagedialog.cpp +++ b/src/qt/signverifymessagedialog.cpp @@ -60,6 +60,8 @@ SignVerifyMessageDialog::SignVerifyMessageDialog(QWidget* parent) : GUIUtil::updateFonts(); GUIUtil::disableMacFocusRect(this); + + GUIUtil::handleCloseWindowShortcut(this); } SignVerifyMessageDialog::~SignVerifyMessageDialog() diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp index 70cca5cfd119a..088b97ff937bb 100644 --- a/src/qt/splashscreen.cpp +++ b/src/qt/splashscreen.cpp @@ -135,6 +135,8 @@ SplashScreen::SplashScreen(interfaces::Node& node, const NetworkStyle *networkSt subscribeToCoreSignals(); installEventFilter(this); + + GUIUtil::handleCloseWindowShortcut(this); } SplashScreen::~SplashScreen() diff --git a/src/qt/transactiondescdialog.cpp b/src/qt/transactiondescdialog.cpp index ea91cf72af7c6..2b4fd452fd16a 100644 --- a/src/qt/transactiondescdialog.cpp +++ b/src/qt/transactiondescdialog.cpp @@ -2,10 +2,10 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include #include #include +#include #include #include @@ -21,6 +21,8 @@ TransactionDescDialog::TransactionDescDialog(const QModelIndex &idx, QWidget *pa setWindowTitle(tr("Details for %1").arg(idx.data(TransactionTableModel::TxHashRole).toString())); QString desc = idx.data(TransactionTableModel::LongDescriptionRole).toString(); ui->detailText->setHtml(desc); + + GUIUtil::handleCloseWindowShortcut(this); } TransactionDescDialog::~TransactionDescDialog() diff --git a/src/qt/utilitydialog.cpp b/src/qt/utilitydialog.cpp index 39e538d30518c..4c0ac6cfebdbe 100644 --- a/src/qt/utilitydialog.cpp +++ b/src/qt/utilitydialog.cpp @@ -146,6 +146,8 @@ For more information, see the %1 documentation." ui->aboutMessage->setWordWrap(true); ui->helpMessage->setVisible(false); } + + GUIUtil::handleCloseWindowShortcut(this); } HelpMessageDialog::~HelpMessageDialog() @@ -189,6 +191,8 @@ ShutdownWindow::ShutdownWindow(interfaces::Node& node, QWidget *parent, Qt::Wind setLayout(layout); GUIUtil::updateFonts(); + + GUIUtil::handleCloseWindowShortcut(this); } QWidget* ShutdownWindow::showShutdownWindow(interfaces::Node& node, QMainWindow* window) From 2cda5f5051b83a9f083bcf5e3a17f3f22261d617 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Fri, 29 May 2020 10:02:16 +0200 Subject: [PATCH 4/4] Merge #17597: qt: Fix height of QR-less ReceiveRequestDialog 73529f0859c060087dd41e9e176fd4198d0f385f qt: Rename slot to updateDisplayUnit() (Hennadii Stepanov) 68288ef0c15522799d4bf6239d2ae1e8086b5abf qt: Overhaul ReceiveRequestDialog (Hennadii Stepanov) Pull request description: If master (89a1f7a250ef70ff2d65701564f1e24bb9280d90) is compiled without QR support, the "Request payment to..." dialog looks ugly: ![Screenshot from 2019-11-25 19-58-59](https://user-images.githubusercontent.com/32963518/69566647-3d9c1c80-0fc0-11ea-8ff6-183cea9372c5.png) With this PR: ![Screenshot from 2019-12-26 00-42-46](https://user-images.githubusercontent.com/32963518/71451226-221c6100-277a-11ea-94ae-c19a5c6256f7.png) ![Screenshot from 2019-12-26 00-44-34](https://user-images.githubusercontent.com/32963518/71451228-29436f00-277a-11ea-8ac5-1bafe6d73b5c.png) ![Screenshot from 2019-12-26 00-48-51](https://user-images.githubusercontent.com/32963518/71451230-2e082300-277a-11ea-8c4c-726ca7b776e7.png) Other minor changes: - "URI" abbreviation is not translated now - wallet name is shown if available ACKs for top commit: jonasschnelli: Tested ACK 73529f0859c060087dd41e9e176fd4198d0f385f Tree-SHA512: 45f9a41d3c72978d78eb2e8ca98e274b8be5abf5352fd3e1f4f49514ce744994545fb3012e80600ded936ae41c6be4d4825a0c5f7bcb3db671d69e0299f0f65b --- src/qt/forms/receiverequestdialog.ui | 288 +++++++++++++++++++++------ src/qt/receiverequestdialog.cpp | 89 +++++---- src/qt/receiverequestdialog.h | 3 +- src/qt/test/wallettests.cpp | 26 ++- 4 files changed, 290 insertions(+), 116 deletions(-) diff --git a/src/qt/forms/receiverequestdialog.ui b/src/qt/forms/receiverequestdialog.ui index 9f896ee3b199b..f6d47234655e5 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 be2aeb06e1e08..028a58092b3dd 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,41 +49,57 @@ 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()) + "
"; + QString uri_style = GUIUtil::getThemedStyleQString(GUIUtil::ThemedStyle::TS_COMMAND); + ui->uri_content->setText(QString("%3").arg(uri_style).arg(uri).arg(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(); } - ui->outUri->setText(html); - if (ui->lblQRCode->setQR(uri, info.address)) { - ui->btnSaveAs->setEnabled(true); + if (!info.message.isEmpty()) { + ui->message_content->setText(info.message); + } else { + ui->message_tag->hide(); + ui->message_content->hide(); } + + 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() diff --git a/src/qt/receiverequestdialog.h b/src/qt/receiverequestdialog.h index 40e3d5ffa8ac8..846478643d819 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 efbb33c39b1a2..deb3b76aa3e15 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")); } }