From 162c5febda0163fd102069a620d8dba4e562b4b5 Mon Sep 17 00:00:00 2001 From: Sighthesia Date: Mon, 10 Nov 2025 17:32:03 +0800 Subject: [PATCH] Background: add startup wallpaper transition --- Assets/settings-default.json | 1 + Commons/Settings.qml | 1 + Modules/Background/Background.qml | 59 ++++++++++++++++++- Modules/Panels/Settings/Tabs/WallpaperTab.qml | 9 +++ 4 files changed, 68 insertions(+), 2 deletions(-) diff --git a/Assets/settings-default.json b/Assets/settings-default.json index add3d975..88e7c4fd 100644 --- a/Assets/settings-default.json +++ b/Assets/settings-default.json @@ -120,6 +120,7 @@ "randomIntervalSec": 300, "transitionDuration": 1500, "transitionType": "random", + "startupTransitionType": "disc", "transitionEdgeSmoothness": 0.05, "monitors": [], "panelPosition": "follow_bar" diff --git a/Commons/Settings.qml b/Commons/Settings.qml index 3d7be7f1..861be375 100644 --- a/Commons/Settings.qml +++ b/Commons/Settings.qml @@ -258,6 +258,7 @@ Singleton { property int randomIntervalSec: 300 // 5 min property int transitionDuration: 1500 // 1500 ms property string transitionType: "random" + property string startupTransitionType: "disc" property real transitionEdgeSmoothness: 0.05 property list monitors: [] property string panelPosition: "follow_bar" diff --git a/Modules/Background/Background.qml b/Modules/Background/Background.qml index abea1806..40fd81ea 100644 --- a/Modules/Background/Background.qml +++ b/Modules/Background/Background.qml @@ -21,6 +21,7 @@ Variants { // Internal state management property string transitionType: "fade" property real transitionProgress: 0 + property bool isStartupTransition: true readonly property real edgeSmoothness: Settings.data.wallpaper.transitionEdgeSmoothness readonly property var allTransitions: WallpaperService.allTransitions @@ -77,7 +78,11 @@ Variants { Connections { target: CompositorService function onDisplayScalesChanged() { - setWallpaperInitial() + // Recalculate image sizes without interrupting startup transition + if (isStartupTransition) { + return + } + recalculateImageSizes() } } @@ -360,7 +365,10 @@ Variants { return } - setWallpaperImmediate(WallpaperService.getWallpaper(modelData.name)) + const wallpaperPath = WallpaperService.getWallpaper(modelData.name) + + futureWallpaper = wallpaperPath + performStartupTransition() } // ------------------------------------------------------ @@ -453,6 +461,53 @@ Variants { break } } + + // ------------------------------------------------------ + // Dedicated function for startup animation + function performStartupTransition() { + // Get the transitionType from the settings + var transitionSettingType = Settings.data.wallpaper.startupTransitionType + + if (transitionSettingType == "random") { + var idx = Math.floor(Math.random() * allTransitions.length) + transitionSettingType = allTransitions[idx] + } + + // Ensure the transition type really exists + if (transitionSettingType !== "none" && !allTransitions.includes(transitionSettingType)) { + transitionSettingType = "fade" + } + + // Apply transitionType so the shader loader picks the correct shader + this.transitionType = transitionSettingType + + // Perform the chosen transition; for startup prefer centered disc when disc selected + switch (transitionSettingType) { + case "none": + setWallpaperImmediate(futureWallpaper) + break + case "wipe": + wipeDirection = Math.random() * 4 + setWallpaperWithTransition(futureWallpaper) + break + case "disc": + // Force center origin for elegant startup animation + discCenterX = 0.5 + discCenterY = 0.5 + setWallpaperWithTransition(futureWallpaper) + break + case "stripes": + stripesCount = Math.round(Math.random() * 20 + 4) + stripesAngle = Math.random() * 360 + setWallpaperWithTransition(futureWallpaper) + break + default: + setWallpaperWithTransition(futureWallpaper) + break + } + // Mark startup transition complete + isStartupTransition = false + } } } } diff --git a/Modules/Panels/Settings/Tabs/WallpaperTab.qml b/Modules/Panels/Settings/Tabs/WallpaperTab.qml index ec3995a0..fd128fea 100644 --- a/Modules/Panels/Settings/Tabs/WallpaperTab.qml +++ b/Modules/Panels/Settings/Tabs/WallpaperTab.qml @@ -205,6 +205,15 @@ ColumnLayout { onSelected: key => Settings.data.wallpaper.transitionType = key } + // Startup Transition Type + NComboBox { + label: I18n.tr("settings.wallpaper.look-feel.startup-transition-type.label") + description: I18n.tr("settings.wallpaper.look-feel.startup-transition-type.description") + model: WallpaperService.transitionsModel + currentKey: Settings.data.wallpaper.startupTransitionType + onSelected: key => Settings.data.wallpaper.startupTransitionType = key + } + // Transition Duration ColumnLayout { NLabel {