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 bool randomEnabled: false
|
||||||
property int randomIntervalSec: 300 // 5 min
|
property int randomIntervalSec: 300 // 5 min
|
||||||
property int transitionDuration: 1500 // 1500 ms
|
property int transitionDuration: 1500 // 1500 ms
|
||||||
property string transitionType: "fade"
|
property string transitionType: "random"
|
||||||
property list<var> monitors: []
|
property list<var> monitors: []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,10 @@ Variants {
|
||||||
|
|
||||||
// Internal state management
|
// Internal state management
|
||||||
property bool firstWallpaper: true
|
property bool firstWallpaper: true
|
||||||
|
property string transitionType: 'fade'
|
||||||
property bool transitioning: false
|
property bool transitioning: false
|
||||||
property real transitionProgress: 0.0
|
property real transitionProgress: 0.0
|
||||||
|
readonly property var allTransitions: WallpaperService.allTransitions
|
||||||
|
|
||||||
// Wipe direction: 0=left, 1=right, 2=up, 3=down
|
// Wipe direction: 0=left, 1=right, 2=up, 3=down
|
||||||
property real wipeDirection: 0
|
property real wipeDirection: 0
|
||||||
|
|
@ -38,29 +40,44 @@ Variants {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (Settings.data.wallpaper.transitionType) {
|
// Get the transitionType from the settings
|
||||||
case "none":
|
transitionType = Settings.data.wallpaper.transitionType
|
||||||
setWallpaperImmediate(servicedWallpaper)
|
|
||||||
break
|
if (transitionType == 'random') {
|
||||||
case "wipe_left":
|
var index = Math.floor(Math.random() * allTransitions.length)
|
||||||
wipeDirection = 0
|
transitionType = allTransitions[index]
|
||||||
setWallpaperWithTransition(servicedWallpaper)
|
}
|
||||||
break
|
|
||||||
case "wipe_right":
|
// Ensure the transition type really exists
|
||||||
wipeDirection = 1
|
if (transitionType !== "none" && !allTransitions.includes(transitionType)) {
|
||||||
setWallpaperWithTransition(servicedWallpaper)
|
transitionType = 'fade'
|
||||||
break
|
}
|
||||||
case "wipe_up":
|
|
||||||
wipeDirection = 2
|
Logger.log("Background", "Using transition:", transitionType)
|
||||||
setWallpaperWithTransition(servicedWallpaper)
|
|
||||||
break
|
switch (transitionType) {
|
||||||
case "wipe_down":
|
case "none":
|
||||||
wipeDirection = 3
|
setWallpaperImmediate(servicedWallpaper)
|
||||||
setWallpaperWithTransition(servicedWallpaper)
|
break
|
||||||
break
|
case "wipe_left":
|
||||||
default:
|
wipeDirection = 0
|
||||||
setWallpaperWithTransition(servicedWallpaper)
|
setWallpaperWithTransition(servicedWallpaper)
|
||||||
break
|
break
|
||||||
|
case "wipe_right":
|
||||||
|
wipeDirection = 1
|
||||||
|
setWallpaperWithTransition(servicedWallpaper)
|
||||||
|
break
|
||||||
|
case "wipe_up":
|
||||||
|
wipeDirection = 2
|
||||||
|
setWallpaperWithTransition(servicedWallpaper)
|
||||||
|
break
|
||||||
|
case "wipe_down":
|
||||||
|
wipeDirection = 3
|
||||||
|
setWallpaperWithTransition(servicedWallpaper)
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
setWallpaperWithTransition(servicedWallpaper)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -83,10 +100,10 @@ Variants {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
fillMode: Image.PreserveAspectCrop
|
fillMode: Image.PreserveAspectCrop
|
||||||
source: ""
|
source: ""
|
||||||
cache: true
|
|
||||||
smooth: true
|
smooth: true
|
||||||
mipmap: false
|
mipmap: false
|
||||||
visible: false
|
visible: false
|
||||||
|
cache: false
|
||||||
}
|
}
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
|
|
@ -94,17 +111,17 @@ Variants {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
fillMode: Image.PreserveAspectCrop
|
fillMode: Image.PreserveAspectCrop
|
||||||
source: ""
|
source: ""
|
||||||
cache: true
|
|
||||||
smooth: true
|
smooth: true
|
||||||
mipmap: false
|
mipmap: false
|
||||||
visible: false
|
visible: false
|
||||||
|
cache: false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fade transition shader
|
// Fade transition shader
|
||||||
ShaderEffect {
|
ShaderEffect {
|
||||||
id: fadeShader
|
id: fadeShader
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
visible: Settings.data.wallpaper.transitionType === 'fade'
|
visible: transitionType === 'fade' || transitionType === 'none'
|
||||||
|
|
||||||
property variant source1: currentWallpaper
|
property variant source1: currentWallpaper
|
||||||
property variant source2: nextWallpaper
|
property variant source2: nextWallpaper
|
||||||
|
|
@ -116,7 +133,7 @@ Variants {
|
||||||
ShaderEffect {
|
ShaderEffect {
|
||||||
id: wipeShader
|
id: wipeShader
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
visible: Settings.data.wallpaper.transitionType.startsWith('wipe_')
|
visible: transitionType.startsWith('wipe_')
|
||||||
|
|
||||||
property variant source1: currentWallpaper
|
property variant source1: currentWallpaper
|
||||||
property variant source2: nextWallpaper
|
property variant source2: nextWallpaper
|
||||||
|
|
@ -134,14 +151,7 @@ Variants {
|
||||||
from: 0.0
|
from: 0.0
|
||||||
to: 1.0
|
to: 1.0
|
||||||
duration: Settings.data.wallpaper.transitionDuration ?? 1000
|
duration: Settings.data.wallpaper.transitionDuration ?? 1000
|
||||||
easing.type: {
|
easing.type: transitionType.startsWith('wipe_') ? Easing.InOutCubic : Easing.InOutCubic
|
||||||
const transitionType = Settings.data.wallpaper.transitionType ?? 'fade'
|
|
||||||
if (transitionType.startsWith('wipe_')) {
|
|
||||||
return Easing.InOutCubic
|
|
||||||
}
|
|
||||||
return Easing.InOutCubic
|
|
||||||
}
|
|
||||||
|
|
||||||
onFinished: {
|
onFinished: {
|
||||||
// Swap images after transition completes
|
// Swap images after transition completes
|
||||||
currentWallpaper.source = nextWallpaper.source
|
currentWallpaper.source = nextWallpaper.source
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,9 @@ Variants {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
fillMode: Image.PreserveAspectCrop
|
fillMode: Image.PreserveAspectCrop
|
||||||
source: WallpaperService.getWallpaper(modelData.name)
|
source: WallpaperService.getWallpaper(modelData.name)
|
||||||
cache: true
|
|
||||||
smooth: true
|
smooth: true
|
||||||
mipmap: false
|
mipmap: false
|
||||||
|
cache: false
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiEffect {
|
MultiEffect {
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,10 @@ Singleton {
|
||||||
key: "none"
|
key: "none"
|
||||||
name: "None"
|
name: "None"
|
||||||
}
|
}
|
||||||
|
ListElement {
|
||||||
|
key: "random"
|
||||||
|
name: "Random"
|
||||||
|
}
|
||||||
ListElement {
|
ListElement {
|
||||||
key: "fade"
|
key: "fade"
|
||||||
name: "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 var wallpaperLists: ({})
|
||||||
property int scanningCount: 0
|
property int scanningCount: 0
|
||||||
readonly property bool scanning: (scanningCount > 0)
|
readonly property bool scanning: (scanningCount > 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue