Repository navigation
Expand file tree
/
Copy pathKeycodePicker.qml
More file actions
49 lines (48 loc) · 1.7 KB
/
Copy pathKeycodePicker.qml
File metadata and controls
49 lines (48 loc) · 1.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
pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Controls as Controls
import QtQuick.Layouts
import qs.Commons as Commons
import qs.Ui as Ui
ColumnLayout {
id: root
required property var codes
required property int layerCount
signal chosen(int value)
signal closed()
Commons.Translations { id: strings; directory: Qt.resolvedUrl("i18n") }
readonly property var allCodes: codes.concat(Array.from({length: layerCount}, function(_, i) {
return {name: "MO(" + i + ")", value: 0x5220 | i, group: "layer", description: "", aliases: ""}
}))
readonly property var filtered: allCodes.filter(function(k) {
return (k.name + " " + k.group + " " + k.description + " " + k.aliases).toLowerCase().indexOf(search.text.toLowerCase()) >= 0
})
BoundedTextField {
id: search; objectName: "keycodeSearch"
Layout.fillWidth: true; placeholderText: strings.t("keymapSearch")
foreground: Commons.Color.popups.text; maximumLength: 100
Component.onCompleted: forceActiveFocus()
Keys.onEscapePressed: root.closed()
}
Controls.ScrollView {
Layout.fillWidth: true
Layout.preferredHeight: Commons.Style.space(180)
clip: true
contentWidth: availableWidth
ColumnLayout {
width: parent.width
Repeater {
model: root.filtered
delegate: Ui.Button {
required property var modelData
objectName: "keycode-" + modelData.value
Layout.fillWidth: true
text: modelData.name + " · " + modelData.group
foreground: Commons.Color.popups.text; focusable: true
onClicked: root.chosen(modelData.value)
}
}
}
}
Ui.Button { text: strings.t("done"); focusable: true; onClicked: root.closed() }
}