background: parallax: make amount configurable, fix change reactivity, disable by default

This commit is contained in:
end-4
2026-04-10 21:36:24 +02:00
parent fa3bf6f5df
commit 3e0561578c
2 changed files with 14 additions and 15 deletions
@@ -216,9 +216,9 @@ Singleton {
property JsonObject parallax: JsonObject { property JsonObject parallax: JsonObject {
property bool vertical: false property bool vertical: false
property bool autoVertical: false property bool autoVertical: false
property bool enableWorkspace: true property bool enableWorkspace: false
property real workspaceZoom: 1.0 // Relative to wallpaper size property real workspaceZoom: 1.07 // Relative to wallpaper size
property bool enableSidebar: true property bool enableSidebar: false
property real widgetsFactor: 1.2 property real widgetsFactor: 1.2
} }
} }
@@ -48,9 +48,9 @@ Variants {
const sensitiveNetwork = (CF.StringUtils.stringListContainsSubstring(Network.networkName.toLowerCase(), Config.options.workSafety.triggerCondition.networkNameKeywords)); const sensitiveNetwork = (CF.StringUtils.stringListContainsSubstring(Network.networkName.toLowerCase(), Config.options.workSafety.triggerCondition.networkNameKeywords));
return enabled && sensitiveWallpaper && sensitiveNetwork; return enabled && sensitiveWallpaper && sensitiveNetwork;
} }
readonly property real parallaxRation: 1.1 readonly property real parallaxRation: Config.options.background.parallax.workspaceZoom
readonly property real additionalScaleFactor: Config.options.background.parallax.workspaceZoom property real minSuitableScale: 1 // Some reasonable init, to be updated
property real effectiveWallpaperScale: 1 // Some reasonable init value, to be updated property real effectiveWallpaperScale: minSuitableScale * parallaxRation
property int wallpaperWidth: modelData.width // Some reasonable init value, to be updated property int wallpaperWidth: modelData.width // Some reasonable init value, to be updated
property int wallpaperHeight: modelData.height // Some reasonable init value, to be updated property int wallpaperHeight: modelData.height // Some reasonable init value, to be updated
property real scaledWallpaperWidth: wallpaperWidth * effectiveWallpaperScale property real scaledWallpaperWidth: wallpaperWidth * effectiveWallpaperScale
@@ -119,8 +119,7 @@ Variants {
// Small picture; scale > 1; will zoom in the picture // Small picture; scale > 1; will zoom in the picture
// Big picture; scale < 1; will zoom out the picture // Big picture; scale < 1; will zoom out the picture
// Choose max number so every side will fit // Choose max number so every side will fit
const minSuitableScale = Math.max(screenWidth / width, screenHeight / height); bgRoot.minSuitableScale = Math.max(screenWidth / width, screenHeight / height);
bgRoot.effectiveWallpaperScale = minSuitableScale * bgRoot.additionalScaleFactor * bgRoot.parallaxRation;
} }
} }
} }
@@ -167,16 +166,16 @@ Variants {
} }
x: { x: {
if (bgRoot.screen.width > bgRoot.scaledWallpaperWidth) { if (bgRoot.screen.width > width) {
// Center the picture // Center the picture
return (bgRoot.screen.width - bgRoot.scaledWallpaperWidth) / 2; return (bgRoot.screen.width - width) / 2;
} }
return - bgRoot.parallaxTotalPixelsX * usedFractionX; return - bgRoot.parallaxTotalPixelsX * usedFractionX;
} }
y: { y: {
if (bgRoot.screen.height > bgRoot.scaledWallpaperHeight) { if (bgRoot.screen.height > height) {
// Center the picture // Center the picture
return (bgRoot.screen.height - bgRoot.scaledWallpaperHeight) / 2; return (bgRoot.screen.height - height) / 2;
} }
return - bgRoot.parallaxTotalPixelsY * usedFractionY; return - bgRoot.parallaxTotalPixelsY * usedFractionY;
} }
@@ -235,10 +234,10 @@ Variants {
height: parent.height height: parent.height
readonly property real parallaxFactor: { readonly property real parallaxFactor: {
var f = Config.options.background.parallax.widgetsFactor; var f = Config.options.background.parallax.widgetsFactor;
return f / Config.options.background.parallax.workspaceZoom; return f / bgRoot.parallaxRation;
} }
readonly property real baseWallpaperOffsetX: (bgRoot.screen.width - bgRoot.scaledWallpaperWidth) / 2 readonly property real baseWallpaperOffsetX: (bgRoot.screen.width - wallpaper.width) / 2
readonly property real baseWallpaperOffsetY: (bgRoot.screen.height - bgRoot.scaledWallpaperHeight) / 2 readonly property real baseWallpaperOffsetY: (bgRoot.screen.height - wallpaper.height) / 2
readonly property real wallpaperTotalOffsetX: wallpaper.x - baseWallpaperOffsetX readonly property real wallpaperTotalOffsetX: wallpaper.x - baseWallpaperOffsetX
readonly property real wallpaperTotalOffsetY: wallpaper.y - baseWallpaperOffsetY readonly property real wallpaperTotalOffsetY: wallpaper.y - baseWallpaperOffsetY
readonly property bool locked: GlobalStates.screenLocked readonly property bool locked: GlobalStates.screenLocked