コード例 #1
0
// 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))
{
    // Allow for separate UI settings for testnets
    QApplication::setApplicationName(appName);
    // Make sure settings migrated properly
    GUIUtil::migrateQtSettings();
    // Grab theme from settings
    QString theme = GUIUtil::getThemeName();
    // load pixmap
    QPixmap appIconPixmap(":/icons/bitcoin");
    QPixmap splashImagePixmap(":/images/" + theme + "/splash");

    if(iconColorHueShift != 0 && iconColorSaturationReduction != 0)
    {
        // generate QImage from QPixmap
        QImage appIconImg = appIconPixmap.toImage();
        QImage splashImageImg = splashImagePixmap.toImage();

        rotateColors(appIconImg, iconColorHueShift, iconColorSaturationReduction);
        rotateColors(splashImageImg, iconColorHueShift, iconColorSaturationReduction);

        //convert back to QPixmap
#if QT_VERSION >= 0x040700
        appIconPixmap.convertFromImage(appIconImg);
        splashImagePixmap.convertFromImage(splashImageImg);
#else
        appIconPixmap = QPixmap::fromImage(appIconImg);
        splashImagePixmap = QPixmap::fromImage(splashImageImg);
#endif
    }

    appIcon             = QIcon(appIconPixmap);
    trayAndWindowIcon   = QIcon(appIconPixmap.scaled(QSize(256,256)));
    splashImage         = splashImagePixmap;
}
コード例 #2
0
ファイル: networkstyle.cpp プロジェクト: GregoryBetz/syscoin2
// 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))
{
	// SYSCOIN
	QString theme = GUIUtil::getThemeName();
    // load pixmap
    QPixmap pixmap(":/icons/" + theme + "/syscoin");
	// SYSCOIN
	QPixmap splashImagePixmap(":/images/" + theme + "/splash");

    if(iconColorHueShift != 0 && iconColorSaturationReduction != 0)
    {
        // generate QImage from QPixmap
        QImage img = pixmap.toImage();
		QImage splashImageImg = splashImagePixmap.toImage();
        int h,s,l,a;

        // traverse though lines
        for(int y=0;y<img.height();y++)
        {
            QRgb *scL = reinterpret_cast< QRgb *>( img.scanLine( y ) );

            // loop through pixels
            for(int x=0;x<img.width();x++)
            {
                // preserve alpha because QColor::getHsl doesen't return the alpha value
                a = qAlpha(scL[x]);
                QColor col(scL[x]);

                // get hue value
                col.getHsl(&h,&s,&l);

                // rotate color on RGB color circle
                // 70° should end up with the typical "testnet" green
                h+=iconColorHueShift;

                // change saturation value
                if(s>iconColorSaturationReduction)
                {
                    s -= iconColorSaturationReduction;
                }
                col.setHsl(h,s,l,a);

                // set the pixel
                scL[x] = col.rgba();
            }
        }

        //convert back to QPixmap
#if QT_VERSION >= 0x040700
        pixmap.convertFromImage(img);
		splashImagePixmap.convertFromImage(splashImageImg);
#else
        pixmap = QPixmap::fromImage(img);
		splashImagePixmap = QPixmap::fromImage(splashImageImg);
#endif
    }

    appIcon             = QIcon(pixmap);
    trayAndWindowIcon   = QIcon(pixmap.scaled(QSize(256,256)));
	splashImage         = splashImagePixmap;
}