Repository navigation
Expand file tree
/
Copy pathClockworkFullscreenBreak.qml
More file actions
193 lines (169 loc) · 6.58 KB
/
Copy pathClockworkFullscreenBreak.qml
File metadata and controls
193 lines (169 loc) · 6.58 KB
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
183
184
185
186
187
188
189
190
191
192
193
import QtQuick
import Quickshell
import Quickshell.Wayland
import qs.Common
import qs.Widgets
import "." as ClockworkCore
PanelWindow {
id: root
// =========================================================================
// Properties
// =========================================================================
property var targetScreen: null
property bool active: false
// The state singleton already trims the message and substitutes the default when it is empty.
readonly property string message: ClockworkCore.ClockworkState.countdownMessage
// =========================================================================
// Signals
// =========================================================================
signal closeRequested()
signal toggleRequested()
signal resetRequested()
// =========================================================================
// Window Configuration
// =========================================================================
screen: targetScreen
visible: active
color: "transparent"
WlrLayershell.namespace: "dms:dankClockwork-break"
WlrLayershell.layer: WlrLayer.Overlay
WlrLayershell.exclusiveZone: -1
WlrLayershell.keyboardFocus: active ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None
anchors {
left: true
right: true
top: true
bottom: true
}
onVisibleChanged: {
if (visible) {
Qt.callLater(() => {
keyCatcher.forceActiveFocus();
});
}
}
// Material 3 translucent background
Rectangle {
id: backdrop
anchors.fill: parent
color: Theme.withAlpha(Theme.surface, 0.94)
MouseArea {
anchors.fill: parent
onClicked: keyCatcher.forceActiveFocus()
}
}
FocusScope {
id: keyCatcher
anchors.fill: parent
focus: true
Keys.onPressed: event => {
if (event.modifiers & (Qt.ControlModifier | Qt.AltModifier | Qt.MetaModifier)) return;
if (event.key === Qt.Key_Escape) {
root.closeRequested();
} else if (event.key === Qt.Key_Space || event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
root.toggleRequested();
} else if (event.key === Qt.Key_R) {
root.resetRequested();
} else {
return;
}
event.accepted = true;
}
// Top right close button
DankActionButton {
anchors.top: parent.top
anchors.right: parent.right
anchors.margins: Theme.spacingXL
iconName: "close"
iconSize: Theme.iconSize
iconColor: Theme.surfaceText
tooltipText: I18n.trFor("dankClockwork", "Close (Esc)")
onClicked: root.closeRequested()
}
// Centered Content
Column {
anchors.centerIn: parent
spacing: Theme.spacingXL
width: Math.min(parent.width - Theme.spacingXL * 4, Theme.fontSizeXLarge * 30)
DankIcon {
anchors.horizontalCenter: parent.horizontalCenter
name: "emoji_food_beverage"
size: Theme.iconSizeLarge * 2
color: Theme.primary
}
StyledText {
anchors.horizontalCenter: parent.horizontalCenter
text: root.message
font.pixelSize: Theme.fontSizeMedium * 2
font.weight: Font.Bold
color: Theme.surfaceText
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
width: parent.width
}
StyledText {
anchors.horizontalCenter: parent.horizontalCenter
text: ClockworkCore.ClockworkState.displayText
font.pixelSize: Theme.fontSizeXLarge * 3.6
font.weight: Font.Bold
font.family: Theme.monoFontFamily
color: Theme.primary
horizontalAlignment: Text.AlignHCenter
}
// Progress bar
Item {
anchors.horizontalCenter: parent.horizontalCenter
width: Math.min(parent.width, Theme.fontSizeMedium * 30)
height: Theme.spacingXS * 1.5
visible: ClockworkCore.ClockworkState.progress > 0
Rectangle {
anchors.fill: parent
radius: height / 2
color: Theme.withAlpha(Theme.surfaceVariantText, 0.2)
}
Rectangle {
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: parent.bottom
width: Math.max(height, parent.width * Math.max(0, Math.min(1, ClockworkCore.ClockworkState.progress)))
radius: height / 2
color: Theme.primary
Behavior on width {
NumberAnimation {
duration: 100
easing.type: Easing.OutCubic
}
}
}
}
// Quick actions
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: Theme.spacingM
DankButton {
text: ClockworkCore.ClockworkState.running
? I18n.trFor("dankClockwork", "Pause")
: (ClockworkCore.ClockworkState.completed ? I18n.trFor("dankClockwork", "Restart") : I18n.trFor("dankClockwork", "Resume"))
iconName: ClockworkCore.ClockworkState.running ? "pause" : "play_arrow"
backgroundColor: Theme.primary
textColor: Theme.primaryText
onClicked: root.toggleRequested()
}
DankButton {
text: I18n.trFor("dankClockwork", "Reset")
iconName: "restart_alt"
backgroundColor: Theme.surfaceContainerHighest
textColor: Theme.surfaceText
onClicked: root.resetRequested()
}
DankButton {
text: I18n.trFor("dankClockwork", "Close")
iconName: "close"
backgroundColor: Theme.surfaceContainerHighest
textColor: Theme.surfaceText
onClicked: root.closeRequested()
}
}
}
}
}