From 73cd5b25b901e17d24bd2ebeb7fe334f6092d3d8 Mon Sep 17 00:00:00 2001 From: Cristian Mircea Messel Date: Mon, 2 Oct 2017 17:59:32 +0300 Subject: [PATCH] [gui] Add proxy icon in statusbar --- contrib/debian/copyright | 7 +++- src/Makefile.qt.include | 1 + src/qt/bitcoin.qrc | 1 + src/qt/bitcoingui.cpp | 24 +++++++++++++ src/qt/bitcoingui.h | 5 +++ src/qt/clientmodel.cpp | 11 ++++++ src/qt/clientmodel.h | 2 ++ src/qt/res/icons/proxy.png | Bin 0 -> 1278 bytes src/qt/res/src/proxy.svg | 70 +++++++++++++++++++++++++++++++++++++ 9 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 src/qt/res/icons/proxy.png create mode 100644 src/qt/res/src/proxy.svg diff --git a/contrib/debian/copyright b/contrib/debian/copyright index c6484157a..21cca7d9a 100644 --- a/contrib/debian/copyright +++ b/contrib/debian/copyright @@ -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 @@ -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 diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 38eb12ce0..a84a11ac4 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -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 \ diff --git a/src/qt/bitcoin.qrc b/src/qt/bitcoin.qrc index 451d39123..fddc2a568 100644 --- a/src/qt/bitcoin.qrc +++ b/src/qt/bitcoin.qrc @@ -53,6 +53,7 @@ res/icons/hd_enabled.png res/icons/hd_disabled.png res/icons/network_disabled.png + res/icons/proxy.png res/movies/spinner-000.png diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index aed5374a7..5511ca84e 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -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), @@ -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) @@ -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(); @@ -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) { @@ -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 enabled: %1").arg(ip_port_q)); + } else { + labelProxyIcon->show(); + } + } else { + labelProxyIcon->hide(); + } +} + void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden) { if(!clientModel) diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index e59c71cd4..8ce14f06c 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -92,6 +92,7 @@ private: UnitDisplayStatusBarControl *unitDisplayControl; QLabel *labelWalletEncryptionIcon; QLabel *labelWalletHDStatusIcon; + QLabel *labelProxyIcon; QLabel *connectionsControl; QLabel *labelBlocksIcon; QLabel *progressBarLabel; @@ -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 */ diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 37fd06ccc..a623771aa 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -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; +} diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h index a609222f7..9d4fa74b7 100644 --- a/src/qt/clientmodel.h +++ b/src/qt/clientmodel.h @@ -70,6 +70,8 @@ public: QString formatClientStartupTime() const; QString dataDir() const; + bool getProxyInfo(std::string& ip_port) const; + // caches for the best header mutable std::atomic cachedBestHeaderHeight; mutable std::atomic cachedBestHeaderTime; diff --git a/src/qt/res/icons/proxy.png b/src/qt/res/icons/proxy.png new file mode 100644 index 0000000000000000000000000000000000000000..67c552d0de594ab546ecde7c9bb0b825ca99c3c1 GIT binary patch literal 1278 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7uRSEX7WqAsj$Z!;#Vf2?p zUk71ECym(^Ktah8*NBqf{Irtt#G+J&^73-M%)IR4vqZS`kriE_MUM`JePtc>x4N>9)64}%NZsGGn~|Hcp~CZM4s@wJ^R>yn5UUB-?{%I zPv!^j4^a!|IZR@WuI2VOf9zvF+_uB|#u+ol`(G>$34P!!;IZJ6Df+HoJ!iQjtHIvK z2ka8o@7Dif>!ZuH;7sC!%JTZv?;UqtntZ^>y21SHn~s^eFRN$hi8z>VXOf?BGtW5s z_ICqS5r^{Z#`K2fv~3&TCoU3ku-(qse&)@kee9h945hh@&(6MCw2yt}HHG^eTvnWK zG$Yav96g|V!0mxlLU3#4HYR=M@1Z-^K0Efo=tFY({)LzR#_^tE+Rpr)>3R8%opay) z^XlCh6~v%@zCiVZ$_ERB-~wUwhSzug9$(cQy6icFcER`ecm8T7NPkE?=o`ak6I;IO zm&gIj9lz5L=pM*sJuPpznRlxDDlbN#gLls}@EcZgTO|GcwCi9HLvYde`;EIB);D{< z&ol5d`j@-v|LkXYpshB&%brcA=b?VBYBEQ{!lR*wHeHx}fc$)gH*-qA`pP)1 wAvRcU_l=?n8;#4~SF^pG=*LJ(M*huxZNZz1PVo<;fMpefr>mdKI;Vst0NN2ClK=n! literal 0 HcmV?d00001 diff --git a/src/qt/res/src/proxy.svg b/src/qt/res/src/proxy.svg new file mode 100644 index 000000000..b42fa6394 --- /dev/null +++ b/src/qt/res/src/proxy.svg @@ -0,0 +1,70 @@ + + + + + + + + + + image/svg+xml + + + + + + + P + +