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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
|
import QtQuick
import Quickshell
import Quickshell.Io
import qs.Common
import qs.Services
import qs.Widgets
FloatingWindow {
id: root
property bool disablePopupTransparency: true
property int currentPage: 0
readonly property int totalPages: 3
readonly property var pageComponents: [welcomePage, doctorPage, completePage]
property var cheatsheetData: ({})
property bool cheatsheetLoaded: false
readonly property int modalWidth: 720
readonly property int modalHeight: screen ? Math.min(760, screen.height - 80) : 760
signal greeterCompleted
Component.onCompleted: Qt.callLater(loadCheatsheet)
function loadCheatsheet() {
const provider = KeybindsService.cheatsheetProvider;
if (KeybindsService.cheatsheetAvailable && provider && !cheatsheetLoaded) {
cheatsheetProcess.command = ["dms", "keybinds", "show", provider];
cheatsheetProcess.running = true;
}
}
Connections {
target: KeybindsService
function onCheatsheetAvailableChanged() {
if (KeybindsService.cheatsheetAvailable && !root.cheatsheetLoaded)
loadCheatsheet();
}
}
function getKeybind(actionPattern) {
if (!cheatsheetLoaded || !cheatsheetData.binds)
return "";
for (const category in cheatsheetData.binds) {
const binds = cheatsheetData.binds[category];
for (let i = 0; i < binds.length; i++) {
const bind = binds[i];
if (bind.action && bind.action.includes(actionPattern))
return bind.key || "";
}
}
return "";
}
function show() {
currentPage = FirstLaunchService.requestedStartPage || 0;
visible = true;
}
function showAtPage(page) {
currentPage = page;
visible = true;
}
function nextPage() {
if (currentPage < totalPages - 1)
currentPage++;
}
function prevPage() {
if (currentPage > 0)
currentPage--;
}
function finish() {
FirstLaunchService.markFirstLaunchComplete();
greeterCompleted();
visible = false;
}
function skip() {
FirstLaunchService.markFirstLaunchComplete();
greeterCompleted();
visible = false;
}
objectName: "greeterModal"
title: I18n.tr("Welcome", "greeter modal window title")
minimumSize: Qt.size(modalWidth, modalHeight)
maximumSize: Qt.size(modalWidth, modalHeight)
color: Theme.surfaceContainer
visible: false
Process {
id: cheatsheetProcess
running: false
stdout: StdioCollector {
onStreamFinished: {
const trimmed = text.trim();
if (trimmed.length === 0)
return;
try {
root.cheatsheetData = JSON.parse(trimmed);
root.cheatsheetLoaded = true;
} catch (e) {
console.warn("Greeter: Failed to parse cheatsheet:", e);
}
}
}
}
FocusScope {
id: contentFocusScope
anchors.fill: parent
focus: true
Keys.onEscapePressed: event => {
root.skip();
event.accepted = true;
}
Keys.onPressed: event => {
switch (event.key) {
case Qt.Key_Return:
case Qt.Key_Enter:
if (root.currentPage < root.totalPages - 1)
root.nextPage();
else
root.finish();
event.accepted = true;
break;
case Qt.Key_Left:
if (root.currentPage > 0)
root.prevPage();
event.accepted = true;
break;
case Qt.Key_Right:
if (root.currentPage < root.totalPages - 1)
root.nextPage();
event.accepted = true;
break;
}
}
MouseArea {
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
height: headerRow.height + Theme.spacingM
onPressed: windowControls.tryStartMove()
onDoubleClicked: windowControls.tryToggleMaximize()
}
Item {
id: headerRow
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
anchors.margins: Theme.spacingM
height: Math.round(Theme.fontSizeMedium * 2.85)
Rectangle {
id: pageIndicatorContainer
readonly property real indicatorHeight: Math.round(Theme.fontSizeMedium * 2)
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
width: pageIndicatorRow.width + Theme.spacingM * 2
height: indicatorHeight
radius: indicatorHeight / 2
color: Theme.surfaceContainerHigh
Row {
id: pageIndicatorRow
anchors.centerIn: parent
spacing: Theme.spacingS
Repeater {
model: root.totalPages
Rectangle {
required property int index
property bool isActive: index === root.currentPage
readonly property real dotSize: Math.round(Theme.spacingS * 1.3)
width: isActive ? dotSize * 3 : dotSize
height: dotSize
radius: dotSize / 2
color: isActive ? Theme.primary : Theme.surfaceTextAlpha
anchors.verticalCenter: parent.verticalCenter
Behavior on width {
NumberAnimation {
duration: Theme.shortDuration
easing.type: Theme.emphasizedEasing
}
}
Behavior on color {
ColorAnimation {
duration: Theme.shortDuration
}
}
}
}
}
}
Row {
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
spacing: Theme.spacingXS
DankActionButton {
visible: windowControls.supported && windowControls.canMaximize
iconName: root.maximized ? "fullscreen_exit" : "fullscreen"
iconSize: Theme.iconSize - 4
iconColor: Theme.surfaceText
onClicked: windowControls.tryToggleMaximize()
}
DankActionButton {
iconName: "close"
iconSize: Theme.iconSize - 4
iconColor: Theme.surfaceText
onClicked: root.skip()
DankTooltip {
text: I18n.tr("Skip setup", "greeter skip button tooltip")
}
}
}
}
Item {
anchors.left: parent.left
anchors.right: parent.right
anchors.top: headerRow.bottom
anchors.bottom: footerRow.top
anchors.topMargin: Theme.spacingS
Loader {
id: pageLoader
anchors.fill: parent
sourceComponent: root.pageComponents[root.currentPage]
property var greeterRoot: root
}
}
Rectangle {
id: footerRow
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
height: Math.round(Theme.fontSizeMedium * 4.5)
color: Theme.surfaceContainerHigh
Rectangle {
anchors.top: parent.top
width: parent.width
height: 1
color: Theme.outlineMedium
opacity: 0.5
}
Row {
anchors.right: parent.right
anchors.rightMargin: Theme.spacingL
anchors.verticalCenter: parent.verticalCenter
spacing: Theme.spacingM
DankButton {
visible: root.currentPage < root.totalPages - 1
text: I18n.tr("Skip", "greeter skip button")
backgroundColor: "transparent"
textColor: Theme.surfaceVariantText
onClicked: root.skip()
}
DankButton {
visible: root.currentPage > 0
text: I18n.tr("Back", "greeter back button")
iconName: "arrow_back"
backgroundColor: Theme.surfaceContainerHighest
textColor: Theme.surfaceText
onClicked: root.prevPage()
}
DankButton {
visible: root.currentPage < root.totalPages - 1
enabled: !(root.currentPage === 1 && pageLoader.item && pageLoader.item.isRunning)
text: root.currentPage === 0 ? I18n.tr("Get Started", "greeter first page button") : I18n.tr("Next", "greeter next button")
iconName: "arrow_forward"
backgroundColor: Theme.primary
textColor: Theme.primaryText
onClicked: root.nextPage()
}
DankButton {
visible: root.currentPage === root.totalPages - 1
text: I18n.tr("Finish", "greeter finish button")
iconName: "check"
backgroundColor: Theme.primary
textColor: Theme.primaryText
onClicked: root.finish()
}
}
}
}
FloatingWindowControls {
id: windowControls
targetWindow: root
}
Component {
id: welcomePage
GreeterWelcomePage {}
}
Component {
id: doctorPage
GreeterDoctorPage {}
}
Component {
id: completePage
GreeterCompletePage {}
}
}
|