summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Martin <[email protected]>2017-01-10 13:43:49 +0100
committerMarco Martin <[email protected]>2017-01-10 13:52:04 +0100
commitfcfd900a8be2cdcdb1abf4ee0a985eac5a98d459 (patch)
treeddc81f609868773d9f077de880d7e07c6bb9348c
parent1556cc295bac3dbdb33b26f7d71b1dcd3acac1b2 (diff)
heuristically find the color scheme
Summary: why this loop trough all the scheme files? the scheme theme name is an heuristic, there is no plugin metadata whatsoever. is based on the file name stripped from weird characters or the eventual id- prefix store.kde.org puts, so we can just find a theme that ends as the specified name Test Plan: now themes downloaded from store.kde.org are correctly applied such as "Kshell" use case Reviewers: #plasma, davidedmundson Reviewed By: #plasma, davidedmundson Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D4066
-rw-r--r--kcms/lookandfeel/kcm.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/kcms/lookandfeel/kcm.cpp b/kcms/lookandfeel/kcm.cpp
index 0961d8a..0c3c8ae 100644
--- a/kcms/lookandfeel/kcm.cpp
+++ b/kcms/lookandfeel/kcm.cpp
@@ -297,8 +297,27 @@ void KCMLookandFeel::save()
colorScheme.replace(offset, fixer.matchedLength(), fixer.cap(1).toUpper());
}
colorScheme.replace(0, 1, colorScheme.at(0).toUpper());
- QString src = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "color-schemes/" + colorScheme + ".colors");
- setColors(colorScheme, src);
+
+ //NOTE: why this loop trough all the scheme files?
+ //the scheme theme name is an heuristic, there is no plugin metadata whatsoever.
+ //is based on the file name stripped from weird characters or the
+ //eventual id- prefix store.kde.org puts, so we can just find a
+ //theme that ends as the specified name
+ bool schemeFound = false;
+ const QStringList schemeDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("color-schemes"), QStandardPaths::LocateDirectory);
+ for (const QString &dir : schemeDirs) {
+ const QStringList fileNames = QDir(dir).entryList(QStringList()<<QStringLiteral("*.colors"));
+ for (const QString &file : fileNames) {
+ if (file.endsWith(colorScheme + ".colors")) {
+ setColors(colorScheme, dir + QChar('/') + file);
+ schemeFound = true;
+ break;
+ }
+ }
+ if (schemeFound) {
+ break;
+ }
+ }
}
}