Skip to content

Commit 418dd58

Browse files
committed
gui: Add access to the Peers tab from the network icon
1 parent d22e7ee commit 418dd58

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

src/qt/bitcoingui.cpp

+27-7
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
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));
@@ -936,6 +941,21 @@ void BitcoinGUI::setNumConnections(int count)
936941
void BitcoinGUI::setNetworkActive(bool networkActive)
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+
m_node.getNetworkActive() ?
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] { m_node.setNetworkActive(!m_node.getNetworkActive()); });
939959
}
940960

941961
void BitcoinGUI::updateHeadersSyncProgressLabel()

src/qt/bitcoingui.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <QLabel>
1717
#include <QMainWindow>
1818
#include <QMap>
19+
#include <QMenu>
1920
#include <QPoint>
2021
#include <QSystemTrayIcon>
2122

@@ -50,7 +51,6 @@ QT_BEGIN_NAMESPACE
5051
class QAction;
5152
class QComboBox;
5253
class QDateTime;
53-
class QMenu;
5454
class QProgressBar;
5555
class QProgressDialog;
5656
QT_END_NAMESPACE
@@ -174,6 +174,8 @@ class BitcoinGUI : public QMainWindow
174174
HelpMessageDialog* helpMessageDialog = nullptr;
175175
ModalOverlay* modalOverlay = nullptr;
176176

177+
QMenu* m_network_context_menu = new QMenu(this);
178+
177179
#ifdef Q_OS_MAC
178180
CAppNapInhibitor* m_app_nap_inhibitor = nullptr;
179181
#endif

0 commit comments

Comments
 (0)