Wallpaper: added random transition + fixed "none" transition
This commit is contained in:
parent
3496169c68
commit
26fc6098dc
4 changed files with 57 additions and 37 deletions
|
|
@ -169,7 +169,7 @@ Singleton {
|
|||
property bool randomEnabled: false
|
||||
property int randomIntervalSec: 300 // 5 min
|
||||
property int transitionDuration: 1500 // 1500 ms
|
||||
property string transitionType: "fade"
|
||||
property string transitionType: "random"
|
||||
property list<var> monitors: []
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,8 +19,10 @@ Variants {
|
|||
|
||||
// Internal state management
|
||||
property bool firstWallpaper: true
|
||||
property string transitionType: 'fade'
|
||||
property bool transitioning: false
|
||||
property real transitionProgress: 0.0
|
||||
readonly property var allTransitions: WallpaperService.allTransitions
|
||||
|
||||
// Wipe direction: 0=left, 1=right, 2=up, 3=down
|
||||
property real wipeDirection: 0
|
||||
|
|
@ -38,7 +40,22 @@ Variants {
|
|||
return
|
||||
}
|
||||
|
||||
switch (Settings.data.wallpaper.transitionType) {
|
||||
// Get the transitionType from the settings
|
||||
transitionType = Settings.data.wallpaper.transitionType
|
||||
|
||||
if (transitionType == 'random') {
|
||||
var index = Math.floor(Math.random() * allTransitions.length)
|
||||
transitionType = allTransitions[index]
|
||||
}
|
||||
|
||||
// Ensure the transition type really exists
|
||||
if (transitionType !== "none" && !allTransitions.includes(transitionType)) {
|
||||
transitionType = 'fade'
|
||||
}
|
||||
|
||||
Logger.log("Background", "Using transition:", transitionType)
|
||||
|
||||
switch (transitionType) {
|
||||
case "none":
|
||||
setWallpaperImmediate(servicedWallpaper)
|
||||
break
|
||||
|
|
@ -83,10 +100,10 @@ Variants {
|
|||
anchors.fill: parent
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
source: ""
|
||||
cache: true
|
||||
smooth: true
|
||||
mipmap: false
|
||||
visible: false
|
||||
cache: false
|
||||
}
|
||||
|
||||
Image {
|
||||
|
|
@ -94,17 +111,17 @@ Variants {
|
|||
anchors.fill: parent
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
source: ""
|
||||
cache: true
|
||||
smooth: true
|
||||
mipmap: false
|
||||
visible: false
|
||||
cache: false
|
||||
}
|
||||
|
||||
// Fade transition shader
|
||||
ShaderEffect {
|
||||
id: fadeShader
|
||||
anchors.fill: parent
|
||||
visible: Settings.data.wallpaper.transitionType === 'fade'
|
||||
visible: transitionType === 'fade' || transitionType === 'none'
|
||||
|
||||
property variant source1: currentWallpaper
|
||||
property variant source2: nextWallpaper
|
||||
|
|
@ -116,7 +133,7 @@ Variants {
|
|||
ShaderEffect {
|
||||
id: wipeShader
|
||||
anchors.fill: parent
|
||||
visible: Settings.data.wallpaper.transitionType.startsWith('wipe_')
|
||||
visible: transitionType.startsWith('wipe_')
|
||||
|
||||
property variant source1: currentWallpaper
|
||||
property variant source2: nextWallpaper
|
||||
|
|
@ -134,14 +151,7 @@ Variants {
|
|||
from: 0.0
|
||||
to: 1.0
|
||||
duration: Settings.data.wallpaper.transitionDuration ?? 1000
|
||||
easing.type: {
|
||||
const transitionType = Settings.data.wallpaper.transitionType ?? 'fade'
|
||||
if (transitionType.startsWith('wipe_')) {
|
||||
return Easing.InOutCubic
|
||||
}
|
||||
return Easing.InOutCubic
|
||||
}
|
||||
|
||||
easing.type: transitionType.startsWith('wipe_') ? Easing.InOutCubic : Easing.InOutCubic
|
||||
onFinished: {
|
||||
// Swap images after transition completes
|
||||
currentWallpaper.source = nextWallpaper.source
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@ Variants {
|
|||
anchors.fill: parent
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
source: WallpaperService.getWallpaper(modelData.name)
|
||||
cache: true
|
||||
smooth: true
|
||||
mipmap: false
|
||||
cache: false
|
||||
}
|
||||
|
||||
MultiEffect {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,10 @@ Singleton {
|
|||
key: "none"
|
||||
name: "None"
|
||||
}
|
||||
ListElement {
|
||||
key: "random"
|
||||
name: "Random"
|
||||
}
|
||||
ListElement {
|
||||
key: "fade"
|
||||
name: "Fade"
|
||||
|
|
@ -41,6 +45,12 @@ Singleton {
|
|||
}
|
||||
}
|
||||
|
||||
// All transition keys but filter out "random"
|
||||
readonly property var allTransitions: Array.from({
|
||||
"length": transitionsModel.count
|
||||
}, (_, i) => transitionsModel.get(i).key).filter(
|
||||
key => key !== "random" && key != "none")
|
||||
|
||||
property var wallpaperLists: ({})
|
||||
property int scanningCount: 0
|
||||
readonly property bool scanning: (scanningCount > 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue