@@ -360,6 +360,7 @@ void BitcoinGUI::createActions()
360
360
m_migrate_wallet_action = new QAction (tr (" Migrate Wallet" ), this );
361
361
m_migrate_wallet_action->setEnabled (false );
362
362
m_migrate_wallet_action->setStatusTip (tr (" Migrate a wallet" ));
363
+ m_migrate_wallet_menu = new QMenu (this );
363
364
364
365
showHelpMessageAction = new QAction (tr (" &Command-line options" ), this );
365
366
showHelpMessageAction->setMenuRole (QAction::NoRole);
@@ -455,10 +456,33 @@ void BitcoinGUI::createActions()
455
456
connect (m_close_all_wallets_action, &QAction::triggered, [this ] {
456
457
m_wallet_controller->closeAllWallets (this );
457
458
});
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
+ QString name = GUIUtil::WalletDisplayName (wallet_name);
464
+ // Menu items remove single &. Single & are shown when && is in
465
+ // the string, but only the first occurrence. So replace only
466
+ // the first & with &&.
467
+ name.replace (name.indexOf (QChar (' &' )), 1 , QString (" &&" ));
468
+ QAction* action = m_migrate_wallet_menu->addAction (name);
469
+
470
+ if (format != " bdb" ) {
471
+ // This wallet is already migrated
472
+ action->setEnabled (false );
473
+ continue ;
474
+ }
475
+
476
+ connect (action, &QAction::triggered, [this , wallet_name] {
477
+ auto activity = new MigrateWalletActivity (m_wallet_controller, this );
478
+ connect (activity, &MigrateWalletActivity::migrated, this , &BitcoinGUI::setCurrentWallet);
479
+ activity->migrate (wallet_name);
480
+ });
481
+ }
482
+ if (m_migrate_wallet_menu->isEmpty ()) {
483
+ QAction* action = m_migrate_wallet_menu->addAction (tr (" No wallets available" ));
484
+ action->setEnabled (false );
485
+ }
462
486
});
463
487
connect (m_mask_values_action, &QAction::toggled, this , &BitcoinGUI::setPrivacy);
464
488
connect (m_mask_values_action, &QAction::toggled, this , &BitcoinGUI::enableHistoryAction);
@@ -691,6 +715,8 @@ void BitcoinGUI::setWalletController(WalletController* wallet_controller, bool s
691
715
m_open_wallet_action->setEnabled (true );
692
716
m_open_wallet_action->setMenu (m_open_wallet_menu);
693
717
m_restore_wallet_action->setEnabled (true );
718
+ m_migrate_wallet_action->setEnabled (true );
719
+ m_migrate_wallet_action->setMenu (m_migrate_wallet_menu);
694
720
695
721
GUIUtil::ExceptionSafeConnect (wallet_controller, &WalletController::walletAdded, this , &BitcoinGUI::addWallet);
696
722
connect (wallet_controller, &WalletController::walletRemoved, this , &BitcoinGUI::removeWallet);
@@ -771,7 +797,6 @@ void BitcoinGUI::setCurrentWallet(WalletModel* wallet_model)
771
797
}
772
798
}
773
799
updateWindowTitle ();
774
- m_migrate_wallet_action->setEnabled (wallet_model->wallet ().isLegacy ());
775
800
}
776
801
777
802
void BitcoinGUI::setCurrentWalletBySelectorIndex (int index)
@@ -805,7 +830,6 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled)
805
830
openAction->setEnabled (enabled);
806
831
m_close_wallet_action->setEnabled (enabled);
807
832
m_close_all_wallets_action->setEnabled (enabled);
808
- m_migrate_wallet_action->setEnabled (enabled);
809
833
}
810
834
811
835
void BitcoinGUI::createTrayIcon ()
0 commit comments