From ead8ceefa2a142b59e346b9df39a0070de709c73 Mon Sep 17 00:00:00 2001 From: tsujan Date: Tue, 19 Apr 2022 20:36:19 +0430 Subject: [PATCH] Consider LXQt theme names case-insensitively (#308) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `lxqt-config` may also need a small change, but this PR ignores the letter case in the value of `lxqt.conf` → General → theme. Closes https://github.com/lxqt/lxqt-themes/issues/69 --- lxqtsettings.cpp | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/lxqtsettings.cpp b/lxqtsettings.cpp index 5303af2..057ea43 100644 --- a/lxqtsettings.cpp +++ b/lxqtsettings.cpp @@ -415,9 +415,16 @@ QString LXQtThemeData::findTheme(const QString &themeName) for(const QString &path : qAsConst(paths)) { - QDir dir(QString::fromLatin1("%1/lxqt/themes/%2").arg(path, themeName)); - if (dir.isReadable()) - return dir.absolutePath(); + QDir dir(QString::fromLatin1("%1/lxqt/themes").arg(path)); + const QFileInfoList dirs = dir.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name); + for(const QFileInfo &dir : dirs) + { + if (QString::compare(dir.fileName(), themeName, Qt::CaseInsensitive) == 0 && + QDir(dir.absoluteFilePath()).exists(QL1S("lxqt-panel.qss"))) + { + return dir.absoluteFilePath(); + } + } } return QString(); @@ -555,7 +562,7 @@ const LXQtTheme &LXQtTheme::currentTheme() { static LXQtTheme theme; QString name = Settings::globalSettings()->value(QL1S("theme")).toString(); - if (theme.name() != name) + if (QString::compare(theme.name(), name, Qt::CaseInsensitive) != 0) { theme = LXQtTheme(name); } @@ -578,14 +585,15 @@ QList LXQtTheme::allThemes() for(const QString &path : qAsConst(paths)) { QDir dir(QString::fromLatin1("%1/lxqt/themes").arg(path)); - const QFileInfoList dirs = dir.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot); + const QFileInfoList dirs = dir.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name); for(const QFileInfo &dir : dirs) { - if (!processed.contains(dir.fileName()) && - QDir(dir.absoluteFilePath()).exists(QL1S("lxqt-panel.qss"))) + auto name = dir.fileName().toLower(); + if (!processed.contains(name) && + QDir(dir.absoluteFilePath()).exists(QL1S("lxqt-panel.qss"))) { - processed << dir.fileName(); + processed << name; ret << LXQtTheme(dir.absoluteFilePath()); } @@ -698,7 +706,8 @@ void GlobalSettings::fileChanged() QString rt = value(QL1S("theme")).toString(); qlonglong themeUpdated = value(QL1S("__theme_updated__")).toLongLong(); - if ((d->mLXQtTheme != rt) || (d->mThemeUpdated != themeUpdated)) + if (QString::compare(d->mLXQtTheme, rt, Qt::CaseInsensitive) != 0 || + d->mThemeUpdated != themeUpdated) { d->mLXQtTheme = rt; Q_EMIT lxqtThemeChanged();