Skip to content

Commit

Permalink
Use real LXQt theme name for comparison
Browse files Browse the repository at this point in the history
Previously, the value of the "theme" key was used, which may differ in letter cases from the current theme name.

Also, the themes list is sorted alphabetically. Previously, the user themes came first.

This PR requires and depends on lxqt/liblxqt#309.
  • Loading branch information
tsujan committed Apr 24, 2022
1 parent 29a722a commit 1db3fab
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lxqt-config-appearance/lxqtthemeconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ LXQtThemeConfig::LXQtThemeConfig(LXQt::Settings *settings, QWidget *parent) :
item->setData(0, Qt::UserRole, theme.name());
ui->lxqtThemeList->addTopLevelItem(item);
}
ui->lxqtThemeList->sortItems(0, Qt::AscendingOrder);

initControls();

Expand All @@ -109,11 +110,13 @@ LXQtThemeConfig::~LXQtThemeConfig()

void LXQtThemeConfig::initControls()
{
QString currentTheme = mSettings->value(QStringLiteral("theme")).toString();
LXQt::LXQtTheme currentTheme{mSettings->value(QStringLiteral("theme")).toString()};

QTreeWidgetItemIterator it(ui->lxqtThemeList);
while (*it) {
if ((*it)->data(0, Qt::UserRole).toString() == currentTheme)
// use the theme name for comparison because the value of the "theme" key
// may differ in letter cases from it
if ((*it)->data(0, Qt::UserRole).toString() == currentTheme.name())
{
ui->lxqtThemeList->setCurrentItem((*it));
break;
Expand All @@ -131,10 +134,10 @@ void LXQtThemeConfig::applyLxqtTheme()
return;

LXQt::LXQtTheme currentTheme{mSettings->value(QStringLiteral("theme")).toString()};
QVariant themeName = item->data(0, Qt::UserRole);
if(mSettings->value(QStringLiteral("theme")) != themeName)
QString themeName = item->data(0, Qt::UserRole).toString();
if(currentTheme.name() != themeName)
mSettings->setValue(QStringLiteral("theme"), themeName);
LXQt::LXQtTheme theme(themeName.toString());
LXQt::LXQtTheme theme(themeName);
if(theme.isValid()) {
QString wallpaper = theme.desktopBackground();
if(!wallpaper.isEmpty() && (ui->wallpaperOverride->isChecked() || !isWallpaperChanged(currentTheme.desktopBackground()))) {
Expand Down

0 comments on commit 1db3fab

Please sign in to comment.