diff options
author | Ava Chow <github@achow101.com> | 2024-06-10 15:39:35 -0400 |
---|---|---|
committer | Ava Chow <github@achow101.com> | 2024-08-13 11:25:38 -0400 |
commit | bfba63880fbb1108b73540faeb0620ba24b8cdd0 (patch) | |
tree | ec24d963c610addfb09b2cd9e24f1ea92465769c /src | |
parent | 28fc562f2692af4f37f918d4ae31c4d115e03aee (diff) | |
download | bitcoin-bfba63880fbb1108b73540faeb0620ba24b8cdd0.tar.xz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/qt/bitcoingui.cpp | 2 | ||||
-rw-r--r-- | src/qt/guiutil.cpp | 9 | ||||
-rw-r--r-- | src/qt/guiutil.h | 3 | ||||
-rw-r--r-- | src/qt/walletcontroller.cpp | 2 | ||||
-rw-r--r-- | src/qt/walletmodel.cpp | 3 |
5 files changed, 15 insertions, 4 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 6590147c6f..189af77a0c 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -398,7 +398,7 @@ void BitcoinGUI::createActions() m_open_wallet_menu->clear(); for (const auto& [path, info] : m_wallet_controller->listWalletDir()) { const auto& [loaded, _] = info; - QString name = path.empty() ? QString("["+tr("default wallet")+"]") : QString::fromStdString(path); + QString name = GUIUtil::WalletDisplayName(path); // An single ampersand in the menu item's text sets a shortcut for this item. // Single & are shown when && is in the string. So replace & with &&. name.replace(QChar('&'), QString("&&")); diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index f04e5c86f8..2369f6b631 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -1008,4 +1008,13 @@ void ShowModalDialogAsynchronously(QDialog* dialog) dialog->show(); } +QString WalletDisplayName(const QString& name) +{ + return name.isEmpty() ? "[" + QObject::tr("default wallet") + "]" : name; +} + +QString WalletDisplayName(const std::string& name) +{ + return WalletDisplayName(QString::fromStdString(name)); +} } // namespace GUIUtil diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 3e28e54557..4525198794 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -436,6 +436,9 @@ namespace GUIUtil return false; } + QString WalletDisplayName(const std::string& name); + QString WalletDisplayName(const QString& name); + } // namespace GUIUtil #endif // BITCOIN_QT_GUIUTIL_H diff --git a/src/qt/walletcontroller.cpp b/src/qt/walletcontroller.cpp index 7b3d920e56..ca7c00da41 100644 --- a/src/qt/walletcontroller.cpp +++ b/src/qt/walletcontroller.cpp @@ -343,7 +343,7 @@ void OpenWalletActivity::finish() void OpenWalletActivity::open(const std::string& path) { - QString name = path.empty() ? QString("["+tr("default wallet")+"]") : QString::fromStdString(path); + QString name = GUIUtil::WalletDisplayName(path); showProgressDialog( //: Title of window indicating the progress of opening of a wallet. diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index f8ce068e12..0a01c0a45b 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -594,8 +594,7 @@ QString WalletModel::getWalletName() const QString WalletModel::getDisplayName() const { - const QString name = getWalletName(); - return name.isEmpty() ? "["+tr("default wallet")+"]" : name; + return GUIUtil::WalletDisplayName(getWalletName()); } bool WalletModel::isMultiwallet() const |