mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
LockScreen: use cached wallpaper
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user