From 594177d5fe130af4d651b97080a755750a097aca Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Fri, 25 Oct 2024 21:26:02 +0000 Subject: [PATCH] merge bitcoin-core/gui#403: Make paths to update Encryption and HD wallet statuses simpler --- src/qt/bitcoingui.cpp | 17 +++++++++-------- src/qt/walletframe.cpp | 3 ++- src/qt/walletframe.h | 1 + src/qt/walletview.cpp | 11 +---------- src/qt/walletview.h | 5 ----- 5 files changed, 13 insertions(+), 24 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index e4f13195e6..9cdd8851dc 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -112,14 +112,15 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const NetworkStyle* networkStyle, { /** Create wallet frame*/ walletFrame = new WalletFrame(this); - connect(walletFrame, &WalletFrame::message, [this](const QString& title, const QString& message, unsigned int style) { - this->message(title, message, style); - }); connect(walletFrame, &WalletFrame::createWalletButtonClicked, [this] { auto activity = new CreateWalletActivity(getWalletController(), this); connect(activity, &CreateWalletActivity::finished, activity, &QObject::deleteLater); activity->create(); }); + connect(walletFrame, &WalletFrame::message, [this](const QString& title, const QString& message, unsigned int style) { + this->message(title, message, style); + }); + connect(walletFrame, &WalletFrame::currentWalletSet, [this] { updateWalletStatus(); }); } else #endif // ENABLE_WALLET { @@ -932,7 +933,6 @@ void BitcoinGUI::addWallet(WalletModel* walletModel) }); connect(wallet_view, &WalletView::encryptionStatusChanged, this, &BitcoinGUI::updateWalletStatus); connect(wallet_view, &WalletView::incomingTransaction, this, &BitcoinGUI::incomingTransaction); - connect(wallet_view, &WalletView::hdEnabledStatusChanged, this, &BitcoinGUI::updateWalletStatus); connect(this, &BitcoinGUI::setPrivacy, wallet_view, &WalletView::setPrivacy); wallet_view->setPrivacy(isPrivacyModeActivated()); const QString display_name = walletModel->getDisplayName(); @@ -1679,7 +1679,9 @@ void BitcoinGUI::changeEvent(QEvent *e) if (e->type() == QEvent::StyleChange) { updateNetworkState(); #ifdef ENABLE_WALLET - updateWalletStatus(); + if (walletFrame) { + updateWalletStatus(); + } #endif if (m_node.masternodeSync().isSynced()) { labelBlocksIcon->setPixmap(GUIUtil::getIcon("synced", GUIUtil::ThemedColor::GREEN).pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); @@ -1911,9 +1913,8 @@ void BitcoinGUI::setEncryptionStatus(int status) void BitcoinGUI::updateWalletStatus() { - if (!walletFrame) { - return; - } + assert(walletFrame); + WalletView * const walletView = walletFrame->currentWalletView(); if (!walletView) { return; diff --git a/src/qt/walletframe.cpp b/src/qt/walletframe.cpp index 0148003e20..d97b1d7553 100644 --- a/src/qt/walletframe.cpp +++ b/src/qt/walletframe.cpp @@ -123,7 +123,8 @@ void WalletFrame::setCurrentWallet(WalletModel* wallet_model) walletView->updateGeometry(); walletStack->setCurrentWidget(walletView); - walletView->updateEncryptionStatus(); + + Q_EMIT currentWalletSet(); } void WalletFrame::removeWallet(WalletModel* wallet_model) diff --git a/src/qt/walletframe.h b/src/qt/walletframe.h index 4b76dc40ec..948af49ad6 100644 --- a/src/qt/walletframe.h +++ b/src/qt/walletframe.h @@ -50,6 +50,7 @@ public: Q_SIGNALS: void message(const QString& title, const QString& message, unsigned int style); + void currentWalletSet(); void createWalletButtonClicked(); diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index 6869854ced..1a99436660 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -177,10 +177,6 @@ void WalletView::setWalletModel(WalletModel *_walletModel) // Handle changes in encryption status connect(_walletModel, &WalletModel::encryptionStatusChanged, this, &WalletView::encryptionStatusChanged); - updateEncryptionStatus(); - - // update HD status - Q_EMIT hdEnabledStatusChanged(); // Balloon pop-up for new transaction connect(_walletModel->getTransactionTableModel(), &TransactionTableModel::rowsInserted, this, &WalletView::processNewTransaction); @@ -304,11 +300,6 @@ void WalletView::showOutOfSyncWarning(bool fShow) overviewPage->showOutOfSyncWarning(fShow); } -void WalletView::updateEncryptionStatus() -{ - Q_EMIT encryptionStatusChanged(); -} - void WalletView::encryptWallet() { if(!walletModel) @@ -317,7 +308,7 @@ void WalletView::encryptWallet() dlg.setModel(walletModel); dlg.exec(); - updateEncryptionStatus(); + Q_EMIT encryptionStatusChanged(); } void WalletView::backupWallet() diff --git a/src/qt/walletview.h b/src/qt/walletview.h index 8886de7ecb..30dab9f170 100644 --- a/src/qt/walletview.h +++ b/src/qt/walletview.h @@ -116,9 +116,6 @@ public Q_SLOTS: /** Show used receiving addresses */ void usedReceivingAddresses(); - /** Re-emit encryption status signal */ - void updateEncryptionStatus(); - /** Show progress dialog e.g. for rescan */ void showProgress(const QString &title, int nProgress); @@ -132,8 +129,6 @@ Q_SIGNALS: void message(const QString &title, const QString &message, unsigned int style); /** Encryption status of wallet changed */ void encryptionStatusChanged(); - /** HD-Enabled status of wallet changed (only possible during startup) */ - void hdEnabledStatusChanged(); /** Notify that a new transaction appeared */ void incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label, const QString& walletName); /** Notify that the out of sync warning icon has been pressed */