Skip to content

Commit a315b79

Browse files
committed
Merge #13275: Qt: use [default wallet] as name for wallet with no name
2885c13 Qt: use [default wallet] as name for wallet with no name (Jonas Schnelli) Pull request description: Loading a wallet from a state where only the default wallet was active results in using an empty string for the initial/default wallet name. This is a GUI only quick-fix that overrides wallet(s) with name "" to "[default wallet]". Does not affect `getwalletinfo` or `listwallets`. Also, unsure if it should be fixed at a deeper level and if – instead of [default wallet] – it should use `wallet.dat` (the filename of the default wallet). Tree-SHA512: 1d50dbb200b23df5ac53ce15aeb6453af4da354d6e6e53fe33ff075b477493254d6028b6d3569a7804b1aa616cb9a988a53de818937e37cdcb19cb70a90e2a88
2 parents 14a4b49 + 2885c13 commit a315b79

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/qt/bitcoingui.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ void BitcoinGUI::createToolBars()
476476
toolbar->addWidget(spacer);
477477

478478
m_wallet_selector = new QComboBox();
479-
connect(m_wallet_selector, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(setCurrentWallet(const QString&)));
479+
connect(m_wallet_selector, SIGNAL(currentIndexChanged(int)), this, SLOT(setCurrentWalletBySelectorIndex(int)));
480480
#endif
481481
}
482482
}
@@ -552,8 +552,9 @@ bool BitcoinGUI::addWallet(WalletModel *walletModel)
552552
if(!walletFrame)
553553
return false;
554554
const QString name = walletModel->getWalletName();
555+
QString display_name = name.isEmpty() ? "["+tr("default wallet")+"]" : name;
555556
setWalletActionsEnabled(true);
556-
m_wallet_selector->addItem(name);
557+
m_wallet_selector->addItem(display_name, name);
557558
if (m_wallet_selector->count() == 2) {
558559
m_wallet_selector_label = new QLabel();
559560
m_wallet_selector_label->setText(tr("Wallet:") + " ");
@@ -572,6 +573,12 @@ bool BitcoinGUI::setCurrentWallet(const QString& name)
572573
return walletFrame->setCurrentWallet(name);
573574
}
574575

576+
bool BitcoinGUI::setCurrentWalletBySelectorIndex(int index)
577+
{
578+
QString internal_name = m_wallet_selector->itemData(index).toString();
579+
return setCurrentWallet(internal_name);
580+
}
581+
575582
void BitcoinGUI::removeAllWallets()
576583
{
577584
if(!walletFrame)

src/qt/bitcoingui.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ public Q_SLOTS:
186186

187187
#ifdef ENABLE_WALLET
188188
bool setCurrentWallet(const QString& name);
189+
bool setCurrentWalletBySelectorIndex(int index);
189190
/** Set the UI status indicators based on the currently selected wallet.
190191
*/
191192
void updateWalletStatus();

src/qt/rpcconsole.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,8 @@ void RPCConsole::addWallet(WalletModel * const walletModel)
702702
{
703703
const QString name = walletModel->getWalletName();
704704
// use name for text and internal data object (to allow to move to a wallet id later)
705-
ui->WalletSelector->addItem(name, name);
705+
QString display_name = name.isEmpty() ? "["+tr("default wallet")+"]" : name;
706+
ui->WalletSelector->addItem(display_name, name);
706707
if (ui->WalletSelector->count() == 2 && !isVisible()) {
707708
// First wallet added, set to default so long as the window isn't presently visible (and potentially in use)
708709
ui->WalletSelector->setCurrentIndex(1);

0 commit comments

Comments
 (0)