-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLauncherPlease.qml
More file actions
779 lines (696 loc) · 29.9 KB
/
Copy pathLauncherPlease.qml
File metadata and controls
779 lines (696 loc) · 29.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
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
import QtQuick
import Quickshell
import Quickshell.Io
import Quickshell.Wayland
import qs.Commons
import qs.Ui
import "ChordKey.js" as ChordKey
import "GridLayout.js" as GridLayout
import "LauncherConfig.js" as LauncherConfig
import "LauncherModel.js" as LauncherModel
import "LauncherUsage.js" as LauncherUsage
Item {
id: root
property var shell: null
property var manifest: null
property bool opened: false
property string filterText: ""
property int cursorIndex: 0
property bool cursorActive: true
property int bounceIndex: -1
property real fadeOpacity: 1
readonly property int fadeMs: 260
property var rawApps: []
property var apps: []
property var layout: ({ rows: [], count: 0, apps: [] })
property var cfg: LauncherConfig.merge("{}", "{}")
property string fileConfigRaw: "{}"
property string payloadConfigRaw: "{}"
property string usageRaw: "{}"
property bool chordsCaptured: false
property int gridHeight: 0
readonly property string home: Quickshell.env("HOME")
readonly property string pluginDir: root.home + "/.config/omarchy/plugins/jose.launcherplease"
readonly property string listPath: root.pluginDir + "/list.sh"
readonly property string recordPath: root.pluginDir + "/record.sh"
readonly property string setLayoutPath: root.pluginDir + "/set-layout.sh"
readonly property string usagePath: root.home + "/.local/state/omarchy/launcherplease/usage.json"
property color background: Color.menu.background
property color foreground: Color.menu.text
property color borderColor: Color.menu.border
property color scrim: Color.menu.scrim
property color selectedBackground: Color.menu.selectedBackground
property color selectedText: Color.menu.selectedText
property color accent: Color.accent
property var borderSpec: Border.surfaceSpec("menu", "border", root.borderColor, Math.max(1, Style.space(2)))
readonly property int cornerRadius: Style.cornerRadius
property string fontFamily: Style.font.menuFamily
property int columns: 8
readonly property int cellH: Style.space(92)
readonly property int headerH: Math.max(Style.space(22), Style.font.subtitle + Style.spacing.xs)
readonly property int footerH: Math.max(Style.space(20), Style.font.caption + Style.spacing.sm)
readonly property int contentMargin: Style.spacing.md
readonly property int gridGap: Style.spacing.xs
readonly property int iconH: Style.space(28)
readonly property int keycapH: Style.space(16)
readonly property int keycapFont: Style.font.caption - 1
readonly property real keycapCharW: (Style.font.caption - 1) * 0.6
readonly property int keycapPadX: Style.space(3)
readonly property int keycapGap: Style.space(3)
function iconUrl(icon) {
var value = String(icon || "")
if (!value) return ""
if (value.charAt(0) === "/") return Util.fileUrl(value)
var themed = Quickshell.iconPath(value, true)
return themed && themed.length ? themed : ""
}
function applyConfig() {
root.cfg = LauncherConfig.merge(root.fileConfigRaw, root.payloadConfigRaw)
root.columns = Math.max(1, root.cfg.columns)
}
function rebuild() {
var normalized = LauncherModel.normalizeApps(root.rawApps)
var filtered = []
for (var i = 0; i < normalized.length; i++) {
if (LauncherModel.matchesFilter(normalized[i], root.filterText)) filtered.push(normalized[i])
}
var days = LauncherUsage.prune(LauncherUsage.parseDays(root.usageRaw), LauncherUsage.dayKey(), root.cfg.mostUsedDays)
var arranged = LauncherModel.arrange(filtered, root.cfg, LauncherUsage.scores(days))
root.apps = arranged.apps
root.layout = GridLayout.build(root.apps, root.columns, root.cfg.layout)
if (!root.layout.count) root.cursorIndex = 0
else if (root.cursorIndex >= root.layout.count) root.cursorIndex = root.layout.count - 1
else if (root.cursorIndex < 0) root.cursorIndex = 0
var height = 0
var rows = root.layout.rows || []
for (var r = 0; r < rows.length; r++) {
height += rows[r].type === "banner" ? root.headerH : root.cellH
if (r > 0) height += Style.spacing.xs
}
root.gridHeight = height
}
function onListLoaded(raw) {
try { root.rawApps = JSON.parse(String(raw || "[]")) } catch (e) { root.rawApps = [] }
root.rebuild()
if (root.opened) Qt.callLater(function() { keyCatcher.forceActiveFocus() })
}
function refreshList() {
listProc.running = false
listProc.running = true
}
function setFilter(text) {
root.filterText = text
root.cursorIndex = 0
root.rebuild()
}
function moveCursor(dir) {
var next = GridLayout.move(root.layout, root.cursorIndex, dir)
if (next < 0) return
root.cursorIndex = next
root.cursorActive = true
root.scrollToCursor()
}
function jumpCategory(delta) {
if (root.layout.count === 0) return
var next = GridLayout.categoryJump(root.layout, root.cursorIndex, delta)
root.cursorIndex = next
root.cursorActive = true
root.scrollToCursor()
}
function toggleLayout() {
var next = root.cfg.layout === "roomy" ? "compact" : "roomy"
root.cfg.layout = next
root.rebuild()
setLayoutProc.command = ["bash", root.setLayoutPath, next]
setLayoutProc.running = false
setLayoutProc.running = true
}
function scrollToCursor() {
var row = GridLayout.rowOf(root.layout, root.cursorIndex)
if (row < 0 || !flick) return
var y = 0
var rows = root.layout.rows || []
for (var i = 0; i < row && i < rows.length; i++) {
y += rows[i].type === "banner" ? root.headerH : root.cellH
y += Style.spacing.xs
}
var rowH = (rows[row] && rows[row].type === "banner") ? root.headerH : root.cellH
if (y < flick.contentY) flick.contentY = y
else if (y + rowH > flick.contentY + flick.height) flick.contentY = Math.max(0, y + rowH - flick.height)
}
function appIndexById(id) {
for (var i = 0; i < root.apps.length; i++) {
if (root.apps[i].id === id) return i
}
return -1
}
function open(payloadJson) {
root.payloadConfigRaw = payloadJson || "{}"
root.applyConfig()
root.fadeOpacity = 1
root.opened = true
root.cursorActive = true
root.cursorIndex = 0
root.bounceIndex = -1
root.filterText = ""
root.refreshList()
if (root.cfg.duration > 0) {
autoCloseTimer.interval = root.cfg.duration
autoCloseTimer.restart()
} else {
autoCloseTimer.stop()
}
Qt.callLater(function() { keyCatcher.forceActiveFocus() })
root.startChordCapture()
}
function close() {
root.stopChordCapture()
autoCloseTimer.stop()
root.opened = false
root.chordsCaptured = false
}
function beginFade() {
if (!root.opened) return
autoCloseTimer.stop()
root.fadeOpacity = 0
fadeCloseTimer.restart()
}
function toggle(payloadJson) {
if (root.opened) root.close()
else root.open(payloadJson || "{}")
}
function playBounce(appIndex) {
root.bounceIndex = appIndex
bounceClearTimer.restart()
}
function launchApp(appIndex) {
if (appIndex < 0 || appIndex >= root.apps.length) return
var app = root.apps[appIndex]
var command = app.command
if (!command) return
root.recordUsage(app.id)
root.playBounce(appIndex)
root.execLaunch(command)
}
function confirm() {
if (root.layout.count > 0) root.launchApp(root.cursorIndex)
}
function execLaunch(command) {
if (!command) return
Util.execDetached(command)
root.close()
}
function recordUsage(id) {
if (!id) return
recordProc.command = ["bash", root.recordPath, id, String(root.cfg.mostUsedDays)]
recordProc.running = false
recordProc.running = true
}
function qtKeyFromToken(token) {
var t = String(token || "").toUpperCase()
if (t === "RETURN" || t === "ENTER") return Qt.Key_Return
if (t === "SLASH") return Qt.Key_Slash
if (t === "SPACE") return Qt.Key_Space
if (t === "COMMA") return Qt.Key_Comma
if (t === "PERIOD") return Qt.Key_Period
if (t === "MINUS") return Qt.Key_Minus
if (t === "EQUAL") return Qt.Key_Equal
if (t === "TAB") return Qt.Key_Tab
if (t === "ESCAPE" || t === "ESC") return Qt.Key_Escape
if (t.length === 1) return t.charCodeAt(0)
return -1
}
function eventMatchesChord(event, chord) {
var raw = String(chord || "").toUpperCase()
if (!raw) return false
var wantSuper = raw.indexOf("SUPER") >= 0
var wantShift = raw.indexOf("SHIFT") >= 0
var wantCtrl = raw.indexOf("CTRL") >= 0 || raw.indexOf("CONTROL") >= 0
var wantAlt = raw.indexOf("ALT") >= 0
var mods = event.modifiers
if (wantSuper !== !!(mods & Qt.MetaModifier)) return false
if (wantShift !== !!(mods & Qt.ShiftModifier)) return false
if (wantCtrl !== !!(mods & Qt.ControlModifier)) return false
if (wantAlt !== !!(mods & Qt.AltModifier)) return false
var token = raw
var plus = raw.lastIndexOf(" + ")
if (plus >= 0) token = raw.slice(plus + 3).replace(/^\s+|\s+$/g, "")
var wantKey = root.qtKeyFromToken(token)
if (wantKey < 0) return false
if (event.key === wantKey) return true
if (wantKey === Qt.Key_Return && event.key === Qt.Key_Enter) return true
return false
}
function launchMatchingChord(event) {
for (var i = 0; i < root.apps.length; i++) {
if (root.eventMatchesChord(event, root.apps[i].chord)) {
root.launchApp(i)
return true
}
}
return false
}
function luaCmdLiteral(command) {
return String(command || "").replace(/\\/g, "\\\\").replace(/"/g, '\\"')
}
function chordCaptureScript(bind) {
var lines = []
var apps = LauncherModel.normalizeApps(root.rawApps)
var seen = {}
if (bind) {
for (var i = 0; i < apps.length; i++) {
var chord = apps[i].chord
if (!chord || seen[chord]) continue
seen[chord] = true
lines.push('hyprctl eval \'hl.unbind("' + chord + '")\'')
lines.push('hyprctl eval \'hl.bind("' + chord + '", hl.dsp.exec_cmd("omarchy-shell launcherplease launch ' + apps[i].id + '"), { description = "' + apps[i].label + '" })\'')
}
lines.push('hyprctl eval \'hl.unbind("ESCAPE")\'')
lines.push('hyprctl eval \'hl.bind("ESCAPE", hl.dsp.exec_cmd("omarchy-shell launcherplease close"), { description = "LauncherPlease close" })\'')
} else {
for (var j = 0; j < apps.length; j++) {
var chord2 = apps[j].chord
if (!chord2 || seen[chord2]) continue
seen[chord2] = true
lines.push('hyprctl eval \'hl.unbind("' + chord2 + '")\'')
lines.push('hyprctl eval \'hl.bind("' + chord2 + '", hl.dsp.exec_cmd("' + root.luaCmdLiteral(apps[j].command) + '"), { description = "' + apps[j].label + '" })\'')
}
lines.push('hyprctl eval \'hl.unbind("ESCAPE")\'')
}
return lines.join("\n")
}
function startChordCapture() {
if (!root.cfg.captureChords) return
root.chordsCaptured = true
chordProc.command = ["bash", "-c", root.chordCaptureScript(true)]
chordProc.running = false
chordProc.running = true
}
function stopChordCapture() {
if (!root.chordsCaptured) return
root.chordsCaptured = false
chordProc.command = ["bash", "-c", root.chordCaptureScript(false)]
chordProc.running = false
chordProc.running = true
}
IpcHandler {
target: "launcherplease"
function open(payloadJson: string): string { root.open(payloadJson); return "ok" }
function close(): string { root.close(); return "ok" }
function fade(): string { root.beginFade(); return "ok" }
function toggle(payloadJson: string): string { root.toggle(payloadJson); return "ok" }
function state(): string { return root.opened ? "open:" + root.apps.length : "closed" }
function ping(): string { return "ok" }
function refresh(): string { root.refreshList(); return "ok" }
function flash(id: string): string { return "ok" }
function launch(id: string): string {
var idx = root.appIndexById(id)
if (idx >= 0) { root.launchApp(idx); return "ok" }
var apps = LauncherModel.normalizeApps(root.rawApps)
for (var i = 0; i < apps.length; i++) {
if (apps[i].id === id) { root.execLaunch(apps[i].command); return "ok" }
}
return "notfound"
}
}
FileView {
path: root.home + "/.config/omarchy/launcherplease.json"
watchChanges: true
printErrors: false
onLoaded: { root.fileConfigRaw = text() || "{}"; root.applyConfig(); root.rebuild() }
onFileChanged: reload()
onLoadFailed: { root.fileConfigRaw = "{}"; root.applyConfig(); root.rebuild() }
}
FileView {
path: root.usagePath
watchChanges: true
printErrors: false
onLoaded: { root.usageRaw = text() || "{}"; if (root.rawApps.length) root.rebuild() }
onFileChanged: reload()
onLoadFailed: root.usageRaw = "{}"
}
Process {
id: listProc
command: ["bash", root.listPath]
stdout: StdioCollector {
waitForEnd: true
onStreamFinished: root.onListLoaded(text)
}
}
Process { id: chordProc }
Process { id: recordProc }
Process { id: setLayoutProc }
Timer { id: autoCloseTimer; repeat: false; onTriggered: root.beginFade() }
Timer { id: fadeCloseTimer; interval: root.fadeMs; repeat: false; onTriggered: root.close() }
Timer { id: bounceClearTimer; interval: 460; repeat: false; onTriggered: root.bounceIndex = -1 }
Component.onCompleted: {
root.applyConfig()
root.refreshList()
}
PanelWindow {
id: panel
visible: root.opened
anchors { top: true; bottom: true; left: true; right: true }
color: "transparent"
WlrLayershell.namespace: "launcherplease"
WlrLayershell.layer: WlrLayer.Overlay
WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
exclusionMode: ExclusionMode.Ignore
onVisibleChanged: if (visible) Qt.callLater(function() { keyCatcher.forceActiveFocus() })
Rectangle {
anchors.fill: parent
color: root.scrim
opacity: root.fadeOpacity
MouseArea { anchors.fill: parent; onClicked: root.close() }
}
FocusScope {
id: keyCatcher
anchors.fill: parent
opacity: root.fadeOpacity
focus: true
Keys.onPressed: function(event) {
if (event.key === Qt.Key_Escape) {
if (root.filterText) root.setFilter("")
else root.close()
event.accepted = true
return
}
if (root.launchMatchingChord(event)) {
event.accepted = true
return
}
if (event.key === Qt.Key_Tab && (event.modifiers & Qt.ControlModifier)) {
root.toggleLayout()
event.accepted = true
return
}
if (event.key === Qt.Key_Tab) {
root.jumpCategory(event.modifiers & Qt.ShiftModifier ? -1 : 1)
event.accepted = true
return
}
var combo = event.modifiers & (Qt.ControlModifier | Qt.AltModifier | Qt.MetaModifier)
if (combo) {
event.accepted = true
return
}
if (event.key === Qt.Key_Left) {
root.moveCursor("left"); event.accepted = true
} else if (event.key === Qt.Key_Right) {
root.moveCursor("right"); event.accepted = true
} else if (event.key === Qt.Key_Up) {
root.moveCursor("up"); event.accepted = true
} else if (event.key === Qt.Key_Down) {
root.moveCursor("down"); event.accepted = true
} else if (event.key === Qt.Key_PageUp) {
root.moveCursor("up"); event.accepted = true
} else if (event.key === Qt.Key_PageDown) {
root.moveCursor("down"); event.accepted = true
} else if (event.key === Qt.Key_Backspace) {
if (root.filterText) { root.setFilter(root.filterText.slice(0, -1)); event.accepted = true }
} else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
root.confirm(); event.accepted = true
} else if (event.text && event.text.length === 1 && event.text.charCodeAt(0) >= 32 && event.text.charCodeAt(0) !== 127) {
root.setFilter(root.filterText + event.text)
event.accepted = true
}
}
BorderSurface {
id: card
width: Math.min(panel.width * 0.75, panel.width - Style.gapsOut * 4)
height: Math.min(root.headerH + root.footerH + root.gridHeight + root.contentMargin * 2 + Style.spacing.sm * 2,
panel.height - Style.gapsOut * 2)
anchors.centerIn: parent
radius: root.cornerRadius
color: root.background
borderSpec: root.borderSpec
padding: root.contentMargin
clip: true
MouseArea { anchors.fill: parent; onClicked: keyCatcher.forceActiveFocus() }
Column {
id: body
anchors.fill: parent
anchors.topMargin: card.contentTopInset
anchors.rightMargin: card.contentRightInset
anchors.bottomMargin: card.contentBottomInset
anchors.leftMargin: card.contentLeftInset
spacing: Style.spacing.sm
Item {
width: parent.width
height: root.headerH
Text {
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
text: root.filterText ? root.filterText : "Shortcut apps"
color: root.foreground
opacity: root.filterText ? 1 : 0.72
font.family: root.fontFamily
font.pixelSize: Style.font.heading
elide: Text.ElideRight
}
}
Flickable {
id: flick
width: parent.width
height: parent.height - root.headerH - root.footerH - Style.spacing.sm
clip: true
contentWidth: width
contentHeight: gridCol.height
boundsBehavior: Flickable.StopAtBounds
flickableDirection: Flickable.VerticalFlick
interactive: true
focus: false
Column {
id: gridCol
width: flick.width
spacing: Style.spacing.xs
Repeater {
model: root.layout.rows ? root.layout.rows.length : 0
delegate: Item {
id: rowItem
required property int index
readonly property var rowObj: root.layout.rows[index]
readonly property bool isBanner: rowObj && rowObj.type === "banner"
readonly property var rowItems: (rowObj && rowObj.items) ? rowObj.items : []
readonly property real slotW: (width - (root.columns - 1) * root.gridGap) / root.columns
readonly property bool startsCategory: rowObj ? (rowObj.type === "banner" || (rowObj.items && rowObj.items.length && rowObj.items[0].kind === "header")) : false
width: gridCol.width
height: isBanner ? root.headerH : root.cellH
clip: true
Text {
visible: rowItem.isBanner
anchors.fill: parent
verticalAlignment: Text.AlignVCenter
text: root.cfg.showCategories && rowObj ? (rowObj.label + " · " + rowObj.count) : ""
color: root.accent
opacity: 0.85
font.family: root.fontFamily
font.pixelSize: Style.font.title
font.bold: true
}
Row {
visible: !rowItem.isBanner
anchors.fill: parent
spacing: root.gridGap
Repeater {
model: rowItem.rowItems.length
delegate: Item {
id: cell
required property int index
readonly property var slot: rowItem.rowItems[index]
readonly property bool isCat: slot && slot.kind === "header"
readonly property int appIndex: (slot && slot.kind === "cell") ? slot.appIndex : -1
readonly property var app: appIndex >= 0 ? root.apps[appIndex] : null
readonly property string appLabel: app ? app.label : ""
readonly property string appIcon: app ? app.icon : ""
readonly property string appGlyph: app ? app.glyph : ""
readonly property string appFont: app ? app.iconFont : ""
readonly property string appChord: app ? app.chord : ""
readonly property string iconSrc: root.iconUrl(appIcon)
readonly property bool hasCursor: root.cursorActive && appIndex === root.cursorIndex
readonly property bool isBouncing: root.bounceIndex === appIndex
readonly property var chordKeys: ChordKey.chordKeys(appChord)
readonly property var chordRows: ChordKey.wrapKeys(chordKeys, width - Style.spacing.md * 2, root.keycapCharW, root.keycapPadX, root.keycapGap)
width: rowItem.slotW
height: root.cellH
clip: true
Text {
visible: cell.isCat
anchors.fill: parent
anchors.margins: Style.space(2)
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignRight
text: (cell.isCat && slot && slot.label) ? slot.label : ""
color: root.accent
opacity: 0.85
font.family: root.fontFamily
font.pixelSize: Style.font.caption
font.bold: true
wrapMode: Text.WordWrap
elide: Text.ElideRight
}
Rectangle {
visible: cell.isCat && cell.index > 0
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: parent.left
width: Math.max(1, Style.space(1))
color: Util.alpha(root.accent, 0.35)
}
Rectangle {
id: cellBg
visible: !cell.isCat
anchors.fill: parent
anchors.margins: Style.space(2)
radius: root.cornerRadius
color: hasCursor ? root.selectedBackground : (mouseArea.containsMouse ? Util.alpha(root.accent, 0.06) : "transparent")
border.color: hasCursor && root.cfg.effects.glow ? root.accent : "transparent"
border.width: hasCursor && root.cfg.effects.glow ? Math.max(1, Style.space(2)) : 0
scale: isBouncing ? 1.08 : (hasCursor && root.cfg.effects.pulse ? 1.04 : 1)
transformOrigin: Item.Center
Behavior on scale { NumberAnimation { duration: 120; easing.type: Easing.OutBack } }
Behavior on color { ColorAnimation { duration: 100 } }
}
Item {
visible: !cell.isCat
anchors.fill: parent
Item {
id: iconArea
anchors.top: parent.top
anchors.topMargin: Style.spacing.md
anchors.left: parent.left
anchors.leftMargin: Style.spacing.md
anchors.right: parent.right
anchors.rightMargin: Style.spacing.md
height: root.iconH
Image {
id: appIconImg
anchors.centerIn: parent
width: root.iconH
height: root.iconH
sourceSize: Qt.size(root.iconH * 2, root.iconH * 2)
source: cell.iconSrc
fillMode: Image.PreserveAspectFit
visible: cell.iconSrc !== "" && status !== Image.Error
asynchronous: true
}
Text {
anchors.centerIn: parent
visible: !appIconImg.visible
text: cell.appGlyph || ""
color: hasCursor ? root.selectedText : root.foreground
font.family: cell.appFont ? cell.appFont : root.fontFamily
font.pixelSize: Style.font.displayLarge
}
}
Text {
anchors.top: iconArea.bottom
anchors.topMargin: Style.spacing.xxs
anchors.left: parent.left
anchors.leftMargin: Style.spacing.md
anchors.right: parent.right
anchors.rightMargin: Style.spacing.md
text: cell.appLabel
color: hasCursor ? root.selectedText : root.foreground
font.family: root.fontFamily
font.pixelSize: Style.font.caption
horizontalAlignment: Text.AlignHCenter
elide: Text.ElideMiddle
}
Column {
id: chipArea
visible: root.cfg.showChords && cell.chordKeys.length > 0
anchors.bottom: parent.bottom
anchors.bottomMargin: Style.spacing.md
anchors.left: parent.left
anchors.leftMargin: Style.spacing.md
anchors.right: parent.right
anchors.rightMargin: Style.spacing.md
spacing: Style.spacing.xxs
Repeater {
model: cell.chordRows.length
delegate: Item {
id: keyRow
required property int index
width: parent.width
height: root.keycapH
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: root.keycapGap
Repeater {
model: cell.chordRows[keyRow.index].length
delegate: Rectangle {
required property int index
readonly property string keyLabel: cell.chordRows[keyRow.index][index]
height: root.keycapH
width: keyText.implicitWidth + root.keycapPadX * 2
radius: Style.space(4)
color: cell.hasCursor ? Util.alpha(root.selectedText, 0.18) : Util.alpha(root.foreground, 0.08)
border.color: cell.hasCursor ? Util.alpha(root.selectedText, 0.45) : "transparent"
border.width: 1
Text {
id: keyText
anchors.centerIn: parent
text: keyLabel
color: cell.hasCursor ? root.selectedText : root.foreground
font.family: root.fontFamily
font.pixelSize: root.keycapFont
}
}
}
}
}
}
}
}
MouseArea {
id: mouseArea
visible: !cell.isCat
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onContainsMouseChanged: if (containsMouse && cell.appIndex >= 0) {
root.cursorActive = true
root.cursorIndex = cell.appIndex
}
onClicked: {
if (cell.appIndex < 0) return
root.cursorIndex = cell.appIndex
keyCatcher.forceActiveFocus()
root.launchApp(cell.appIndex)
}
}
}
}
}
Rectangle {
visible: rowItem.startsCategory && rowItem.index > 0
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
height: Math.max(1, Style.space(1))
color: Util.alpha(root.accent, 0.35)
}
}
}
}
}
Item {
width: parent.width
height: root.footerH
Text {
anchors.fill: parent
verticalAlignment: Text.AlignVCenter
text: "↑↓←→ mover Tab categoría Ctrl+Tab layout ↵ abrir Esc cerrar"
color: root.foreground
opacity: 0.5
font.family: root.fontFamily
font.pixelSize: Style.font.caption
}
}
}
}
}
}
}