-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScreenkeyOverlay.qml
More file actions
362 lines (315 loc) · 15.9 KB
/
Copy pathScreenkeyOverlay.qml
File metadata and controls
362 lines (315 loc) · 15.9 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
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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
import QtQuick
import Quickshell
import Quickshell.Wayland
import qs.Common
import qs.Widgets
import "./dms-common"
PanelWindow {
id: overlayWindow
property var daemon: null
readonly property bool isCentered: daemon ? (daemon.position === "bottom_center" || daemon.position === "top_center") : false
readonly property bool isMouseClick: daemon ? (daemon.displayText === "LMB Click" || daemon.displayText === "RMB Click" || daemon.displayText === "MMB Click") : false
readonly property bool isOverlayVisible: daemon && (daemon.displayText !== "" || (daemon.showModifierStatus && (daemon.ctrlActive || daemon.altActive || daemon.shiftActive || daemon.superActive)))
// Dynamic positioning based on settings (e.g. "bottom_center", "top_left", etc.)
anchors.bottom: daemon ? daemon.position.includes("bottom") : false
anchors.top: daemon ? daemon.position.includes("top") : false
anchors.left: isCentered || (daemon ? daemon.position.includes("left") : false)
anchors.right: isCentered || (daemon ? daemon.position.includes("right") : false)
// Wayland specific window properties
WlrLayershell.layer: WlrLayershell.Overlay
WlrLayershell.keyboardFocus: WlrLayershell.None // Absolutely critical: do not steal focus
WlrLayershell.exclusiveZone: -1
exclusionMode: ExclusionMode.Ignore
WlrLayershell.margins {
left: daemon ? daemon.marginSize : 24
right: daemon ? daemon.marginSize : 24
top: daemon ? daemon.marginSize : 24
bottom: daemon ? daemon.marginSize : 24
}
// Dummy text to calculate a unified height based on current font size
StyledText {
id: dummyText
visible: false
font.pixelSize: daemon ? daemon.fontSize : 24
font.bold: true
text: "A"
}
readonly property real unifiedHeight: dummyText.implicitHeight + Theme.spacingXS * 2
function resolveColor(mode, custom) {
if (mode === "custom") return custom ? Qt.color(custom) : Theme.primary;
if (mode === "default") return Theme.primary;
return Theme.roleColor(mode);
}
function getOverlayKeyText(keyText) {
if (!daemon || !daemon.macSymbols) return keyText;
const macMap = {
"Ctrl": "⌃",
"Alt": "⌥",
"Shift": "⇧",
"Super": "⌘",
"Enter": "⏎",
"Backspace": "⌫",
"Tab": "⇥",
"Esc": "⎋",
"Space": "␣"
};
return macMap[keyText] || keyText;
}
readonly property color resolvedTextColor: daemon ? overlayWindow.resolveColor(daemon.textColorMode, daemon.textColorCustom) : Theme.primary
readonly property color resolvedKeycapTextColor: daemon ? overlayWindow.resolveColor(daemon.keycapTextColorMode, daemon.keycapTextColorCustom) : Theme.primary
readonly property bool roundedKeycaps: daemon ? daemon.roundedKeycaps : true
readonly property color resolvedBgColor: {
if (!daemon) return Theme.withAlpha(Theme.surface, 0.85);
if (daemon.bgColorMode === "default") return Theme.withAlpha(Theme.surface, 0.85);
if (daemon.bgColorMode === "custom") return Qt.color(daemon.bgColorCustom);
return Theme.roleColor(daemon.bgColorMode);
}
// Match window size to container size
implicitWidth: isCentered ? (screen ? screen.width : 1920) : cardContainer.width
implicitHeight: cardContainer.height
color: "transparent"
StyledRect {
id: cardContainer
// Match contents with padding
width: contentColumn.implicitWidth + Theme.spacingXL * 2
height: contentColumn.implicitHeight + Theme.spacingL * 2
anchors.top: (daemon && daemon.position.includes("top")) ? parent.top : undefined
anchors.bottom: (daemon && daemon.position.includes("bottom")) ? parent.bottom : undefined
anchors.left: (daemon && daemon.position.includes("left")) ? parent.left : undefined
anchors.right: (daemon && daemon.position.includes("right")) ? parent.right : undefined
anchors.horizontalCenter: isCentered ? parent.horizontalCenter : undefined
// Smooth scaling when content changes
Behavior on width { NumberAnimation { duration: 100 } }
Behavior on height { NumberAnimation { duration: 100 } }
radius: Theme.cornerRadius
color: overlayWindow.resolvedBgColor
border.color: Theme.withAlpha(Theme.outline, 0.15)
border.width: 1
// Display with dynamic animations based on settings
opacity: overlayWindow.isOverlayVisible ? (daemon ? daemon.overlayOpacity / 100.0 : 0.9) : 0.0
scale: overlayWindow.isOverlayVisible ? 1.0 : (daemon && daemon.animationType === "zoom" ? 0.9 : 1.0)
property real yOffset: {
if (!daemon || daemon.animationType !== "slide") return 0;
const isVisible = overlayWindow.isOverlayVisible;
if (isVisible) return 0;
const isTop = daemon.position.includes("top");
return isTop ? -20 : 20;
}
transform: Translate {
y: cardContainer.yOffset
}
Behavior on opacity {
enabled: daemon && daemon.animationType !== "none"
OpacityAnimator { duration: 150 }
}
Behavior on scale {
enabled: daemon && daemon.animationType === "zoom"
NumberAnimation { duration: 150; easing.type: Easing.OutBack }
}
Behavior on yOffset {
enabled: daemon && daemon.animationType === "slide"
NumberAnimation { duration: 150; easing.type: Easing.OutCubic }
}
Column {
id: contentColumn
anchors.centerIn: parent
spacing: Theme.spacingS
Repeater {
model: daemon ? daemon.historyList : []
delegate: Row {
spacing: (daemon && daemon.macSymbols) ? Theme.spacingXS : Theme.spacingS
anchors.horizontalCenter: isCentered ? parent.horizontalCenter : undefined
readonly property string lineText: modelData.text
readonly property bool isCombo: modelData.isCombo
readonly property bool isMouseClick: lineText === "LMB Click" || lineText === "RMB Click" || lineText === "MMB Click"
readonly property var keysList: isCombo ? lineText.split(" + ") : []
// Render keycaps for combinations
Repeater {
model: isCombo ? keysList : 0
delegate: Row {
spacing: (daemon && daemon.macSymbols) ? Theme.spacingXS : Theme.spacingS
anchors.verticalCenter: parent.verticalCenter
StyledRect {
anchors.verticalCenter: parent.verticalCenter
width: keycapText.implicitWidth + Theme.spacingM * 2
height: overlayWindow.unifiedHeight
radius: overlayWindow.roundedKeycaps ? Theme.cornerRadius / 2 : 0
color: Theme.surfaceContainerHighest
border.color: Theme.withAlpha(Theme.outline, 0.25)
border.width: 1
StyledText {
id: keycapText
anchors.centerIn: parent
font.pixelSize: daemon ? daemon.fontSize : 24
font.bold: true
color: overlayWindow.resolvedKeycapTextColor
text: overlayWindow.getOverlayKeyText(modelData)
}
}
// Render separator unless it is the last item
StyledText {
visible: index < keysList.length - 1
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: daemon ? daemon.fontSize : 24
font.bold: true
color: Theme.outline
text: daemon ? daemon.customSeparator : "+"
}
}
}
// Render mouse click indicator
Row {
id: mouseIcon
visible: isMouseClick
anchors.verticalCenter: parent.verticalCenter
spacing: Theme.spacingS
height: overlayWindow.unifiedHeight
readonly property bool isLeft: lineText === "LMB Click"
readonly property bool isRight: lineText === "RMB Click"
readonly property bool isMiddle: lineText === "MMB Click"
Rectangle {
width: 14
height: 22
radius: 7
color: "transparent"
border.color: Theme.outline
border.width: 1.5
anchors.verticalCenter: parent.verticalCenter
Rectangle {
width: 7
height: 11
radius: 3
color: mouseIcon.isLeft ? Theme.primary : "transparent"
border.color: Theme.outline
border.width: 1
anchors.left: parent.left
anchors.top: parent.top
}
Rectangle {
width: 7
height: 11
radius: 3
color: mouseIcon.isRight ? Theme.primary : "transparent"
border.color: Theme.outline
border.width: 1
anchors.right: parent.right
anchors.top: parent.top
}
Rectangle {
width: 2
height: 5
radius: 1
color: mouseIcon.isMiddle ? Theme.primary : Theme.outline
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 3
}
}
StyledText {
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: daemon ? daemon.fontSize : 24
font.bold: true
color: overlayWindow.resolvedKeycapTextColor
text: mouseIcon.isLeft ? "L" : (mouseIcon.isRight ? "R" : "M")
}
}
// Render standard text for normal typing
StyledText {
visible: !isCombo && !isMouseClick
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: daemon ? daemon.fontSize : 24
font.bold: true
color: overlayWindow.resolvedTextColor
text: overlayWindow.getOverlayKeyText(lineText)
height: overlayWindow.unifiedHeight
verticalAlignment: Text.AlignVCenter
}
}
}
// Divider between history and active modifiers
Separator {
id: modifierDivider
visible: daemon && daemon.showModifierStatus && (daemon.ctrlActive || daemon.altActive || daemon.shiftActive || daemon.superActive) && daemon.historyList.length > 0
}
// Real-time held modifiers status bar
Row {
id: modifierStatusRow
visible: daemon && daemon.showModifierStatus && (daemon.ctrlActive || daemon.altActive || daemon.shiftActive || daemon.superActive)
spacing: Theme.spacingS
anchors.horizontalCenter: isCentered ? parent.horizontalCenter : undefined
// Ctrl Pill
StyledRect {
visible: daemon && daemon.ctrlActive
height: overlayWindow.unifiedHeight
width: ctrlText.implicitWidth + Theme.spacingM * 2
radius: overlayWindow.roundedKeycaps ? height / 2 : 0
color: Theme.primaryContainer
border.color: Theme.withAlpha(Theme.outline, 0.15)
border.width: 1
StyledText {
id: ctrlText
anchors.centerIn: parent
font.pixelSize: daemon ? daemon.fontSize - 4 : 20
font.bold: true
color: Theme.onPrimary
text: overlayWindow.getOverlayKeyText("Ctrl")
}
}
// Alt Pill
StyledRect {
visible: daemon && daemon.altActive
height: overlayWindow.unifiedHeight
width: altText.implicitWidth + Theme.spacingM * 2
radius: overlayWindow.roundedKeycaps ? height / 2 : 0
color: Theme.primaryContainer
border.color: Theme.withAlpha(Theme.outline, 0.15)
border.width: 1
StyledText {
id: altText
anchors.centerIn: parent
font.pixelSize: daemon ? daemon.fontSize - 4 : 20
font.bold: true
color: Theme.onPrimary
text: overlayWindow.getOverlayKeyText("Alt")
}
}
// Shift Pill
StyledRect {
visible: daemon && daemon.shiftActive
height: overlayWindow.unifiedHeight
width: shiftText.implicitWidth + Theme.spacingM * 2
radius: overlayWindow.roundedKeycaps ? height / 2 : 0
color: Theme.primaryContainer
border.color: Theme.withAlpha(Theme.outline, 0.15)
border.width: 1
StyledText {
id: shiftText
anchors.centerIn: parent
font.pixelSize: daemon ? daemon.fontSize - 4 : 20
font.bold: true
color: Theme.onPrimary
text: overlayWindow.getOverlayKeyText("Shift")
}
}
// Super Pill
StyledRect {
visible: daemon && daemon.superActive
height: overlayWindow.unifiedHeight
width: superText.implicitWidth + Theme.spacingM * 2
radius: overlayWindow.roundedKeycaps ? height / 2 : 0
color: Theme.primaryContainer
border.color: Theme.withAlpha(Theme.outline, 0.15)
border.width: 1
StyledText {
id: superText
anchors.centerIn: parent
font.pixelSize: daemon ? daemon.fontSize - 4 : 20
font.bold: true
color: Theme.onPrimary
text: overlayWindow.getOverlayKeyText("Super")
}
}
}
}
}
}