Skip to content

Commit 774a4f5

Browse files
committed
Merge bitcoin-core#403: refactor: Make paths to update Encryption and HD wallet statuses simpler
b8aa84b qt, refactor: Replace `if` check with `assert` (Hennadii Stepanov) fcdc8b0 qt, refactor: Drop redundant signalling in WalletView::setWalletModel (Hennadii Stepanov) 37dcf16 qt, refactor: Emit WalletView::encryptionStatusChanged signal directly (Hennadii Stepanov) 7d0d4c0 qt: Add WalletFrame::currentWalletSet signal (Hennadii Stepanov) Pull request description: This PR makes signal-slot paths to reach `setHDStatus` and `setEncryptionStatus` functions shorter and easier to reason about them. Required to simplify bitcoin-core#398 (see bitcoin-core#398 (comment)). --- **Note for reviewers.** Please verify that "Encrypt Wallet..." menu item, and the following icons ![DeepinScreenshot_select-area_20210811202120](https://user-images.githubusercontent.com/32963518/129074601-13fa998a-ac47-4ad2-be00-ba400b12c18a.png) and updated properly in each and every possible scenario. ACKs for top commit: jarolrod: tACK b8aa84b Talkless: Code review ACK b8aa84b. Did build on Debian Sid with Qt 5.15.2 but no actual testing performed. ryanofsky: Code review ACK b8aa84b. Only change since last review was rebase Tree-SHA512: 275737cdba02baff71049df41bc24089e916f96326dd2dea26ec607c7949cb3aae368eeabbe3ad5a0a27651503a1d65536873726de854c5f6af259bcc29727e7
2 parents 7740ebc + b8aa84b commit 774a4f5

File tree

5 files changed

+7
-20
lines changed

5 files changed

+7
-20
lines changed

src/qt/bitcoingui.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
113113
connect(walletFrame, &WalletFrame::message, [this](const QString& title, const QString& message, unsigned int style) {
114114
this->message(title, message, style);
115115
});
116+
connect(walletFrame, &WalletFrame::currentWalletSet, [this] { updateWalletStatus(); });
116117
setCentralWidget(walletFrame);
117118
} else
118119
#endif // ENABLE_WALLET
@@ -694,7 +695,6 @@ void BitcoinGUI::addWallet(WalletModel* walletModel)
694695
});
695696
connect(wallet_view, &WalletView::encryptionStatusChanged, this, &BitcoinGUI::updateWalletStatus);
696697
connect(wallet_view, &WalletView::incomingTransaction, this, &BitcoinGUI::incomingTransaction);
697-
connect(wallet_view, &WalletView::hdEnabledStatusChanged, this, &BitcoinGUI::updateWalletStatus);
698698
connect(this, &BitcoinGUI::setPrivacy, wallet_view, &WalletView::setPrivacy);
699699
wallet_view->setPrivacy(isPrivacyModeActivated());
700700
const QString display_name = walletModel->getDisplayName();
@@ -1340,9 +1340,8 @@ void BitcoinGUI::setEncryptionStatus(int status)
13401340

13411341
void BitcoinGUI::updateWalletStatus()
13421342
{
1343-
if (!walletFrame) {
1344-
return;
1345-
}
1343+
assert(walletFrame);
1344+
13461345
WalletView * const walletView = walletFrame->currentWalletView();
13471346
if (!walletView) {
13481347
return;

src/qt/walletframe.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ void WalletFrame::setCurrentWallet(WalletModel* wallet_model)
109109
walletView->updateGeometry();
110110

111111
walletStack->setCurrentWidget(walletView);
112-
walletView->updateEncryptionStatus();
112+
113+
Q_EMIT currentWalletSet();
113114
}
114115

115116
void WalletFrame::removeWallet(WalletModel* wallet_model)

src/qt/walletframe.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class WalletFrame : public QFrame
4949
Q_SIGNALS:
5050
void createWalletButtonClicked();
5151
void message(const QString& title, const QString& message, unsigned int style);
52+
void currentWalletSet();
5253

5354
private:
5455
QStackedWidget *walletStack;

src/qt/walletview.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,6 @@ void WalletView::setWalletModel(WalletModel *_walletModel)
118118

119119
// Handle changes in encryption status
120120
connect(_walletModel, &WalletModel::encryptionStatusChanged, this, &WalletView::encryptionStatusChanged);
121-
updateEncryptionStatus();
122-
123-
// update HD status
124-
Q_EMIT hdEnabledStatusChanged();
125121

126122
// Balloon pop-up for new transaction
127123
connect(_walletModel->getTransactionTableModel(), &TransactionTableModel::rowsInserted, this, &WalletView::processNewTransaction);
@@ -211,11 +207,6 @@ void WalletView::showOutOfSyncWarning(bool fShow)
211207
overviewPage->showOutOfSyncWarning(fShow);
212208
}
213209

214-
void WalletView::updateEncryptionStatus()
215-
{
216-
Q_EMIT encryptionStatusChanged();
217-
}
218-
219210
void WalletView::encryptWallet()
220211
{
221212
if(!walletModel)
@@ -224,7 +215,7 @@ void WalletView::encryptWallet()
224215
dlg.setModel(walletModel);
225216
dlg.exec();
226217

227-
updateEncryptionStatus();
218+
Q_EMIT encryptionStatusChanged();
228219
}
229220

230221
void WalletView::backupWallet()

src/qt/walletview.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ public Q_SLOTS:
103103
/** Show used receiving addresses */
104104
void usedReceivingAddresses();
105105

106-
/** Re-emit encryption status signal */
107-
void updateEncryptionStatus();
108-
109106
/** Show progress dialog e.g. for rescan */
110107
void showProgress(const QString &title, int nProgress);
111108

@@ -117,8 +114,6 @@ public Q_SLOTS:
117114
void message(const QString &title, const QString &message, unsigned int style);
118115
/** Encryption status of wallet changed */
119116
void encryptionStatusChanged();
120-
/** HD-Enabled status of wallet changed (only possible during startup) */
121-
void hdEnabledStatusChanged();
122117
/** Notify that a new transaction appeared */
123118
void incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label, const QString& walletName);
124119
/** Notify that the out of sync warning icon has been pressed */

0 commit comments

Comments
 (0)