24
24
The padding between the thumb and the outside border of the switch.
26
property real thumbPadding: units.gu(0.33)
29
The padding between the icon and the border of the thumb.
31
property real iconPadding: thumbPadding
33
implicitWidth: units.gu(6)
34
implicitHeight: units.gu(3)
35
opacity: styledItem.enabled ? 1.0 : 0.5
26
property real thumbPadding: 0
28
implicitWidth: units.gu(5)
29
implicitHeight: units.gu(2.5)
36
30
LayoutMirroring.enabled: false
37
31
LayoutMirroring.childrenInherit: true
40
34
The background color of the switch.
42
property color backgroundColor: theme.palette.normal.base
45
The background color of the thumb when the switch is checked.
47
property color checkedThumbColor: UbuntuColors.green
50
The background color of the thumb when the switch is not checked.
52
property color uncheckedThumbColor: Qt.rgba(0, 0, 0, 0.2)
55
The foreground color of the icon that is currently selected.
57
property color selectedIconColor: theme.palette.normal.foregroundText
60
The color of the icon that is not currently selected.
62
property color unselectedIconColor: theme.palette.normal.backgroundText
65
The source of the selected icon when the switch is checked.
67
property url checkedIconSource: "image://theme/tick"
70
The source of the selected icon when the switch is not checked.
72
property url uncheckedIconSource: "image://theme/close"
36
property color backgroundColor: styledItem.enabled ? theme.palette.normal.base : theme.palette.inactive.base
39
The background color of the checked switch.
41
property color checkedBackgroundColor: styledItem.enabled ? theme.palette.normal.positive : theme.palette.inactive.base
43
The background color of the thumb.
45
property color thumbColor: styledItem.enabled ? theme.palette.normal.raised : theme.palette.inactive.raised
88
61
when: styledItem.checked
91
x: rightThumbPosition.x
92
backgroundColor: switchStyle.checkedThumbColor
64
anchors.left: undefined
65
anchors.right: parent.right
97
when: !styledItem.checked
100
x: leftThumbPosition.x
101
backgroundColor: switchStyle.uncheckedThumbColor
69
backgroundColor: switchStyle.checkedBackgroundColor
107
75
// Avoid animations on width changes (during initialization)
108
76
// by explicitly setting from and to for the Transitions.
112
UbuntuNumberAnimation {
115
duration: UbuntuAnimation.FastDuration
116
easing: UbuntuAnimation.StandardEasing
120
properties: "backgroundColor"
121
duration: UbuntuAnimation.FastDuration
122
easing: UbuntuAnimation.StandardEasing
128
UbuntuNumberAnimation {
131
84
duration: UbuntuAnimation.FastDuration
132
85
easing: UbuntuAnimation.StandardEasing
96
backgroundColor: switchStyle.thumbColor
143
97
width: (background.width - switchStyle.thumbPadding * 3.0) / 2.0
146
100
bottom: parent.bottom
147
102
topMargin: switchStyle.thumbPadding
148
103
bottomMargin: switchStyle.thumbPadding
151
property real iconSize: Math.min(width, height) - 2*switchStyle.iconPadding
155
verticalCenter: parent.verticalCenter
157
rightMargin: switchStyle.iconPadding + switchStyle.thumbPadding
159
rightColor: switchStyle.unselectedIconColor
161
source: switchStyle.uncheckedIconSource
163
width: thumb.iconSize
164
height: thumb.iconSize
171
verticalCenter: parent.verticalCenter
173
leftMargin: switchStyle.iconPadding + switchStyle.thumbPadding
175
rightColor: switchStyle.unselectedIconColor
177
source: switchStyle.checkedIconSource
179
width: thumb.iconSize
180
height: thumb.iconSize
187
id: leftThumbPosition
191
leftMargin: switchStyle.thumbPadding
192
topMargin: switchStyle.thumbPadding
198
anchors.centerIn: parent
200
source: switchStyle.uncheckedIconSource
202
width: thumb.iconSize
203
height: thumb.iconSize
206
progress: MathUtils.clamp((thumb.x - parent.x - x) / width, 0.0, 1.0)
207
leftColor: "transparent"
208
rightColor: switchStyle.selectedIconColor
213
id: rightThumbPosition
217
rightMargin: switchStyle.thumbPadding
218
topMargin: switchStyle.thumbPadding
224
anchors.centerIn: parent
226
source: switchStyle.checkedIconSource
228
width: thumb.iconSize
229
height: thumb.iconSize
232
progress: MathUtils.clamp((thumb.x + thumb.width - parent.x - x) / width, 0.0, 1.0)
233
leftColor: switchStyle.selectedIconColor
234
rightColor: "transparent"