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
20 import "Themes.js" as Themes
\r
27 property alias theme: theme_manager.item
\r
28 source: Themes.default_theme()
\r
33 property string fontName: "Nokia Sans"
\r
34 property int fontSize: 18
\r
35 property color fontColor: "black"
\r
36 // Images for switch states
\r
37 property string imageOn: theme_manager.theme.switch_on
\r
38 property string imageOff:theme_manager.theme.switch_off
\r
39 // Property indicating current state
\r
40 property bool switchedOn: true
\r
41 // Labels for the states
\r
42 property alias textOn: textOn.text
\r
43 property alias textOff: textOff.text
\r
44 // Spacing between labels and switch
\r
45 property alias spacing: row.spacing
\r
47 // Signal that gets fired when switch state has been toggled
\r
48 signal switched(bool position)
\r
59 height: container.height
\r
60 color: container.fontColor
\r
62 family: container.fontName
\r
63 pointSize: container.fontSize
\r
65 verticalAlignment: Text.AlignVCenter
\r
69 height: container.height
\r
70 width: 2.22 * height
\r
71 source: switchedOn ? imageOn : imageOff
\r
72 fillMode: Image.PreserveAspectFit
\r
77 height: container.height
\r
79 color: container.fontColor
\r
81 family: container.fontName
\r
82 pointSize: container.fontSize
\r
84 verticalAlignment: Text.AlignVCenter
\r
89 onClicked: { switchedOn = !switchedOn; switched(switchedOn) }
\r