registerShortcut
[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                 MouseArea {
113                     anchors.fill: parent
114                     onClicked: {
115                         homescreenHandler.killRunningApplications()
116                     }
117                 }
118             }
119         }
120         ColumnLayout {
121             id: icons
122             Layout.fillWidth: true
123             Layout.fillHeight: true
124             Layout.preferredWidth: 76
125             spacing: -10
126             Rectangle {
127                 Layout.preferredWidth: 77
128                 Layout.preferredHeight: 55
129                 opacity: 0
130             }
131
132             Image {
133                 id: bt_icon
134                 Layout.preferredWidth: 77
135                 Layout.preferredHeight: 55
136                 source: connStatus ? './images/Status/HMI_Status_Bluetooth_On-01.png' : './images/Status/HMI_Status_Bluetooth_Inactive-01.png'
137                 fillMode: Image.PreserveAspectFit
138                 property string deviceName: "none"
139                 property bool connStatus: false
140                 Connections {
141                     target: bluetooth
142
143                     onPowerChanged: {
144                             bt_icon.connStatus = state
145                     }
146                 }
147             }
148             Repeater {
149                 model: StatusBarModel { objectName: "statusBar" }
150                 delegate: Image {
151                     Layout.preferredWidth: 77
152                     Layout.preferredHeight: 55
153                     source: model.modelData
154                     fillMode: Image.PreserveAspectFit
155                 }
156             }
157         }
158     }
159 }