Skip to content

Commit d1ec34a

Browse files
luke-jrjonasschnelli
authored andcommitted
Qt: QComboBox::setVisible doesn't work in toolbars, so defer adding it at all until needed
1 parent d49cc70 commit d1ec34a

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/qt/bitcoingui.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle *
8686
progressBar(0),
8787
progressDialog(0),
8888
appMenuBar(0),
89+
appToolBar(0),
8990
overviewAction(0),
9091
historyAction(0),
9192
quitAction(0),
@@ -453,6 +454,7 @@ void BitcoinGUI::createToolBars()
453454
if(walletFrame)
454455
{
455456
QToolBar *toolbar = addToolBar(tr("Tabs toolbar"));
457+
appToolBar = toolbar;
456458
toolbar->setContextMenuPolicy(Qt::PreventContextMenu);
457459
toolbar->setMovable(false);
458460
toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
@@ -467,15 +469,7 @@ void BitcoinGUI::createToolBars()
467469
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
468470
toolbar->addWidget(spacer);
469471

470-
m_wallet_selector_label = new QLabel();
471-
m_wallet_selector_label->setText(tr("Wallet:") + " ");
472-
toolbar->addWidget(m_wallet_selector_label);
473-
m_wallet_selector_label->setVisible(false);
474472
m_wallet_selector = new QComboBox();
475-
toolbar->addWidget(m_wallet_selector);
476-
m_wallet_selector->setVisible(false);
477-
m_wallet_selector_label->setBuddy(m_wallet_selector);
478-
479473
connect(m_wallet_selector, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(setCurrentWallet(const QString&)));
480474
#endif
481475
}
@@ -551,8 +545,11 @@ bool BitcoinGUI::addWallet(const QString& name, WalletModel *walletModel)
551545
setWalletActionsEnabled(true);
552546
m_wallet_selector->addItem(name);
553547
if (m_wallet_selector->count() == 2) {
554-
m_wallet_selector->setVisible(true);
555-
m_wallet_selector->setVisible(true);
548+
m_wallet_selector_label = new QLabel();
549+
m_wallet_selector_label->setText(tr("Wallet:") + " ");
550+
m_wallet_selector_label->setBuddy(m_wallet_selector);
551+
appToolBar->addWidget(m_wallet_selector_label);
552+
appToolBar->addWidget(m_wallet_selector);
556553
}
557554
rpcConsole->addWallet(name, walletModel);
558555
return walletFrame->addWallet(name, walletModel);

src/qt/bitcoingui.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class BitcoinGUI : public QMainWindow
8989
QProgressDialog *progressDialog;
9090

9191
QMenuBar *appMenuBar;
92+
QToolBar *appToolBar;
9293
QAction *overviewAction;
9394
QAction *historyAction;
9495
QAction *quitAction;

0 commit comments

Comments
 (0)