0.9.3-1 release
[ubi] / qml / ubi / components / NotificationNew.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     state: "invisible"
8
9     //width: box.width
10     height: box.height
11
12     Rectangle {
13         width: box.width
14         height: box.height
15         color: Const.SHADOW_COLOR;
16         radius: 5
17         x: 2*Const.SHADOW_OFFSET;
18         y: 2*Const.SHADOW_OFFSET;
19     }
20
21     Rectangle {
22         id: box
23         height: text.height+4*Const.DEFAULT_MARGIN
24         width: root.width
25         color: Const.COOL_GREY_COLOR
26         radius: 5
27
28         border.color: Const.WARM_GREY_COLOR
29         border.width: 1
30
31         Text {
32             id: text
33             anchors.centerIn: parent
34             anchors.margins: Const.DEFAULT_MARGIN
35             color: Const.DEFAULT_FOREGROUND_COLOR
36             wrapMode: Text.WordWrap
37             font.pixelSize: Const.DEFAULT_FONT_PIXEL_SIZE
38             width: parent.width-2*Const.DEFAULT_MARGIN
39             horizontalAlignment: Text.Center
40         }
41
42         MouseArea {
43             anchors.fill: parent
44             onClicked: tip.state = "invisible"
45         }
46     }
47
48     function show(_text)
49     {
50         text.text= _text;
51         if(_text.length > 40) {
52             time.interval = _text.length*100;
53         } else {
54             time.interval = 3000;
55         }
56         state = "visible"
57         time.restart();
58     }
59
60     function show2(_text,interval)
61     {
62         text.text= _text;
63         time.interval = interval;
64         state = "visible"
65         time.restart();
66     }
67
68     function hide()
69     {
70         text.text="";
71         state="invisible";
72     }
73
74     Timer {
75         id: time
76         interval: 3000
77         onTriggered: {
78             tip.state = "invisible";
79         }
80     }
81
82     states: [
83         State {
84             name: "visible"
85             PropertyChanges { target: root; opacity: 1 }
86             PropertyChanges { target: root; width: mainWindow.width-2*Const.TEXT_MARGIN }
87             PropertyChanges { target: text; font.pixelSize: Const.DEFAULT_FONT_PIXEL_SIZE }
88         },
89         State {
90             name: "invisible"
91             PropertyChanges { target: root; width: 0 }
92             PropertyChanges { target: text; font.pixelSize: 1 }
93             PropertyChanges { target: root; opacity: 0 }
94         }
95     ]
96
97     transitions: Transition {
98         NumberAnimation { properties: "opacity"; easing.type: Easing.InOutBack }
99         NumberAnimation { properties: "width"; easing.type: Easing.InOutBack}
100         NumberAnimation { properties: "font.pixelSize"; easing.type: Easing.InOutBack}
101     }
102
103 }