Skip to content

Commit 2885c13

Browse files
committed
Qt: use [default wallet] as name for wallet with no name
1 parent 1a8b12c commit 2885c13

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)