gui: correct replacement of amp character in the wallet name for QMenu

The comment in the code regarding the use of an "&"
on a menu item is misleading. If a wallet name has an "&" in it,
it is not supposed to be interpreted as a hot-key, but it should be
shown as it is without replacing it to an underscore.
This commit is contained in:
Konstantin Akimov 2024-07-13 13:14:02 +07:00
parent c4d45b695e
commit 8233ee41ab
No known key found for this signature in database
GPG Key ID: 2176C4A5D01EA524

View File

@ -399,10 +399,9 @@ void BitcoinGUI::createActions()
for (const std::pair<const std::string, bool>& i : m_wallet_controller->listWalletDir()) { for (const std::pair<const std::string, bool>& i : m_wallet_controller->listWalletDir()) {
const std::string& path = i.first; const std::string& path = i.first;
QString name = path.empty() ? QString("["+tr("default wallet")+"]") : QString::fromStdString(path); QString name = path.empty() ? QString("["+tr("default wallet")+"]") : QString::fromStdString(path);
// Menu items remove single &. Single & are shown when && is in // An single ampersand in the menu item's text sets a shortcut for this item.
// the string, but only the first occurrence. So replace only // Single & are shown when && is in the string. So replace & with &&.
// the first & with &&. name.replace(QChar('&'), QString("&&"));
name.replace(name.indexOf(QChar('&')), 1, QString("&&"));
QAction* action = m_open_wallet_menu->addAction(name); QAction* action = m_open_wallet_menu->addAction(name);
if (i.second) { if (i.second) {