blob: 4e09d9f25d1bffd5c071e54ae7b0af154d80f79f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
<?xml version="1.0" encoding="UTF-8"?>
<WebXML>
<document>
<page name="componentset/Switch.qml" href="test-componentset-switch-qml.html" title="Switch.qml Example File" fulltitle="Switch.qml Example File" subtitle="componentset/Switch.qml">
<description>
<code><@comment>// Copyright (C) 2016 The Qt Company Ltd.</@comment>
<@comment>// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause</@comment>
import QtQuick 1.0
<@comment>/*!
\qmltype ToggleSwitch
\inqmlmodule UIComponents
\brief A component that can be turned on or off.
A toggle switch has two states: an \c on and an \c off state. The \c off
state is when the \l on property is set to \c false.
The ToggleSwitch component is part of the \l {UI Components} module.
This documentation is part of the \l{componentset}{UIComponents} example.
*/</@comment>
<@type>Item</@type> {
<@name>id</@name>: <@name>toggleswitch</@name>
<@name>width</@name>: <@name>background</@name>.<@name>width</@name>; <@name>height</@name>: <@name>background</@name>.<@name>height</@name>
<@comment>/*!
Indicates the state of the switch. If \c false, then the switch is in
the \c off state.
\omit
The \qmlproperty &lt;type&gt; &lt;propertyname&gt; is not necessary as QDoc
will associate this property to the ToggleSwitch
QDoc will not publish the documentation within omit and endomit.
\endomit
*/</@comment>
property <@type>bool</@type> <@name>on</@name>: <@number>false</@number>
<@comment>/*!
A method to toggle the switch. If the switch is \c on, the toggling it
will turn it \c off. Toggling a switch in the \c off position will
turn it \c on.
*/</@comment>
<@keyword>function </@keyword><@name>toggle</@name>() {
<@keyword>if</@keyword> (<@name>toggleswitch</@name>.<@name>state</@name> <@op>==</@op> <@string>&quot;on&quot;</@string>)
<@name>toggleswitch</@name>.<@name>state</@name> <@op>=</@op> <@string>&quot;off&quot;</@string>;
<@keyword>else</@keyword>
<@name>toggleswitch</@name>.<@name>state</@name> <@op>=</@op> <@string>&quot;on&quot;</@string>;
}
<@comment>/*!
\internal
An internal function to synchronize the switch's internals. This
function is not for public access. The \internal command will
prevent QDoc from publishing this comment in the public API.
*/</@comment>
<@keyword>function </@keyword><@name>releaseSwitch</@name>() {
<@keyword>if</@keyword> (<@name>knob</@name>.<@name>x</@name> <@op>==</@op> <@number>1</@number>) {
<@keyword>if</@keyword> (<@name>toggleswitch</@name>.<@name>state</@name> <@op>==</@op> <@string>&quot;off&quot;</@string>) <@keyword>return</@keyword>;
}
<@keyword>if</@keyword> (<@name>knob</@name>.<@name>x</@name> <@op>==</@op> <@number>78</@number>) {
<@keyword>if</@keyword> (<@name>toggleswitch</@name>.<@name>state</@name> <@op>==</@op> <@string>&quot;on&quot;</@string>) <@keyword>return</@keyword>;
}
<@name>toggle</@name>();
}
<@type>Rectangle</@type> {
<@name>id</@name>: <@name>background</@name>
<@name>width</@name>: <@number>130</@number>; <@name>height</@name>: <@number>48</@number>
<@name>radius</@name>: <@number>48</@number>
<@name>color</@name>: <@string>&quot;lightsteelblue&quot;</@string>
<@type>MouseArea</@type> { <@name>anchors</@name>.fill: <@name>parent</@name>; <@name>onClicked</@name>: <@name>toggle</@name>() }
}
<@type>Rectangle</@type> {
<@name>id</@name>: <@name>knob</@name>
<@name>width</@name>: <@number>48</@number>; <@name>height</@name>: <@number>48</@number>
<@name>radius</@name>: <@name>width</@name>
<@name>color</@name>: <@string>&quot;lightblue&quot;</@string>
<@type>MouseArea</@type> {
<@name>anchors</@name>.fill: <@name>parent</@name>
<@name>drag</@name>.target: <@name>knob</@name>; <@name>drag</@name>.axis: <@name>Drag</@name>.<@name>XAxis</@name>; <@name>drag</@name>.minimumX: <@number>1</@number>; <@name>drag</@name>.maximumX: <@number>78</@number>
<@name>onClicked</@name>: <@name>toggle</@name>()
<@name>onReleased</@name>: <@name>releaseSwitch</@name>()
}
}
<@name>states</@name>: [
<@type>State</@type> {
<@name>name</@name>: <@string>&quot;on&quot;</@string>
<@type>PropertyChanges</@type> { <@name>target</@name>: <@name>knob</@name>; <@name>x</@name>: <@number>78</@number> }
<@type>PropertyChanges</@type> { <@name>target</@name>: <@name>toggleswitch</@name>; <@name>on</@name>: <@number>true</@number> }
},
<@type>State</@type> {
<@name>name</@name>: <@string>&quot;off&quot;</@string>
<@type>PropertyChanges</@type> { <@name>target</@name>: <@name>knob</@name>; <@name>x</@name>: <@number>1</@number> }
<@type>PropertyChanges</@type> { <@name>target</@name>: <@name>toggleswitch</@name>; <@name>on</@name>: <@number>false</@number> }
}
]
<@name>transitions</@name>: <@name>Transition</@name> {
<@type>NumberAnimation</@type> { <@name>properties</@name>: <@string>&quot;x&quot;</@string>; <@name>easing</@name>.type: <@name>Easing</@name>.<@name>InOutQuad</@name>; <@name>duration</@name>: <@number>200</@number> }
}
}</code>
</description>
</page>
</document>
</WebXML>
|