diff --git a/doc/release-notes.md b/doc/release-notes.md --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -5,3 +5,5 @@ This release includes the following features and fixes: - Wallets loaded dynamically through the RPC interface may now be displayed in the bitcoin-qt GUI. + - The default wallet will now be labeled `[default wallet]` in the bitcoin-qt + GUI if no name is provided by the `-wallet` option on start up. diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -198,6 +198,7 @@ #ifdef ENABLE_WALLET bool setCurrentWallet(const QString &name); + bool setCurrentWalletBySelectorIndex(int index); /** Set the UI status indicators based on the currently selected wallet. */ void updateWalletStatus(); diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -503,8 +503,8 @@ toolbar->addWidget(spacer); m_wallet_selector = new QComboBox(); - connect(m_wallet_selector, SIGNAL(currentIndexChanged(const QString &)), - this, SLOT(setCurrentWallet(const QString &))); + connect(m_wallet_selector, SIGNAL(currentIndexChanged(int)), this, + SLOT(setCurrentWalletBySelectorIndex(int))); #endif } } @@ -582,8 +582,10 @@ bool BitcoinGUI::addWallet(WalletModel *walletModel) { if (!walletFrame) return false; const QString name = walletModel->getWalletName(); + QString display_name = + name.isEmpty() ? "[" + tr("default wallet") + "]" : name; setWalletActionsEnabled(true); - m_wallet_selector->addItem(name); + m_wallet_selector->addItem(display_name, name); if (m_wallet_selector->count() == 2) { m_wallet_selector_label = new QLabel(); m_wallet_selector_label->setText(tr("Wallet:") + " "); @@ -600,6 +602,11 @@ return walletFrame->setCurrentWallet(name); } +bool BitcoinGUI::setCurrentWalletBySelectorIndex(int index) { + QString internal_name = m_wallet_selector->itemData(index).toString(); + return setCurrentWallet(internal_name); +} + void BitcoinGUI::removeAllWallets() { if (!walletFrame) return; setWalletActionsEnabled(false); diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -821,7 +821,9 @@ const QString name = walletModel->getWalletName(); // use name for text and internal data object (to allow to move to a wallet // id later) - ui->WalletSelector->addItem(name, name); + QString display_name = + name.isEmpty() ? "[" + tr("default wallet") + "]" : name; + ui->WalletSelector->addItem(display_name, name); if (ui->WalletSelector->count() == 2 && !isVisible()) { // First wallet added, set to default so long as the window isn't // presently visible (and potentially in use)