Skip to content

Commit

Permalink
Merge pull request #2 from uhlik-mdfkbtc-veles-development/0.18
Browse files Browse the repository at this point in the history
add check for theme availability
  • Loading branch information
mdfkbtc committed Jul 8, 2019
2 parents adcfe0f + d312c8f commit 06986f2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
18 changes: 12 additions & 6 deletions src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ QString getThemeName()
if(!theme.isEmpty()){
return theme;
}
return QString("Veles");
return QString("velesTheme");
}

// Open CSS when configured
Expand All @@ -851,25 +851,30 @@ QString loadStyleSheet()
QString styleSheet;
QSettings settings;
QString cssName;
QString theme = settings.value("theme", "").toString();
QString theme = getThemeName();
QString customCssPath = QString::fromStdString(gArgs.GetArg("-loadcss", ""));
QString dumpCssPath = QString::fromStdString(gArgs.GetArg("-dumpcss", ""));

if(customCssPath != "") {
cssName = customCssPath; // load custom CSS for dev / testing purposes

} if(!theme.isEmpty()){
} else {
cssName = QString(":/css/") + theme; // custom style from settings
}

} else {
cssName = QString(":/css/velesTheme"); // default style
// check if theme available
QFile qFileCheck(cssName);
if (!qFileCheck.open(QFile::ReadOnly)) {
cssName = QString(":/css/velesTheme"); // default style if theme not available
settings.setValue("theme", "velesTheme");
} else {
qFileCheck.close();
}

// load the css
QFile qFile(cssName);
if (qFile.open(QFile::ReadOnly)) {
styleSheet = QLatin1String(qFile.readAll());
qFile.close();
}

// dump the css if rewuired
Expand All @@ -878,6 +883,7 @@ QString loadStyleSheet()
if (outFile.open(QFile::WriteOnly | QFile::Truncate)) {
QTextStream out(&outFile);
out << styleSheet;
outFile.close();
}
}

Expand Down
19 changes: 15 additions & 4 deletions src/qt/splashscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,27 @@ SplashScreen::SplashScreen(interfaces::Node& node, Qt::WindowFlags f, const Netw
QString versionText = QString::fromStdString(FormatFullVersion()).split("-").value(0) + " \"" + CLIENT_VERSION_CODENAME + "\"";
//QString splashScreenPath = ":/images/splash";
// networkstyle.cpp can't (yet) read themes, so we do it here to get the correct Splash-screen
QString splashScreenPath = ":/images/" + GUIUtil::getThemeName() + "/splash";
QString theme = GUIUtil::getThemeName();
// check if theme available
QString cssName;
cssName = QString(":/css/") + theme;
QFile qFileCheck(cssName);
if (!qFileCheck.open(QFile::ReadOnly)) {
theme = "velesTheme"; // default theme if not available
} else {
qFileCheck.close();
}

QString splashScreenPath = ":/images/" + theme + "/splash";

if (!CLIENT_VERSION_IS_RELEASE)
splashScreenPath = ":/images/" + GUIUtil::getThemeName() + "/splash_prerelease";
splashScreenPath = ":/images/" + theme + "/splash_prerelease";
//splashScreenPath = ":/images/splash_prerelease";
if(gArgs.GetBoolArg("-regtest", false))
splashScreenPath = ":/images/" + GUIUtil::getThemeName() + "/splash_testnet";
splashScreenPath = ":/images/" + theme + "/splash_testnet";
//splashScreenPath = ":/images/splash_testnet";
if(gArgs.GetBoolArg("-testnet", false))
splashScreenPath = ":/images/" + GUIUtil::getThemeName() + "/splash_testnet";
splashScreenPath = ":/images/" + theme + "/splash_testnet";
//splashScreenPath = ":/images/splash_testnet";

// replace for copyright sign
Expand Down

0 comments on commit 06986f2

Please sign in to comment.