Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
qt: Move WalletView connections from WalletFrame to BitcoinGUI
This changes remove some pointers to the BitcoinGUI instance that is
required for the next commits.

This commit does not change behavior.
  • Loading branch information
hebasto committed May 29, 2021
commit 20e2e24e90d782219e853ef0676ac66dc6a9de6a
17 changes: 16 additions & 1 deletion src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,10 @@ WalletController* BitcoinGUI::getWalletController()
void BitcoinGUI::addWallet(WalletModel* walletModel)
{
if (!walletFrame) return;
if (!walletFrame->addWallet(walletModel)) return;

WalletView* wallet_view = new WalletView(platformStyle, walletFrame);
if (!walletFrame->addWallet(walletModel, wallet_view)) return;

rpcConsole->addWallet(walletModel);
if (m_wallet_selector->count() == 0) {
setWalletActionsEnabled(true);
Expand All @@ -680,6 +683,18 @@ void BitcoinGUI::addWallet(WalletModel* walletModel)
}
const QString display_name = walletModel->getDisplayName();
m_wallet_selector->addItem(display_name, QVariant::fromValue(walletModel));

connect(wallet_view, &WalletView::outOfSyncWarningClicked, walletFrame, &WalletFrame::outOfSyncWarningClicked);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, maybe this should stay in WalletFrame?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing in this way keeps compatibility with #333.

connect(wallet_view, &WalletView::transactionClicked, this, &BitcoinGUI::gotoHistoryPage);
connect(wallet_view, &WalletView::coinsSent, this, &BitcoinGUI::gotoHistoryPage);
connect(wallet_view, &WalletView::message, [this](const QString& title, const QString& message, unsigned int style) {
this->message(title, message, style);
});
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());
}

void BitcoinGUI::removeWallet(WalletModel* walletModel)
Expand Down
15 changes: 1 addition & 14 deletions src/qt/walletframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,15 @@ void WalletFrame::setClientModel(ClientModel *_clientModel)
}
}

bool WalletFrame::addWallet(WalletModel *walletModel)
bool WalletFrame::addWallet(WalletModel* walletModel, WalletView* walletView)
{
if (!gui || !clientModel || !walletModel) return false;

if (mapWalletViews.count(walletModel) > 0) return false;

WalletView *walletView = new WalletView(platformStyle, this);
walletView->setClientModel(clientModel);
walletView->setWalletModel(walletModel);
walletView->showOutOfSyncWarning(bOutOfSync);
walletView->setPrivacy(gui->isPrivacyModeActivated());

WalletView* current_wallet_view = currentWalletView();
if (current_wallet_view) {
Expand All @@ -88,17 +86,6 @@ bool WalletFrame::addWallet(WalletModel *walletModel)
walletStack->addWidget(walletView);
mapWalletViews[walletModel] = walletView;

connect(walletView, &WalletView::outOfSyncWarningClicked, this, &WalletFrame::outOfSyncWarningClicked);
connect(walletView, &WalletView::transactionClicked, gui, &BitcoinGUI::gotoHistoryPage);
connect(walletView, &WalletView::coinsSent, gui, &BitcoinGUI::gotoHistoryPage);
connect(walletView, &WalletView::message, [this](const QString& title, const QString& message, unsigned int style) {
gui->message(title, message, style);
});
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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/qt/walletframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class WalletFrame : public QFrame

void setClientModel(ClientModel *clientModel);

bool addWallet(WalletModel *walletModel);
bool addWallet(WalletModel* walletModel, WalletView* walletView);
void setCurrentWallet(WalletModel* wallet_model);
void removeWallet(WalletModel* wallet_model);
void removeAllWallets();
Expand Down