Skip to content

Commit bd8df33

Browse files
committed
qt: Add "All connections are via Tor" icon to the status bar
1 parent d8dc1f5 commit bd8df33

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/qt/bitcoingui.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ const std::string BitcoinGUI::DEFAULT_UIPLATFORM =
7777
BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformStyle, const NetworkStyle *networkStyle, QWidget *parent) :
7878
QMainWindow(parent),
7979
m_node(node),
80+
m_tor_icon{new GUIUtil::ClickableLabel()},
8081
trayIconMenu{new QMenu()},
8182
platformStyle(_platformStyle),
8283
m_network_style(networkStyle)
@@ -160,6 +161,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
160161
frameBlocksLayout->addWidget(labelWalletEncryptionIcon);
161162
frameBlocksLayout->addWidget(labelWalletHDStatusIcon);
162163
}
164+
frameBlocksLayout->addWidget(m_tor_icon);
163165
frameBlocksLayout->addWidget(labelProxyIcon);
164166
frameBlocksLayout->addStretch();
165167
frameBlocksLayout->addWidget(connectionsControl);
@@ -202,6 +204,9 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
202204
connect(labelProxyIcon, &GUIUtil::ClickableLabel::clicked, [this] {
203205
openOptionsDialogWithTab(OptionsDialog::TAB_NETWORK);
204206
});
207+
connect(m_tor_icon, &GUIUtil::ClickableLabel::clicked, [this] {
208+
openOptionsDialogWithTab(OptionsDialog::TAB_NETWORK);
209+
});
205210

206211
connect(labelBlocksIcon, &GUIUtil::ClickableLabel::clicked, this, &BitcoinGUI::showModalOverlay);
207212
connect(progressBar, &GUIUtil::ClickableProgressBar::clicked, this, &BitcoinGUI::showModalOverlay);
@@ -898,7 +903,8 @@ void BitcoinGUI::gotoLoadPSBT(bool from_clipboard)
898903

899904
void BitcoinGUI::updateNetworkState()
900905
{
901-
int count = m_node.peerCount();
906+
const ConnCounts conn_counts = m_node.connectionCounts();
907+
const int count = conn_counts.all;
902908
QString icon;
903909
switch(count)
904910
{
@@ -921,8 +927,15 @@ void BitcoinGUI::updateNetworkState()
921927
// Don't word-wrap this (fixed-width) tooltip
922928
tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
923929
connectionsControl->setToolTip(tooltip);
924-
925930
connectionsControl->setPixmap(platformStyle->SingleColorIcon(icon).pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
931+
932+
if (conn_counts.onion_only) {
933+
m_tor_icon->setPixmap(platformStyle->SingleColorIcon(":/icons/tor_connected").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
934+
m_tor_icon->setToolTip(tr("All connections are <b>via Tor</b> only"));
935+
m_tor_icon->show();
936+
} else {
937+
m_tor_icon->hide();
938+
}
926939
}
927940

928941
void BitcoinGUI::updateHeadersSyncProgressLabel()

src/qt/bitcoingui.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ class BitcoinGUI : public QMainWindow
122122
UnitDisplayStatusBarControl* unitDisplayControl = nullptr;
123123
QLabel* labelWalletEncryptionIcon = nullptr;
124124
QLabel* labelWalletHDStatusIcon = nullptr;
125+
GUIUtil::ClickableLabel* m_tor_icon{nullptr};
125126
GUIUtil::ClickableLabel* labelProxyIcon = nullptr;
126127
GUIUtil::ClickableLabel* connectionsControl = nullptr;
127128
GUIUtil::ClickableLabel* labelBlocksIcon = nullptr;

0 commit comments

Comments
 (0)