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 6a0a1e2d38ce4..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() @@ -445,6 +447,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)); @@ -453,6 +458,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); @@ -532,6 +542,11 @@ 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); + }); + + connect(m_mask_values_action, &QAction::toggled, this, &BitcoinGUI::setPrivacy); } #endif // ENABLE_WALLET } @@ -553,6 +568,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); @@ -576,6 +592,8 @@ void BitcoinGUI::createMenuBar() settings->addAction(unlockWalletAction); settings->addAction(lockWalletAction); settings->addSeparator(); + settings->addAction(m_mask_values_action); + settings->addSeparator(); } settings->addAction(optionsAction); @@ -972,6 +990,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() @@ -1999,6 +2018,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 adb584b34c577..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; @@ -171,7 +173,9 @@ 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; + QAction* m_mask_values_action{nullptr}; QComboBox* m_wallet_selector = nullptr; @@ -252,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/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/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/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/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/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/receiverequestdialog.cpp b/src/qt/receiverequestdialog.cpp index 96c7584494eb9..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,12 +27,7 @@ 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); } ReceiveRequestDialog::~ReceiveRequestDialog() @@ -45,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(); @@ -54,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/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/test/wallettests.cpp b/src/qt/test/wallettests.cpp index 23c58c9eede28..deb3b76aa3e15 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 @@ -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")); } } 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) 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); 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 */