Skip to content

Commit

Permalink
[gui] Add proxy icon in statusbar
Browse files Browse the repository at this point in the history
  • Loading branch information
mess110 committed May 15, 2018
1 parent 13da289 commit 73cd5b2
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 1 deletion.
7 changes: 6 additions & 1 deletion contrib/debian/copyright
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ Comment:

Files: src/qt/res/icons/clock*.png
src/qt/res/icons/eye_*.png
src/qt/res/icons/verify.png
src/qt/res/icons/tx_in*.png
src/qt/res/icons/verify.png
src/qt/res/src/clock_*.svg
src/qt/res/src/tx_*.svg
src/qt/res/src/verify.svg
Expand All @@ -93,6 +93,11 @@ Copyright: Bitboy, Jonas Schnelli
License: public-domain
Comment: Site: https://bitcointalk.org/?topic=1756.0

Files: src/qt/res/icons/proxy.png
src/qt/res/src/proxy.svg
Copyright: Cristian Mircea Messel
Licese: public-domain


License: Expat
Permission is hereby granted, free of charge, to any person obtaining a
Expand Down
1 change: 1 addition & 0 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ RES_ICONS = \
qt/res/icons/network_disabled.png \
qt/res/icons/open.png \
qt/res/icons/overview.png \
qt/res/icons/proxy.png \
qt/res/icons/quit.png \
qt/res/icons/receive.png \
qt/res/icons/remove.png \
Expand Down
1 change: 1 addition & 0 deletions src/qt/bitcoin.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<file alias="hd_enabled">res/icons/hd_enabled.png</file>
<file alias="hd_disabled">res/icons/hd_disabled.png</file>
<file alias="network_disabled">res/icons/network_disabled.png</file>
<file alias="proxy">res/icons/proxy.png</file>
</qresource>
<qresource prefix="/movies">
<file alias="spinner-000">res/movies/spinner-000.png</file>
Expand Down
24 changes: 24 additions & 0 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
unitDisplayControl(0),
labelWalletEncryptionIcon(0),
labelWalletHDStatusIcon(0),
labelProxyIcon(0),
connectionsControl(0),
labelBlocksIcon(0),
progressBarLabel(0),
Expand Down Expand Up @@ -201,6 +202,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
unitDisplayControl = new UnitDisplayStatusBarControl(platformStyle);
labelWalletEncryptionIcon = new QLabel();
labelWalletHDStatusIcon = new QLabel();
labelProxyIcon = new QLabel();
connectionsControl = new GUIUtil::ClickableLabel();
labelBlocksIcon = new GUIUtil::ClickableLabel();
if(enableWallet)
Expand All @@ -211,6 +213,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
frameBlocksLayout->addWidget(labelWalletEncryptionIcon);
frameBlocksLayout->addWidget(labelWalletHDStatusIcon);
}
frameBlocksLayout->addWidget(labelProxyIcon);
frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(connectionsControl);
frameBlocksLayout->addStretch();
Expand Down Expand Up @@ -503,6 +506,9 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel)
connect(_clientModel, SIGNAL(showProgress(QString,int)), this, SLOT(showProgress(QString,int)));

rpcConsole->setClientModel(_clientModel);

updateProxyIcon();

#ifdef ENABLE_WALLET
if(walletFrame)
{
Expand Down Expand Up @@ -1125,6 +1131,24 @@ void BitcoinGUI::updateWalletStatus()
}
#endif // ENABLE_WALLET

void BitcoinGUI::updateProxyIcon()
{
std::string ip_port;
bool proxy_enabled = clientModel->getProxyInfo(ip_port);

if (proxy_enabled) {
if (labelProxyIcon->pixmap() == 0) {
QString ip_port_q = QString::fromStdString(ip_port);
labelProxyIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/proxy").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
labelProxyIcon->setToolTip(tr("Proxy is <b>enabled</b>: %1").arg(ip_port_q));
} else {
labelProxyIcon->show();
}
} else {
labelProxyIcon->hide();
}
}

void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden)
{
if(!clientModel)
Expand Down
5 changes: 5 additions & 0 deletions src/qt/bitcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class BitcoinGUI : public QMainWindow
UnitDisplayStatusBarControl *unitDisplayControl;
QLabel *labelWalletEncryptionIcon;
QLabel *labelWalletHDStatusIcon;
QLabel *labelProxyIcon;
QLabel *connectionsControl;
QLabel *labelBlocksIcon;
QLabel *progressBarLabel;
Expand Down Expand Up @@ -209,6 +210,10 @@ public Q_SLOTS:
void incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label, const QString& walletName);
#endif // ENABLE_WALLET

private:
/** Set the proxy-enabled icon as shown in the UI. */
void updateProxyIcon();

private Q_SLOTS:
#ifdef ENABLE_WALLET
/** Switch to overview (home) page */
Expand Down
11 changes: 11 additions & 0 deletions src/qt/clientmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <interfaces/node.h>
#include <validation.h>
#include <net.h>
#include <netbase.h>
#include <txmempool.h>
#include <ui_interface.h>
#include <util.h>
Expand Down Expand Up @@ -268,3 +269,13 @@ void ClientModel::unsubscribeFromCoreSignals()
m_handler_notify_block_tip->disconnect();
m_handler_notify_header_tip->disconnect();
}

bool ClientModel::getProxyInfo(std::string& ip_port) const
{
proxyType ipv4, ipv6;
if (m_node.getProxy((Network) 1, ipv4) && m_node.getProxy((Network) 2, ipv6)) {
ip_port = ipv4.proxy.ToStringIPPort();
return true;
}
return false;
}
2 changes: 2 additions & 0 deletions src/qt/clientmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class ClientModel : public QObject
QString formatClientStartupTime() const;
QString dataDir() const;

bool getProxyInfo(std::string& ip_port) const;

// caches for the best header
mutable std::atomic<int> cachedBestHeaderHeight;
mutable std::atomic<int64_t> cachedBestHeaderTime;
Expand Down
Binary file added src/qt/res/icons/proxy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions src/qt/res/src/proxy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 73cd5b2

Please sign in to comment.