Skip to content

Commit

Permalink
Merge bitcoin-core/gui#403: refactor: Make paths to update Encryption…
Browse files Browse the repository at this point in the history
… 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 ElementsProject#398 (see bitcoin-core/gui#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
  • Loading branch information
hebasto committed Aug 26, 2021
2 parents 7740ebc + b8aa84b commit 774a4f5
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 20 deletions.
7 changes: 3 additions & 4 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
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(); });
setCentralWidget(walletFrame);
} else
#endif // ENABLE_WALLET
Expand Down Expand Up @@ -694,7 +695,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();
Expand Down Expand Up @@ -1340,9 +1340,8 @@ void BitcoinGUI::setEncryptionStatus(int status)

void BitcoinGUI::updateWalletStatus()
{
if (!walletFrame) {
return;
}
assert(walletFrame);

WalletView * const walletView = walletFrame->currentWalletView();
if (!walletView) {
return;
Expand Down
3 changes: 2 additions & 1 deletion src/qt/walletframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ void WalletFrame::setCurrentWallet(WalletModel* wallet_model)
walletView->updateGeometry();

walletStack->setCurrentWidget(walletView);
walletView->updateEncryptionStatus();

Q_EMIT currentWalletSet();
}

void WalletFrame::removeWallet(WalletModel* wallet_model)
Expand Down
1 change: 1 addition & 0 deletions src/qt/walletframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class WalletFrame : public QFrame
Q_SIGNALS:
void createWalletButtonClicked();
void message(const QString& title, const QString& message, unsigned int style);
void currentWalletSet();

private:
QStackedWidget *walletStack;
Expand Down
11 changes: 1 addition & 10 deletions src/qt/walletview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,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);
Expand Down Expand Up @@ -211,11 +207,6 @@ void WalletView::showOutOfSyncWarning(bool fShow)
overviewPage->showOutOfSyncWarning(fShow);
}

void WalletView::updateEncryptionStatus()
{
Q_EMIT encryptionStatusChanged();
}

void WalletView::encryptWallet()
{
if(!walletModel)
Expand All @@ -224,7 +215,7 @@ void WalletView::encryptWallet()
dlg.setModel(walletModel);
dlg.exec();

updateEncryptionStatus();
Q_EMIT encryptionStatusChanged();
}

void WalletView::backupWallet()
Expand Down
5 changes: 0 additions & 5 deletions src/qt/walletview.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,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);

Expand All @@ -117,8 +114,6 @@ public Q_SLOTS:
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 */
Expand Down

0 comments on commit 774a4f5

Please sign in to comment.