Added global controller andalso filebrowser qml
[lichviet] / qml / LichViet / Switch.qml
1 /*\r
2 Copyright (C) 2011  by Cuong Le <metacuong@gmail.com>\r
3 \r
4 This program is free software: you can redistribute it and/or modify\r
5 it under the terms of the GNU General Public License as published by\r
6 the Free Software Foundation, either version 2 of the License, or\r
7 (at your option) any later version.\r
8 \r
9 This program is distributed in the hope that it will be useful,\r
10 but WITHOUT ANY WARRANTY; without even the implied warranty of\r
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
12 GNU General Public License for more details.\r
13 \r
14 You should have received a copy of the GNU General Public License\r
15 along with this program.  If not, see <http://www.gnu.org/licenses/>\r
16 */\r
17 \r
18 import QtQuick 1.0\r
19 \r
20 Item {\r
21     id: container\r
22 \r
23     // Font properties\r
24     property string fontName: "Nokia Sans"\r
25     property int fontSize: 18\r
26     property color fontColor: "black"\r
27     // Images for switch states\r
28     property string imageOn: theme_manager.theme.switch_on\r
29     property string imageOff:theme_manager.theme.switch_off\r
30     // Property indicating current state\r
31     property bool switchedOn: true\r
32     // Labels for the states\r
33     property alias textOn: textOn.text\r
34     property alias textOff: textOff.text\r
35     // Spacing between labels and switch\r
36     property alias spacing: row.spacing\r
37 \r
38     // Signal that gets fired when switch state has been toggled\r
39     signal switched(bool position)\r
40 \r
41     width: row.width\r
42     height: 44\r
43 \r
44     Row {\r
45         id: row\r
46         spacing: 8\r
47         Text {\r
48             id: textOn\r
49             text: "Bật"\r
50             height: container.height\r
51             color: container.fontColor\r
52             font {\r
53                 family: container.fontName\r
54                 pointSize: container.fontSize\r
55             }\r
56             verticalAlignment: Text.AlignVCenter\r
57         }\r
58         Image {\r
59             id: toggleSwitch\r
60             height: container.height\r
61             width: 2.22 * height\r
62             source: switchedOn ? imageOn : imageOff\r
63             fillMode: Image.PreserveAspectFit\r
64             smooth: true\r
65         }\r
66         Text {\r
67             id: textOff\r
68             height: container.height\r
69             text: "Tắt"\r
70             color: container.fontColor\r
71             font {\r
72                 family: container.fontName\r
73                 pointSize: container.fontSize\r
74             }\r
75             verticalAlignment: Text.AlignVCenter\r
76         }\r
77     }\r
78     MouseArea {\r
79         anchors.fill: row\r
80         onClicked: { switchedOn = !switchedOn; switched(switchedOn) }\r
81     }\r
82 }\r