-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathColorPicker.qml
58 lines (52 loc) · 1.45 KB
/
ColorPicker.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
import QtQuick 2.2
import QtQuick.Dialogs 1.2
Rectangle {
id: picker;
border.width: 1;
border.color: "black";
width: 100;
height: 62;
color: "#80800000";
property var colorDlg: null;
MouseArea {
anchors.fill: parent;
onClicked: {
colorDlg = clr.createObject(picker, { "currentColor" : picker.color});
colorDlg.accepted.connect(picker.onAccepted);
colorDlg.rejected.connect(picker.onRejected);
}
}
Text {
id: colorLabel;
anchors.centerIn: parent;
text: colorUtil.nameOfColor(picker.color);
color: colorUtil.invert(picker.color);
}
/*
Component.onCompleted: {
colorLabel.color = colorUtil.invert(picker.color);
console.log("ColorPicker orig color, ", colorUtil.nameOfColor(picker.color));
console.log("ColorPicker label color, ", colorUtil.nameOfColor(colorLabel.color));
}
*/
function onAccepted() {
color = colorDlg.currentColor;
colorLabel.text = colorUtil.nameOfColor(color);
colorLabel.color = colorUtil.invert(color);
colorDlg.destroy();
}
function onRejected() {
colorDlg.destroy();
}
Component {
id: clr;
ColorDialog {
id: colorDlg;
width: 400;
height: 400;
title: "Please choose a color";
showAlphaChannel: true;
visible: true;
}
}
}