* New icons
[ubi] / qml / ubi / TaskBar.qml
1 import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
2 import "components"
3 import "UIConstants.js" as Const
4
5 Item {
6     id: root
7
8     property bool isEmpty: progressArea.count==0 && menu.children.length==0
9     property bool isActiveDownloads: progressArea.count>0
10
11     width: mainWindow.width
12     height: items.height + 3*Const.DEFAULT_MARGIN
13     state: "closed"
14
15     function open() {
16         if(progressArea.count>0 || menu.children.length>0) {
17             state = "opened";
18             pageStack.currentPage.mask.state = "defocused";
19         }
20     }
21
22     function close() {
23         state = "closed"
24         pageStack.currentPage.mask.state = "idle";
25     }
26
27     function addTask(filename) {
28         progress.addTask(filename);
29     }
30
31     function getMenu() {
32         return menu;
33     }
34
35     function fixHeight() {
36         root.height = items.height + 3*Const.DEFAULT_MARGIN;
37     }
38
39     Rectangle {
40         id: box
41         width: parent.width
42         height: parent.height
43         y: 0
44         color: Const.LIGHT_AUBERGINE_COLOR
45
46         MouseArea {
47             anchors.fill: parent
48         }
49     }
50
51     Shadow {
52         y: box.height
53     }
54
55     Connections {
56         target: Utils
57         onFileDownloadProgress: progressArea.setProgress(filename,progress)
58         onFileUploadProgress: progressArea.setProgress(filename,progress)
59         onDownloadAdded: progressArea.addTask("download",filename)
60         onUploadAdded: progressArea.addTask("upload",filename)
61         onDownloadStarted: progressArea.start(filename)
62         onUploadStarted: progressArea.start(filename)
63         onFileDownloaded: progressArea.stop(filename)
64         onFileUploaded: progressArea.stop(filename)
65         onDownloadError: progressArea.stop(filename)
66         onUploadError: progressArea.stop(filename)
67     }
68
69     Column {
70         id: items
71         y: Const.DEFAULT_MARGIN
72         width: root.width-2*Const.DEFAULT_MARGIN
73         spacing: Const.DEFAULT_MARGIN
74         anchors.horizontalCenter: box.horizontalCenter
75
76         Flow {
77             id: menu
78             width: parent.width
79             spacing: Const.DEFAULT_MARGIN
80         }
81
82         Line {
83             width: root.width-3*Const.DEFAULT_MARGIN
84             anchors.horizontalCenter: parent.horizontalCenter
85             visible: progressArea.count>0
86         }
87         Spacer {
88             visible: progressArea.count>0
89         }
90
91         DownloadArea {
92             id: progressArea
93             width: root.width-3*Const.DEFAULT_MARGIN
94         }
95
96     }
97
98     states: [
99         State {
100             name: "opened"
101             PropertyChanges { target: root; opacity: 1 }
102             PropertyChanges { target: root; y: 0}
103         },
104         State {
105             name: "closed"
106             PropertyChanges { target: root; opacity: 0 }
107             PropertyChanges { target: root; y: 0-root.height }
108         }
109     ]
110
111     transitions: Transition {
112         NumberAnimation { properties: "opacity"; easing.type: Easing.InOutQuad }
113         NumberAnimation { properties: "y"; easing.type: Easing.InOutQuad }
114         NumberAnimation { properties: "height"; easing.type: Easing.InOutQuad }
115     }
116
117 }