@@ -360,6 +360,7 @@ void BitcoinGUI::createActions()
360360 m_migrate_wallet_action = new QAction (tr (" Migrate Wallet" ), this );
361361 m_migrate_wallet_action->setEnabled (false );
362362 m_migrate_wallet_action->setStatusTip (tr (" Migrate a wallet" ));
363+ m_migrate_wallet_menu = new QMenu (this );
363364
364365 showHelpMessageAction = new QAction (tr (" &Command-line options" ), this );
365366 showHelpMessageAction->setMenuRole (QAction::NoRole);
@@ -455,10 +456,31 @@ void BitcoinGUI::createActions()
455456 connect (m_close_all_wallets_action, &QAction::triggered, [this ] {
456457 m_wallet_controller->closeAllWallets (this );
457458 });
458- connect (m_migrate_wallet_action, &QAction::triggered, [this ] {
459- auto activity = new MigrateWalletActivity (m_wallet_controller, this );
460- connect (activity, &MigrateWalletActivity::migrated, this , &BitcoinGUI::setCurrentWallet);
461- activity->migrate (walletFrame->currentWalletModel ()->wallet ().getWalletName ());
459+ connect (m_migrate_wallet_menu, &QMenu::aboutToShow, [this ] {
460+ m_migrate_wallet_menu->clear ();
461+ for (const auto & [wallet_name, info] : m_wallet_controller->listWalletDir ()) {
462+ const auto & [loaded, format] = info;
463+
464+ if (format != " bdb" ) { // Skip already migrated wallets
465+ continue ;
466+ }
467+
468+ QString name = GUIUtil::WalletDisplayName (wallet_name);
469+ // An single ampersand in the menu item's text sets a shortcut for this item.
470+ // Single & are shown when && is in the string. So replace & with &&.
471+ name.replace (QChar (' &' ), QString (" &&" ));
472+ QAction* action = m_migrate_wallet_menu->addAction (name);
473+
474+ connect (action, &QAction::triggered, [this , wallet_name] {
475+ auto activity = new MigrateWalletActivity (m_wallet_controller, this );
476+ connect (activity, &MigrateWalletActivity::migrated, this , &BitcoinGUI::setCurrentWallet);
477+ activity->migrate (wallet_name);
478+ });
479+ }
480+ if (m_migrate_wallet_menu->isEmpty ()) {
481+ QAction* action = m_migrate_wallet_menu->addAction (tr (" No wallets available" ));
482+ action->setEnabled (false );
483+ }
462484 });
463485 connect (m_mask_values_action, &QAction::toggled, this , &BitcoinGUI::setPrivacy);
464486 connect (m_mask_values_action, &QAction::toggled, this , &BitcoinGUI::enableHistoryAction);
@@ -691,6 +713,8 @@ void BitcoinGUI::setWalletController(WalletController* wallet_controller, bool s
691713 m_open_wallet_action->setEnabled (true );
692714 m_open_wallet_action->setMenu (m_open_wallet_menu);
693715 m_restore_wallet_action->setEnabled (true );
716+ m_migrate_wallet_action->setEnabled (true );
717+ m_migrate_wallet_action->setMenu (m_migrate_wallet_menu);
694718
695719 GUIUtil::ExceptionSafeConnect (wallet_controller, &WalletController::walletAdded, this , &BitcoinGUI::addWallet);
696720 connect (wallet_controller, &WalletController::walletRemoved, this , &BitcoinGUI::removeWallet);
@@ -771,7 +795,6 @@ void BitcoinGUI::setCurrentWallet(WalletModel* wallet_model)
771795 }
772796 }
773797 updateWindowTitle ();
774- m_migrate_wallet_action->setEnabled (wallet_model->wallet ().isLegacy ());
775798}
776799
777800void BitcoinGUI::setCurrentWalletBySelectorIndex (int index)
@@ -805,7 +828,6 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled)
805828 openAction->setEnabled (enabled);
806829 m_close_wallet_action->setEnabled (enabled);
807830 m_close_all_wallets_action->setEnabled (enabled);
808- m_migrate_wallet_action->setEnabled (enabled);
809831}
810832
811833void BitcoinGUI::createTrayIcon ()
0 commit comments