merge bitcoin-core/gui#403: Make paths to update Encryption and HD wallet statuses simpler

This commit is contained in:
Kittywhiskers Van Gogh 2024-10-25 21:26:02 +00:00
parent ba5ad1fc6c
commit 594177d5fe
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD
5 changed files with 13 additions and 24 deletions

View File

@ -112,14 +112,15 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const NetworkStyle* networkStyle,
{ {
/** Create wallet frame*/ /** Create wallet frame*/
walletFrame = new WalletFrame(this); 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] { connect(walletFrame, &WalletFrame::createWalletButtonClicked, [this] {
auto activity = new CreateWalletActivity(getWalletController(), this); auto activity = new CreateWalletActivity(getWalletController(), this);
connect(activity, &CreateWalletActivity::finished, activity, &QObject::deleteLater); connect(activity, &CreateWalletActivity::finished, activity, &QObject::deleteLater);
activity->create(); 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 } else
#endif // ENABLE_WALLET #endif // ENABLE_WALLET
{ {
@ -932,7 +933,6 @@ void BitcoinGUI::addWallet(WalletModel* walletModel)
}); });
connect(wallet_view, &WalletView::encryptionStatusChanged, this, &BitcoinGUI::updateWalletStatus); connect(wallet_view, &WalletView::encryptionStatusChanged, this, &BitcoinGUI::updateWalletStatus);
connect(wallet_view, &WalletView::incomingTransaction, this, &BitcoinGUI::incomingTransaction); connect(wallet_view, &WalletView::incomingTransaction, this, &BitcoinGUI::incomingTransaction);
connect(wallet_view, &WalletView::hdEnabledStatusChanged, this, &BitcoinGUI::updateWalletStatus);
connect(this, &BitcoinGUI::setPrivacy, wallet_view, &WalletView::setPrivacy); connect(this, &BitcoinGUI::setPrivacy, wallet_view, &WalletView::setPrivacy);
wallet_view->setPrivacy(isPrivacyModeActivated()); wallet_view->setPrivacy(isPrivacyModeActivated());
const QString display_name = walletModel->getDisplayName(); const QString display_name = walletModel->getDisplayName();
@ -1679,7 +1679,9 @@ void BitcoinGUI::changeEvent(QEvent *e)
if (e->type() == QEvent::StyleChange) { if (e->type() == QEvent::StyleChange) {
updateNetworkState(); updateNetworkState();
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
if (walletFrame) {
updateWalletStatus(); updateWalletStatus();
}
#endif #endif
if (m_node.masternodeSync().isSynced()) { if (m_node.masternodeSync().isSynced()) {
labelBlocksIcon->setPixmap(GUIUtil::getIcon("synced", GUIUtil::ThemedColor::GREEN).pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); 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() void BitcoinGUI::updateWalletStatus()
{ {
if (!walletFrame) { assert(walletFrame);
return;
}
WalletView * const walletView = walletFrame->currentWalletView(); WalletView * const walletView = walletFrame->currentWalletView();
if (!walletView) { if (!walletView) {
return; return;

View File

@ -123,7 +123,8 @@ void WalletFrame::setCurrentWallet(WalletModel* wallet_model)
walletView->updateGeometry(); walletView->updateGeometry();
walletStack->setCurrentWidget(walletView); walletStack->setCurrentWidget(walletView);
walletView->updateEncryptionStatus();
Q_EMIT currentWalletSet();
} }
void WalletFrame::removeWallet(WalletModel* wallet_model) void WalletFrame::removeWallet(WalletModel* wallet_model)

View File

@ -50,6 +50,7 @@ public:
Q_SIGNALS: Q_SIGNALS:
void message(const QString& title, const QString& message, unsigned int style); void message(const QString& title, const QString& message, unsigned int style);
void currentWalletSet();
void createWalletButtonClicked(); void createWalletButtonClicked();

View File

@ -177,10 +177,6 @@ void WalletView::setWalletModel(WalletModel *_walletModel)
// Handle changes in encryption status // Handle changes in encryption status
connect(_walletModel, &WalletModel::encryptionStatusChanged, this, &WalletView::encryptionStatusChanged); connect(_walletModel, &WalletModel::encryptionStatusChanged, this, &WalletView::encryptionStatusChanged);
updateEncryptionStatus();
// update HD status
Q_EMIT hdEnabledStatusChanged();
// Balloon pop-up for new transaction // Balloon pop-up for new transaction
connect(_walletModel->getTransactionTableModel(), &TransactionTableModel::rowsInserted, this, &WalletView::processNewTransaction); connect(_walletModel->getTransactionTableModel(), &TransactionTableModel::rowsInserted, this, &WalletView::processNewTransaction);
@ -304,11 +300,6 @@ void WalletView::showOutOfSyncWarning(bool fShow)
overviewPage->showOutOfSyncWarning(fShow); overviewPage->showOutOfSyncWarning(fShow);
} }
void WalletView::updateEncryptionStatus()
{
Q_EMIT encryptionStatusChanged();
}
void WalletView::encryptWallet() void WalletView::encryptWallet()
{ {
if(!walletModel) if(!walletModel)
@ -317,7 +308,7 @@ void WalletView::encryptWallet()
dlg.setModel(walletModel); dlg.setModel(walletModel);
dlg.exec(); dlg.exec();
updateEncryptionStatus(); Q_EMIT encryptionStatusChanged();
} }
void WalletView::backupWallet() void WalletView::backupWallet()

View File

@ -116,9 +116,6 @@ public Q_SLOTS:
/** Show used receiving addresses */ /** Show used receiving addresses */
void usedReceivingAddresses(); void usedReceivingAddresses();
/** Re-emit encryption status signal */
void updateEncryptionStatus();
/** Show progress dialog e.g. for rescan */ /** Show progress dialog e.g. for rescan */
void showProgress(const QString &title, int nProgress); void showProgress(const QString &title, int nProgress);
@ -132,8 +129,6 @@ Q_SIGNALS:
void message(const QString &title, const QString &message, unsigned int style); void message(const QString &title, const QString &message, unsigned int style);
/** Encryption status of wallet changed */ /** Encryption status of wallet changed */
void encryptionStatusChanged(); void encryptionStatusChanged();
/** HD-Enabled status of wallet changed (only possible during startup) */
void hdEnabledStatusChanged();
/** Notify that a new transaction appeared */ /** 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); 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 */ /** Notify that the out of sync warning icon has been pressed */