forked from bitcoin-core/gui
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gui: Add access to the Peers tab from the network icon
- Loading branch information
Showing
2 changed files
with
28 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ | |
#include <QAction> | ||
#include <QApplication> | ||
#include <QComboBox> | ||
#include <QCursor> | ||
#include <QDateTime> | ||
#include <QDragEnterEvent> | ||
#include <QListWidget> | ||
|
@@ -199,8 +200,19 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty | |
// Subscribe to notifications from core | ||
subscribeToCoreSignals(); | ||
|
||
m_network_context_menu = new QMenu(this); | ||
m_network_context_menu->addAction( | ||
//: A context menu item. The "Peers tab" is an element of the "Node window". | ||
tr("Show Peers tab"), | ||
[this] { | ||
rpcConsole->setTabFocus(RPCConsole::TabTypes::PEERS); | ||
showDebugWindow(); | ||
}); | ||
m_network_context_menu->addAction( | ||
QString(), | ||
[this] { m_node.setNetworkActive(!m_node.getNetworkActive()); }); | ||
connect(connectionsControl, &GUIUtil::ClickableLabel::clicked, [this] { | ||
m_node.setNetworkActive(!m_node.getNetworkActive()); | ||
GUIUtil::PopupMenu(m_network_context_menu, QCursor::pos()); | ||
}); | ||
connect(labelProxyIcon, &GUIUtil::ClickableLabel::clicked, [this] { | ||
openOptionsDialogWithTab(OptionsDialog::TAB_NETWORK); | ||
|
@@ -586,7 +598,7 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH | |
createTrayIconMenu(); | ||
|
||
// Keep up to date with client | ||
updateNetworkState(); | ||
setNetworkActive(m_node.getNetworkActive()); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
connect(_clientModel, &ClientModel::numConnectionsChanged, this, &BitcoinGUI::setNumConnections); | ||
connect(_clientModel, &ClientModel::networkActiveChanged, this, &BitcoinGUI::setNetworkActive); | ||
|
||
|
@@ -915,14 +927,18 @@ void BitcoinGUI::updateNetworkState() | |
QString tooltip; | ||
|
||
if (m_node.getNetworkActive()) { | ||
tooltip = tr("%n active connection(s) to Bitcoin network", "", count) + QString(".<br>") + tr("Click to disable network activity."); | ||
//: A substring of the tooltip. | ||
tooltip = tr("%n active connection(s) to Bitcoin network.", "", count); | ||
} else { | ||
tooltip = tr("Network activity disabled.") + QString("<br>") + tr("Click to enable network activity again."); | ||
//: A substring of the tooltip. | ||
tooltip = tr("Network activity disabled."); | ||
icon = ":/icons/network_disabled"; | ||
} | ||
|
||
// Don't word-wrap this (fixed-width) tooltip | ||
tooltip = QString("<nobr>") + tooltip + QString("</nobr>"); | ||
tooltip = QLatin1String("<nobr>") + tooltip + QLatin1String("<br>") + | ||
//: A substring of the tooltip. "More actions" are available via the context menu. | ||
tr("Click for more actions.") + QLatin1String("</nobr>"); | ||
connectionsControl->setToolTip(tooltip); | ||
|
||
connectionsControl->setPixmap(platformStyle->SingleColorIcon(icon).pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); | ||
|
@@ -936,6 +952,12 @@ void BitcoinGUI::setNumConnections(int count) | |
void BitcoinGUI::setNetworkActive(bool networkActive) | ||
{ | ||
updateNetworkState(); | ||
m_network_context_menu->actions().last()->setText( | ||
This comment has been minimized.
Sorry, something went wrong.
hebasto
Author
Owner
|
||
networkActive ? | ||
//: A context menu item. | ||
tr("Disable network activity") : | ||
//: A context menu item. The network activity was disabled previously. | ||
tr("Enable network activity")); | ||
} | ||
|
||
void BitcoinGUI::updateHeadersSyncProgressLabel() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bitcoin-core#309 (review)
But we should set the action text at the first time. However, it could be done the
addAction
above, but it will be a code duplication.