@@ -639,8 +639,19 @@ void BitcoinGUI::createToolBars()
639639
640640#ifdef ENABLE_WALLET
641641 m_wallet_selector = new QComboBox (this );
642- m_wallet_selector->setHidden (true );
643- connect (m_wallet_selector, SIGNAL (currentIndexChanged (const QString&)), this , SLOT (setCurrentWallet (const QString&)));
642+ connect (m_wallet_selector, SIGNAL (currentIndexChanged (int )), this , SLOT (setCurrentWalletBySelectorIndex (int )));
643+
644+ QVBoxLayout* walletSelectorLayout = new QVBoxLayout (this );
645+ walletSelectorLayout->addWidget (m_wallet_selector);
646+ walletSelectorLayout->setSpacing (0 );
647+ walletSelectorLayout->setMargin (0 );
648+ walletSelectorLayout->setContentsMargins (5 , 0 , 5 , 0 );
649+ QWidget* walletSelector = new QWidget (this );
650+ walletSelector->setSizePolicy (QSizePolicy::Preferred, QSizePolicy::Preferred);
651+ walletSelector->setObjectName (" walletSelector" );
652+ walletSelector->setLayout (walletSelectorLayout);
653+ m_wallet_selector_action = appToolBar->insertWidget (appToolBarLogoAction, walletSelector);
654+ m_wallet_selector_action->setVisible (false );
644655#endif
645656
646657 QLabel *logoLabel = new QLabel ();
@@ -769,32 +780,44 @@ bool BitcoinGUI::addWallet(WalletModel *walletModel)
769780 if (!walletFrame)
770781 return false ;
771782 const QString name = walletModel->getWalletName ();
783+ QString display_name = name.isEmpty () ? " [" +tr (" default wallet" )+" ]" : name;
772784 setWalletActionsEnabled (true );
773- m_wallet_selector->addItem (name);
785+ m_wallet_selector->addItem (display_name, name);
774786 if (m_wallet_selector->count () == 2 ) {
775- m_wallet_selector->setHidden (false );
776- QVBoxLayout* layout = new QVBoxLayout (this );
777- layout->addWidget (m_wallet_selector);
778- layout->setSpacing (0 );
779- layout->setMargin (0 );
780- layout->setContentsMargins (5 , 0 , 5 , 0 );
781- QWidget* walletSelector = new QWidget (this );
782- walletSelector->setSizePolicy (QSizePolicy::Preferred, QSizePolicy::Preferred);
783- walletSelector->setObjectName (" walletSelector" );
784- walletSelector->setLayout (layout);
785- appToolBar->insertWidget (appToolBarLogoAction, walletSelector);
787+ m_wallet_selector_action->setVisible (true );
786788 }
787789 rpcConsole->addWallet (walletModel);
788790 return walletFrame->addWallet (walletModel);
789791}
790792
793+ bool BitcoinGUI::removeWallet (WalletModel* walletModel)
794+ {
795+ if (!walletFrame) return false ;
796+ QString name = walletModel->getWalletName ();
797+ int index = m_wallet_selector->findData (name);
798+ m_wallet_selector->removeItem (index);
799+ if (m_wallet_selector->count () == 0 ) {
800+ setWalletActionsEnabled (false );
801+ } else if (m_wallet_selector->count () == 1 ) {
802+ m_wallet_selector_action->setVisible (false );
803+ }
804+ rpcConsole->removeWallet (walletModel);
805+ return walletFrame->removeWallet (name);
806+ }
807+
791808bool BitcoinGUI::setCurrentWallet (const QString& name)
792809{
793810 if (!walletFrame)
794811 return false ;
795812 return walletFrame->setCurrentWallet (name);
796813}
797814
815+ bool BitcoinGUI::setCurrentWalletBySelectorIndex (int index)
816+ {
817+ QString internal_name = m_wallet_selector->itemData (index).toString ();
818+ return setCurrentWallet (internal_name);
819+ }
820+
798821void BitcoinGUI::removeAllWallets ()
799822{
800823 if (!walletFrame)
0 commit comments