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

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()
endResetModel();
}
QString themesBaseDir = KSharedConfig::openConfig(QStringLiteral(SDDM_CONFIG_FILE), KConfig::SimpleConfig)->group("Theme").readEntry("ThemeDir");
if (themesBaseDir.isEmpty()) {
themesBaseDir = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("sddm/themes"), QStandardPaths::LocateDirectory);
}
QDir dir(themesBaseDir);
if (!dir.exists()) {
return;
const QString themesBaseDir = KSharedConfig::openConfig(QStringLiteral(SDDM_CONFIG_FILE), KConfig::SimpleConfig)->group("Theme").readEntry("ThemeDir");
QStringList themesBaseDirs;
if (!themesBaseDir.isEmpty()) {
themesBaseDirs.append(themesBaseDir);
} else {
themesBaseDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("sddm/themes"), QStandardPaths::LocateDirectory);
}
foreach (const QString &theme, dir.entryList(QDir::AllDirs | QDir::Readable)) {
QString path = themesBaseDir + QLatin1Char('/') + theme;
if (QFile::exists(path + QStringLiteral("/metadata.desktop") )) {
add(theme, path);
auto alreadyHave = [this] (const QString &theme) {
return std::any_of(mThemeList.cbegin(), mThemeList.cend(), [&theme] (const ThemeMetadata &data) {
return data.themeid() == theme;
});
};
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