aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/appearance/TransitionsTab.qml
blob: 5da88f21e3897abafb9599bcdb6d362c6b63febf (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// 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.

import QtQuick
import "../.."

Item {
    id: tab
    implicitHeight: col.implicitHeight

    readonly property int activeWidth: 70
    readonly property int randomWidth: 90

    // What the monitor shows: the last one previewed, or else the choice.
    property string previewed: ""
    readonly property string staged: previewed !== "" ? previewed
        : Transitions.draftPick !== "random" ? Transitions.draftPick
        : Transitions.draftPool[0] ?? "burn"
    property real progress: 0
    property point origin: Qt.point(0.5, 0.5)

    function play(name) {
        previewed = name;
        origin = Qt.point(Math.random(), Math.random());
        anim.restart();
    }

    NumberAnimation {
        id: anim
        target: tab
        property: "progress"
        from: 0
        to: 1
        duration: Transitions.duration
        // ponytail: back on the old picture with a cut.
        onFinished: tab.progress = 0
    }

    Column {
        id: col
        width: parent.width
        spacing: 14

        MockScreen {
            anchors.horizontalCenter: parent.horizontalCenter
            panelWidth: Math.min(col.width, 640)
            panelHeight: Math.round(panelWidth * 1080 / 2560)

            TransitionView {
                anchors.fill: parent
                name: tab.staged
                progress: tab.progress
                origin: tab.origin
            }
        }

        Text {
            width: col.width
            horizontalAlignment: Text.AlignHCenter
            wrapMode: Text.Wrap
            text: (Transitions.all.find(t => t.name === tab.staged) ?? { label: "" }).label
                + ". Click a line to play it here; Active is what wallpaper changes use."
            color: Theme.overlay
            font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
        }

        Column {
            width: col.width
            spacing: 2

            Item {
                width: parent.width
                height: 22

                Text {
                    anchors { left: parent.left; leftMargin: 6; verticalCenter: parent.verticalCenter }
                    text: "Transition"
                    color: Theme.overlay
                    font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
                }
                Text {
                    id: randomHead
                    anchors { right: parent.right; verticalCenter: parent.verticalCenter }
                    width: tab.randomWidth
                    horizontalAlignment: Text.AlignHCenter
                    text: "In Random"
                    color: Theme.overlay
                    font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
                }
                Text {
                    anchors { right: randomHead.left; verticalCenter: parent.verticalCenter }
                    width: tab.activeWidth
                    horizontalAlignment: Text.AlignHCenter
                    text: "Active"
                    color: Theme.overlay
                    font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
                }
            }

            Repeater {
                model: Transitions.all.concat([{ name: "random", label: "Random" }])

                TransitionRow {
                    required property var modelData
                    width: parent.width
                    name: modelData.name
                    label: modelData.label
                    activeWidth: tab.activeWidth
                    randomWidth: tab.randomWidth
                    onPreview: tab.play(name)
                    onActivated: if (!random) tab.play(name)
                }
            }
        }
    }
}