mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-12 05:34:57 +01:00
Merge #15101: gui: Add WalletController
0dd9bdefagui: Refactor to use WalletController (João Barbosa)8fa271f08gui: Add WalletController (João Barbosa)cefb399e2gui: Use AutoConnection for WalletModel::unload signal (João Barbosa) Pull request description: This PR is a subset of the work done in the context of #13100. This change consists in extracting from the application class the code that manages the wallet models. The role of the `WalletController` instance is to coordinate wallet operations and the window. Tree-SHA512: 6a824054376730eb7d16c643dd2003f5f60778e8ad3af707b82bc12c48438db179ca4446316b28fb17b206f4b9aba8998419aab8c5dd1f7c32467015732b5094
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include <qt/utilitydialog.h>
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
#include <qt/walletcontroller.h>
|
||||
#include <qt/walletframe.h>
|
||||
#include <qt/walletmodel.h>
|
||||
#include <qt/walletview.h>
|
||||
@@ -565,18 +566,33 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel)
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
void BitcoinGUI::setWalletController(WalletController* wallet_controller)
|
||||
{
|
||||
assert(!m_wallet_controller);
|
||||
assert(wallet_controller);
|
||||
|
||||
m_wallet_controller = wallet_controller;
|
||||
|
||||
connect(wallet_controller, &WalletController::walletAdded, this, &BitcoinGUI::addWallet);
|
||||
connect(wallet_controller, &WalletController::walletRemoved, this, &BitcoinGUI::removeWallet);
|
||||
|
||||
for (WalletModel* wallet_model : m_wallet_controller->getWallets()) {
|
||||
addWallet(wallet_model);
|
||||
}
|
||||
}
|
||||
|
||||
void BitcoinGUI::addWallet(WalletModel* walletModel)
|
||||
{
|
||||
if (!walletFrame) return;
|
||||
const QString display_name = walletModel->getDisplayName();
|
||||
setWalletActionsEnabled(true);
|
||||
rpcConsole->addWallet(walletModel);
|
||||
walletFrame->addWallet(walletModel);
|
||||
m_wallet_selector->addItem(display_name, QVariant::fromValue(walletModel));
|
||||
if (m_wallet_selector->count() == 2) {
|
||||
m_wallet_selector_label_action->setVisible(true);
|
||||
m_wallet_selector_action->setVisible(true);
|
||||
}
|
||||
rpcConsole->addWallet(walletModel);
|
||||
walletFrame->addWallet(walletModel);
|
||||
}
|
||||
|
||||
void BitcoinGUI::removeWallet(WalletModel* walletModel)
|
||||
@@ -599,13 +615,19 @@ void BitcoinGUI::setCurrentWallet(WalletModel* wallet_model)
|
||||
{
|
||||
if (!walletFrame) return;
|
||||
walletFrame->setCurrentWallet(wallet_model);
|
||||
for (int index = 0; index < m_wallet_selector->count(); ++index) {
|
||||
if (m_wallet_selector->itemData(index).value<WalletModel*>() == wallet_model) {
|
||||
m_wallet_selector->setCurrentIndex(index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
updateWindowTitle();
|
||||
}
|
||||
|
||||
void BitcoinGUI::setCurrentWalletBySelectorIndex(int index)
|
||||
{
|
||||
WalletModel* wallet_model = m_wallet_selector->itemData(index).value<WalletModel*>();
|
||||
setCurrentWallet(wallet_model);
|
||||
if (wallet_model) setCurrentWallet(wallet_model);
|
||||
}
|
||||
|
||||
void BitcoinGUI::removeAllWallets()
|
||||
|
||||
Reference in New Issue
Block a user