Changeset View
Changeset View
Standalone View
Standalone View
src/qt/bitcoingui.cpp
Show First 20 Lines • Show All 499 Lines • ▼ Show 20 Lines | |||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
QWidget *spacer = new QWidget(); | QWidget *spacer = new QWidget(); | ||||
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | ||||
toolbar->addWidget(spacer); | toolbar->addWidget(spacer); | ||||
m_wallet_selector = new QComboBox(); | m_wallet_selector = new QComboBox(); | ||||
connect(m_wallet_selector, SIGNAL(currentIndexChanged(int)), this, | connect(m_wallet_selector, SIGNAL(currentIndexChanged(int)), this, | ||||
SLOT(setCurrentWalletBySelectorIndex(int))); | SLOT(setCurrentWalletBySelectorIndex(int))); | ||||
m_wallet_selector_label = new QLabel(); | |||||
m_wallet_selector_label->setText(tr("Wallet:") + " "); | |||||
m_wallet_selector_label->setBuddy(m_wallet_selector); | |||||
m_wallet_selector_label_action = | |||||
appToolBar->addWidget(m_wallet_selector_label); | |||||
m_wallet_selector_action = appToolBar->addWidget(m_wallet_selector); | |||||
m_wallet_selector_label_action->setVisible(false); | |||||
m_wallet_selector_action->setVisible(false); | |||||
#endif | #endif | ||||
} | } | ||||
} | } | ||||
void BitcoinGUI::setClientModel(ClientModel *_clientModel) { | void BitcoinGUI::setClientModel(ClientModel *_clientModel) { | ||||
this->clientModel = _clientModel; | this->clientModel = _clientModel; | ||||
if (_clientModel) { | if (_clientModel) { | ||||
// Create system tray menu (or setup the dock menu) that late to prevent | // Create system tray menu (or setup the dock menu) that late to prevent | ||||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | |||||
bool BitcoinGUI::addWallet(WalletModel *walletModel) { | bool BitcoinGUI::addWallet(WalletModel *walletModel) { | ||||
if (!walletFrame) return false; | if (!walletFrame) return false; | ||||
const QString name = walletModel->getWalletName(); | const QString name = walletModel->getWalletName(); | ||||
QString display_name = | QString display_name = | ||||
name.isEmpty() ? "[" + tr("default wallet") + "]" : name; | name.isEmpty() ? "[" + tr("default wallet") + "]" : name; | ||||
setWalletActionsEnabled(true); | setWalletActionsEnabled(true); | ||||
m_wallet_selector->addItem(display_name, name); | m_wallet_selector->addItem(display_name, name); | ||||
if (m_wallet_selector->count() == 2) { | if (m_wallet_selector->count() == 2) { | ||||
m_wallet_selector_label = new QLabel(); | m_wallet_selector_label_action->setVisible(true); | ||||
m_wallet_selector_label->setText(tr("Wallet:") + " "); | m_wallet_selector_action->setVisible(true); | ||||
m_wallet_selector_label->setBuddy(m_wallet_selector); | |||||
appToolBar->addWidget(m_wallet_selector_label); | |||||
appToolBar->addWidget(m_wallet_selector); | |||||
} | } | ||||
rpcConsole->addWallet(walletModel); | rpcConsole->addWallet(walletModel); | ||||
return walletFrame->addWallet(walletModel); | return walletFrame->addWallet(walletModel); | ||||
} | } | ||||
bool BitcoinGUI::removeWallet(WalletModel *walletModel) { | |||||
if (!walletFrame) { | |||||
return false; | |||||
} | |||||
QString name = walletModel->getWalletName(); | |||||
int index = m_wallet_selector->findData(name); | |||||
m_wallet_selector->removeItem(index); | |||||
if (m_wallet_selector->count() == 0) { | |||||
setWalletActionsEnabled(false); | |||||
} else if (m_wallet_selector->count() == 1) { | |||||
m_wallet_selector_label_action->setVisible(false); | |||||
m_wallet_selector_action->setVisible(false); | |||||
} | |||||
rpcConsole->removeWallet(walletModel); | |||||
return walletFrame->removeWallet(name); | |||||
} | |||||
bool BitcoinGUI::setCurrentWallet(const QString &name) { | bool BitcoinGUI::setCurrentWallet(const QString &name) { | ||||
if (!walletFrame) return false; | if (!walletFrame) return false; | ||||
return walletFrame->setCurrentWallet(name); | return walletFrame->setCurrentWallet(name); | ||||
} | } | ||||
bool BitcoinGUI::setCurrentWalletBySelectorIndex(int index) { | bool BitcoinGUI::setCurrentWalletBySelectorIndex(int index) { | ||||
QString internal_name = m_wallet_selector->itemData(index).toString(); | QString internal_name = m_wallet_selector->itemData(index).toString(); | ||||
return setCurrentWallet(internal_name); | return setCurrentWallet(internal_name); | ||||
▲ Show 20 Lines • Show All 740 Lines • Show Last 20 Lines |