summaryrefslogtreecommitdiffstats
path: root/CoffeeTweed/Counter_cupsDown.qml
blob: 9507390518cd94de94479fed5286ac81be6048f2 (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
import Qt 4.7

Item {
    width: 100; height: 90;
    state: "default"

    Text {
        id: cupsDown_counter
        x: 20; y: 0
        width: parent.width

        text: "0"
        color: "#999"; font.bold: true; font.pixelSize: 50; smooth: true; horizontalAlignment: "AlignRight"

        Behavior on opacity {
            NumberAnimation { duration: 300;}
        }
    }

    function reset_counter_state() {
        counter_cupsDown.state = "default"
    }

    states: [
        State {
            name: "default"
        },
        State {
            name: "add_count"
        },
        State {
            name: "remove_count"
        }
    ]

    transitions: [
        Transition {
            from: "default"; to: "add_count"
            SequentialAnimation {
                PropertyAnimation { target: cupsDown_counter; property: "opacity"; to: 0; }
                PropertyAction{ target: cupsDown_counter; property: "text"; value: coffee_count }
                PauseAnimation { duration: 1500; }
                PropertyAnimation { target: cupsDown_counter; property: "opacity"; to: 1; }
                ScriptAction { script: reset_counter_state() }
            }
        },
        Transition {
            from: "default"; to: "remove_count"
            SequentialAnimation {
                PropertyAnimation { target: cupsDown_counter; property: "opacity"; to: 0; }
                PropertyAction{ target: cupsDown_counter; property: "text"; value: coffee_count }
                PauseAnimation { duration: 300; }
                PropertyAnimation { target: cupsDown_counter; property: "opacity"; to: 1; }
                ScriptAction { script: reset_counter_state() }
            }
        }
    ]
}