Changeset View
Changeset View
Standalone View
Standalone View
src/qt/bitcoingui.cpp
Show All 24 Lines | |||||
#include <qt/notificator.h> | #include <qt/notificator.h> | ||||
#include <qt/openuridialog.h> | #include <qt/openuridialog.h> | ||||
#include <qt/optionsdialog.h> | #include <qt/optionsdialog.h> | ||||
#include <qt/optionsmodel.h> | #include <qt/optionsmodel.h> | ||||
#include <qt/platformstyle.h> | #include <qt/platformstyle.h> | ||||
#include <qt/rpcconsole.h> | #include <qt/rpcconsole.h> | ||||
#include <qt/utilitydialog.h> | #include <qt/utilitydialog.h> | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
#include <qt/walletcontroller.h> | |||||
#include <qt/walletframe.h> | #include <qt/walletframe.h> | ||||
#include <qt/walletmodel.h> | #include <qt/walletmodel.h> | ||||
#include <qt/walletview.h> | #include <qt/walletview.h> | ||||
#endif // ENABLE_WALLET | #endif // ENABLE_WALLET | ||||
#include <ui_interface.h> | #include <ui_interface.h> | ||||
#include <util/system.h> | #include <util/system.h> | ||||
#include <QAction> | #include <QAction> | ||||
▲ Show 20 Lines • Show All 558 Lines • ▼ Show 20 Lines | #ifdef ENABLE_WALLET | ||||
walletFrame->setClientModel(nullptr); | walletFrame->setClientModel(nullptr); | ||||
} | } | ||||
#endif // ENABLE_WALLET | #endif // ENABLE_WALLET | ||||
unitDisplayControl->setOptionsModel(nullptr); | unitDisplayControl->setOptionsModel(nullptr); | ||||
} | } | ||||
} | } | ||||
#ifdef ENABLE_WALLET | #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) { | void BitcoinGUI::addWallet(WalletModel *walletModel) { | ||||
if (!walletFrame) { | if (!walletFrame) { | ||||
return; | return; | ||||
} | } | ||||
const QString display_name = walletModel->getDisplayName(); | const QString display_name = walletModel->getDisplayName(); | ||||
setWalletActionsEnabled(true); | setWalletActionsEnabled(true); | ||||
rpcConsole->addWallet(walletModel); | |||||
walletFrame->addWallet(walletModel); | |||||
m_wallet_selector->addItem(display_name, QVariant::fromValue(walletModel)); | m_wallet_selector->addItem(display_name, QVariant::fromValue(walletModel)); | ||||
if (m_wallet_selector->count() == 2) { | if (m_wallet_selector->count() == 2) { | ||||
m_wallet_selector_label_action->setVisible(true); | m_wallet_selector_label_action->setVisible(true); | ||||
m_wallet_selector_action->setVisible(true); | m_wallet_selector_action->setVisible(true); | ||||
} | } | ||||
rpcConsole->addWallet(walletModel); | |||||
walletFrame->addWallet(walletModel); | |||||
} | } | ||||
void BitcoinGUI::removeWallet(WalletModel *walletModel) { | void BitcoinGUI::removeWallet(WalletModel *walletModel) { | ||||
if (!walletFrame) { | if (!walletFrame) { | ||||
return; | return; | ||||
} | } | ||||
int index = m_wallet_selector->findData(QVariant::fromValue(walletModel)); | int index = m_wallet_selector->findData(QVariant::fromValue(walletModel)); | ||||
m_wallet_selector->removeItem(index); | m_wallet_selector->removeItem(index); | ||||
if (m_wallet_selector->count() == 0) { | if (m_wallet_selector->count() == 0) { | ||||
setWalletActionsEnabled(false); | setWalletActionsEnabled(false); | ||||
} else if (m_wallet_selector->count() == 1) { | } else if (m_wallet_selector->count() == 1) { | ||||
m_wallet_selector_label_action->setVisible(false); | m_wallet_selector_label_action->setVisible(false); | ||||
m_wallet_selector_action->setVisible(false); | m_wallet_selector_action->setVisible(false); | ||||
} | } | ||||
rpcConsole->removeWallet(walletModel); | rpcConsole->removeWallet(walletModel); | ||||
walletFrame->removeWallet(walletModel); | walletFrame->removeWallet(walletModel); | ||||
updateWindowTitle(); | updateWindowTitle(); | ||||
} | } | ||||
void BitcoinGUI::setCurrentWallet(WalletModel *wallet_model) { | void BitcoinGUI::setCurrentWallet(WalletModel *wallet_model) { | ||||
if (!walletFrame) { | if (!walletFrame) { | ||||
return; | return; | ||||
} | } | ||||
walletFrame->setCurrentWallet(wallet_model); | 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(); | updateWindowTitle(); | ||||
} | } | ||||
void BitcoinGUI::setCurrentWalletBySelectorIndex(int index) { | void BitcoinGUI::setCurrentWalletBySelectorIndex(int index) { | ||||
WalletModel *wallet_model = | WalletModel *wallet_model = | ||||
m_wallet_selector->itemData(index).value<WalletModel *>(); | m_wallet_selector->itemData(index).value<WalletModel *>(); | ||||
if (wallet_model) { | |||||
setCurrentWallet(wallet_model); | setCurrentWallet(wallet_model); | ||||
} | } | ||||
} | |||||
void BitcoinGUI::removeAllWallets() { | void BitcoinGUI::removeAllWallets() { | ||||
if (!walletFrame) return; | if (!walletFrame) return; | ||||
setWalletActionsEnabled(false); | setWalletActionsEnabled(false); | ||||
walletFrame->removeAllWallets(); | walletFrame->removeAllWallets(); | ||||
} | } | ||||
#endif // ENABLE_WALLET | #endif // ENABLE_WALLET | ||||
▲ Show 20 Lines • Show All 773 Lines • Show Last 20 Lines |