Skip to content

Commit bfba638

Browse files
committed
gui: Consolidate wallet display name to GUIUtil function
Instead of having the code for the wallet display name being copy and pasted, use a GUIUtil function to get that for us.
1 parent 28fc562 commit bfba638

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

src/qt/bitcoingui.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ void BitcoinGUI::createActions()
398398
m_open_wallet_menu->clear();
399399
for (const auto& [path, info] : m_wallet_controller->listWalletDir()) {
400400
const auto& [loaded, _] = info;
401-
QString name = path.empty() ? QString("["+tr("default wallet")+"]") : QString::fromStdString(path);
401+
QString name = GUIUtil::WalletDisplayName(path);
402402
// An single ampersand in the menu item's text sets a shortcut for this item.
403403
// Single & are shown when && is in the string. So replace & with &&.
404404
name.replace(QChar('&'), QString("&&"));

src/qt/guiutil.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,4 +1008,13 @@ void ShowModalDialogAsynchronously(QDialog* dialog)
10081008
dialog->show();
10091009
}
10101010

1011+
QString WalletDisplayName(const QString& name)
1012+
{
1013+
return name.isEmpty() ? "[" + QObject::tr("default wallet") + "]" : name;
1014+
}
1015+
1016+
QString WalletDisplayName(const std::string& name)
1017+
{
1018+
return WalletDisplayName(QString::fromStdString(name));
1019+
}
10111020
} // namespace GUIUtil

src/qt/guiutil.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,9 @@ namespace GUIUtil
436436
return false;
437437
}
438438

439+
QString WalletDisplayName(const std::string& name);
440+
QString WalletDisplayName(const QString& name);
441+
439442
} // namespace GUIUtil
440443

441444
#endif // BITCOIN_QT_GUIUTIL_H

src/qt/walletcontroller.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ void OpenWalletActivity::finish()
343343

344344
void OpenWalletActivity::open(const std::string& path)
345345
{
346-
QString name = path.empty() ? QString("["+tr("default wallet")+"]") : QString::fromStdString(path);
346+
QString name = GUIUtil::WalletDisplayName(path);
347347

348348
showProgressDialog(
349349
//: Title of window indicating the progress of opening of a wallet.

src/qt/walletmodel.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,7 @@ QString WalletModel::getWalletName() const
594594

595595
QString WalletModel::getDisplayName() const
596596
{
597-
const QString name = getWalletName();
598-
return name.isEmpty() ? "["+tr("default wallet")+"]" : name;
597+
return GUIUtil::WalletDisplayName(getWalletName());
599598
}
600599

601600
bool WalletModel::isMultiwallet() const

0 commit comments

Comments
 (0)