summaryrefslogtreecommitdiffstats
path: root/examples/declarative/tutorials/contacts/3_Collections/3/Button.qml
blob: 8290d35d3cb8c830d1d85f34cac835db896f8421 (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
<Item id="button" width="30" height="30">
    <properties>
        <Property name="icon"/>
    </properties>
    <signals>
        <Signal name="clicked"/>
    </signals>
    <Rect id="buttonRect"
        anchors.fill="{parent}"
        color="lightgreen"
        radius="5">
        <Image id="iconImage"
            src="{button.icon}"
            anchors.horizontalCenter="{buttonRect.horizontalCenter}"
            anchors.verticalCenter="{buttonRect.verticalCenter}"/>
        <MouseRegion id="buttonMouseRegion"
            anchors.fill="{buttonRect}"
            onClicked="button.clicked.emit()"/>
        <states>
            <State name="pressed" when="{buttonMouseRegion.pressed == true}">
                <SetProperty target="{buttonRect}" property="color" value="green"/>
            </State>
        </states>
        <transitions>
            <Transition fromState="*" toState="pressed">
                <ColorAnimation duration="200"/>
            </Transition>
            <Transition fromState="pressed" toState="*">
                <ColorAnimation duration="1000"/>
            </Transition>
        </transitions>
    </Rect>
    <opacity>
        <Behaviour>
            <NumericAnimation property="opacity" duration="250"/>
        </Behaviour>
    </opacity>
</Item>