change size to 1920x1080
[apps/homescreen.git] / homescreen / qml / StatusArea.qml
1 /*
2  * Copyright (C) 2016 The Qt Company Ltd.
3  * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 import QtQuick 2.2
19 import QtQuick.Layouts 1.1
20 import HomeScreen 1.0
21
22 Item {
23     id: root
24     width: 700
25     height: 80
26
27     property date now: new Date
28     Timer {
29         interval: 100; running: true; repeat: true;
30         onTriggered: root.now = new Date
31     }
32
33     Timer {
34         id:notificationTimer
35         interval: 3000
36         running: false
37         repeat: true
38         onTriggered: notificationItem.visible = false
39     }
40
41     Connections {
42         target: weather
43
44         onConditionChanged: {
45             var icon = ''
46
47             if (condition.indexOf("clouds") !== -1) {
48                 icon = "WeatherIcons_Cloudy-01.png"
49             } else if (condition.indexOf("thunderstorm") !== -1) {
50                 icon = "WeatherIcons_Thunderstorm-01.png"
51             } else if (condition.indexOf("snow") !== -1) {
52                 icon = "WeatherIcons_Snow-01.png"
53             } else if (condition.indexOf("rain") !== -1) {
54                 icon = "WeatherIcons_Rain-01.png"
55             }
56
57             condition_item.source = icon ? './images/Weather/' + icon : ''
58         }
59
60         onTemperatureChanged: {
61             temperature_item.text = temperature.split(".")[0] + '°F'
62         }
63     }
64
65         RowLayout {
66             anchors.fill: parent
67             spacing: 0
68             RowLayout {
69                 id: icons
70                 Layout.fillWidth: true
71                 Layout.fillHeight: true
72                 Layout.preferredWidth: 120
73                 spacing: -10
74
75                 Image {
76                     id: bt_icon
77                     Layout.preferredWidth: 50
78                     Layout.preferredHeight: 50
79                     source: connStatus ? './images/Status/HMI_Status_Bluetooth_On-01.png' : './images/Status/HMI_Status_Bluetooth_Inactive-01.png'
80                     fillMode: Image.PreserveAspectFit
81                     property string deviceName: "none"
82                     property bool connStatus: false
83                     Connections {
84                         target: bluetooth
85                         onConnectionEvent: {
86                             console.log("onConnectionEvent", data.Status)
87                             if (data.Status === "connected") {
88                                 bt_icon.connStatus = true
89                             } else if (data.Status === "disconnected") {
90                                 bt_icon.connStatus = false
91                             }
92                         }
93                         onDeviceUpdateEvent: {
94                             console.log("onConnectionEvent", data.Paired)
95                             if (data.Paired === "True" && data.Connected === "True") {
96                                 bt_icon.deviceName = data.name
97                                 bt_icon.connStatus = true
98                             } else {
99                                 if(bt_icon.deviceName === data.Name)
100                                 {
101                                     bt_icon.connStatus = false
102                                 }
103                             }
104                         }
105                     }
106                 }
107
108                 Repeater {
109                     model: StatusBarModel { objectName: "statusBar" }
110                     delegate: Image {
111                         Layout.preferredWidth: 50
112                         Layout.preferredHeight: 50
113                         source: model.modelData
114                         fillMode: Image.PreserveAspectFit
115                     }
116                 }
117             }
118             Item {
119                 anchors.left: icons.right
120                 Layout.fillHeight: true
121                 width: 440
122                 ColumnLayout {
123                     anchors.fill: parent
124                     anchors.margins: 17
125                     spacing: 0
126                     Text {
127                         Layout.fillWidth: true
128                         Layout.fillHeight: true
129                         text: Qt.formatDate(now, 'dddd').toUpperCase()
130                         font.family: 'Roboto'
131                         font.pixelSize: 13
132                         color: 'white'
133                         horizontalAlignment:  Text.AlignHCenter
134                         verticalAlignment:  Text.AlignVCenter
135                     }
136                     Text {
137                         Layout.fillWidth: true
138                         Layout.fillHeight: true
139                         text: Qt.formatTime(now, 'h:mm ap').toUpperCase()
140                         font.family: 'Roboto'
141                         font.pixelSize: 38
142                         color: 'white'
143                         horizontalAlignment:  Text.AlignHCenter
144                         verticalAlignment:  Text.AlignVCenter
145                     }
146                 }
147             }
148             RowLayout {
149                 Layout.fillWidth: true
150                 Layout.fillHeight: true
151                 Layout.preferredHeight: 20
152
153                 Image {
154                     id: condition_item
155                     source: './images/Weather/WeatherIcons_Rain-01.png'
156                 }
157                 Text {
158                     id: temperature_item
159                     text: '64°F'
160                     color: 'white'
161                     font.family: 'Helvetica'
162                     font.pixelSize: 32
163                 }
164             }
165         }
166
167         Item {
168             id: notificationItem
169             x: 0
170             y: 0
171             z: 1
172             width: parent.width
173             height: 100
174             opacity: 0.8
175             visible: false
176
177             Rectangle {
178                 width: parent.width
179                 height: parent.height
180                 anchors.fill: parent
181                 color: "gray"
182                 Image {
183                     id: notificationIcon
184                     width: 70
185                     height: 70
186                     anchors.left: parent.left
187                     anchors.leftMargin: 20
188                     anchors.verticalCenter: parent.verticalCenter
189                     source: ""
190                 }
191
192                 Text {
193                     id: notificationtext
194                     font.pixelSize: 25
195                     anchors.left: notificationIcon.right
196                     anchors.leftMargin: 5
197                     anchors.verticalCenter: parent.verticalCenter
198                     color: "white"
199                     text: qsTr("")
200                 }
201             }
202         }
203
204         Connections {
205             target: homescreenHandler
206             onNotification: {
207                 notificationIcon.source = './images/Shortcut/%1.svg'.arg(id)
208                 notificationtext.text = text
209                 notificationItem.visible = true
210                 notificationTimer.restart()
211             }
212         }
213
214 }