aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmldesigner/data/merging/SwitchExpected.qml
blob: ebaf20c17816ae7c233117536105629f4fc52fc0 (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
import QtQuick 2.10
import QtQuick.Templates 2.1 as T
import TemplateMerging 1.0

T.Switch {
    id: control

    implicitWidth: background.implicitWidth
    implicitHeight: background.implicitHeight

    text: "test"
    indicator: Rectangle {
        id: switchIndicator
        x: control.leftPadding
        y: 34
        width: 64
        height: 44
        color: "#e9e9e9"
        radius: 16
        border.color: "#dddddd"
        anchors.verticalCenter: parent.verticalCenter
        Rectangle {
            id: switchHandle
            width: 31
            height: 44
            color: "#e9e9e9"
            radius: 16
            border.color: "#808080"
        }
    }

    background: Item {
        implicitWidth: switchBackground.width
        implicitHeight: switchBackground.height

        Rectangle {
            id: switchBackground
            width: 144
            height: 52
            color: "#c2c2c2"
            border.color: "#808080"
            anchors.fill: parent
            Text {
                id: switchBackgroundText
                text: control.text
                anchors.verticalCenter: parent.verticalCenter
                anchors.right: parent.right
                anchors.rightMargin: 12
            }
        }
    }

    leftPadding: 4

    contentItem: Item  { //designer want to edit the label as part of background
    }


    states: [
        State {
            name: "off"
            when: !control.checked && !control.down
        },
        State {
            name: "on"
            when: control.checked && !control.down

            PropertyChanges {
                target: switchIndicator
                color: "#1713de"
                border.color: "#1713de"
            }

            PropertyChanges {
                target: switchHandle
                x: parent.width - width
            }
        },
        State {
            name: "off_down"
            when: !control.checked && control.down

            PropertyChanges {
                target: switchIndicator
                color: "#e9e9e9"
            }

            PropertyChanges {
                target: switchHandle
                color: "#d2d2d2"
                border.color: "#d2d2d2"
            }
        },
        State {
            name: "on_down"
            when: control.checked && control.down

            PropertyChanges {
                target: switchHandle
                x: parent.width - width
                color: "#e9e9e9"
            }

            PropertyChanges {
                target: switchIndicator
                color: "#030381"
                border.color: "#030381"
            }
        }
    ]
}