mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
Only load valid themes, fallback to "Light" theme otherwise (#3285)
* Only load valid themes, fallback to "light" otherwise * Refactor PR3285 a bit * fix Co-authored-by: Nathan Marley <nathan.marley@gmail.com>
This commit is contained in:
parent
617c588488
commit
1c885bbedf
@ -54,10 +54,12 @@
|
||||
<file alias="network_disabled">res/icons/network_disabled.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/css">
|
||||
<file alias="dark">res/css/dark.css</file>
|
||||
<file alias="light">res/css/light.css</file>
|
||||
<file alias="scrollbars">res/css/scrollbars.css</file>
|
||||
<file alias="trad">res/css/trad.css</file>
|
||||
</qresource>
|
||||
<qresource prefix="/themes">
|
||||
<file alias="Dark">res/css/dark.css</file>
|
||||
<file alias="Light">res/css/light.css</file>
|
||||
<file alias="Traditional">res/css/trad.css</file>
|
||||
</qresource>
|
||||
<qresource prefix="/images">
|
||||
<file alias="arrow_down">res/images/arrow_down.png</file>
|
||||
|
@ -922,25 +922,23 @@ void migrateQtSettings()
|
||||
// Open CSS when configured
|
||||
QString loadStyleSheet()
|
||||
{
|
||||
QString styleSheet;
|
||||
QSettings settings;
|
||||
QString cssName;
|
||||
QString theme = settings.value("theme", "").toString();
|
||||
|
||||
if(!theme.isEmpty()){
|
||||
cssName = QString(":/css/") + theme;
|
||||
}
|
||||
else {
|
||||
cssName = QString(":/css/light");
|
||||
settings.setValue("theme", "light");
|
||||
QDir themes(":themes");
|
||||
// Make sure settings are pointing to an existent theme
|
||||
// Set "Light" theme by default if settings are missing or incorrect
|
||||
if (theme.isEmpty() || !themes.exists(theme)) {
|
||||
theme = "Light";
|
||||
settings.setValue("theme", theme);
|
||||
}
|
||||
|
||||
QFile qFile(cssName);
|
||||
QFile qFile(":themes/" + theme);
|
||||
if (qFile.open(QFile::ReadOnly)) {
|
||||
styleSheet = QLatin1String(qFile.readAll());
|
||||
return QLatin1String(qFile.readAll());
|
||||
}
|
||||
|
||||
return styleSheet;
|
||||
return QString();
|
||||
}
|
||||
|
||||
void setClipboard(const QString& str)
|
||||
|
@ -91,9 +91,10 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
|
||||
}
|
||||
|
||||
/* Theme selector */
|
||||
ui->theme->addItem(QString("Dark"), QVariant("dark"));
|
||||
ui->theme->addItem(QString("Light"), QVariant("light"));
|
||||
ui->theme->addItem(QString("Traditional"), QVariant("trad"));
|
||||
QDir themes(":themes");
|
||||
for (const QString &entry : themes.entryList()) {
|
||||
ui->theme->addItem(entry, QVariant(entry));
|
||||
}
|
||||
|
||||
/* Language selector */
|
||||
QDir translations(":translations");
|
||||
|
Loading…
Reference in New Issue
Block a user