Skip to content

Commit e449f9a

Browse files
luke-jrjonasschnelli
authored andcommitted
Qt: Add a combobox to toolbar to select from multiple wallets
1 parent 3dba3c3 commit e449f9a

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/qt/bitcoingui.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
#include <QAction>
3838
#include <QApplication>
39+
#include <QComboBox>
3940
#include <QDateTime>
4041
#include <QDesktopWidget>
4142
#include <QDragEnterEvent>
@@ -459,6 +460,23 @@ void BitcoinGUI::createToolBars()
459460
toolbar->addAction(receiveCoinsAction);
460461
toolbar->addAction(historyAction);
461462
overviewAction->setChecked(true);
463+
464+
#ifdef ENABLE_WALLET
465+
QWidget *spacer = new QWidget();
466+
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
467+
toolbar->addWidget(spacer);
468+
469+
m_wallet_selector_label = new QLabel();
470+
m_wallet_selector_label->setText(tr("Wallet:") + " ");
471+
toolbar->addWidget(m_wallet_selector_label);
472+
m_wallet_selector_label->setVisible(false);
473+
m_wallet_selector = new QComboBox();
474+
toolbar->addWidget(m_wallet_selector);
475+
m_wallet_selector->setVisible(false);
476+
m_wallet_selector_label->setBuddy(m_wallet_selector);
477+
478+
connect(m_wallet_selector, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(setCurrentWallet(const QString&)));
479+
#endif
462480
}
463481
}
464482

@@ -530,6 +548,11 @@ bool BitcoinGUI::addWallet(const QString& name, WalletModel *walletModel)
530548
if(!walletFrame)
531549
return false;
532550
setWalletActionsEnabled(true);
551+
m_wallet_selector->addItem(name);
552+
if (m_wallet_selector->count() == 2) {
553+
m_wallet_selector->setVisible(true);
554+
m_wallet_selector->setVisible(true);
555+
}
533556
return walletFrame->addWallet(name, walletModel);
534557
}
535558

src/qt/bitcoingui.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class ModalOverlay;
3333

3434
QT_BEGIN_NAMESPACE
3535
class QAction;
36+
class QComboBox;
3637
class QProgressBar;
3738
class QProgressDialog;
3839
QT_END_NAMESPACE
@@ -62,7 +63,6 @@ class BitcoinGUI : public QMainWindow
6263
functionality.
6364
*/
6465
bool addWallet(const QString& name, WalletModel *walletModel);
65-
bool setCurrentWallet(const QString& name);
6666
void removeAllWallets();
6767
#endif // ENABLE_WALLET
6868
bool enableWallet;
@@ -111,6 +111,9 @@ class BitcoinGUI : public QMainWindow
111111
QAction *openAction;
112112
QAction *showHelpMessageAction;
113113

114+
QLabel *m_wallet_selector_label;
115+
QComboBox *m_wallet_selector;
116+
114117
QSystemTrayIcon *trayIcon;
115118
QMenu *trayIconMenu;
116119
Notificator *notificator;
@@ -170,6 +173,9 @@ public Q_SLOTS:
170173
void message(const QString &title, const QString &message, unsigned int style, bool *ret = nullptr);
171174

172175
#ifdef ENABLE_WALLET
176+
bool setCurrentWallet(const QString& name);
177+
178+
private:
173179
/** Set the encryption status as shown in the UI.
174180
@param[in] status current encryption status
175181
@see WalletModel::EncryptionStatus

0 commit comments

Comments
 (0)