Skip to content

Commit 91b0606

Browse files
committed
Merge 1122590 into merged_master (Bitcoin PR bitcoin-core/gui#309)
2 parents 57dadc1 + 1122590 commit 91b0606

2 files changed

Lines changed: 32 additions & 10 deletions

File tree

src/qt/bitcoingui.cpp

Lines changed: 28 additions & 8 deletions
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
});
@@ -581,7 +579,10 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH
581579
createTrayIconMenu();
582580

583581
// Keep up to date with client
584-
updateNetworkState();
582+
setNetworkActive(m_node.getNetworkActive());
583+
connect(connectionsControl, &GUIUtil::ClickableLabel::clicked, [this] {
584+
GUIUtil::PopupMenu(m_network_context_menu, QCursor::pos());
585+
});
585586
connect(_clientModel, &ClientModel::numConnectionsChanged, this, &BitcoinGUI::setNumConnections);
586587
connect(_clientModel, &ClientModel::networkActiveChanged, this, &BitcoinGUI::setNetworkActive);
587588

@@ -900,14 +901,18 @@ void BitcoinGUI::updateNetworkState()
900901
QString tooltip;
901902

902903
if (m_node.getNetworkActive()) {
903-
tooltip = tr("%n active connection(s) to %1 network", "", count).arg("Liquid") + QString(".<br>") + tr("Click to disable network activity.");
904+
//: A substring of the tooltip.
905+
tooltip = tr("%n active connection(s) to %1 network", "", count).arg("Liquid");
904906
} else {
905-
tooltip = tr("Network activity disabled.") + QString("<br>") + tr("Click to enable network activity again.");
907+
//: A substring of the tooltip.
908+
tooltip = tr("Network activity disabled.");
906909
icon = ":/icons/network_disabled";
907910
}
908911

909912
// Don't word-wrap this (fixed-width) tooltip
910-
tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
913+
tooltip = QLatin1String("<nobr>") + tooltip + QLatin1String("<br>") +
914+
//: A substring of the tooltip. "More actions" are available via the context menu.
915+
tr("Click for more actions.") + QLatin1String("</nobr>");
911916
connectionsControl->setToolTip(tooltip);
912917

913918
connectionsControl->setThemedPixmap(icon, STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);
@@ -918,9 +923,24 @@ void BitcoinGUI::setNumConnections(int count)
918923
updateNetworkState();
919924
}
920925

921-
void BitcoinGUI::setNetworkActive(bool networkActive)
926+
void BitcoinGUI::setNetworkActive(bool network_active)
922927
{
923928
updateNetworkState();
929+
m_network_context_menu->clear();
930+
m_network_context_menu->addAction(
931+
//: A context menu item. The "Peers tab" is an element of the "Node window".
932+
tr("Show Peers tab"),
933+
[this] {
934+
rpcConsole->setTabFocus(RPCConsole::TabTypes::PEERS);
935+
showDebugWindow();
936+
});
937+
m_network_context_menu->addAction(
938+
network_active ?
939+
//: A context menu item.
940+
tr("Disable network activity") :
941+
//: A context menu item. The network activity was disabled previously.
942+
tr("Enable network activity"),
943+
[this, new_state = !network_active] { m_node.setNetworkActive(new_state); });
924944
}
925945

926946
void BitcoinGUI::updateHeadersSyncProgressLabel()

src/qt/bitcoingui.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <QLabel>
1818
#include <QMainWindow>
1919
#include <QMap>
20+
#include <QMenu>
2021
#include <QPoint>
2122
#include <QSystemTrayIcon>
2223

@@ -51,7 +52,6 @@ QT_BEGIN_NAMESPACE
5152
class QAction;
5253
class QComboBox;
5354
class QDateTime;
54-
class QMenu;
5555
class QProgressBar;
5656
class QProgressDialog;
5757
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
@@ -219,7 +221,7 @@ public Q_SLOTS:
219221
/** Set number of connections shown in the UI */
220222
void setNumConnections(int count);
221223
/** Set network state shown in the UI */
222-
void setNetworkActive(bool networkActive);
224+
void setNetworkActive(bool network_active);
223225
/** Set number of blocks and last block date shown in the UI */
224226
void setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool headers, SynchronizationState sync_state);
225227

0 commit comments

Comments
 (0)