mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 18:53:23 -03:00
Merge bitcoin-core/gui#309: Add access to the Peers tab from the network icon
d29ea72393
gui: Add access to the Peers tab from the network icon (Hennadii Stepanov) Pull request description: This PR add a small context menu to the network activity icon that provides an access to the Peers tab: ![gui-network-icon](https://user-images.githubusercontent.com/32963518/116794314-d64b9b80-aad4-11eb-89ca-7f75c7442ba8.gif) Closes #93. ACKs for top commit: Sjors: re-ACKd29ea72393
kristapsk: re-ACKd29ea72393
promag: Code review ACKd29ea72393
. Tree-SHA512: dd871415fe514a19c6a22100d58f31954d9e55b80585d5a3f26e17a8d51dadf912441786fc0d23beabd812f1b501658fec1dbe345cd41beae5832a8eda890f77
This commit is contained in:
commit
11225905b7
2 changed files with 32 additions and 10 deletions
|
@ -43,6 +43,7 @@
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
#include <QCursor>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDragEnterEvent>
|
#include <QDragEnterEvent>
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
|
@ -199,9 +200,6 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
|
||||||
// Subscribe to notifications from core
|
// Subscribe to notifications from core
|
||||||
subscribeToCoreSignals();
|
subscribeToCoreSignals();
|
||||||
|
|
||||||
connect(connectionsControl, &GUIUtil::ClickableLabel::clicked, [this] {
|
|
||||||
m_node.setNetworkActive(!m_node.getNetworkActive());
|
|
||||||
});
|
|
||||||
connect(labelProxyIcon, &GUIUtil::ClickableLabel::clicked, [this] {
|
connect(labelProxyIcon, &GUIUtil::ClickableLabel::clicked, [this] {
|
||||||
openOptionsDialogWithTab(OptionsDialog::TAB_NETWORK);
|
openOptionsDialogWithTab(OptionsDialog::TAB_NETWORK);
|
||||||
});
|
});
|
||||||
|
@ -586,7 +584,10 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH
|
||||||
createTrayIconMenu();
|
createTrayIconMenu();
|
||||||
|
|
||||||
// Keep up to date with client
|
// Keep up to date with client
|
||||||
updateNetworkState();
|
setNetworkActive(m_node.getNetworkActive());
|
||||||
|
connect(connectionsControl, &GUIUtil::ClickableLabel::clicked, [this] {
|
||||||
|
GUIUtil::PopupMenu(m_network_context_menu, QCursor::pos());
|
||||||
|
});
|
||||||
connect(_clientModel, &ClientModel::numConnectionsChanged, this, &BitcoinGUI::setNumConnections);
|
connect(_clientModel, &ClientModel::numConnectionsChanged, this, &BitcoinGUI::setNumConnections);
|
||||||
connect(_clientModel, &ClientModel::networkActiveChanged, this, &BitcoinGUI::setNetworkActive);
|
connect(_clientModel, &ClientModel::networkActiveChanged, this, &BitcoinGUI::setNetworkActive);
|
||||||
|
|
||||||
|
@ -915,14 +916,18 @@ void BitcoinGUI::updateNetworkState()
|
||||||
QString tooltip;
|
QString tooltip;
|
||||||
|
|
||||||
if (m_node.getNetworkActive()) {
|
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 {
|
} 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";
|
icon = ":/icons/network_disabled";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't word-wrap this (fixed-width) tooltip
|
// 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->setToolTip(tooltip);
|
||||||
|
|
||||||
connectionsControl->setThemedPixmap(icon, STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);
|
connectionsControl->setThemedPixmap(icon, STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);
|
||||||
|
@ -933,9 +938,24 @@ void BitcoinGUI::setNumConnections(int count)
|
||||||
updateNetworkState();
|
updateNetworkState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinGUI::setNetworkActive(bool networkActive)
|
void BitcoinGUI::setNetworkActive(bool network_active)
|
||||||
{
|
{
|
||||||
updateNetworkState();
|
updateNetworkState();
|
||||||
|
m_network_context_menu->clear();
|
||||||
|
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(
|
||||||
|
network_active ?
|
||||||
|
//: A context menu item.
|
||||||
|
tr("Disable network activity") :
|
||||||
|
//: A context menu item. The network activity was disabled previously.
|
||||||
|
tr("Enable network activity"),
|
||||||
|
[this, new_state = !network_active] { m_node.setNetworkActive(new_state); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinGUI::updateHeadersSyncProgressLabel()
|
void BitcoinGUI::updateHeadersSyncProgressLabel()
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
#include <QMenu>
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
|
|
||||||
|
@ -51,7 +52,6 @@ QT_BEGIN_NAMESPACE
|
||||||
class QAction;
|
class QAction;
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
class QDateTime;
|
class QDateTime;
|
||||||
class QMenu;
|
|
||||||
class QProgressBar;
|
class QProgressBar;
|
||||||
class QProgressDialog;
|
class QProgressDialog;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -175,6 +175,8 @@ private:
|
||||||
HelpMessageDialog* helpMessageDialog = nullptr;
|
HelpMessageDialog* helpMessageDialog = nullptr;
|
||||||
ModalOverlay* modalOverlay = nullptr;
|
ModalOverlay* modalOverlay = nullptr;
|
||||||
|
|
||||||
|
QMenu* m_network_context_menu = new QMenu(this);
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
CAppNapInhibitor* m_app_nap_inhibitor = nullptr;
|
CAppNapInhibitor* m_app_nap_inhibitor = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
@ -222,7 +224,7 @@ public Q_SLOTS:
|
||||||
/** Set number of connections shown in the UI */
|
/** Set number of connections shown in the UI */
|
||||||
void setNumConnections(int count);
|
void setNumConnections(int count);
|
||||||
/** Set network state shown in the UI */
|
/** Set network state shown in the UI */
|
||||||
void setNetworkActive(bool networkActive);
|
void setNetworkActive(bool network_active);
|
||||||
/** Set number of blocks and last block date shown in the UI */
|
/** Set number of blocks and last block date shown in the UI */
|
||||||
void setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool headers, SynchronizationState sync_state);
|
void setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool headers, SynchronizationState sync_state);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue