summaryrefslogtreecommitdiffstats
path: root/examples/declarative/tutorials/contacts/2_Reuse/1/RemoveButton.qml
blob: a0f38802f9d3f10af497a49a2c96e52b33d6fa91 (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
Rect {
    id: removeButton
    width: 30
    height: 30
    color: "red"
    radius: 5
    resources: [
        Script {
            function toggle() {
                if (removeButton.state == 'opened') {
                    removeButton.state = '';
                } else {
                    removeButton.state = 'opened';
                }
            }
        
        }
    ]
    Image {
        id: trashIcon
        width: 22
        height: 22
        anchors.right: parent.right
        anchors.rightMargin: 4
        anchors.verticalCenter: parent.verticalCenter
        source: "../../shared/pics/trash.png"
        opacity: 1
        MouseRegion {
            anchors.fill: parent
            onClicked: { toggle() }
        }
    }
    Image {
        id: cancelIcon
        width: 22
        height: 22
        anchors.right: parent.right
        anchors.rightMargin: 4
        anchors.verticalCenter: parent.verticalCenter
        source: "../../shared/pics/cancel.png"
        opacity: 0
        MouseRegion {
            anchors.fill: parent
            onClicked: { toggle() }
        }
    }
    Image {
        id: confirmIcon
        width: 22
        height: 22
        anchors.left: parent.left
        anchors.leftMargin: 4
        anchors.verticalCenter: parent.verticalCenter
        source: "../../shared/pics/ok.png"
        opacity: 0
        MouseRegion {
            anchors.fill: parent
            onClicked: { toggle() }
        }
    }
    Text {
        id: text
        anchors.verticalCenter: parent.verticalCenter
        anchors.left: confirmIcon.right
        anchors.leftMargin: 4
        anchors.right: cancelIcon.left
        anchors.rightMargin: 4
        font.bold: true
        color: "white"
        hAlign: "AlignHCenter"
        text: "Remove"
        opacity: 0
    }
    states: [
        State {
            name: "opened"
            SetProperties {
                target: removeButton
                width: 230
            }
            SetProperties {
                target: text
                opacity: 1
            }
            SetProperties {
                target: confirmIcon
                opacity: 1
            }
            SetProperties {
                target: cancelIcon
                opacity: 1
            }
            SetProperties {
                target: trashIcon
                opacity: 0
            }
        }
    ]
    transitions: [
        Transition {
            fromState: "*"
            toState: "opened"
            reversible: true
            NumberAnimation {
                properties: "opacity,x,width"
                duration: 200
            }
        }
    ]
}