mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-06-11 00:47:22 +00:00
Sync lockscreen wallpaper with homescreen changes
When homescreen wallpaper is set, also persist the same image for lockscreen. Add a one-time migration in loadHomescreenSettings() that updates lockscreen when it is unset or still points to legacy Next wallpaper.
This commit is contained in:
parent
378e4830ac
commit
9d076bf542
1 changed files with 22 additions and 0 deletions
|
|
@ -20,6 +20,15 @@
|
|||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
|
||||
namespace
|
||||
{
|
||||
bool isLegacyNextWallpaperPath(const QString &path)
|
||||
{
|
||||
return path == QStringLiteral("Next") || path.startsWith(QStringLiteral("/usr/share/wallpapers/Next/"))
|
||||
|| path.startsWith(QStringLiteral("file:///usr/share/wallpapers/Next/"));
|
||||
}
|
||||
}
|
||||
|
||||
WallpaperPlugin::WallpaperPlugin(QObject *parent)
|
||||
: QObject{parent}
|
||||
, m_homescreenConfig{new QQmlPropertyMap{this}}
|
||||
|
|
@ -183,6 +192,11 @@ QCoro::Task<void> WallpaperPlugin::setHomescreenWallpaper(const QString &path)
|
|||
qWarning() << "Failed to set wallpaper for screen" << screen << ":" << reply.error();
|
||||
}
|
||||
}
|
||||
|
||||
// Keep lockscreen wallpaper aligned with homescreen wallpaper selections.
|
||||
if (!path.isEmpty()) {
|
||||
setLockscreenWallpaper(path);
|
||||
}
|
||||
}
|
||||
|
||||
void WallpaperPlugin::setLockscreenWallpaper(const QString &path)
|
||||
|
|
@ -256,6 +270,14 @@ QCoro::Task<void> WallpaperPlugin::loadHomescreenSettings()
|
|||
// parse image configuration
|
||||
if (m_homescreenWallpaperPlugin == QStringLiteral("org.kde.image")) {
|
||||
m_homescreenWallpaperPath = map["Image"].toString();
|
||||
|
||||
// One-time migration for stale lockscreen wallpaper defaults.
|
||||
const bool lockscreenUnset = m_lockscreenWallpaperPlugin.isEmpty() || m_lockscreenWallpaperPath.isEmpty();
|
||||
const bool lockscreenLegacyNext =
|
||||
m_lockscreenWallpaperPlugin == QStringLiteral("org.kde.image") && isLegacyNextWallpaperPath(m_lockscreenWallpaperPath);
|
||||
if (!m_homescreenWallpaperPath.isEmpty() && m_lockscreenWallpaperPath != m_homescreenWallpaperPath && (lockscreenUnset || lockscreenLegacyNext)) {
|
||||
setLockscreenWallpaper(m_homescreenWallpaperPath);
|
||||
}
|
||||
}
|
||||
|
||||
Q_EMIT homescreenConfigurationChanged();
|
||||
|
|
|
|||
Loading…
Reference in a new issue