use system palete colors
[makneto-zunavac1.git] / src / ui-mobile / declarative / BoardToolbar.qml
blobad415842298045e7e99a009a6a7804e152e99238
1 import QtQuick 1.0
2 import Qt 4.7
3 import "ColorPicker"
5 Rectangle {
6     id: toolbar
7     width: 100
8     height: 62
9     color: main.useSyspal? syspal.window :parent.color
11     signal foregroundColorChanged(variant color)
12     property variant foregroundColor: "#ff0000"
13     property variant backgroundColor: "#ffffff"
15     property variant pickerComponent : Qt.createComponent("ColorPicker/ColorPickerPopup.qml");
16     property variant popup: undefined;
18     function log(msg){
19         console.log("II [BoardToolbar.qml]: "+msg);
20     }
21     function error(msg){
22         console.log("EE [BoardToolbar.qml]: "+msg);
23     }
24     function warn(msg){
25         console.log("WW [BoardToolbar.qml]: "+msg);
26     }
28     Component.onCompleted:{
29         foregroundColorChanged.connect(function(color){toolbar.foregroundColor = color;});
30     }
32     SystemPalette{ id: syspal }
34     Rectangle{
35         id: foregroundColorSelector
36         anchors{margins: 4; left: parent.left; right: parent.right; top: parent.top; }
37         anchors.topMargin: 44
39         height: width
41         Rectangle{
42             anchors.fill: parent
43             color: toolbar.foregroundColor
44             radius: border.radius
46             Rectangle{
47                 id: border
48                 anchors.fill: parent
49                 radius: 3
50                 border{ color: "white"; width: 1 }
51                 color: "transparent"
52                 opacity: 0.25
53                 //opacity: 1.0
54             }
55         }
56         MouseArea{
57             anchors.fill: parent
58             onClicked: {
59                 //log("clicked on statusIndicator ");
61                 if(pickerComponent.status != Component.Ready){
62                     error("Component "+pickerComponent.url+" is not ready!");
63                     error(pickerComponent.errorString());
64                     return false;
65                 }
67                 if (popup !== undefined && popup !== null && popup.state != "hide"){
68                     popup.hidePopup();
69                 }
71                 popup = pickerComponent.createObject(main);
72                 if(popup === null){
73                     error("error creating popup");
74                     error(pickerComponent.errorString());
75                     return false;
76                 }
77                 var pos = foregroundColorSelector.mapToItem(main,0, 0);
78                 popup.popupFromX = pos.x;
79                 popup.popupFromY = pos.y;
80                 popup.color = foregroundColor;
82                 popup.colorChanged.connect(foregroundColorChanged)
84                 popup.state = "visible"
85                 //log("visible popup "+JSON.stringify(parent));
86             }
87         }
89     }