Qt: Add a combobox to toolbar to select from multiple wallets

This commit is contained in:
Luke Dashjr 2016-09-09 10:43:54 +00:00 committed by Jonas Schnelli
parent 3dba3c3ac1
commit e449f9a9e6
No known key found for this signature in database
GPG Key ID: 1EB776BB03C7922D
2 changed files with 30 additions and 1 deletions

View File

@ -36,6 +36,7 @@
#include <QAction> #include <QAction>
#include <QApplication> #include <QApplication>
#include <QComboBox>
#include <QDateTime> #include <QDateTime>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QDragEnterEvent> #include <QDragEnterEvent>
@ -459,6 +460,23 @@ void BitcoinGUI::createToolBars()
toolbar->addAction(receiveCoinsAction); toolbar->addAction(receiveCoinsAction);
toolbar->addAction(historyAction); toolbar->addAction(historyAction);
overviewAction->setChecked(true); overviewAction->setChecked(true);
#ifdef ENABLE_WALLET
QWidget *spacer = new QWidget();
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
toolbar->addWidget(spacer);
m_wallet_selector_label = new QLabel();
m_wallet_selector_label->setText(tr("Wallet:") + " ");
toolbar->addWidget(m_wallet_selector_label);
m_wallet_selector_label->setVisible(false);
m_wallet_selector = new QComboBox();
toolbar->addWidget(m_wallet_selector);
m_wallet_selector->setVisible(false);
m_wallet_selector_label->setBuddy(m_wallet_selector);
connect(m_wallet_selector, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(setCurrentWallet(const QString&)));
#endif
} }
} }
@ -530,6 +548,11 @@ bool BitcoinGUI::addWallet(const QString& name, WalletModel *walletModel)
if(!walletFrame) if(!walletFrame)
return false; return false;
setWalletActionsEnabled(true); setWalletActionsEnabled(true);
m_wallet_selector->addItem(name);
if (m_wallet_selector->count() == 2) {
m_wallet_selector->setVisible(true);
m_wallet_selector->setVisible(true);
}
return walletFrame->addWallet(name, walletModel); return walletFrame->addWallet(name, walletModel);
} }

View File

@ -33,6 +33,7 @@ class ModalOverlay;
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QAction; class QAction;
class QComboBox;
class QProgressBar; class QProgressBar;
class QProgressDialog; class QProgressDialog;
QT_END_NAMESPACE QT_END_NAMESPACE
@ -62,7 +63,6 @@ public:
functionality. functionality.
*/ */
bool addWallet(const QString& name, WalletModel *walletModel); bool addWallet(const QString& name, WalletModel *walletModel);
bool setCurrentWallet(const QString& name);
void removeAllWallets(); void removeAllWallets();
#endif // ENABLE_WALLET #endif // ENABLE_WALLET
bool enableWallet; bool enableWallet;
@ -111,6 +111,9 @@ private:
QAction *openAction; QAction *openAction;
QAction *showHelpMessageAction; QAction *showHelpMessageAction;
QLabel *m_wallet_selector_label;
QComboBox *m_wallet_selector;
QSystemTrayIcon *trayIcon; QSystemTrayIcon *trayIcon;
QMenu *trayIconMenu; QMenu *trayIconMenu;
Notificator *notificator; Notificator *notificator;
@ -170,6 +173,9 @@ public Q_SLOTS:
void message(const QString &title, const QString &message, unsigned int style, bool *ret = nullptr); void message(const QString &title, const QString &message, unsigned int style, bool *ret = nullptr);
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
bool setCurrentWallet(const QString& name);
private:
/** Set the encryption status as shown in the UI. /** Set the encryption status as shown in the UI.
@param[in] status current encryption status @param[in] status current encryption status
@see WalletModel::EncryptionStatus @see WalletModel::EncryptionStatus