mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
Merge bitcoin-core/gui#309: Add access to the Peers tab from the network icon
d29ea72393ac1d9b32a6976062e9c9fb75876295 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-ACK d29ea72393ac1d9b32a6976062e9c9fb75876295 kristapsk: re-ACK d29ea72393ac1d9b32a6976062e9c9fb75876295 promag: Code review ACK d29ea72393ac1d9b32a6976062e9c9fb75876295. Tree-SHA512: dd871415fe514a19c6a22100d58f31954d9e55b80585d5a3f26e17a8d51dadf912441786fc0d23beabd812f1b501658fec1dbe345cd41beae5832a8eda890f77
This commit is contained in:
parent
c858325d40
commit
69a1305978
@ -47,6 +47,7 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QButtonGroup>
|
#include <QButtonGroup>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
#include <QCursor>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDragEnterEvent>
|
#include <QDragEnterEvent>
|
||||||
#include <QKeySequence>
|
#include <QKeySequence>
|
||||||
@ -211,8 +212,6 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const NetworkStyle* networkStyle,
|
|||||||
// Subscribe to notifications from core
|
// Subscribe to notifications from core
|
||||||
subscribeToCoreSignals();
|
subscribeToCoreSignals();
|
||||||
|
|
||||||
// Jump to peers tab by clicking on connections icon
|
|
||||||
connect(labelConnectionsIcon, &GUIUtil::ClickableLabel::clicked, this, &BitcoinGUI::showPeers);
|
|
||||||
connect(labelProxyIcon, &GUIUtil::ClickableLabel::clicked, [this] {
|
connect(labelProxyIcon, &GUIUtil::ClickableLabel::clicked, [this] {
|
||||||
openOptionsDialogWithTab(OptionsDialog::TAB_NETWORK);
|
openOptionsDialogWithTab(OptionsDialog::TAB_NETWORK);
|
||||||
});
|
});
|
||||||
@ -812,8 +811,11 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Keep up to date with client
|
// Keep up to date with client
|
||||||
updateNetworkState();
|
setNetworkActive(m_node.getNetworkActive());
|
||||||
setNumConnections(_clientModel->getNumConnections());
|
setNumConnections(_clientModel->getNumConnections());
|
||||||
|
connect(labelConnectionsIcon, &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);
|
||||||
|
|
||||||
@ -1270,14 +1272,21 @@ void BitcoinGUI::updateNetworkState()
|
|||||||
nCountPrev = count;
|
nCountPrev = count;
|
||||||
fNetworkActivePrev = fNetworkActive;
|
fNetworkActivePrev = fNetworkActive;
|
||||||
|
|
||||||
|
QString tooltip;
|
||||||
if (fNetworkActive) {
|
if (fNetworkActive) {
|
||||||
labelConnectionsIcon->setToolTip(tr("%n active connection(s) to Dash network", "", count));
|
//: A substring of the tooltip.
|
||||||
|
tooltip = tr("%n active connection(s) to Dash network", "", count);
|
||||||
} else {
|
} else {
|
||||||
labelConnectionsIcon->setToolTip(tr("Network activity disabled"));
|
tooltip = tr("Network activity disabled");
|
||||||
icon = "connect_4";
|
icon = "connect_4";
|
||||||
color = GUIUtil::ThemedColor::RED;
|
color = GUIUtil::ThemedColor::RED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't word-wrap this (fixed-width) tooltip
|
||||||
|
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>");
|
||||||
|
|
||||||
if (fNetworkActive && count == 0) {
|
if (fNetworkActive && count == 0) {
|
||||||
startConnectingAnimation();
|
startConnectingAnimation();
|
||||||
}
|
}
|
||||||
@ -1285,6 +1294,7 @@ void BitcoinGUI::updateNetworkState()
|
|||||||
stopConnectingAnimation();
|
stopConnectingAnimation();
|
||||||
labelConnectionsIcon->setPixmap(GUIUtil::getIcon(icon, color).pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
|
labelConnectionsIcon->setPixmap(GUIUtil::getIcon(icon, color).pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
|
||||||
}
|
}
|
||||||
|
labelConnectionsIcon->setToolTip(tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinGUI::setNumConnections(int count)
|
void BitcoinGUI::setNumConnections(int count)
|
||||||
@ -1292,9 +1302,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()
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
#include <QMenu>
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
@ -51,7 +52,6 @@ class QAction;
|
|||||||
class QButtonGroup;
|
class QButtonGroup;
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
class QDateTime;
|
class QDateTime;
|
||||||
class QMenu;
|
|
||||||
class QProgressBar;
|
class QProgressBar;
|
||||||
class QProgressDialog;
|
class QProgressDialog;
|
||||||
class QToolButton;
|
class QToolButton;
|
||||||
@ -190,6 +190,8 @@ private:
|
|||||||
ModalOverlay* modalOverlay = nullptr;
|
ModalOverlay* modalOverlay = nullptr;
|
||||||
QButtonGroup* tabGroup = nullptr;
|
QButtonGroup* tabGroup = 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
|
||||||
@ -264,7 +266,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);
|
||||||
/** Get restart command-line parameters and request restart */
|
/** Get restart command-line parameters and request restart */
|
||||||
void handleRestart(QStringList args);
|
void handleRestart(QStringList args);
|
||||||
/** Set number of blocks and last block date shown in the UI */
|
/** Set number of blocks and last block date shown in the UI */
|
||||||
|
Loading…
Reference in New Issue
Block a user