summaryrefslogtreecommitdiff
path: root/modules/launcher/Launcher.qml
blob: 8313721052bb3b537d4aab815785570181d214d4 (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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
import "root:/widgets"
import "root:/config"
import Quickshell
import QtQuick
import QtQuick.Shapes
import Qt5Compat.GraphicalEffects

Scope {
    id: root

    property bool bindInterrupted
    property bool launcherVisible

    LazyLoader {
        id: loader

        loading: true

        StyledWindow {
            id: win

            name: "launcher"

            width: content.width + bg.rounding * 2
            height: content.implicitHeight

            anchors.bottom: true

            Shape {
                id: bg

                readonly property int rounding: Appearance.rounding.large
                readonly property int roundingY: Math.min(rounding, wrapper.height / 2)
                readonly property real wrapperHeight: wrapper.height - 1 // Pixel issues :sob:

                anchors.left: parent.left
                anchors.right: parent.right
                anchors.bottom: parent.bottom

                preferredRendererType: Shape.CurveRenderer
                opacity: Appearance.transparency.enabled ? Appearance.transparency.base : 1

                ShapePath {
                    strokeWidth: -1
                    fillColor: Appearance.colours.m3surface

                    startY: bg.wrapperHeight

                    PathArc {
                        relativeX: bg.rounding
                        relativeY: -bg.roundingY
                        radiusX: bg.rounding
                        radiusY: bg.roundingY
                        direction: PathArc.Counterclockwise
                    }
                    PathLine {
                        relativeX: 0
                        y: bg.roundingY
                    }
                    PathArc {
                        relativeX: bg.rounding
                        relativeY: -bg.roundingY
                        radiusX: bg.rounding
                        radiusY: bg.roundingY
                    }
                    PathLine {
                        x: wrapper.width - bg.rounding * 2
                    }
                    PathArc {
                        relativeX: bg.rounding
                        relativeY: bg.roundingY
                        radiusX: bg.rounding
                        radiusY: bg.roundingY
                    }
                    PathLine {
                        relativeX: 0
                        y: bg.wrapperHeight - bg.roundingY
                    }
                    PathArc {
                        relativeX: bg.rounding
                        relativeY: bg.roundingY
                        radiusX: bg.rounding
                        radiusY: bg.roundingY
                        direction: PathArc.Counterclockwise
                    }
                }
            }

            Item {
                id: wrapper

                anchors.left: parent.left
                anchors.right: parent.right
                anchors.bottom: parent.bottom

                height: 0
                visible: false

                clip: true

                states: State {
                    name: "visible"
                    when: root.launcherVisible

                    PropertyChanges {
                        wrapper.height: content.height
                        wrapper.visible: true
                    }
                }

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

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

                        SequentialAnimation {
                            NumberAnimation {
                                target: wrapper
                                property: "height"
                                duration: Appearance.anim.durations.extraLarge
                                easing.type: Easing.BezierSpline
                                easing.bezierCurve: Appearance.anim.curves.emphasizedDecel
                            }
                            PropertyAction {
                                target: wrapper
                                property: "visible"
                            }
                        }
                    }
                ]

                PaddedRect {
                    id: content

                    width: LauncherConfig.sizes.width
                    padding: Appearance.padding.large
                    anchors.horizontalCenter: parent.horizontalCenter

                    StyledText {
                        text: "Launcher"
                        font.pointSize: 80
                    }
                }
            }
        }
    }

    CustomShortcut {
        name: "launcher"
        description: "Toggle launcher"
        onPressed: root.bindInterrupted = false
        onReleased: {
            if (!root.bindInterrupted)
                root.launcherVisible = !root.launcherVisible;
            root.bindInterrupted = false;
        }
    }

    CustomShortcut {
        name: "launcherInterrupt"
        description: "Interrupt launcher keybind"
        onPressed: root.bindInterrupted = true
    }
}