d2e0930f8e84cc3a4fbd5a569d01d5b6e115020e
[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  * Copyright (c) 2017, 2018 TOYOTA MOTOR CORPORATION
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 import QtQuick 2.2
20 import QtQuick.Layouts 1.1
21 import HomeScreen 1.0
22
23 Item {
24     id: root
25     width: 295
26     height: 218
27
28     property date now: new Date
29     Timer {
30         interval: 100; running: true; repeat: true;
31         onTriggered: root.now = new Date
32     }
33
34     Connections {
35         target: weather
36
37         onConditionChanged: {
38             var icon = ''
39
40             if (condition.indexOf("clouds") != -1) {
41                 icon = "WeatherIcons_Cloudy-01.png"
42             } else if (condition.indexOf("thunderstorm") != -1) {
43                 icon = "WeatherIcons_Thunderstorm-01.png"
44             } else if (condition.indexOf("snow") != -1) {
45                 icon = "WeatherIcons_Snow-01.png"
46             } else if (condition.indexOf("rain") != -1) {
47                 icon = "WeatherIcons_Rain-01.png"
48             }
49
50             condition_item.source = icon ? './images/Weather/' + icon : ''
51         }
52
53         onTemperatureChanged: {
54             temperature_item.text = temperature.split(".")[0] + '°F'
55         }
56     }
57
58     RowLayout {
59         anchors.fill: parent
60         spacing: 0
61         Item {
62             Layout.fillWidth: true
63             Layout.fillHeight: true
64             Layout.preferredWidth: 295 - 76
65             ColumnLayout {
66                 anchors.fill: parent
67                 anchors.margins: 40
68                 spacing: 0
69                 Text {
70                     Layout.fillWidth: true
71                     Layout.fillHeight: true
72                     text: Qt.formatDate(now, 'dddd').toUpperCase()
73                     font.family: 'Roboto'
74                     font.pixelSize: 13
75                     color: 'white'
76                     verticalAlignment:  Text.AlignVCenter
77 //                    Rectangle {
78 //                        anchors.fill: parent
79 //                        anchors.margins: 5
80 //                        color: 'red'
81 //                        border.color: 'blue'
82 //                        border.width: 1
83 //                        z: -1
84 //                    }
85                 }
86                 Text {
87                     Layout.fillWidth: true
88                     Layout.fillHeight: true
89                     text: Qt.formatTime(now, 'h:mm ap').toUpperCase()
90                     font.family: 'Roboto'
91                     font.pixelSize: 40
92                     color: 'white'
93                     horizontalAlignment:  Text.AlignHCenter
94                     verticalAlignment:  Text.AlignVCenter
95                 }
96                 RowLayout {
97                     Layout.fillWidth: true
98                     Layout.fillHeight: true
99                     Layout.preferredHeight: 20
100                     Image {
101                         id: condition_item
102                         source: './images/Weather/WeatherIcons_Rain-01.png'
103                     }
104                     Text {
105                         id: temperature_item
106                         text: '64°F'
107                         color: 'white'
108                         font.family: 'Helvetica'
109                         font.pixelSize: 32
110                     }
111                 }
112             }
113         }
114         ColumnLayout {
115             id: icons
116             Layout.fillWidth: true
117             Layout.fillHeight: true
118             Layout.preferredWidth: 76
119             spacing: -10
120
121             Image {
122                 id: bt_icon
123                 Layout.preferredWidth: 77
124                 Layout.preferredHeight: 73
125                 source: connStatus ? './images/Status/HMI_Status_Bluetooth_On-01.png' : './images/Status/HMI_Status_Bluetooth_Inactive-01.png'
126                 fillMode: Image.PreserveAspectFit
127                 property string deviceName: "none"
128                 property bool connStatus: false
129                 Connections {
130                     target: bluetooth
131
132                     onPowerChanged: {
133                             bt_icon.connStatus = state
134                     }
135                 }
136             }
137             Repeater {
138                 model: StatusBarModel { objectName: "statusBar" }
139                 delegate: Image {
140                     Layout.preferredWidth: 77
141                     Layout.preferredHeight: 73
142                     source: model.modelData
143                     fillMode: Image.PreserveAspectFit
144                 }
145             }
146         }
147     }
148 }