Skip to content

Commit

Permalink
qt: Add "All connections are via Tor" icon to the status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto committed Sep 11, 2020
1 parent 606c817 commit e61b120
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/qt/bitcoingui.cpp
Expand Up @@ -77,6 +77,7 @@ const std::string BitcoinGUI::DEFAULT_UIPLATFORM =
BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformStyle, const NetworkStyle *networkStyle, QWidget *parent) :
QMainWindow(parent),
m_node(node),
m_tor_icon{new GUIUtil::ClickableLabel()},
trayIconMenu{new QMenu()},
platformStyle(_platformStyle),
m_network_style(networkStyle)
Expand Down Expand Up @@ -160,6 +161,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
frameBlocksLayout->addWidget(labelWalletEncryptionIcon);
frameBlocksLayout->addWidget(labelWalletHDStatusIcon);
}
frameBlocksLayout->addWidget(m_tor_icon);
frameBlocksLayout->addWidget(labelProxyIcon);
frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(connectionsControl);
Expand Down Expand Up @@ -202,6 +204,9 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
connect(labelProxyIcon, &GUIUtil::ClickableLabel::clicked, [this] {
openOptionsDialogWithTab(OptionsDialog::TAB_NETWORK);
});
connect(m_tor_icon, &GUIUtil::ClickableLabel::clicked, [this] {
openOptionsDialogWithTab(OptionsDialog::TAB_NETWORK);
});

connect(labelBlocksIcon, &GUIUtil::ClickableLabel::clicked, this, &BitcoinGUI::showModalOverlay);
connect(progressBar, &GUIUtil::ClickableProgressBar::clicked, this, &BitcoinGUI::showModalOverlay);
Expand Down Expand Up @@ -893,7 +898,8 @@ void BitcoinGUI::gotoLoadPSBT(bool from_clipboard)

void BitcoinGUI::updateNetworkState()
{
int count = m_node.peerCount();
const ConnectionCounts conn_counts = m_node.connectionCounts();
const int count = conn_counts.all;
QString icon;
switch(count)
{
Expand All @@ -916,8 +922,15 @@ void BitcoinGUI::updateNetworkState()
// Don't word-wrap this (fixed-width) tooltip
tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
connectionsControl->setToolTip(tooltip);

connectionsControl->setPixmap(platformStyle->SingleColorIcon(icon).pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));

if (conn_counts.tor_only) {
m_tor_icon->setPixmap(platformStyle->SingleColorIcon(":/icons/tor_connected").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
m_tor_icon->setToolTip(tr("All connections are <b>via Tor</b> only"));
m_tor_icon->show();
} else {
m_tor_icon->hide();
}
}

void BitcoinGUI::updateHeadersSyncProgressLabel()
Expand Down
1 change: 1 addition & 0 deletions src/qt/bitcoingui.h
Expand Up @@ -121,6 +121,7 @@ class BitcoinGUI : public QMainWindow
UnitDisplayStatusBarControl* unitDisplayControl = nullptr;
QLabel* labelWalletEncryptionIcon = nullptr;
QLabel* labelWalletHDStatusIcon = nullptr;
GUIUtil::ClickableLabel* m_tor_icon{nullptr};
GUIUtil::ClickableLabel* labelProxyIcon = nullptr;
GUIUtil::ClickableLabel* connectionsControl = nullptr;
GUIUtil::ClickableLabel* labelBlocksIcon = nullptr;
Expand Down

0 comments on commit e61b120

Please sign in to comment.