mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 23:07:59 +01:00
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.
This commit is contained in:
parent
28fc562f26
commit
bfba63880f
5 changed files with 15 additions and 4 deletions
|
@ -398,7 +398,7 @@ void BitcoinGUI::createActions()
|
||||||
m_open_wallet_menu->clear();
|
m_open_wallet_menu->clear();
|
||||||
for (const auto& [path, info] : m_wallet_controller->listWalletDir()) {
|
for (const auto& [path, info] : m_wallet_controller->listWalletDir()) {
|
||||||
const auto& [loaded, _] = info;
|
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.
|
// 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 &&.
|
// Single & are shown when && is in the string. So replace & with &&.
|
||||||
name.replace(QChar('&'), QString("&&"));
|
name.replace(QChar('&'), QString("&&"));
|
||||||
|
|
|
@ -1008,4 +1008,13 @@ void ShowModalDialogAsynchronously(QDialog* dialog)
|
||||||
dialog->show();
|
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
|
} // namespace GUIUtil
|
||||||
|
|
|
@ -436,6 +436,9 @@ namespace GUIUtil
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString WalletDisplayName(const std::string& name);
|
||||||
|
QString WalletDisplayName(const QString& name);
|
||||||
|
|
||||||
} // namespace GUIUtil
|
} // namespace GUIUtil
|
||||||
|
|
||||||
#endif // BITCOIN_QT_GUIUTIL_H
|
#endif // BITCOIN_QT_GUIUTIL_H
|
||||||
|
|
|
@ -343,7 +343,7 @@ void OpenWalletActivity::finish()
|
||||||
|
|
||||||
void OpenWalletActivity::open(const std::string& path)
|
void OpenWalletActivity::open(const std::string& path)
|
||||||
{
|
{
|
||||||
QString name = path.empty() ? QString("["+tr("default wallet")+"]") : QString::fromStdString(path);
|
QString name = GUIUtil::WalletDisplayName(path);
|
||||||
|
|
||||||
showProgressDialog(
|
showProgressDialog(
|
||||||
//: Title of window indicating the progress of opening of a wallet.
|
//: Title of window indicating the progress of opening of a wallet.
|
||||||
|
|
|
@ -594,8 +594,7 @@ QString WalletModel::getWalletName() const
|
||||||
|
|
||||||
QString WalletModel::getDisplayName() const
|
QString WalletModel::getDisplayName() const
|
||||||
{
|
{
|
||||||
const QString name = getWalletName();
|
return GUIUtil::WalletDisplayName(getWalletName());
|
||||||
return name.isEmpty() ? "["+tr("default wallet")+"]" : name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WalletModel::isMultiwallet() const
|
bool WalletModel::isMultiwallet() const
|
||||||
|
|
Loading…
Add table
Reference in a new issue