Merge branch 'noctalia-dev:main' into local

This commit is contained in:
Jose Chasey Pratama 2025-08-31 00:20:29 +07:00 committed by GitHub
commit d2ac174427
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 382 additions and 152 deletions

View file

@ -12,82 +12,42 @@ Variants {
required property ShellScreen modelData
active: Settings.isLoaded && WallpaperService.getWallpaper(modelData.name)
active: Settings.isLoaded
sourceComponent: PanelWindow {
id: root
// Internal state management
property bool firstWallpaper: true
property string transitionType: 'fade'
property bool transitioning: false
property real transitionProgress: 0.0
property string transitionType: "fade"
property real transitionProgress: 0
readonly property real edgeSmoothness: Settings.data.wallpaper.transitionEdgeSmoothness
readonly property var allTransitions: WallpaperService.allTransitions
readonly property bool transitioning: transitionAnimation.running
// Wipe direction: 0=left, 1=right, 2=up, 3=down
property real wipeDirection: 0
property real wipeSmoothness: 0.05
// Disc
property real discCenterX: 0.5
property real discCenterY: 0.5
property real discSmoothness: 0.05
// Stripe
property real stripesCount: 16
property real stripesAngle: 0
// External state management
property string servicedWallpaper: WallpaperService.getWallpaper(modelData.name)
property string futureWallpaper: ""
onServicedWallpaperChanged: {
if (servicedWallpaper && servicedWallpaper !== currentWallpaper.source) {
// Set wallpaper immediately on startup
if (firstWallpaper) {
firstWallpaper = false
setWallpaperImmediate(servicedWallpaper)
return
}
// 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
case "wipe_left":
wipeDirection = 0
setWallpaperWithTransition(servicedWallpaper)
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
case "disc":
discCenterX = Math.random()
discCenterY = Math.random()
setWallpaperWithTransition(servicedWallpaper)
break
default:
setWallpaperWithTransition(servicedWallpaper)
break
}
// Set wallpaper immediately on startup
if (firstWallpaper) {
firstWallpaper = false
setWallpaperImmediate(servicedWallpaper)
} else {
futureWallpaper = servicedWallpaper
debounceTimer.restart()
}
}
@ -104,6 +64,16 @@ Variants {
left: true
}
Timer {
id: debounceTimer
interval: 333
running: false
repeat: false
onTriggered: {
changeWallpaper()
}
}
Image {
id: currentWallpaper
anchors.fill: parent
@ -113,6 +83,8 @@ Variants {
mipmap: false
visible: false
cache: false
// currentWallpaper should not be asynchronous to avoid flickering when swapping next to current.
asynchronous: false
}
Image {
@ -124,17 +96,18 @@ Variants {
mipmap: false
visible: false
cache: false
asynchronous: true
}
// Fade or None transition shader
ShaderEffect {
id: fadeShader
anchors.fill: parent
visible: transitionType === 'fade' || transitionType === 'none'
visible: transitionType === "fade" || transitionType === "none"
property variant source1: currentWallpaper
property variant source2: nextWallpaper
property real fade: transitionProgress
property real progress: root.transitionProgress
fragmentShader: Qt.resolvedUrl("../../Shaders/qsb/wp_fade.frag.qsb")
}
@ -142,13 +115,14 @@ Variants {
ShaderEffect {
id: wipeShader
anchors.fill: parent
visible: transitionType.startsWith('wipe_')
visible: transitionType === "wipe"
property variant source1: currentWallpaper
property variant source2: nextWallpaper
property real progress: transitionProgress
property real direction: wipeDirection
property real smoothness: wipeSmoothness
property real progress: root.transitionProgress
property real smoothness: root.edgeSmoothness
property real direction: root.wipeDirection
fragmentShader: Qt.resolvedUrl("../../Shaders/qsb/wp_wipe.frag.qsb")
}
@ -156,18 +130,36 @@ Variants {
ShaderEffect {
id: discShader
anchors.fill: parent
visible: transitionType === 'disc'
visible: transitionType === "disc"
property variant source1: currentWallpaper
property variant source2: nextWallpaper
property real progress: transitionProgress
property real centerX: discCenterX
property real centerY: discCenterY
property real smoothness: discSmoothness
property real aspectRatio: width / height
property real progress: root.transitionProgress
property real smoothness: root.edgeSmoothness
property real aspectRatio: root.width / root.height
property real centerX: root.discCenterX
property real centerY: root.discCenterY
fragmentShader: Qt.resolvedUrl("../../Shaders/qsb/wp_disc.frag.qsb")
}
// Diagonal stripes transition shader
ShaderEffect {
id: stripesShader
anchors.fill: parent
visible: transitionType === "stripes"
property variant source1: currentWallpaper
property variant source2: nextWallpaper
property real progress: root.transitionProgress
property real smoothness: root.edgeSmoothness
property real aspectRatio: root.width / root.height
property real stripeCount: root.stripesCount
property real angle: root.stripesAngle
fragmentShader: Qt.resolvedUrl("../../Shaders/qsb/wp_stripes.frag.qsb")
}
// Animation for the transition progress
NumberAnimation {
id: transitionAnimation
@ -175,29 +167,29 @@ Variants {
property: "transitionProgress"
from: 0.0
to: 1.0
duration: Settings.data.wallpaper.transitionDuration ?? 1000
easing.type: transitionType.startsWith('wipe_') ? Easing.InOutCubic : Easing.OutQuad
// The stripes shader feels faster visually, we make it a bit slower here.
duration: transitionType == "stripes" ? Settings.data.wallpaper.transitionDuration
* 1.6 : Settings.data.wallpaper.transitionDuration
easing.type: Easing.InOutCubic
onFinished: {
// Swap images after transition completes
currentWallpaper.source = nextWallpaper.source
nextWallpaper.source = ""
transitionProgress = 0.0
transitioning = false
}
}
function startTransition() {
if (!transitioning && nextWallpaper.source != currentWallpaper.source) {
transitioning = true
transitionAnimation.start()
}
}
function setWallpaperImmediate(source) {
transitionAnimation.stop()
transitionProgress = 0.0
currentWallpaper.source = source
nextWallpaper.source = ""
transitionProgress = 0.0
transitioning = false
}
function setWallpaperWithTransition(source) {
@ -206,16 +198,55 @@ Variants {
if (transitioning) {
// We are interrupting a transition
transitionAnimation.stop()
transitionProgress = 0
currentWallpaper.source = nextWallpaper.source
nextWallpaper.source = ""
transitionProgress = 0
transitioning = false
}
nextWallpaper.source = source
startTransition()
}
}
// Main method that actually trigger the wallpaper change
function changeWallpaper() {
// 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", "New wallpaper: ", futureWallpaper, "On:", modelData.name, "Transition:", transitionType)
switch (transitionType) {
case "none":
setWallpaperImmediate(futureWallpaper)
break
case "wipe":
wipeDirection = Math.random() * 4
setWallpaperWithTransition(futureWallpaper)
break
case "disc":
discCenterX = Math.random()
discCenterY = Math.random()
setWallpaperWithTransition(futureWallpaper)
break
case "stripes":
stripesCount = Math.round(Math.random() * 20 + 4)
stripesAngle = Math.random() * 360
setWallpaperWithTransition(futureWallpaper)
break
default:
setWallpaperWithTransition(futureWallpaper)
break
}
}
}
}
}

View file

@ -8,6 +8,7 @@ import qs.Widgets
ColumnLayout {
id: root
width: parent.width
spacing: Style.marginL * scaling
@ -94,12 +95,10 @@ ColumnLayout {
GridView {
id: wallpaperGridView
anchors.fill: parent
clip: true
model: wallpapersList
boundsBehavior: Flickable.StopAtBounds
flickableDirection: Flickable.VerticalFlick
interactive: false
clip: true
property int columns: 5
property int itemSize: Math.floor((width - leftMargin - rightMargin - (4 * Style.marginS * scaling)) / columns)
@ -180,7 +179,8 @@ ColumnLayout {
anchors.fill: parent
acceptedButtons: Qt.LeftButton
hoverEnabled: true
onClicked: {
// Use on pressed instead of clicked to better register clicks
onPressed: {
if (Settings.data.wallpaper.setWallpaperOnAllMonitors) {
WallpaperService.changeWallpaper(undefined, wallpaperPath)
} else {

View file

@ -88,47 +88,14 @@ ColumnLayout {
// Random Wallpaper
NToggle {
label: "Random Wallpaper"
description: "Automatically select random wallpapers from the folder."
description: "Schedule random wallpaper changes at regular intervals."
checked: Settings.data.wallpaper.randomEnabled
onToggled: checked => Settings.data.wallpaper.randomEnabled = checked
}
// Transition Type
NComboBox {
label: "Transition Type"
description: "Animation type when switching between wallpapers."
model: WallpaperService.transitionsModel
currentKey: Settings.data.wallpaper.transitionType
onSelected: key => Settings.data.wallpaper.transitionType = key
}
// Transition Duration
ColumnLayout {
NLabel {
label: "Transition Duration"
description: "Duration of transition animations in seconds."
}
RowLayout {
spacing: Style.marginL * scaling
NSlider {
Layout.fillWidth: true
from: 100
to: 5000
stepSize: 100
value: Settings.data.wallpaper.transitionDuration
onMoved: Settings.data.wallpaper.transitionDuration = value
cutoutColor: Color.mSurface
}
NText {
text: (Settings.data.wallpaper.transitionDuration / 1000).toFixed(2) + "s"
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
}
}
}
// Interval (slider + H:M inputs)
// Interval
ColumnLayout {
visible: Settings.data.wallpaper.randomEnabled
RowLayout {
NLabel {
label: "Wallpaper Interval"
@ -224,6 +191,64 @@ ColumnLayout {
}
}
}
// Transition Type
NComboBox {
label: "Transition Type"
description: "Animation type when switching between wallpapers."
model: WallpaperService.transitionsModel
currentKey: Settings.data.wallpaper.transitionType
onSelected: key => Settings.data.wallpaper.transitionType = key
}
// Transition Duration
ColumnLayout {
NLabel {
label: "Transition Duration"
description: "Duration of transition animations in seconds."
}
RowLayout {
spacing: Style.marginL * scaling
NSlider {
Layout.fillWidth: true
from: 100
to: 5000
stepSize: 100
value: Settings.data.wallpaper.transitionDuration
onMoved: Settings.data.wallpaper.transitionDuration = value
cutoutColor: Color.mSurface
}
NText {
text: (Settings.data.wallpaper.transitionDuration / 1000).toFixed(2) + "s"
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
}
}
}
// Edge Smoothness
ColumnLayout {
NLabel {
label: "Transition Edge Smoothness"
description: "Duration of transition animations in seconds."
}
RowLayout {
spacing: Style.marginL * scaling
NSlider {
Layout.fillWidth: true
from: 0.0
to: 1.0
value: Settings.data.wallpaper.transitionEdgeSmoothness
onMoved: Settings.data.wallpaper.transitionEdgeSmoothness = value
cutoutColor: Color.mSurface
}
NText {
text: Math.round(Settings.data.wallpaper.transitionEdgeSmoothness * 100) + "%"
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
}
}
}
}
// Reusable component for interval preset chips