summaryrefslogtreecommitdiff
path: root/modules/bar/Bar.qml
blob: 37d26179d093d423059e9aa556e094600ceda508 (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
import "root:/widgets"
import "root:/config"
import Quickshell
import QtQuick

Variants {
    model: Quickshell.screens

    StyledWindow {
        id: win

        required property ShellScreen modelData

        screen: modelData
        name: "bar"

        width: BarConfig.vertical ? BarConfig.sizes.totalHeight : -1
        height: BarConfig.vertical ? -1 : BarConfig.sizes.totalHeight

        anchors.top: true
        anchors.left: true

        Component.onCompleted: {
            if (BarConfig.vertical)
                win.anchors.bottom = true;
            else
                win.anchors.right = true;
        }

        Connections {
            target: BarConfig

            function onVerticalChanged(): void {
                win.visible = false;
                if (BarConfig.vertical) {
                    win.anchors.right = false;
                    win.anchors.bottom = true;
                } else {
                    win.anchors.bottom = false;
                    win.anchors.right = true;
                }
                win.visible = true;
            }
        }

        Preset {
            presetName: "pills"
            sourceComponent: Pills {}
        }

        Preset {
            presetName: "panel"
            sourceComponent: Panel {}
        }
    }

    component Preset: Loader {
        id: loader

        required property string presetName

        anchors.fill: parent
        asynchronous: true
        active: false
        opacity: 0

        states: State {
            name: "visible"
            when: BarConfig.preset.name === loader.presetName

            PropertyChanges {
                loader.opacity: 1
                loader.active: true
            }
        }

        transitions: [
            Transition {
                from: ""
                to: "visible"

                SequentialAnimation {
                    PropertyAction {}
                    NumberAnimation {
                        property: "opacity"
                        duration: Appearance.anim.durations.large
                        easing.type: Easing.BezierSpline
                        easing.bezierCurve: Appearance.anim.curves.standard
                    }
                }
            },
            Transition {
                from: "visible"
                to: ""

                SequentialAnimation {
                    NumberAnimation {
                        property: "opacity"
                        duration: Appearance.anim.durations.large
                        easing.type: Easing.BezierSpline
                        easing.bezierCurve: Appearance.anim.curves.standard
                    }
                    PropertyAction {}
                }
            }
        ]

        Connections {
            target: BarConfig

            function onVerticalChanged(): void {
                if (loader.state === "visible") {
                    loader.active = false;
                    loader.active = true;
                }
            }
        }
    }
}