Qt: QComboBox::setVisible doesn't work in toolbars, so defer adding it at all until needed

This commit is contained in:
Luke Dashjr 2016-12-29 13:53:25 +00:00 committed by Jonas Schnelli
parent d49cc70e6d
commit d1ec34a761
No known key found for this signature in database
GPG Key ID: 1EB776BB03C7922D
2 changed files with 8 additions and 10 deletions

View File

@ -86,6 +86,7 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle *
progressBar(0), progressBar(0),
progressDialog(0), progressDialog(0),
appMenuBar(0), appMenuBar(0),
appToolBar(0),
overviewAction(0), overviewAction(0),
historyAction(0), historyAction(0),
quitAction(0), quitAction(0),
@ -453,6 +454,7 @@ void BitcoinGUI::createToolBars()
if(walletFrame) if(walletFrame)
{ {
QToolBar *toolbar = addToolBar(tr("Tabs toolbar")); QToolBar *toolbar = addToolBar(tr("Tabs toolbar"));
appToolBar = toolbar;
toolbar->setContextMenuPolicy(Qt::PreventContextMenu); toolbar->setContextMenuPolicy(Qt::PreventContextMenu);
toolbar->setMovable(false); toolbar->setMovable(false);
toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
@ -467,15 +469,7 @@ void BitcoinGUI::createToolBars()
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
toolbar->addWidget(spacer); 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(); 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&))); connect(m_wallet_selector, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(setCurrentWallet(const QString&)));
#endif #endif
} }
@ -551,8 +545,11 @@ bool BitcoinGUI::addWallet(const QString& name, WalletModel *walletModel)
setWalletActionsEnabled(true); setWalletActionsEnabled(true);
m_wallet_selector->addItem(name); m_wallet_selector->addItem(name);
if (m_wallet_selector->count() == 2) { if (m_wallet_selector->count() == 2) {
m_wallet_selector->setVisible(true); m_wallet_selector_label = new QLabel();
m_wallet_selector->setVisible(true); m_wallet_selector_label->setText(tr("Wallet:") + " ");
m_wallet_selector_label->setBuddy(m_wallet_selector);
appToolBar->addWidget(m_wallet_selector_label);
appToolBar->addWidget(m_wallet_selector);
} }
rpcConsole->addWallet(name, walletModel); rpcConsole->addWallet(name, walletModel);
return walletFrame->addWallet(name, walletModel); return walletFrame->addWallet(name, walletModel);

View File

@ -89,6 +89,7 @@ private:
QProgressDialog *progressDialog; QProgressDialog *progressDialog;
QMenuBar *appMenuBar; QMenuBar *appMenuBar;
QToolBar *appToolBar;
QAction *overviewAction; QAction *overviewAction;
QAction *historyAction; QAction *historyAction;
QAction *quitAction; QAction *quitAction;