Skip to content

Commit 40c34a0

Browse files
committed
Merge #11491: [gui] Add proxy icon in statusbar
73cd5b2 [gui] Add proxy icon in statusbar (Cristian Mircea Messel) Pull request description: Relates to #7734 ![image](https://user-images.githubusercontent.com/226170/33406640-8ea700c6-d576-11e7-9d69-fde9a696c219.png) Please ignore the wrong alpha in the screenshot, I couldn't get the screenshot alpha right :( I plan to extend this feature in future PRs to include: - custom Tor icon - clickable icon which opens network settings Old proposals, dropped in favor of current ![image](https://user-images.githubusercontent.com/226170/32688635-979ef690-c6dd-11e7-8869-49da7e0f0a11.png) ![proxy_preview](https://user-images.githubusercontent.com/226170/31521305-99c43f22-afb1-11e7-9daf-d1ed6347daa8.png) ![image](https://user-images.githubusercontent.com/226170/31680585-72706098-b37d-11e7-88ad-028c4c723f42.png) Tree-SHA512: e5f18c20c0be292256a3e78c91cdf390a3b6084346a192a8170460f706f5b6cd198ba5b0035798a85a442fe7f262cf1c2350064670085ff8f473f880ab5ba589
2 parents 13da289 + 73cd5b2 commit 40c34a0

File tree

9 files changed

+120
-1
lines changed

9 files changed

+120
-1
lines changed

contrib/debian/copyright

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ Comment:
7676

7777
Files: src/qt/res/icons/clock*.png
7878
src/qt/res/icons/eye_*.png
79-
src/qt/res/icons/verify.png
8079
src/qt/res/icons/tx_in*.png
80+
src/qt/res/icons/verify.png
8181
src/qt/res/src/clock_*.svg
8282
src/qt/res/src/tx_*.svg
8383
src/qt/res/src/verify.svg
@@ -93,6 +93,11 @@ Copyright: Bitboy, Jonas Schnelli
9393
License: public-domain
9494
Comment: Site: https://bitcointalk.org/?topic=1756.0
9595

96+
Files: src/qt/res/icons/proxy.png
97+
src/qt/res/src/proxy.svg
98+
Copyright: Cristian Mircea Messel
99+
Licese: public-domain
100+
96101

97102
License: Expat
98103
Permission is hereby granted, free of charge, to any person obtaining a

src/Makefile.qt.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ RES_ICONS = \
278278
qt/res/icons/network_disabled.png \
279279
qt/res/icons/open.png \
280280
qt/res/icons/overview.png \
281+
qt/res/icons/proxy.png \
281282
qt/res/icons/quit.png \
282283
qt/res/icons/receive.png \
283284
qt/res/icons/remove.png \

src/qt/bitcoin.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
<file alias="hd_enabled">res/icons/hd_enabled.png</file>
5454
<file alias="hd_disabled">res/icons/hd_disabled.png</file>
5555
<file alias="network_disabled">res/icons/network_disabled.png</file>
56+
<file alias="proxy">res/icons/proxy.png</file>
5657
</qresource>
5758
<qresource prefix="/movies">
5859
<file alias="spinner-000">res/movies/spinner-000.png</file>

src/qt/bitcoingui.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
8383
unitDisplayControl(0),
8484
labelWalletEncryptionIcon(0),
8585
labelWalletHDStatusIcon(0),
86+
labelProxyIcon(0),
8687
connectionsControl(0),
8788
labelBlocksIcon(0),
8889
progressBarLabel(0),
@@ -201,6 +202,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
201202
unitDisplayControl = new UnitDisplayStatusBarControl(platformStyle);
202203
labelWalletEncryptionIcon = new QLabel();
203204
labelWalletHDStatusIcon = new QLabel();
205+
labelProxyIcon = new QLabel();
204206
connectionsControl = new GUIUtil::ClickableLabel();
205207
labelBlocksIcon = new GUIUtil::ClickableLabel();
206208
if(enableWallet)
@@ -211,6 +213,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
211213
frameBlocksLayout->addWidget(labelWalletEncryptionIcon);
212214
frameBlocksLayout->addWidget(labelWalletHDStatusIcon);
213215
}
216+
frameBlocksLayout->addWidget(labelProxyIcon);
214217
frameBlocksLayout->addStretch();
215218
frameBlocksLayout->addWidget(connectionsControl);
216219
frameBlocksLayout->addStretch();
@@ -503,6 +506,9 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel)
503506
connect(_clientModel, SIGNAL(showProgress(QString,int)), this, SLOT(showProgress(QString,int)));
504507

505508
rpcConsole->setClientModel(_clientModel);
509+
510+
updateProxyIcon();
511+
506512
#ifdef ENABLE_WALLET
507513
if(walletFrame)
508514
{
@@ -1125,6 +1131,24 @@ void BitcoinGUI::updateWalletStatus()
11251131
}
11261132
#endif // ENABLE_WALLET
11271133

1134+
void BitcoinGUI::updateProxyIcon()
1135+
{
1136+
std::string ip_port;
1137+
bool proxy_enabled = clientModel->getProxyInfo(ip_port);
1138+
1139+
if (proxy_enabled) {
1140+
if (labelProxyIcon->pixmap() == 0) {
1141+
QString ip_port_q = QString::fromStdString(ip_port);
1142+
labelProxyIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/proxy").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
1143+
labelProxyIcon->setToolTip(tr("Proxy is <b>enabled</b>: %1").arg(ip_port_q));
1144+
} else {
1145+
labelProxyIcon->show();
1146+
}
1147+
} else {
1148+
labelProxyIcon->hide();
1149+
}
1150+
}
1151+
11281152
void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden)
11291153
{
11301154
if(!clientModel)

src/qt/bitcoingui.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class BitcoinGUI : public QMainWindow
9292
UnitDisplayStatusBarControl *unitDisplayControl;
9393
QLabel *labelWalletEncryptionIcon;
9494
QLabel *labelWalletHDStatusIcon;
95+
QLabel *labelProxyIcon;
9596
QLabel *connectionsControl;
9697
QLabel *labelBlocksIcon;
9798
QLabel *progressBarLabel;
@@ -209,6 +210,10 @@ public Q_SLOTS:
209210
void incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label, const QString& walletName);
210211
#endif // ENABLE_WALLET
211212

213+
private:
214+
/** Set the proxy-enabled icon as shown in the UI. */
215+
void updateProxyIcon();
216+
212217
private Q_SLOTS:
213218
#ifdef ENABLE_WALLET
214219
/** Switch to overview (home) page */

src/qt/clientmodel.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <interfaces/node.h>
1818
#include <validation.h>
1919
#include <net.h>
20+
#include <netbase.h>
2021
#include <txmempool.h>
2122
#include <ui_interface.h>
2223
#include <util.h>
@@ -268,3 +269,13 @@ void ClientModel::unsubscribeFromCoreSignals()
268269
m_handler_notify_block_tip->disconnect();
269270
m_handler_notify_header_tip->disconnect();
270271
}
272+
273+
bool ClientModel::getProxyInfo(std::string& ip_port) const
274+
{
275+
proxyType ipv4, ipv6;
276+
if (m_node.getProxy((Network) 1, ipv4) && m_node.getProxy((Network) 2, ipv6)) {
277+
ip_port = ipv4.proxy.ToStringIPPort();
278+
return true;
279+
}
280+
return false;
281+
}

src/qt/clientmodel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class ClientModel : public QObject
7070
QString formatClientStartupTime() const;
7171
QString dataDir() const;
7272

73+
bool getProxyInfo(std::string& ip_port) const;
74+
7375
// caches for the best header
7476
mutable std::atomic<int> cachedBestHeaderHeight;
7577
mutable std::atomic<int64_t> cachedBestHeaderTime;

src/qt/res/icons/proxy.png

1.25 KB
Loading

src/qt/res/src/proxy.svg

Lines changed: 70 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)