aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/appearance/Transitions.qml
blob: e28718c09181b9754e3a83d6d20d28ca4845b456 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
//
// 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;
    }
}