Skip to content

Commit 377dca8

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 357b19e commit 377dca8

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
// Menu items remove single &. Single & are shown when && is in
403403
// the string, but only the first occurrence. So replace only
404404
// the first & with &&.

src/qt/guiutil.cpp

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

1010+
QString WalletDisplayName(const QString& name)
1011+
{
1012+
return name.isEmpty() ? "[" + QObject::tr("default wallet") + "]" : name;
1013+
}
1014+
1015+
QString WalletDisplayName(const std::string& name)
1016+
{
1017+
return WalletDisplayName(QString::fromStdString(name));
1018+
}
10101019
} // 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
@@ -342,7 +342,7 @@ void OpenWalletActivity::finish()
342342

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

347347
showProgressDialog(
348348
//: 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
@@ -593,8 +593,7 @@ QString WalletModel::getWalletName() const
593593

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

600599
bool WalletModel::isMultiwallet() const

0 commit comments

Comments
 (0)