summaryrefslogtreecommitdiffstats
path: root/examples/declarative/tutorials/contacts/t8/Field.qml
blob: 0191ef89f9b42fe73de9b41445aa7e076dff2e94 (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
<Item height="30" width="200" id="field">
    <properties>
        <Property name="value" onValueChanged="fieldText.text=field.value"/>
        <Property name="icon"/>
        <Property name="editable" value="0"/>
        <Property name="label"/>
    </properties>
    <Item id="fieldSelector" width="30" height="30"
        x="0"
        anchors.top="{parent.top}"
        anchors.bottom="{parent.bottom}">
        <Image src="{field.icon}"
            anchors.verticalCenter="{parent.verticalCenter}"
            anchors.horizontalCenter="{parent.horizontalCenter}"/>
    </Item>
    <FieldText id="fieldText"
        label="{field.label}"
        width="{field.width-70}"
        anchors.left="{fieldSelector.right}"
        anchors.leftMargin="5"
        anchors.top="{parent.top}"
        anchors.bottom="{parent.bottom}"
        onTextEdited="field.value = fieldText.text"/>
    <FieldRemover id="fieldRemover"
        anchors.left="{fieldText.right}"
        anchors.leftMargin="5"
        anchors.top="{parent.top}"
        anchors.bottom="{parent.bottom}"
        onConfirm="fieldText.text = ''"
        opacity="{field.editable}"/>
    <states>
        <State name="textFill" when="{fieldText.open == 'true'}">
            <SetProperty target="{fieldText}" property="width" value="{field.width}"/>
            <SetProperty target="{fieldText}" property="x" value="0"/>
            <SetProperty target="{fieldRemover}" property="opacity" value="0"/>
            <SetProperty target="{fieldSelector}" property="opacity" value="0"/>
            <SetProperty target="{fieldSelector}" property="x" value="{-5-fieldSelector.width}"/>
        </State>
        <State name="removerFill" when="{fieldRemover.open == 'true'}">
            <SetProperty target="{fieldRemover}" property="width" value="{field.width}"/>
            <SetProperty target="{fieldRemover}" property="x" value="0"/>
            <SetProperty target="{fieldText}" property="opacity" value="0"/>
            <SetProperty target="{fieldSelector}" property="opacity" value="0"/>
            <SetProperty target="{fieldSelector}" property="x" value="{-10-fieldText.width-fieldSelector.width}"/>
        </State>
    </states>
    <transitions>
        <Transition fromState="*" toState="*">
            <NumericAnimation target="{fieldSelector}" properties="width,x,opacity" duration="200"/>
            <NumericAnimation target="{fieldText}" properties="width,x,opacity" duration="200"/>
            <NumericAnimation target="{fieldRemover}" properties="width,x,opacity" duration="200"/>
        </Transition>
    </transitions>
</Item>