Source init for master branch.
[lichviet] / qml / DatePicker / component / Button.qml
1 import QtQuick 1.0\r
2 \r
3 Item {\r
4     id: container\r
5 \r
6     property string buttonName: "NOT SET"\r
7     property string target: "NOT SET"\r
8     property string text: "NOT SET"\r
9 \r
10     property string fontName: "Helvetica"\r
11     property int fontSize: 14\r
12     property color fontColor: "black"\r
13 \r
14     property bool active: false\r
15 \r
16     property string bgImage: theme_manager.theme.datepicker.button\r
17     property string bgImagePressed: theme_manager.theme.datepicker.button_pressed\r
18     property string bgImageActive: theme_manager.theme.datepicker.button_active\r
19 \r
20     // These Component properties can be used to modify the Button's LaF\r
21     // from the calling component. They have to define a BorderImage component.\r
22     property Component bg: defaultBackground\r
23     property Component bgPressed: defaultPressedBackground\r
24     property Component bgActive: defaultActiveBackground\r
25 \r
26     signal clicked(string target, string button)\r
27 \r
28     width: 140\r
29     height: 60\r
30     opacity: enabled ? 1.0 : 0.5    \r
31 \r
32     Loader {\r
33         id: background\r
34         sourceComponent: container.bg\r
35         anchors.fill: parent\r
36     }\r
37 \r
38     Component {\r
39         id: defaultBackground\r
40         BorderImage {\r
41             border { top: 8; bottom: 8; left: 8; right: 8 }\r
42             source: bgImage\r
43         }\r
44     }\r
45     Component {\r
46         id: defaultPressedBackground\r
47         BorderImage {\r
48             border { top: 8; bottom: 8; left: 8; right: 8 }\r
49             source: bgImagePressed\r
50         }\r
51     }\r
52 \r
53     Component {\r
54         id: defaultActiveBackground\r
55         BorderImage {\r
56             border { top: 8; bottom: 8; left: 8; right: 8 }\r
57             source: bgImageActive\r
58         }\r
59     }\r
60 \r
61     Text {\r
62         id: buttonLabel\r
63         text: parent.text\r
64         wrapMode: Text.WordWrap\r
65 \r
66         anchors {\r
67             horizontalCenter: parent.horizontalCenter\r
68             verticalCenter: parent.verticalCenter\r
69         }\r
70         font {\r
71             family: container.fontName\r
72             pointSize: container.fontSize\r
73         }\r
74         color: container.fontColor\r
75     }\r
76 \r
77     MouseArea {\r
78         id: mouseArea\r
79         anchors.fill: parent\r
80 \r
81     }\r
82 \r
83     states: [\r
84         State {\r
85             name: 'pressed'; when: mouseArea.pressed\r
86             PropertyChanges { target: background; sourceComponent: container.bgPressed }\r
87         },\r
88         State {\r
89             name: 'active'; when: container.active\r
90             PropertyChanges { target: background; sourceComponent: container.defaultActiveBackground; }\r
91         }\r
92     ]\r
93 \r
94 }\r