Repository navigation
Expand file tree
/
Copy pathEditKeybindDialog.qml
More file actions
919 lines (808 loc) · 31.7 KB
/
Copy pathEditKeybindDialog.qml
File metadata and controls
919 lines (808 loc) · 31.7 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
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Quickshell
import qs.Commons
import qs.Ui
import "Model.js" as Model
// Modal dialog for adding, modifying, or re-homing a keybinding.
//
// Modes:
// openCreate(preset) new binding (catalog preset or custom)
// openEdit(row) edit an existing row (disabled rows use oldKey "")
// openRehome(row, lostKey, winnerDesc) row lost its key to `winnerDesc`; pick a new one,
// disable it, or leave it unbound.
Item {
id: root
property bool opened: false
property bool isEditing: false
property bool isRehome: false
property var itemData: null
property var allBindings: []
property var catalog: []
// "ask" | "rehome" | "override" — drives the wording of the live conflict banner.
property string conflictMode: "rehome"
// Parent sets this while a backend mutator is running.
property bool saving: false
property string actionTitle: ""
property string actionCommand: ""
property string actionCategory: "Custom"
property string actionKey: ""
property string oldKey: ""
property string actionType: "preset" // "preset" | "custom"
// Stable identity passed to the backend as --id ("" for brand-new custom rows).
property string bindingId: ""
// Catalog preset's Lua dispatcher (e.g. hl.dsp.window.close()); "" for exec
// presets and custom/edited rows. Sent as `action` instead of `command`.
property string actionDispatcher: ""
// Description snapshot at open time (self-conflict exclusion).
property string ownDescription: ""
// "was SUPER + F" hint for disabled rows.
property string wasKeyHint: ""
// Rehome state
property var displacedBinding: null
property string rehomeBannerText: ""
property string rehomeLostKey: ""
// Live backend `check` result for the current chord (null until fresh).
property var checkResult: null
property bool checkPending: false
property color background: Color.background
property color foreground: Color.foreground
property color accent: Color.accent
property color urgent: Color.urgent
readonly property string backendPath: Quickshell.env("HOME") + "/.config/omarchy/plugins/davedes.mouse-keybind-settings/backend/keybinds_manager.py"
signal saved(string key, string description, string command, string action, string oldKey, string id)
signal canceled()
signal closed()
signal disableRequested(string id, string key)
signal unboundAccepted(string id)
readonly property string effectiveId: root.bindingId.length > 0 ? root.bindingId : root.actionTitle.trim().toLowerCase()
readonly property bool checkFresh: Boolean(root.checkResult && root.checkResult.key !== undefined
&& Model.normalizeKey(root.checkResult.key) === Model.normalizeKey(keyRecorder.value))
readonly property var liveConflict: (root.checkFresh && root.checkResult.conflict) ? root.checkResult.conflict : null
readonly property var lockedInfo: (root.checkFresh && root.checkResult.locked) ? root.checkResult.locked : null
readonly property bool keyAcceptable: keyRecorder.complete && (keyRecorder.hasModifier || Model.isStandaloneKey(keyRecorder.mainKey))
readonly property bool canSave: root.keyAcceptable && root.actionTitle.trim().length > 0 && !root.saving && root.lockedInfo === null
readonly property bool canDisable: Boolean(root.itemData && (
(root.itemData.default_key && String(root.itemData.default_key).length > 0) || root.itemData.managed === true))
readonly property string conflictBannerText: {
if (root.lockedInfo) {
var l = root.lockedInfo
var where = l.file_line ? " (bindings.lua line " + l.file_line + ")" : ""
var why = l.reason ? ": " + l.reason : ""
return "This binding is locked" + where + why + ". Edit it in the editor instead."
}
if (root.liveConflict) {
var d = root.liveConflict.description || "another binding"
var tail
if (root.conflictMode === "override") tail = "Saving will override it — " + d + " loses its key."
else if (root.conflictMode === "ask") tail = "Saving will ask what to do with " + d + "."
else tail = "Saving will ask you to rehome " + d + "."
return keyRecorder.value + " is " + d + ". " + tail
}
return ""
}
readonly property string saveLabel: {
if (root.saving) return "Saving…"
if (root.liveConflict) return root.conflictMode === "override" ? "Override & Save" : "Save & Rehome"
return "Save & Apply"
}
readonly property string saveHint: {
if (root.saving) return "Applying the previous change…"
if (root.lockedInfo) return "Locked binding"
if (!keyRecorder.complete) return keyRecorder.hasModifier ? "Pick a key to complete the chord" : "Choose a shortcut"
if (!root.keyAcceptable) return "Add a modifier (or use an F-key / PRINT / XF86 key)"
if (root.actionTitle.trim().length === 0) return "Give the action a name"
return ""
}
// Smart Suggested Free Combinations
readonly property var suggestedKeys: {
var bound = {}
if (root.allBindings) {
for (var i = 0; i < root.allBindings.length; i++) {
var b = root.allBindings[i]
if (b && b.status !== "disabled" && b.key) {
bound[Model.normalizeKey(b.key)] = true
}
}
}
var firstLetter = ""
if (root.actionTitle && root.actionTitle.trim().length > 0) {
var cleanTitle = root.actionTitle.trim()
for (var j = 0; j < cleanTitle.length; j++) {
var ch = cleanTitle.charAt(j).toUpperCase()
if (ch >= 'A' && ch <= 'Z') {
firstLetter = ch
break
}
}
}
var candidates = []
if (firstLetter) {
candidates.push("SUPER + " + firstLetter)
candidates.push("SUPER + ALT + " + firstLetter)
candidates.push("SUPER + SHIFT + " + firstLetter)
candidates.push("SUPER + CTRL + " + firstLetter)
}
var letters = ["B", "D", "E", "H", "M", "N", "R", "T", "U", "Y", "Z", "A", "C", "F", "K", "L", "P", "Q", "S", "W"]
for (var k = 0; k < letters.length; k++) {
var l = letters[k]
if (l !== firstLetter) {
candidates.push("SUPER + " + l)
candidates.push("SUPER + ALT + " + l)
candidates.push("SUPER + SHIFT + " + l)
candidates.push("SUPER + CTRL + " + l)
}
}
var current = Model.normalizeKey(root.actionKey)
var suggestions = []
for (var c = 0; c < candidates.length; c++) {
var chord = candidates[c]
var norm = Model.normalizeKey(chord)
if (!bound[norm] && suggestions.indexOf(chord) === -1 && norm !== current) {
suggestions.push(chord)
if (suggestions.length >= 4) break
}
}
return suggestions
}
function resetCommon() {
root.checkResult = null
root.checkPending = false
root.wasKeyHint = ""
root.displacedBinding = null
root.rehomeBannerText = ""
root.rehomeLostKey = ""
root.isRehome = false
root.actionDispatcher = ""
}
function openCreate(presetItem) {
resetCommon()
root.isEditing = false
root.itemData = presetItem || null
root.oldKey = ""
if (presetItem) {
root.actionTitle = presetItem.name || presetItem.description || ""
root.actionCommand = presetItem.command || ""
root.actionCategory = presetItem.category || "General"
root.actionKey = presetItem.default_key || ""
root.actionType = presetItem.name ? "preset" : "custom"
// Catalog `id` is a preset id ("win.close"), not a binding id: row_id is
// the existing binding row for this action, or null for a brand-new one.
root.bindingId = presetItem.row_id || ""
root.actionDispatcher = (presetItem.dispatcher && presetItem.dispatcher !== "exec") ? presetItem.dispatcher : ""
} else {
root.actionTitle = ""
root.actionCommand = ""
root.actionCategory = "Custom"
root.actionKey = ""
root.actionType = "custom"
root.bindingId = ""
}
root.ownDescription = ""
keyRecorder.load(root.actionKey)
root.opened = true
root.scheduleCheck()
Qt.callLater(function() {
if (descInput) descInput.forceActiveFocus()
})
}
function openEdit(bindingItem) {
resetCommon()
var b = bindingItem || null
root.isEditing = true
root.itemData = b
root.actionTitle = (b && b.description) || ""
root.actionCommand = (b && (b.action || b.command)) || ""
root.actionCategory = (b && b.category) || "Custom"
root.actionType = (b && b.source === "default") ? "preset" : "custom"
root.bindingId = Model.rowId(b)
root.ownDescription = (b && b.description) || ""
if (b && b.status === "disabled") {
// A disabled row holds no key: nothing to release, so oldKey stays "".
root.oldKey = ""
var dk = (b.default_key) ? String(b.default_key) : ""
root.wasKeyHint = dk ? "was " + dk : ""
// Prefill the default only when nobody else holds it.
root.actionKey = (dk && Model.holdersOf(root.allBindings, dk, root.bindingId).length === 0) ? dk : ""
} else {
root.actionKey = (b && b.key) || ""
root.oldKey = (b && b.key) || ""
}
keyRecorder.load(root.actionKey)
root.opened = true
root.scheduleCheck()
Qt.callLater(function() {
if (descInput) descInput.forceActiveFocus()
})
}
function openRehome(bindingItem, lostKey, winnerDescription) {
resetCommon()
var b = bindingItem || null
root.isEditing = true
root.isRehome = true
root.itemData = b
root.displacedBinding = b
root.actionTitle = (b && b.description) || ""
root.actionCommand = (b && (b.action || b.command)) || ""
root.actionCategory = (b && b.category) || "Custom"
root.actionType = (b && b.source === "default") ? "preset" : "custom"
root.bindingId = Model.rowId(b)
root.ownDescription = (b && b.description) || ""
root.oldKey = ""
root.actionKey = ""
root.rehomeLostKey = lostKey ? String(lostKey) : ""
root.wasKeyHint = root.rehomeLostKey ? "was " + root.rehomeLostKey : ""
root.rehomeBannerText = root.actionTitle + " lost " + (root.rehomeLostKey || "its key") + " to "
+ (winnerDescription || "another binding") + ". Pick a new key or disable it."
keyRecorder.load("")
root.opened = true
root.scheduleCheck()
Qt.callLater(function() {
if (root.opened && root.isRehome) keyRecorder.startRecording()
})
}
// Close without deciding. For a rehome dialog the parent keeps the binding
// queued (it still needs a key); the user can come back via "Pick key…".
function close() {
if (!root.opened) return
root.opened = false
root.canceled()
}
function commitSave() {
if (!root.canSave) return
var key = keyRecorder.value
var id = root.effectiveId
// A catalog preset with a Lua dispatcher is written as that action (like
// stock bindings); otherwise the command string is exec'd.
var action = (root.actionType === "preset" && root.actionDispatcher) ? root.actionDispatcher : ""
var cmd = action ? "" : root.actionCommand
root.opened = false
root.saved(key, root.actionTitle.trim(), cmd, action, root.oldKey, id)
}
function requestDisable() {
var id = root.effectiveId
var key = (root.itemData && root.itemData.default_key) ? String(root.itemData.default_key) : root.rehomeLostKey
root.opened = false
root.disableRequested(id, key)
}
function acceptUnbound() {
var id = root.effectiveId
root.opened = false
root.unboundAccepted(id)
}
onOpenedChanged: {
if (!root.opened) {
keyRecorder.stopRecording()
checkDebounce.stop()
root.checkPending = false
root.closed()
}
}
onActionTitleChanged: root.scheduleCheck()
// ---- Live backend conflict check (debounced, never restarted mid-flight) ----
function scheduleCheck() {
if (!root.opened) return
checkDebounce.restart()
}
function runCheck() {
if (!root.opened) return
var key = keyRecorder.value
if (!key || !keyRecorder.complete) {
root.checkResult = null
return
}
if (checkProc.running) {
root.checkPending = true
return
}
root.checkPending = false
var args = [root.backendPath, "check", key, root.actionTitle.trim(), "--id", root.effectiveId]
if (root.oldKey) args.push("--old-key", root.oldKey)
checkProc.command = args
checkProc.running = true
}
Timer {
id: checkDebounce
interval: 150
repeat: false
onTriggered: root.runCheck()
}
BoundedProcess {
id: checkProc
maxBytes: 262144
timeoutMs: 8000
onFinished: {
if (success) {
try {
var r = JSON.parse(stdout || "")
if (r && typeof r === "object") root.checkResult = r
} catch (e) {
console.warn("EditKeybindDialog: check returned invalid JSON:", e)
}
}
if (root.checkPending && root.opened) Qt.callLater(root.runCheck)
}
}
visible: opened
// Scrim backdrop
Rectangle {
anchors.fill: parent
color: Util.alpha(root.background, 0.88)
MouseArea {
anchors.fill: parent
onClicked: root.close()
}
// Modal Card
BorderSurface {
id: card
width: Math.min(parent.width - Style.space(64), Style.space(640))
height: Math.min(parent.height - Style.space(40), card.contentTopInset + card.contentBottomInset + cardLayout.implicitHeight)
anchors.centerIn: parent
color: root.background
borderSpec: Border.flat(root.isRehome ? root.urgent : Util.alpha(root.foreground, 0.25), 1)
radius: Style.cornerRadius
padding: Style.space(28)
MouseArea {
anchors.fill: parent
onClicked: {} // Swallow clicks inside modal
}
ScrollView {
id: cardScroll
anchors.fill: parent
anchors.topMargin: card.contentTopInset
anchors.leftMargin: card.contentLeftInset
anchors.rightMargin: card.contentRightInset
anchors.bottomMargin: card.contentBottomInset
clip: true
contentWidth: availableWidth
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
ScrollBar.vertical.policy: cardLayout.implicitHeight > cardScroll.height ? ScrollBar.AsNeeded : ScrollBar.AlwaysOff
ColumnLayout {
id: cardLayout
width: cardScroll.availableWidth
spacing: Style.space(16)
// 1. Header
RowLayout {
Layout.fillWidth: true
spacing: Style.space(14)
Text {
text: root.isRehome ? "" : ""
color: root.isRehome ? root.urgent : root.foreground
font.family: Style.font.family
font.pixelSize: Style.font.title + 8
}
ColumnLayout {
Layout.fillWidth: true
spacing: Style.space(2)
Text {
text: root.isRehome
? ("Pick a new key for " + root.actionTitle)
: (root.isEditing ? "Edit Keybinding" : "Create New Keybinding")
textFormat: Text.PlainText
Layout.fillWidth: true
elide: Text.ElideRight
color: root.foreground
font.family: Style.font.family
font.pixelSize: Style.font.title
font.bold: true
}
Text {
text: root.isRehome
? "This binding needs a home before it works again."
: (root.isEditing
? "Update the shortcut combination or action details below."
: "Assign a shortcut to a system action or define a custom terminal command.")
Layout.fillWidth: true
wrapMode: Text.WordWrap
color: Util.alpha(root.foreground, 0.6)
font.family: Style.font.family
font.pixelSize: Style.font.caption
}
}
}
// Rehome banner
BorderSurface {
id: rehomeBanner
visible: root.isRehome && root.rehomeBannerText.length > 0
Layout.fillWidth: true
Layout.preferredHeight: rehomeBanner.contentTopInset + rehomeBanner.contentBottomInset + rehomeBannerText.implicitHeight
radius: Style.cornerRadius
color: Util.alpha(root.urgent, 0.12)
borderSpec: Border.flat(root.urgent, 1)
padding: Style.space(12)
Text {
id: rehomeBannerText
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
anchors.leftMargin: rehomeBanner.contentLeftInset
anchors.rightMargin: rehomeBanner.contentRightInset
anchors.topMargin: rehomeBanner.contentTopInset
text: root.rehomeBannerText
textFormat: Text.PlainText
wrapMode: Text.WordWrap
color: root.foreground
font.family: Style.font.family
font.pixelSize: Style.font.body
}
}
PanelSeparator { Layout.fillWidth: true }
// 2. Action Type Selector (Only when creating new)
RowLayout {
visible: !root.isEditing
Layout.fillWidth: true
spacing: Style.space(12)
Text {
text: "Action Source:"
color: root.foreground
font.family: Style.font.family
font.pixelSize: Style.font.body
font.bold: true
}
ButtonGroup {
id: typeGroup
Button {
text: "Preset Catalog Action"
selected: root.actionType === "preset"
horizontalPadding: Style.space(16)
verticalPadding: Style.space(4)
onClicked: root.actionType = "preset"
}
Button {
text: "Custom Command / Script"
selected: root.actionType === "custom"
horizontalPadding: Style.space(16)
verticalPadding: Style.space(4)
onClicked: root.actionType = "custom"
}
}
}
// Preset Selector Row (when creating from catalog)
ColumnLayout {
visible: !root.isEditing && root.actionType === "preset"
Layout.fillWidth: true
spacing: Style.space(6)
Text {
text: "Popular Catalog Presets:"
color: Util.alpha(root.foreground, 0.8)
font.family: Style.font.family
font.pixelSize: Style.font.caption
font.bold: true
}
Flow {
Layout.fillWidth: true
spacing: Style.space(6)
Repeater {
model: (root.catalog && root.catalog.slice(0, 10)) || []
BorderSurface {
id: presetChip
required property var modelData
readonly property bool isPicked: root.actionTitle === modelData.name
height: Style.space(28)
width: chipText.implicitWidth + Style.space(18)
radius: Style.cornerRadius
color: isPicked
? Util.alpha(root.accent, 0.22)
: (chipMouse.containsMouse ? Util.alpha(root.foreground, 0.08) : Util.alpha(root.foreground, 0.04))
borderSpec: Border.flat(isPicked ? root.accent : Util.alpha(root.foreground, 0.15), 1)
MouseArea {
id: chipMouse
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
root.actionTitle = presetChip.modelData.name
root.actionCommand = presetChip.modelData.command
root.actionCategory = presetChip.modelData.category
root.bindingId = presetChip.modelData.row_id || ""
root.actionDispatcher = (presetChip.modelData.dispatcher && presetChip.modelData.dispatcher !== "exec")
? presetChip.modelData.dispatcher : ""
if (!keyRecorder.value && presetChip.modelData.default_key) {
keyRecorder.load(presetChip.modelData.default_key)
}
}
}
Text {
id: chipText
anchors.centerIn: parent
text: presetChip.modelData.name
color: presetChip.isPicked ? root.accent : root.foreground
font.family: Style.font.family
font.pixelSize: Style.font.caption
font.bold: presetChip.isPicked
}
}
}
}
}
// 3. Name / Description Field (read-only summary in rehome mode)
ColumnLayout {
visible: !root.isRehome
Layout.fillWidth: true
spacing: Style.space(4)
Text {
text: "Action Name / Description:"
color: root.foreground
font.family: Style.font.family
font.pixelSize: Style.font.body
font.bold: true
}
TextField {
id: descInput
Layout.fillWidth: true
maximumLength: 200
text: root.actionTitle
placeholderText: "e.g. Launch Terminal, Toggle Fullscreen, My Script"
onTextChanged: if (root.actionTitle !== text) root.actionTitle = text
}
}
// 4. Command Field (custom actions, or editing)
ColumnLayout {
visible: !root.isRehome && (root.actionType === "custom" || root.isEditing)
Layout.fillWidth: true
spacing: Style.space(4)
Text {
text: "Command / Dispatcher:"
color: root.foreground
font.family: Style.font.family
font.pixelSize: Style.font.body
font.bold: true
}
TextField {
id: cmdInput
Layout.fillWidth: true
maximumLength: 2000
text: root.actionCommand
placeholderText: "e.g. alacritty -e btop, omarchy-capture-screenshot"
onTextChanged: if (root.actionCommand !== text) root.actionCommand = text
}
}
// Rehome: compact summary of what is being re-homed
RowLayout {
visible: root.isRehome
Layout.fillWidth: true
spacing: Style.space(8)
Text {
text: "Command:"
color: Util.alpha(root.foreground, 0.7)
font.family: Style.font.family
font.pixelSize: Style.font.caption
font.bold: true
}
Text {
Layout.fillWidth: true
text: root.actionCommand
textFormat: Text.PlainText
elide: Text.ElideRight
color: Util.alpha(root.foreground, 0.7)
font.family: Style.font.family
font.pixelSize: Style.font.caption
}
}
// 5. Suggestions (shown first in rehome mode) + Shortcut recorder
ColumnLayout {
Layout.fillWidth: true
spacing: Style.space(8)
// Suggestions block (rehome: before the recorder)
ColumnLayout {
id: suggestionsTop
visible: root.isRehome && root.suggestedKeys.length > 0
Layout.fillWidth: true
spacing: Style.space(6)
RowLayout {
spacing: Style.space(6)
Text {
text: "💡"
font.pixelSize: Style.font.caption
}
Text {
text: "Free shortcuts (click to pick):"
color: Util.alpha(root.foreground, 0.75)
font.family: Style.font.family
font.pixelSize: Style.font.caption
font.bold: true
}
}
Flow {
Layout.fillWidth: true
spacing: Style.space(8)
Repeater {
model: root.suggestedKeys
BorderSurface {
id: suggestChipTop
required property string modelData
height: Style.space(28)
width: suggestChipTopRow.implicitWidth + Style.space(18)
radius: Style.cornerRadius
color: suggestTopMouse.containsMouse ? Util.alpha(root.accent, 0.24) : Util.alpha(root.accent, 0.10)
borderSpec: Border.flat(suggestTopMouse.containsMouse ? root.accent : Util.alpha(root.accent, 0.4), 1)
MouseArea {
id: suggestTopMouse
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: root.pickSuggestion(suggestChipTop.modelData)
}
RowLayout {
id: suggestChipTopRow
anchors.centerIn: parent
spacing: Style.space(4)
Text {
text: "✨"
font.pixelSize: Style.font.caption - 2
}
Text {
text: suggestChipTop.modelData
color: root.accent
font.family: Style.font.family
font.pixelSize: Style.font.caption
font.bold: true
}
}
}
}
}
}
RowLayout {
Layout.fillWidth: true
spacing: Style.space(8)
Text {
text: "Keyboard Shortcut:"
color: root.foreground
font.family: Style.font.family
font.pixelSize: Style.font.body
font.bold: true
}
Text {
visible: root.wasKeyHint.length > 0
text: root.wasKeyHint
textFormat: Text.PlainText
color: Util.alpha(root.foreground, 0.5)
font.family: Style.font.family
font.pixelSize: Style.font.caption
font.italic: true
}
Item { Layout.fillWidth: true }
}
KeyRecorder {
id: keyRecorder
Layout.fillWidth: true
allBindings: root.allBindings
ownId: root.bindingId
ownDescription: root.ownDescription
ownKey: root.oldKey
conflictMessage: root.conflictBannerText
localConflictEnabled: !root.checkFresh
onKeyChanged: function(newK) {
root.actionKey = newK
}
onValueChanged: root.scheduleCheck()
}
// Suggestions block (normal mode: after the recorder)
ColumnLayout {
visible: !root.isRehome && root.suggestedKeys.length > 0
Layout.fillWidth: true
spacing: Style.space(6)
RowLayout {
spacing: Style.space(6)
Text {
text: "💡"
font.pixelSize: Style.font.caption
}
Text {
text: "Suggested Free Shortcuts (Click to pick):"
color: Util.alpha(root.foreground, 0.75)
font.family: Style.font.family
font.pixelSize: Style.font.caption
font.bold: true
}
}
Flow {
Layout.fillWidth: true
spacing: Style.space(8)
Repeater {
model: root.suggestedKeys
BorderSurface {
id: suggestChip
required property string modelData
height: Style.space(28)
width: suggestChipRow.implicitWidth + Style.space(18)
radius: Style.cornerRadius
color: suggestMouse.containsMouse ? Util.alpha(root.accent, 0.24) : Util.alpha(root.accent, 0.10)
borderSpec: Border.flat(suggestMouse.containsMouse ? root.accent : Util.alpha(root.accent, 0.4), 1)
MouseArea {
id: suggestMouse
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: root.pickSuggestion(suggestChip.modelData)
}
RowLayout {
id: suggestChipRow
anchors.centerIn: parent
spacing: Style.space(4)
Text {
text: "✨"
font.pixelSize: Style.font.caption - 2
}
Text {
text: suggestChip.modelData
color: root.accent
font.family: Style.font.family
font.pixelSize: Style.font.caption
font.bold: true
}
}
}
}
}
}
}
PanelSeparator { Layout.fillWidth: true }
// 6. Footer
RowLayout {
Layout.fillWidth: true
spacing: Style.space(12)
Text {
visible: root.saveHint.length > 0
text: root.saveHint
textFormat: Text.PlainText
color: Util.alpha(root.foreground, 0.55)
font.family: Style.font.family
font.pixelSize: Style.font.caption
font.italic: true
Layout.fillWidth: true
elide: Text.ElideRight
}
Item { visible: root.saveHint.length === 0; Layout.fillWidth: true }
Button {
text: root.isRehome ? "Later" : "Cancel"
tooltipText: root.isRehome ? "Close for now — the binding stays flagged as needing a key" : ""
horizontalPadding: Style.space(20)
verticalPadding: Style.space(6)
onClicked: root.close()
}
Button {
visible: root.isRehome && root.canDisable
text: "Disable it"
iconText: "⊘"
accent: root.urgent
enabled: !root.saving
opacity: enabled ? 1.0 : 0.45
horizontalPadding: Style.space(16)
verticalPadding: Style.space(6)
onClicked: root.requestDisable()
}
Button {
visible: root.isRehome && !root.canDisable
text: "Leave it unbound"
enabled: !root.saving
opacity: enabled ? 1.0 : 0.45
horizontalPadding: Style.space(16)
verticalPadding: Style.space(6)
onClicked: root.acceptUnbound()
}
Button {
id: saveButton
text: root.saveLabel
accent: (root.liveConflict && root.conflictMode === "override") ? root.urgent : root.accent
selected: true
enabled: root.canSave
opacity: root.canSave ? 1.0 : 0.45
horizontalPadding: Style.space(24)
verticalPadding: Style.space(6)
onClicked: root.commitSave()
}
}
}
}
}
}
function pickSuggestion(chord) {
keyRecorder.load(chord)
keyRecorder.recording = false
root.actionKey = chord
root.scheduleCheck()
}
}