Commit b616f247 authored by David Redondo's avatar David Redondo 🏎
Browse files

Load all themes

We need to check every possible directory. In my case my active theme was not
listed!
parent 48dae08e
...@@ -87,23 +87,29 @@ void ThemesModel::populate() ...@@ -87,23 +87,29 @@ void ThemesModel::populate()
endResetModel(); endResetModel();
} }
QString themesBaseDir = KSharedConfig::openConfig(QStringLiteral(SDDM_CONFIG_FILE), KConfig::SimpleConfig)->group("Theme").readEntry("ThemeDir"); const QString themesBaseDir = KSharedConfig::openConfig(QStringLiteral(SDDM_CONFIG_FILE), KConfig::SimpleConfig)->group("Theme").readEntry("ThemeDir");
QStringList themesBaseDirs;
if (themesBaseDir.isEmpty()) { if (!themesBaseDir.isEmpty()) {
themesBaseDir = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("sddm/themes"), QStandardPaths::LocateDirectory); themesBaseDirs.append(themesBaseDir);
} } else {
themesBaseDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("sddm/themes"), QStandardPaths::LocateDirectory);
QDir dir(themesBaseDir);
if (!dir.exists()) {
return;
} }
foreach (const QString &theme, dir.entryList(QDir::AllDirs | QDir::Readable)) { auto alreadyHave = [this] (const QString &theme) {
QString path = themesBaseDir + QLatin1Char('/') + theme; return std::any_of(mThemeList.cbegin(), mThemeList.cend(), [&theme] (const ThemeMetadata &data) {
return data.themeid() == theme;
if (QFile::exists(path + QStringLiteral("/metadata.desktop") )) { });
add(theme, path); };
for (const auto &folder : themesBaseDirs) {
QDir dir(folder);
if (!dir.exists()) {
return;
}
for (const QString &theme : dir.entryList(QDir::AllDirs | QDir::Readable | QDir::NoDotAndDotDot)) {
QString path = folder + QLatin1Char('/') + theme;
if (!alreadyHave(theme) && QFile::exists(path + QStringLiteral("/metadata.desktop"))) {
add(theme, path);
}
} }
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment