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