diff --git a/src/qt/networkstyle.cpp b/src/qt/networkstyle.cpp index 93092501c..dbc6cc839 100644 --- a/src/qt/networkstyle.cpp +++ b/src/qt/networkstyle.cpp @@ -1,96 +1,90 @@ // Copyright (c) 2014-2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "networkstyle.h" #include "guiconstants.h" #include static const struct { const char *networkId; const char *appName; const int iconColorHueShift; const int iconColorSaturationReduction; const char *titleAddText; -} network_styles[] = { - {"main", QAPP_APP_NAME_DEFAULT, 0, 0, ""}, - {"test", QAPP_APP_NAME_TESTNET, 70, 30, QT_TRANSLATE_NOOP("SplashScreen", "[testnet]")}, - {"regtest", QAPP_APP_NAME_TESTNET, 160, 30, "[regtest]"} -}; -static const unsigned network_styles_count = sizeof(network_styles)/sizeof(*network_styles); +} network_styles[] = {{"main", QAPP_APP_NAME_DEFAULT, 0, 0, ""}, + {"test", QAPP_APP_NAME_TESTNET, 70, 30, + QT_TRANSLATE_NOOP("SplashScreen", "[testnet]")}, + {"regtest", QAPP_APP_NAME_TESTNET, 160, 30, "[regtest]"}}; +static const unsigned network_styles_count = + sizeof(network_styles) / sizeof(*network_styles); // titleAddText needs to be const char* for tr() -NetworkStyle::NetworkStyle(const QString &_appName, const int iconColorHueShift, const int iconColorSaturationReduction, const char *_titleAddText): - appName(_appName), - titleAddText(qApp->translate("SplashScreen", _titleAddText)) -{ +NetworkStyle::NetworkStyle(const QString &_appName, const int iconColorHueShift, + const int iconColorSaturationReduction, + const char *_titleAddText) + : appName(_appName), + titleAddText(qApp->translate("SplashScreen", _titleAddText)) { // load pixmap QPixmap pixmap(":/icons/bitcoin"); - if(iconColorHueShift != 0 && iconColorSaturationReduction != 0) - { + if (iconColorHueShift != 0 && iconColorSaturationReduction != 0) { // generate QImage from QPixmap QImage img = pixmap.toImage(); - int h,s,l,a; + int h, s, l, a; // traverse though lines - for(int y=0;y( img.scanLine( y ) ); + for (int y = 0; y < img.height(); y++) { + QRgb *scL = reinterpret_cast(img.scanLine(y)); // loop through pixels - for(int x=0;xiconColorSaturationReduction) - { + if (s > iconColorSaturationReduction) { s -= iconColorSaturationReduction; } - col.setHsl(h,s,l,a); + col.setHsl(h, s, l, a); // set the pixel scL[x] = col.rgba(); } } - //convert back to QPixmap +// convert back to QPixmap #if QT_VERSION >= 0x040700 pixmap.convertFromImage(img); #else pixmap = QPixmap::fromImage(img); #endif } - appIcon = QIcon(pixmap); - trayAndWindowIcon = QIcon(pixmap.scaled(QSize(256,256))); + appIcon = QIcon(pixmap); + trayAndWindowIcon = QIcon(pixmap.scaled(QSize(256, 256))); } -const NetworkStyle *NetworkStyle::instantiate(const QString &networkId) -{ - for (unsigned x=0; x #include #include /* Coin network-specific GUI style information */ -class NetworkStyle -{ +class NetworkStyle { public: - /** Get style associated with provided BIP70 network id, or 0 if not known */ + /** Get style associated with provided BIP70 network id, or 0 if not known + */ static const NetworkStyle *instantiate(const QString &networkId); const QString &getAppName() const { return appName; } const QIcon &getAppIcon() const { return appIcon; } const QIcon &getTrayAndWindowIcon() const { return trayAndWindowIcon; } const QString &getTitleAddText() const { return titleAddText; } private: - NetworkStyle(const QString &appName, const int iconColorHueShift, const int iconColorSaturationReduction, const char *titleAddText); + NetworkStyle(const QString &appName, const int iconColorHueShift, + const int iconColorSaturationReduction, + const char *titleAddText); QString appName; QIcon appIcon; QIcon trayAndWindowIcon; QString titleAddText; }; #endif // BITCOIN_QT_NETWORKSTYLE_H