@@ -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);
@@ -456,10 +457,33 @@ void BitcoinGUI::createActions()
456
457
connect (m_close_all_wallets_action, &QAction::triggered, [this ] {
457
458
m_wallet_controller->closeAllWallets (this );
458
459
});
459
- connect (m_migrate_wallet_action, &QAction::triggered, [this ] {
460
- auto activity = new MigrateWalletActivity (m_wallet_controller, this );
461
- connect (activity, &MigrateWalletActivity::migrated, this , &BitcoinGUI::setCurrentWallet);
462
- activity->migrate (walletFrame->currentWalletModel ()->wallet ().getWalletName ());
460
+ connect (m_migrate_wallet_menu, &QMenu::aboutToShow, [this ] {
461
+ m_migrate_wallet_menu->clear ();
462
+ for (const auto & [wallet_name, info] : m_wallet_controller->listWalletDir ()) {
463
+ const auto & [loaded, format] = info;
464
+ QString name = GUIUtil::WalletDisplayName (wallet_name);
465
+ // Menu items remove single &. Single & are shown when && is in
466
+ // the string, but only the first occurrence. So replace only
467
+ // the first & with &&.
468
+ name.replace (name.indexOf (QChar (' &' )), 1 , QString (" &&" ));
469
+ QAction* action = m_migrate_wallet_menu->addAction (name);
470
+
471
+ if (format != " bdb" ) {
472
+ // This wallet is already migrated
473
+ action->setEnabled (false );
474
+ continue ;
475
+ }
476
+
477
+ connect (action, &QAction::triggered, [this , wallet_name] {
478
+ auto activity = new MigrateWalletActivity (m_wallet_controller, this );
479
+ connect (activity, &MigrateWalletActivity::migrated, this , &BitcoinGUI::setCurrentWallet);
480
+ activity->migrate (wallet_name);
481
+ });
482
+ }
483
+ if (m_migrate_wallet_menu->isEmpty ()) {
484
+ QAction* action = m_migrate_wallet_menu->addAction (tr (" No wallets available" ));
485
+ action->setEnabled (false );
486
+ }
463
487
});
464
488
connect (m_mask_values_action, &QAction::toggled, this , &BitcoinGUI::setPrivacy);
465
489
connect (m_mask_values_action, &QAction::toggled, this , &BitcoinGUI::enableHistoryAction);
@@ -692,6 +716,8 @@ void BitcoinGUI::setWalletController(WalletController* wallet_controller, bool s
692
716
m_open_wallet_action->setEnabled (true );
693
717
m_open_wallet_action->setMenu (m_open_wallet_menu);
694
718
m_restore_wallet_action->setEnabled (true );
719
+ m_migrate_wallet_action->setEnabled (true );
720
+ m_migrate_wallet_action->setMenu (m_migrate_wallet_menu);
695
721
696
722
GUIUtil::ExceptionSafeConnect (wallet_controller, &WalletController::walletAdded, this , &BitcoinGUI::addWallet);
697
723
connect (wallet_controller, &WalletController::walletRemoved, this , &BitcoinGUI::removeWallet);
@@ -772,7 +798,6 @@ void BitcoinGUI::setCurrentWallet(WalletModel* wallet_model)
772
798
}
773
799
}
774
800
updateWindowTitle ();
775
- m_migrate_wallet_action->setEnabled (wallet_model->wallet ().isLegacy ());
776
801
}
777
802
778
803
void BitcoinGUI::setCurrentWalletBySelectorIndex (int index)
0 commit comments