Merge #13275: Qt: use [default wallet] as name for wallet with no name

2885c131b6 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
This commit is contained in:
Wladimir J. van der Laan 2018-05-28 17:04:11 +02:00
commit a315b79ad2
No known key found for this signature in database
GPG key ID: 1E4AED62986CD25D
3 changed files with 12 additions and 3 deletions

View file

@ -476,7 +476,7 @@ void BitcoinGUI::createToolBars()
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
}
}
@ -552,8 +552,9 @@ 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:") + " ");
@ -572,6 +573,12 @@ bool BitcoinGUI::setCurrentWallet(const QString& name)
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)

View file

@ -186,6 +186,7 @@ public Q_SLOTS:
#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();

View file

@ -702,7 +702,8 @@ void RPCConsole::addWallet(WalletModel * const walletModel)
{
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)
ui->WalletSelector->setCurrentIndex(1);