diff options
author | Jonas Schnelli <dev@jonasschnelli.ch> | 2019-05-18 13:01:40 +0200 |
---|---|---|
committer | Jonas Schnelli <dev@jonasschnelli.ch> | 2019-05-18 13:02:29 +0200 |
commit | 387eb5b34307448f16d3769ac0245c4e3d996a38 (patch) | |
tree | 7fe0599a9d88898f365a2f799404566018362fd3 | |
parent | 82b64a5a8102eba2dfa3624247720a1c40f6ae8c (diff) | |
parent | c3ef63a52f304a600fff1f9c7caa5cb804d41d43 (diff) |
Merge #15957: Show "No wallets available" in open menu instead of nothing
c3ef63a52 Show loaded wallets as disabled in open menu instead of nothing (MeshCollider)
Pull request description:
Fixes the confusing behavior reported in #15952
![image](https://user-images.githubusercontent.com/3211283/57224284-0e8e7f80-705d-11e9-9554-2450cc3dbb8e.png)
ACKs for commit c3ef63:
jonasschnelli:
Tested ACK c3ef63a52f304a600fff1f9c7caa5cb804d41d43
kristapsk:
tACK c3ef63a52f304a600fff1f9c7caa5cb804d41d43
Tree-SHA512: fc2b94936ca32b89e8146c65e3629785883d78660afc8838818df652a4df9185ddca6b36ebf140a7159ab42b0fa5aa72867558d4572a009be06f0831fa813d1f
-rw-r--r-- | src/qt/bitcoingui.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index abf9136eee..ff66df376b 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -370,9 +370,18 @@ void BitcoinGUI::createActions() connect(openAction, &QAction::triggered, this, &BitcoinGUI::openClicked); connect(m_open_wallet_action->menu(), &QMenu::aboutToShow, [this] { m_open_wallet_action->menu()->clear(); - for (std::string path : m_wallet_controller->getWalletsAvailableToOpen()) { + std::vector<std::string> available_wallets = m_wallet_controller->getWalletsAvailableToOpen(); + std::vector<std::string> wallets = m_node.listWalletDir(); + for (const auto& path : wallets) { QString name = path.empty() ? QString("["+tr("default wallet")+"]") : QString::fromStdString(path); QAction* action = m_open_wallet_action->menu()->addAction(name); + + if (std::find(available_wallets.begin(), available_wallets.end(), path) == available_wallets.end()) { + // This wallet is already loaded + action->setEnabled(false); + continue; + } + connect(action, &QAction::triggered, [this, name, path] { OpenWalletActivity* activity = m_wallet_controller->openWallet(path); @@ -400,6 +409,10 @@ void BitcoinGUI::createActions() assert(invoked); }); } + if (wallets.empty()) { + QAction* action = m_open_wallet_action->menu()->addAction(tr("No wallets available")); + action->setEnabled(false); + } }); connect(m_close_wallet_action, &QAction::triggered, [this] { m_wallet_controller->closeWallet(walletFrame->currentWalletModel(), this); |