2 Copyright (C) 2011 by Cuong Le <metacuong@gmail.com>
\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
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
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
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
38 // Signal that gets fired when switch state has been toggled
\r
39 signal switched(bool position)
\r
50 height: container.height
\r
51 color: container.fontColor
\r
53 family: container.fontName
\r
54 pointSize: container.fontSize
\r
56 verticalAlignment: Text.AlignVCenter
\r
60 height: container.height
\r
61 width: 2.22 * height
\r
62 source: switchedOn ? imageOn : imageOff
\r
63 fillMode: Image.PreserveAspectFit
\r
68 height: container.height
\r
70 color: container.fontColor
\r
72 family: container.fontName
\r
73 pointSize: container.fontSize
\r
75 verticalAlignment: Text.AlignVCenter
\r
80 onClicked: { switchedOn = !switchedOn; switched(switchedOn) }
\r