Skip to content

Commit

Permalink
qt: Factor out WalletModel::getDisplayName()
Browse files Browse the repository at this point in the history
  • Loading branch information
promag committed Jan 4, 2019
1 parent 9c64278 commit d2a1adf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ bool BitcoinGUI::addWallet(WalletModel *walletModel)
if(!walletFrame)
return false;
const QString name = walletModel->getWalletName();
QString display_name = name.isEmpty() ? "["+tr("default wallet")+"]" : name;
const QString display_name = walletModel->getDisplayName();
setWalletActionsEnabled(true);
m_wallet_selector->addItem(display_name, name);
if (m_wallet_selector->count() == 2) {
Expand Down
2 changes: 1 addition & 1 deletion src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ 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)
QString display_name = name.isEmpty() ? "["+tr("default wallet")+"]" : name;
const QString display_name = walletModel->getDisplayName();
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)
Expand Down
8 changes: 7 additions & 1 deletion src/qt/walletmodel.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2011-2018 The Bitcoin Core developers
// Copyright (c) 2011-2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

Expand Down Expand Up @@ -578,6 +578,12 @@ QString WalletModel::getWalletName() const
return QString::fromStdString(m_wallet->getWalletName());
}

QString WalletModel::getDisplayName() const
{
const QString name = getWalletName();
return name.isEmpty() ? "["+tr("default wallet")+"]" : name;
}

bool WalletModel::isMultiwallet()
{
return m_node.getWallets().size() > 1;
Expand Down
3 changes: 2 additions & 1 deletion src/qt/walletmodel.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2011-2018 The Bitcoin Core developers
// Copyright (c) 2011-2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

Expand Down Expand Up @@ -219,6 +219,7 @@ class WalletModel : public QObject
interfaces::Wallet& wallet() const { return *m_wallet; }

QString getWalletName() const;
QString getDisplayName() const;

bool isMultiwallet();

Expand Down

0 comments on commit d2a1adf

Please sign in to comment.