@@ -277,6 +277,13 @@ void BitcoinGUI::createActions()
277277 historyAction->setShortcut (QKeySequence (QStringLiteral (" Alt+4" )));
278278 tabGroup->addAction (historyAction);
279279
280+ showCoinsAction = new QAction (platformStyle->SingleColorIcon (" :/icons/coins" ), tr (" &Coins" ), this );
281+ showCoinsAction->setStatusTip (tr (" View wallet coins (UTXOs)" ));
282+ showCoinsAction->setToolTip (showCoinsAction->statusTip ());
283+ showCoinsAction->setCheckable (true );
284+ showCoinsAction->setShortcut (QKeySequence (QStringLiteral (" Alt+5" )));
285+ tabGroup->addAction (showCoinsAction);
286+
280287#ifdef ENABLE_WALLET
281288 // These showNormalIfMinimized are needed because Send Coins and Receive Coins
282289 // can be triggered from the tray menu, and need to show the GUI to be useful.
@@ -288,6 +295,7 @@ void BitcoinGUI::createActions()
288295 connect (receiveCoinsAction, &QAction::triggered, this , &BitcoinGUI::gotoReceiveCoinsPage);
289296 connect (historyAction, &QAction::triggered, [this ]{ showNormalIfMinimized (); });
290297 connect (historyAction, &QAction::triggered, this , &BitcoinGUI::gotoHistoryPage);
298+ connect (showCoinsAction, &QAction::triggered, this , &BitcoinGUI::showCoins);
291299#endif // ENABLE_WALLET
292300
293301 quitAction = new QAction (tr (" E&xit" ), this );
@@ -601,8 +609,12 @@ void BitcoinGUI::createToolBars()
601609 toolbar->addAction (sendCoinsAction);
602610 toolbar->addAction (receiveCoinsAction);
603611 toolbar->addAction (historyAction);
612+ toolbar->addAction (showCoinsAction);
604613 overviewAction->setChecked (true );
605614
615+ showCoinsAction->setVisible (false );
616+ showCoinsAction->setEnabled (false );
617+
606618#ifdef ENABLE_WALLET
607619 QWidget *spacer = new QWidget ();
608620 spacer->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);
@@ -676,6 +688,14 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH
676688 }
677689
678690 m_mask_values_action->setChecked (_clientModel->getOptionsModel ()->getOption (OptionsModel::OptionID::MaskValues).toBool ());
691+
692+ // watch for runtime changes and hide/show the coins tab accordingly
693+ updateCoinsTabVisibility ();
694+ if (optionsModel) {
695+ connect (optionsModel, &OptionsModel::coinControlFeaturesChanged, this , [this ](bool ) {
696+ updateCoinsTabVisibility ();
697+ });
698+ }
679699 } else {
680700 // Shutdown requested, disable menus
681701 if (trayIconMenu)
@@ -822,6 +842,7 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled)
822842 sendCoinsAction->setEnabled (enabled);
823843 receiveCoinsAction->setEnabled (enabled);
824844 historyAction->setEnabled (enabled);
845+ showCoinsAction->setEnabled (enabled);
825846 encryptWalletAction->setEnabled (enabled);
826847 backupWalletAction->setEnabled (enabled);
827848 changePassphraseAction->setEnabled (enabled);
@@ -832,6 +853,8 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled)
832853 openAction->setEnabled (enabled);
833854 m_close_wallet_action->setEnabled (enabled);
834855 m_close_all_wallets_action->setEnabled (enabled);
856+ m_wallet_actions_enabled = enabled;
857+ updateCoinsTabVisibility ();
835858}
836859
837860void BitcoinGUI::createTrayIcon ()
@@ -1293,6 +1316,7 @@ void BitcoinGUI::changeEvent(QEvent *e)
12931316 sendCoinsAction->setIcon (platformStyle->SingleColorIcon (QStringLiteral (" :/icons/send" )));
12941317 receiveCoinsAction->setIcon (platformStyle->SingleColorIcon (QStringLiteral (" :/icons/receiving_addresses" )));
12951318 historyAction->setIcon (platformStyle->SingleColorIcon (QStringLiteral (" :/icons/history" )));
1319+ showCoinsAction->setIcon (platformStyle->SingleColorIcon (QStringLiteral (" :/icons/coins" )));
12961320 }
12971321
12981322 QMainWindow::changeEvent (e);
@@ -1468,6 +1492,24 @@ void BitcoinGUI::updateWalletStatus()
14681492}
14691493#endif // ENABLE_WALLET
14701494
1495+ #ifdef ENABLE_WALLET
1496+ void BitcoinGUI::showCoins ()
1497+ {
1498+ if (!(clientModel && clientModel->getOptionsModel () && clientModel->getOptionsModel ()->getCoinControlFeatures ())) {
1499+ if (overviewAction) overviewAction->setChecked (true );
1500+ // if user disables coin control features while this view is active, switch to overview
1501+ if (walletFrame) walletFrame->gotoOverviewPage ();
1502+ return ;
1503+ }
1504+
1505+ if (showCoinsAction) showCoinsAction->setChecked (true );
1506+ if (!walletFrame) return ;
1507+ if (WalletView* wv = walletFrame->currentWalletView ()) {
1508+ wv->gotoCoinsPage ();
1509+ }
1510+ }
1511+ #endif // ENABLE_WALLET
1512+
14711513void BitcoinGUI::updateProxyIcon ()
14721514{
14731515 std::string ip_port;
@@ -1680,3 +1722,27 @@ void UnitDisplayStatusBarControl::onMenuSelection(QAction* action)
16801722 optionsModel->setDisplayUnit (action->data ());
16811723 }
16821724}
1725+
1726+ void BitcoinGUI::updateCoinsTabVisibility ()
1727+ {
1728+ if (!showCoinsAction) return ;
1729+
1730+ bool coin_control_enabled = false ;
1731+ if (clientModel && clientModel->getOptionsModel ()) {
1732+ coin_control_enabled = clientModel->getOptionsModel ()->getCoinControlFeatures ();
1733+ }
1734+
1735+ // Visible only when wallet is compiled/enabled and coin control is enabled
1736+ const bool visible = enableWallet && coin_control_enabled;
1737+ showCoinsAction->setVisible (visible);
1738+
1739+ // Enabled only when visible and wallet actions are globally enabled
1740+ showCoinsAction->setEnabled (visible && m_wallet_actions_enabled);
1741+
1742+ #ifdef ENABLE_WALLET
1743+ // If the Coins tab is active but we turn it off, switch to Overview page
1744+ if (!visible && showCoinsAction->isChecked ()) {
1745+ gotoOverviewPage ();
1746+ }
1747+ #endif
1748+ }
0 commit comments