New GUI
[ubi] / qml / ubi / components / Notification.qml
1 import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
2 import Qt 4.7
3 //import QtMultimediaKit 1.1
4 import "../UIConstants.js" as Const
5
6 Item {
7     id: root
8     state: "invisible"
9     width: box.width; height: box.height
10
11     Rectangle {
12         width: box.width
13         height: box.height
14         color: Const.SHADOW_COLOR;
15         radius: 10
16         x: 2*Const.SHADOW_OFFSET;
17         y: 2*Const.SHADOW_OFFSET;
18     }
19
20     Rectangle {
21         id: box
22         width: text.width+30
23         height: text.height+30
24         color: Const.DEFAULT_DIALOG_FOREGROUND_COLOR
25         radius: 10
26         border.color: Const.WARM_GREY_COLOR
27         border.width: 4
28
29         Text {
30             anchors.centerIn: parent
31             id: text
32             color: Const.DEFAULT_BACKGROUND_COLOR
33             wrapMode: Text.WordWrap
34             font.pixelSize: Const.DEFAULT_FONT_PIXEL_SIZE
35         }
36
37         MouseArea {
38             anchors.fill: parent
39             onClicked: tip.state = "invisible"
40         }
41     }
42
43     function show(_text)
44     {
45         text.text= _text;
46         time.interval = 3000;
47         state = "visible"
48         //sound.play();
49         time.restart();
50     }
51
52     function show2(_text,interval)
53     {
54         text.text= _text;
55         time.interval = interval;
56         state = "visible"
57         //sound.play();
58         time.restart();
59     }
60
61     function hide()
62     {
63         text.text="";
64         state="invisible";
65     }
66
67     /*Audio {
68          id: sound
69          source: "../sound/message.wav"
70     }*/
71
72     Timer {
73         id: time
74         interval: 3000
75         onTriggered: {
76             //console.log("time");
77             tip.state = "invisible";
78         }
79     }
80
81     states: [
82         State {
83             name: "visible"
84             PropertyChanges { target: root; opacity: 1 }
85         },
86         State {
87             name: "invisible"
88             PropertyChanges { target: root; opacity: 0 }
89             PropertyChanges { target: root; x: 0 }
90             PropertyChanges { target: root; y: 0 }
91         }
92     ]
93
94     transitions: Transition {
95         NumberAnimation { properties: "opacity"; easing.type: Easing.InOutQuad }
96         NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad }
97         NumberAnimation { properties: "y"; easing.type: Easing.InOutQuad }
98     }
99
100 }