MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / NetworkStyle

Method NetworkStyle

src/qt/networkstyle.cpp:25–76  ·  view source on GitHub ↗

titleAddText needs to be const char* for tr()

Source from the content-addressed store, hash-verified

23
24// titleAddText needs to be const char* for tr()
25NetworkStyle::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
78const NetworkStyle *NetworkStyle::instantiate(const QString &networkId)
79{

Callers

nothing calls this directly

Calls 1

heightMethod · 0.80

Tested by

no test coverage detected