LockScreen: use cached wallpaper

This commit is contained in:
Ly-sec
2025-12-25 17:13:58 +01:00
parent 82951b6bcf
commit 21f10d50af
+80 -1
View File
@@ -114,11 +114,90 @@ Loader {
property string currentLayout: KeyboardLayoutService.currentLayout
}
// Cached wallpaper path
property string cachedWallpaperPath: ""
// Request preprocessed wallpaper when lock screen becomes active or dimensions change
Component.onCompleted: {
if (screen) {
Qt.callLater(requestCachedWallpaper);
}
}
onWidthChanged: {
if (screen && width > 0 && height > 0) {
Qt.callLater(requestCachedWallpaper);
}
}
onHeightChanged: {
if (screen && width > 0 && height > 0) {
Qt.callLater(requestCachedWallpaper);
}
}
// Listen for wallpaper changes
Connections {
target: WallpaperService
function onWallpaperChanged(screenName, path) {
if (screen && screenName === screen.name) {
Qt.callLater(requestCachedWallpaper);
}
}
}
// Listen for display scale changes
Connections {
target: CompositorService
function onDisplayScalesChanged() {
if (screen && width > 0 && height > 0) {
Qt.callLater(requestCachedWallpaper);
}
}
}
function requestCachedWallpaper() {
if (!screen || width <= 0 || height <= 0) {
return;
}
if (!WallpaperCacheService || !WallpaperCacheService.initialized) {
// Fallback to original if services not ready
const wallpaperPath = WallpaperService.getWallpaper(screen.name);
cachedWallpaperPath = wallpaperPath || "";
return;
}
const wallpaperPath = WallpaperService.getWallpaper(screen.name);
if (!wallpaperPath) {
cachedWallpaperPath = "";
return;
}
const compositorScale = CompositorService.getDisplayScale(screen.name);
const targetWidth = Math.round(width * compositorScale);
const targetHeight = Math.round(height * compositorScale);
if (targetWidth <= 0 || targetHeight <= 0) {
cachedWallpaperPath = wallpaperPath;
return;
}
WallpaperCacheService.getPreprocessed(wallpaperPath, screen.name, targetWidth, targetHeight, function (cachedPath, success) {
if (success) {
cachedWallpaperPath = cachedPath;
} else {
// Fallback to original
cachedWallpaperPath = wallpaperPath;
}
});
}
Image {
id: lockBgImage
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
source: screen ? WallpaperService.getWallpaper(screen.name) : ""
source: cachedWallpaperPath || (screen ? WallpaperService.getWallpaper(screen.name) : "")
cache: true
smooth: true
mipmap: false