-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandInput.qml
More file actions
80 lines (69 loc) · 2.27 KB
/
CommandInput.qml
File metadata and controls
80 lines (69 loc) · 2.27 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
import QtQuick 2.12
Item
{
signal itemSelected(string text)
signal searchChanged(string text)
signal moveUp()
signal moveDown()
signal moveLeft()
signal moveRight()
signal moveHome()
signal moveEnd()
signal toggleNoDisplay()
property string placeholderText: qsTr("Enter application/command/name")
Timer
{
property var payload: []
id: timer
interval: 200
onTriggered: { doSearch(payload.text); }
}
function debounce(text) {
timer.payload = { text: text};
if (timer.running) return;
timer.start();
}
function doSearch(text) {
searchChanged(text);
}
Rectangle
{
color: settings.get("input/bgcolor", "#ffffff")
antialiasing: true
radius: settings.getNumber("input/borderradius", 8)
anchors.fill: parent
border.color: settings.get("input/bordercolor", "#6795cc")
border.width: settings.getNumber("input/borderwidth", 2)
}
TextInput
{
id: input
focus: true
anchors.fill: parent
horizontalAlignment: "AlignHCenter"
color: settings.get("input/textcolor", "#000000")
font.pixelSize: settings.getNumber("input/fontsize", 16)
font.bold: settings.getBool("input/fontbold", true)
onTextEdited: debounce(input.text)
onAccepted: itemSelected(input.text)
Keys.onPressed:
{
if (event.key === Qt.Key_Escape) Qt.quit();
if (event.key === Qt.Key_Left) { event.accepted = true; moveLeft(); }
if (event.key === Qt.Key_Right) { event.accepted = true; moveRight() }
if (event.key === Qt.Key_Down) { event.accepted = true; moveDown(); }
if (event.key === Qt.Key_Up) { event.accepted = true; moveUp();}
if (event.key === Qt.Key_Home) moveHome();
if (event.key === Qt.Key_End) moveEnd();
if (event.key === Qt.Key_Control) { toggleNoDisplay(); }
}
Text {
id: placeholder
color: "grey"
visible: !input.text /* && !input.activeFocus */
text: placeholderText
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
}
}
}