Skip to content

Commit

Permalink
Fixed an old problem in setting wallpapers (#1036)
Browse files Browse the repository at this point in the history
Closes lxqt/lxqt#1186, a very old issue that surfaced recently.
  • Loading branch information
tsujan authored Sep 6, 2024
1 parent a503d39 commit 6f30ac4
Showing 1 changed file with 12 additions and 21 deletions.
33 changes: 12 additions & 21 deletions lxqt-config-appearance/lxqtthemeconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,6 @@ class ThemeDecorator : public QItemDelegate
}
};

/*!
* \brief Check if currently configured wallpaper (read from pcmanfm-qt's
* settings) is the same as \param themeWallpaper
*/
static bool isWallpaperChanged(const QString & themeWallpaper)
{
static const QString config_path = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)
+ QStringLiteral("/pcmanfm-qt/lxqt/settings.conf");
static const QString wallpaper_key = QStringLiteral("Desktop/Wallpaper");
const QString current_wallpaper = QSettings{config_path, QSettings::IniFormat}.value(wallpaper_key).toString();
return themeWallpaper != current_wallpaper;
}

LXQtThemeConfig::LXQtThemeConfig(LXQt::Settings *settings, StyleConfig *stylePage, QWidget *parent) :
QWidget(parent),
ui(new Ui::LXQtThemeConfig),
Expand Down Expand Up @@ -154,14 +141,18 @@ void LXQtThemeConfig::applyLxqtTheme()
QVariant themeName = item->data(0, Qt::UserRole);
if(mSettings->value(QStringLiteral("theme")) != themeName)
mSettings->setValue(QStringLiteral("theme"), themeName);
LXQt::LXQtTheme theme(themeName.toString());
if(theme.isValid()) {
QString wallpaper = theme.desktopBackground();
if(!wallpaper.isEmpty() && (ui->wallpaperOverride->isChecked() || !isWallpaperChanged(currentTheme.desktopBackground()))) {
// call pcmanfm-qt to update wallpaper
QStringList args;
args << QStringLiteral("--set-wallpaper") << wallpaper;
QProcess::startDetached(QStringLiteral("pcmanfm-qt"), args);

if (ui->wallpaperOverride->isChecked())
{ // set the wallpaper
LXQt::LXQtTheme theme(themeName.toString());
if(theme.isValid()) {
QString wallpaper = theme.desktopBackground();
if(!wallpaper.isEmpty()) {
// call pcmanfm-qt to update wallpaper
QStringList args;
args << QStringLiteral("--set-wallpaper") << wallpaper;
QProcess::startDetached(QStringLiteral("pcmanfm-qt"), args);
}
}
}

Expand Down

0 comments on commit 6f30ac4

Please sign in to comment.