-
Notifications
You must be signed in to change notification settings - Fork 15
/
ColourSetter.qml
78 lines (60 loc) · 1.89 KB
/
ColourSetter.qml
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
import QtQuick 1.1
Rectangle {
id: root
color: "#222222"
Keys.onPressed: {
var pressedKeys = [Qt.Key_7, Qt.Key_8, Qt.Key_9, Qt.Key_4, Qt.Key_5, Qt.Key_6, Qt.Key_1, Qt.Key_2, Qt.Key_3]
var theKey = event.key
if(pressedKeys.indexOf(theKey) >= 0){
color_rep.itemAt(pressedKeys.indexOf(theKey)).ma.clicked(true)
}
else if(theKey = Qt.Key_Escape){
root_ma.clicked(true)
}
}
MouseArea {
id: root_ma
anchors.fill: parent
onClicked: {
task_color = root.color;
color_setter_window.visible = false;
units_planned.focus = true;
}
}
Grid {
id: color_grid
spacing: 6
rows: 3
columns: 3
anchors.centerIn: parent
Repeater {
id: color_rep
model: [ "#222222", "#1abc9c", "#27ae60", "#2980b4", "#8e44ad", "#34495e", "#f39c12", "#d35400", "#c0392b" ]
Rectangle {
id: color_rect
property alias ma: mouse_area
property variant shortcutlist: [7, 8, 9, 4, 5, 6, 1, 2, 3]
color: modelData
width: 60
height: width
Text {
id: shortcut
color: "#eee"
anchors.centerIn: parent
text: color_rect.shortcutlist[index]
font.pixelSize: 18
}
MouseArea {
id: mouse_area
anchors.fill: parent
onClicked: {
root.color = color_rect.color;
task_color = color_rect.color;
color_setter_window.visible = false;
units_planned.focus = true;
}
}
}
}
}
}