<?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>&lt;@comment&gt;// Copyright (C) 2016 The Qt Company Ltd.&lt;/@comment&gt;
&lt;@comment&gt;// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause&lt;/@comment&gt;

import QtQuick 1.0

&lt;@comment&gt;/*!
    \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.

*/&lt;/@comment&gt;
&lt;@type&gt;Item&lt;/@type&gt; {
    &lt;@name&gt;id&lt;/@name&gt;: &lt;@name&gt;toggleswitch&lt;/@name&gt;
    &lt;@name&gt;width&lt;/@name&gt;: &lt;@name&gt;background&lt;/@name&gt;.&lt;@name&gt;width&lt;/@name&gt;; &lt;@name&gt;height&lt;/@name&gt;: &lt;@name&gt;background&lt;/@name&gt;.&lt;@name&gt;height&lt;/@name&gt;

    &lt;@comment&gt;/*!
       Indicates the state of the switch. If \c false, then the switch is in
       the \c off state.

       \omit
            The \qmlproperty &amp;lt;type&amp;gt; &amp;lt;propertyname&amp;gt; is not necessary as QDoc
            will associate this property to the ToggleSwitch

           QDoc will not publish the documentation within omit and endomit.
       \endomit
    */&lt;/@comment&gt;
    property &lt;@type&gt;bool&lt;/@type&gt; &lt;@name&gt;on&lt;/@name&gt;: &lt;@number&gt;false&lt;/@number&gt;

    &lt;@comment&gt;/*!
        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.
    */&lt;/@comment&gt;
    &lt;@keyword&gt;function&lt;/@keyword&gt; &lt;@name&gt;toggle&lt;/@name&gt;() {
        &lt;@keyword&gt;if&lt;/@keyword&gt; (&lt;@name&gt;toggleswitch&lt;/@name&gt;.&lt;@name&gt;state&lt;/@name&gt; &lt;@op&gt;==&lt;/@op&gt; &lt;@string&gt;&amp;quot;on&amp;quot;&lt;/@string&gt;)
            &lt;@name&gt;toggleswitch&lt;/@name&gt;.&lt;@name&gt;state&lt;/@name&gt; &lt;@op&gt;=&lt;/@op&gt; &lt;@string&gt;&amp;quot;off&amp;quot;&lt;/@string&gt;;
        &lt;@keyword&gt;else&lt;/@keyword&gt;
            &lt;@name&gt;toggleswitch&lt;/@name&gt;.&lt;@name&gt;state&lt;/@name&gt; &lt;@op&gt;=&lt;/@op&gt; &lt;@string&gt;&amp;quot;on&amp;quot;&lt;/@string&gt;;
    }

    &lt;@comment&gt;/*!
        \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.
    */&lt;/@comment&gt;
    &lt;@keyword&gt;function&lt;/@keyword&gt; &lt;@name&gt;releaseSwitch&lt;/@name&gt;() {
        &lt;@keyword&gt;if&lt;/@keyword&gt; (&lt;@name&gt;knob&lt;/@name&gt;.&lt;@name&gt;x&lt;/@name&gt; &lt;@op&gt;==&lt;/@op&gt; &lt;@number&gt;1&lt;/@number&gt;) {
            &lt;@keyword&gt;if&lt;/@keyword&gt; (&lt;@name&gt;toggleswitch&lt;/@name&gt;.&lt;@name&gt;state&lt;/@name&gt; &lt;@op&gt;==&lt;/@op&gt; &lt;@string&gt;&amp;quot;off&amp;quot;&lt;/@string&gt;) &lt;@keyword&gt;return&lt;/@keyword&gt;;
        }
        &lt;@keyword&gt;if&lt;/@keyword&gt; (&lt;@name&gt;knob&lt;/@name&gt;.&lt;@name&gt;x&lt;/@name&gt; &lt;@op&gt;==&lt;/@op&gt; &lt;@number&gt;78&lt;/@number&gt;) {
            &lt;@keyword&gt;if&lt;/@keyword&gt; (&lt;@name&gt;toggleswitch&lt;/@name&gt;.&lt;@name&gt;state&lt;/@name&gt; &lt;@op&gt;==&lt;/@op&gt; &lt;@string&gt;&amp;quot;on&amp;quot;&lt;/@string&gt;) &lt;@keyword&gt;return&lt;/@keyword&gt;;
        }
        &lt;@name&gt;toggle&lt;/@name&gt;();
    }

    &lt;@type&gt;Rectangle&lt;/@type&gt; {
        &lt;@name&gt;id&lt;/@name&gt;: &lt;@name&gt;background&lt;/@name&gt;
        &lt;@name&gt;width&lt;/@name&gt;: &lt;@number&gt;130&lt;/@number&gt;; &lt;@name&gt;height&lt;/@name&gt;: &lt;@number&gt;48&lt;/@number&gt;
        &lt;@name&gt;radius&lt;/@name&gt;: &lt;@number&gt;48&lt;/@number&gt;
        &lt;@name&gt;color&lt;/@name&gt;: &lt;@string&gt;&amp;quot;lightsteelblue&amp;quot;&lt;/@string&gt;
        &lt;@type&gt;MouseArea&lt;/@type&gt; { &lt;@name&gt;anchors&lt;/@name&gt;.fill: &lt;@name&gt;parent&lt;/@name&gt;; &lt;@name&gt;onClicked&lt;/@name&gt;: &lt;@name&gt;toggle&lt;/@name&gt;() }
    }

    &lt;@type&gt;Rectangle&lt;/@type&gt; {
        &lt;@name&gt;id&lt;/@name&gt;: &lt;@name&gt;knob&lt;/@name&gt;
        &lt;@name&gt;width&lt;/@name&gt;: &lt;@number&gt;48&lt;/@number&gt;; &lt;@name&gt;height&lt;/@name&gt;: &lt;@number&gt;48&lt;/@number&gt;
        &lt;@name&gt;radius&lt;/@name&gt;: &lt;@name&gt;width&lt;/@name&gt;
        &lt;@name&gt;color&lt;/@name&gt;: &lt;@string&gt;&amp;quot;lightblue&amp;quot;&lt;/@string&gt;

        &lt;@type&gt;MouseArea&lt;/@type&gt; {
            &lt;@name&gt;anchors&lt;/@name&gt;.fill: &lt;@name&gt;parent&lt;/@name&gt;
            &lt;@name&gt;drag&lt;/@name&gt;.target: &lt;@name&gt;knob&lt;/@name&gt;; &lt;@name&gt;drag&lt;/@name&gt;.axis: &lt;@name&gt;Drag&lt;/@name&gt;.&lt;@name&gt;XAxis&lt;/@name&gt;; &lt;@name&gt;drag&lt;/@name&gt;.minimumX: &lt;@number&gt;1&lt;/@number&gt;; &lt;@name&gt;drag&lt;/@name&gt;.maximumX: &lt;@number&gt;78&lt;/@number&gt;
            &lt;@name&gt;onClicked&lt;/@name&gt;: &lt;@name&gt;toggle&lt;/@name&gt;()
            &lt;@name&gt;onReleased&lt;/@name&gt;: &lt;@name&gt;releaseSwitch&lt;/@name&gt;()
        }
    }

    &lt;@name&gt;states&lt;/@name&gt;: [
        &lt;@type&gt;State&lt;/@type&gt; {
            &lt;@name&gt;name&lt;/@name&gt;: &lt;@string&gt;&amp;quot;on&amp;quot;&lt;/@string&gt;
            &lt;@type&gt;PropertyChanges&lt;/@type&gt; { &lt;@name&gt;target&lt;/@name&gt;: &lt;@name&gt;knob&lt;/@name&gt;; &lt;@name&gt;x&lt;/@name&gt;: &lt;@number&gt;78&lt;/@number&gt; }
            &lt;@type&gt;PropertyChanges&lt;/@type&gt; { &lt;@name&gt;target&lt;/@name&gt;: &lt;@name&gt;toggleswitch&lt;/@name&gt;; &lt;@name&gt;on&lt;/@name&gt;: &lt;@number&gt;true&lt;/@number&gt; }
        },
        &lt;@type&gt;State&lt;/@type&gt; {
            &lt;@name&gt;name&lt;/@name&gt;: &lt;@string&gt;&amp;quot;off&amp;quot;&lt;/@string&gt;
            &lt;@type&gt;PropertyChanges&lt;/@type&gt; { &lt;@name&gt;target&lt;/@name&gt;: &lt;@name&gt;knob&lt;/@name&gt;; &lt;@name&gt;x&lt;/@name&gt;: &lt;@number&gt;1&lt;/@number&gt; }
            &lt;@type&gt;PropertyChanges&lt;/@type&gt; { &lt;@name&gt;target&lt;/@name&gt;: &lt;@name&gt;toggleswitch&lt;/@name&gt;; &lt;@name&gt;on&lt;/@name&gt;: &lt;@number&gt;false&lt;/@number&gt; }
        }
    ]

    &lt;@name&gt;transitions&lt;/@name&gt;: &lt;@name&gt;Transition&lt;/@name&gt; {
        &lt;@type&gt;NumberAnimation&lt;/@type&gt; { &lt;@name&gt;properties&lt;/@name&gt;: &lt;@string&gt;&amp;quot;x&amp;quot;&lt;/@string&gt;; &lt;@name&gt;easing&lt;/@name&gt;.type: &lt;@name&gt;Easing&lt;/@name&gt;.&lt;@name&gt;InOutQuad&lt;/@name&gt;; &lt;@name&gt;duration&lt;/@name&gt;: &lt;@number&gt;200&lt;/@number&gt; }
    }
}</code>
            </description>
        </page>
    </document>
</WebXML>
