-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathColorPicker.qml
More file actions
88 lines (76 loc) · 1.88 KB
/
ColorPicker.qml
File metadata and controls
88 lines (76 loc) · 1.88 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
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.1
Item {
id: rootId
width: gridViewId.width
height: gridViewId.height
property string selectedColor: "#d5f7ae"
ListModel {
id: colorModelId
ListElement {
name: "#d5f7ae"
}
ListElement {
name: "#f5d3bb"
}
ListElement {
name: "#d5d0f8"
}
ListElement {
name: "#dadbda"
}
ListElement {
name: "#ea6d5b"
}
ListElement {
name: "#f25213"
}
ListElement {
name: "pink"
}
ListElement {
name: "#57a9e0"
}
ListElement {
name: "#f0db13"
}
}
ListModel {
id: selectedColorModelId
ListElement {
name: "#d5f7ae"
}
}
GridView {
id: gridViewId
property bool selected: true
width: selected ? 30 : 90
height: selected ? 30 : 90
cellWidth: 30; cellHeight: 30
focus: true
model: selected ? selectedColorModelId : colorModelId
Rectangle {
anchors.fill: parent
border.color: "black"
color: "transparent"
}
delegate: Item {
width: 30; height: 30
Rectangle {
anchors.fill: parent
color: gridViewId.selected ? rootId.selectedColor : name
border.width: 2
border.color: "white"
MouseArea {
anchors.fill: parent
onClicked: {
console.log("Color " + name + " clicked")
rootId.selectedColor = name
gridViewId.selected = !gridViewId.selected
}
}
}
}
}
}