69c7390fbc4314fb01e767773710147b968d0591
[ubi] / qml / ubi / components / Showable.qml
1 import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
2 //import "../UIConstants.js" as Const
3
4 Item {
5     id: root
6
7     property bool hidden: false
8     property int easingType: Easing.InOutCubic
9     property int speed: 1
10
11     state: hidden ? "closed" : "opened"
12     //visible: !hidden
13
14     Component.onCompleted: {
15         if(hidden) state = "closed";
16     }
17
18     function show() {
19         root.state = "opened";
20     }
21
22     function hide() {
23         root.state = "closed";
24     }
25
26     states: [
27         State {
28             name: "opened"
29             PropertyChanges { target: root; y: 0}
30             PropertyChanges { target: root; visible: true }
31         },
32         State {
33             name: "closed"
34             PropertyChanges { target: root; y: root.height }
35             //PropertyChanges { target: root; visible: false }
36         }
37     ]
38
39     transitions: Transition {
40         NumberAnimation { properties: "y"; easing.type: root.easingType;
41             duration: root.speed*root.height/2;
42         }
43     }
44
45     onStateChanged: {
46         if(state=="closed") time.start()
47     }
48
49     Timer {
50         id: time
51         interval: root.speed*root.height/2
52         onTriggered: {
53             //console.log("aaa");
54             root.visible = false;
55         }
56     }
57
58 }