4343#include < QAction>
4444#include < QApplication>
4545#include < QComboBox>
46+ #include < QCursor>
4647#include < QDateTime>
4748#include < QDragEnterEvent>
4849#include < QListWidget>
@@ -199,9 +200,6 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
199200 // Subscribe to notifications from core
200201 subscribeToCoreSignals ();
201202
202- connect (connectionsControl, &GUIUtil::ClickableLabel::clicked, [this ] {
203- m_node.setNetworkActive (!m_node.getNetworkActive ());
204- });
205203 connect (labelProxyIcon, &GUIUtil::ClickableLabel::clicked, [this ] {
206204 openOptionsDialogWithTab (OptionsDialog::TAB_NETWORK);
207205 });
@@ -586,7 +584,10 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH
586584 createTrayIconMenu ();
587585
588586 // Keep up to date with client
589- updateNetworkState ();
587+ setNetworkActive (m_node.getNetworkActive ());
588+ connect (connectionsControl, &GUIUtil::ClickableLabel::clicked, [this ] {
589+ m_network_context_menu->exec (QCursor::pos ());
590+ });
590591 connect (_clientModel, &ClientModel::numConnectionsChanged, this , &BitcoinGUI::setNumConnections);
591592 connect (_clientModel, &ClientModel::networkActiveChanged, this , &BitcoinGUI::setNetworkActive);
592593
@@ -915,14 +916,18 @@ void BitcoinGUI::updateNetworkState()
915916 QString tooltip;
916917
917918 if (m_node.getNetworkActive ()) {
918- tooltip = tr (" %n active connection(s) to Bitcoin network" , " " , count) + QString (" .<br>" ) + tr (" Click to disable network activity." );
919+ // : A substring of the tooltip.
920+ tooltip = tr (" %n active connection(s) to Bitcoin network." , " " , count);
919921 } else {
920- tooltip = tr (" Network activity disabled." ) + QString (" <br>" ) + tr (" Click to enable network activity again." );
922+ // : A substring of the tooltip.
923+ tooltip = tr (" Network activity disabled." );
921924 icon = " :/icons/network_disabled" ;
922925 }
923926
924927 // Don't word-wrap this (fixed-width) tooltip
925- tooltip = QString (" <nobr>" ) + tooltip + QString (" </nobr>" );
928+ tooltip = QLatin1String (" <nobr>" ) + tooltip + QLatin1String (" <br>" ) +
929+ // : A substring of the tooltip. "More actions" are available via the context menu.
930+ tr (" Click for more actions." ) + QLatin1String (" </nobr>" );
926931 connectionsControl->setToolTip (tooltip);
927932
928933 connectionsControl->setPixmap (platformStyle->SingleColorIcon (icon).pixmap (STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
@@ -933,9 +938,24 @@ void BitcoinGUI::setNumConnections(int count)
933938 updateNetworkState ();
934939}
935940
936- void BitcoinGUI::setNetworkActive (bool networkActive )
941+ void BitcoinGUI::setNetworkActive (bool network_active )
937942{
938943 updateNetworkState ();
944+ m_network_context_menu->clear ();
945+ m_network_context_menu->addAction (
946+ // : A context menu item. The "Peers tab" is an element of the "Node window".
947+ tr (" Show Peers tab" ),
948+ [this ] {
949+ rpcConsole->setTabFocus (RPCConsole::TabTypes::PEERS);
950+ showDebugWindow ();
951+ });
952+ m_network_context_menu->addAction (
953+ network_active ?
954+ // : A context menu item.
955+ tr (" Disable network activity" ) :
956+ // : A context menu item. The network activity was disabled previously.
957+ tr (" Enable network activity again" ),
958+ [this , new_state = !network_active] { m_node.setNetworkActive (new_state); });
939959}
940960
941961void BitcoinGUI::updateHeadersSyncProgressLabel ()
0 commit comments