titleAddText needs to be const char* for tr()
| 23 | |
| 24 | // titleAddText needs to be const char* for tr() |
| 25 | NetworkStyle::NetworkStyle(const QString &_appName, const int iconColorHueShift, const int iconColorSaturationReduction, const char *_titleAddText): |
| 26 | appName(_appName), |
| 27 | titleAddText(qApp->translate("SplashScreen", _titleAddText)) |
| 28 | { |
| 29 | // load pixmap |
| 30 | QPixmap pixmap(":/icons/bitcoin"); |
| 31 | |
| 32 | if(iconColorHueShift != 0 && iconColorSaturationReduction != 0) |
| 33 | { |
| 34 | // generate QImage from QPixmap |
| 35 | QImage img = pixmap.toImage(); |
| 36 | |
| 37 | int h,s,l,a; |
| 38 | |
| 39 | // traverse though lines |
| 40 | for(int y=0;y<img.height();y++) |
| 41 | { |
| 42 | QRgb *scL = reinterpret_cast< QRgb *>( img.scanLine( y ) ); |
| 43 | |
| 44 | // loop through pixels |
| 45 | for(int x=0;x<img.width();x++) |
| 46 | { |
| 47 | // preserve alpha because QColor::getHsl doesn't return the alpha value |
| 48 | a = qAlpha(scL[x]); |
| 49 | QColor col(scL[x]); |
| 50 | |
| 51 | // get hue value |
| 52 | col.getHsl(&h,&s,&l); |
| 53 | |
| 54 | // rotate color on RGB color circle |
| 55 | // 70° should end up with the typical "testnet" green |
| 56 | h+=iconColorHueShift; |
| 57 | |
| 58 | // change saturation value |
| 59 | if(s>iconColorSaturationReduction) |
| 60 | { |
| 61 | s -= iconColorSaturationReduction; |
| 62 | } |
| 63 | col.setHsl(h,s,l,a); |
| 64 | |
| 65 | // set the pixel |
| 66 | scL[x] = col.rgba(); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | //convert back to QPixmap |
| 71 | pixmap.convertFromImage(img); |
| 72 | } |
| 73 | |
| 74 | appIcon = QIcon(pixmap); |
| 75 | trayAndWindowIcon = QIcon(pixmap.scaled(QSize(256,256))); |
| 76 | } |
| 77 | |
| 78 | const NetworkStyle *NetworkStyle::instantiate(const QString &networkId) |
| 79 | { |