gui: Add Open Wallet menu

This commit is contained in:
João Barbosa 2019-01-12 11:40:30 +00:00
parent 32a8c6abfe
commit 6c49a55b47
2 changed files with 17 additions and 0 deletions

View file

@ -334,6 +334,10 @@ void BitcoinGUI::createActions()
openAction = new QAction(platformStyle->TextColorIcon(":/icons/open"), tr("Open &URI..."), this); openAction = new QAction(platformStyle->TextColorIcon(":/icons/open"), tr("Open &URI..."), this);
openAction->setStatusTip(tr("Open a bitcoin: URI or payment request")); openAction->setStatusTip(tr("Open a bitcoin: URI or payment request"));
m_open_wallet_action = new QAction(tr("Open Wallet"), this);
m_open_wallet_action->setMenu(new QMenu(this));
m_open_wallet_action->setStatusTip(tr("Open a wallet"));
showHelpMessageAction = new QAction(platformStyle->TextColorIcon(":/icons/info"), tr("&Command-line options"), this); showHelpMessageAction = new QAction(platformStyle->TextColorIcon(":/icons/info"), tr("&Command-line options"), this);
showHelpMessageAction->setMenuRole(QAction::NoRole); showHelpMessageAction->setMenuRole(QAction::NoRole);
showHelpMessageAction->setStatusTip(tr("Show the %1 help message to get a list with possible Bitcoin command-line options").arg(tr(PACKAGE_NAME))); showHelpMessageAction->setStatusTip(tr("Show the %1 help message to get a list with possible Bitcoin command-line options").arg(tr(PACKAGE_NAME)));
@ -361,6 +365,16 @@ void BitcoinGUI::createActions()
connect(usedSendingAddressesAction, &QAction::triggered, walletFrame, &WalletFrame::usedSendingAddresses); connect(usedSendingAddressesAction, &QAction::triggered, walletFrame, &WalletFrame::usedSendingAddresses);
connect(usedReceivingAddressesAction, &QAction::triggered, walletFrame, &WalletFrame::usedReceivingAddresses); connect(usedReceivingAddressesAction, &QAction::triggered, walletFrame, &WalletFrame::usedReceivingAddresses);
connect(openAction, &QAction::triggered, this, &BitcoinGUI::openClicked); 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()) {
QString name = path.empty() ? QString("["+tr("default wallet")+"]") : QString::fromStdString(path);
QAction* action = m_open_wallet_action->menu()->addAction(name);
connect(action, &QAction::triggered, [this, path] {
setCurrentWallet(m_wallet_controller->openWallet(path));
});
}
});
} }
#endif // ENABLE_WALLET #endif // ENABLE_WALLET
@ -382,6 +396,8 @@ void BitcoinGUI::createMenuBar()
QMenu *file = appMenuBar->addMenu(tr("&File")); QMenu *file = appMenuBar->addMenu(tr("&File"));
if(walletFrame) if(walletFrame)
{ {
file->addAction(m_open_wallet_action);
file->addSeparator();
file->addAction(openAction); file->addAction(openAction);
file->addAction(backupWalletAction); file->addAction(backupWalletAction);
file->addAction(signMessageAction); file->addAction(signMessageAction);

View file

@ -147,6 +147,7 @@ private:
QAction* openRPCConsoleAction = nullptr; QAction* openRPCConsoleAction = nullptr;
QAction* openAction = nullptr; QAction* openAction = nullptr;
QAction* showHelpMessageAction = nullptr; QAction* showHelpMessageAction = nullptr;
QAction* m_open_wallet_action{nullptr};
QAction* m_wallet_selector_label_action = nullptr; QAction* m_wallet_selector_label_action = nullptr;
QAction* m_wallet_selector_action = nullptr; QAction* m_wallet_selector_action = nullptr;