From df12ed91675a64afd0b0248d2487e9a94d860830 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 6 Nov 2026 17:42:27 +0100 Subject: wallpaper: a singleton for the chosen transition Co-Authored-By: Claude Opus 5.5 --- desktop/modules/appearance/Transitions.qml | 63 ++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 desktop/modules/appearance/Transitions.qml (limited to 'desktop/modules') diff --git a/desktop/modules/appearance/Transitions.qml b/desktop/modules/appearance/Transitions.qml new file mode 100644 index 0000000..e28718c --- /dev/null +++ b/desktop/modules/appearance/Transitions.qml @@ -0,0 +1,63 @@ +// Copyright (C) 2026 Danilo M. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +pragma Singleton + +import Quickshell +import QtQuick +import "../.." +import "TransitionPick.js" as TransitionPick + +// Which transition covers a wallpaper change. The page edits the draft, Apply +// saves it, and each run asks next() once, so both screens play the same one. +// See the spec, docs/superpowers/specs/2026-11-06-wallpaper-transitions-design.md. +Singleton { + id: root + + readonly property var all: [ + { name: "burn", label: "Burn" }, + { name: "ink", label: "Ink" }, + { name: "shatter", label: "Shatter" }, + { name: "ripple", label: "Ripple" }, + { name: "melt", label: "Melt" }, + { name: "blinds", label: "Blinds" }, + { name: "crosswarp", label: "Cross-warp" }, + ] + readonly property var names: all.map(t => t.name) + readonly property int duration: 3500 + + readonly property var saved: TransitionPick.clean(Prefs.wallTransition, names) + property string draftPick: saved.pick + property var draftPool: saved.pool + onSavedChanged: reset() + + readonly property bool dirty: draftPick !== saved.pick + || JSON.stringify(draftPool) !== JSON.stringify(saved.pool) + readonly property bool valid: draftPick !== "random" || draftPool.length > 0 + + function toggle(name) { + const on = draftPool.indexOf(name) >= 0; + draftPool = names.filter(n => n === name ? !on : draftPool.indexOf(n) >= 0); + } + function reset() { + draftPick = saved.pick; + draftPool = saved.pool; + } + function apply() { + if (valid) Prefs.setWallTransition({ pick: draftPick, pool: draftPool }); + } + + property string last: "" + function next() { + last = TransitionPick.choose(saved.pick, saved.pool, last); + return last; + } +} -- cgit v1.2.3