websockets mechanism implemented
[staging/HomeScreen.git] / HomeScreen / qml / StatusArea.qml
1 /*
2  * Copyright (C) 2016 The Qt Company Ltd.
3  * Copyright (C) 2016 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 QtQuick.Controls 1.0
21 import HomeScreen 1.0
22
23 Item {
24     id: root
25     width: 295
26     height: 218
27     function languageChanged(lang) {
28         if(lang === "fr") {
29             labelTime.text = Qt.formatTime(now, 'HH:mm').toUpperCase()
30             labelTemperature.text = '18°C'
31             switch(now.getDay()) {
32             case 1:
33                 labelDay.text = 'LUNDI'
34                 break
35             case 2:
36                 labelDay.text = 'MARDI'
37                 break
38             case 3:
39                 labelDay.text = 'MERCREDI'
40                 break
41             case 4:
42                 labelDay.text = 'JEUDI'
43                 break
44             case 5:
45                 labelDay.text = 'VENDREDI'
46                 break
47             case 6:
48                 labelDay.text = 'SAMEDI'
49                 break
50             case 7:
51                 labelDay.text = 'DIMANCHE'
52                 break
53             }
54
55         } else {
56             labelTime.text = Qt.formatTime(now, 'h:mm ap').toUpperCase()
57             labelTemperature.text = '64°F'
58             switch(now.getDay()) {
59             case 1:
60                 labelDay.text = 'MONDAY'
61                 break
62             case 2:
63                 labelDay.text = 'TUESDAY'
64                 break
65             case 3:
66                 labelDay.text = 'WEDNESDAY'
67                 break
68             case 4:
69                 labelDay.text = 'THURSDAY'
70                 break
71             case 5:
72                 labelDay.text = 'FRIDAY'
73                 break
74             case 6:
75                 labelDay.text = 'SATURDAY'
76                 break
77             case 7:
78                 labelDay.text = 'SUNDAY'
79                 break
80             }
81         }
82     }
83
84     property date now: new Date
85     Timer {
86         interval: 100; running: true; repeat: true;
87         onTriggered: root.now = new Date
88     }
89
90     RowLayout {
91         anchors.fill: parent
92         spacing: 0
93         Item {
94             Layout.fillWidth: true
95             Layout.fillHeight: true
96             Layout.preferredWidth: 295 - 76
97             ColumnLayout {
98                 anchors.fill: parent
99                 anchors.margins: 40
100                 spacing: 0
101                 Label {
102                     id: labelDay
103                     Layout.fillWidth: true
104                     Layout.fillHeight: true
105                     text: Qt.formatDate(now, 'dddd').toUpperCase()
106                     font.family: 'Roboto'
107 //                    font.pixelSize: 13
108                     font.pixelSize: 18
109                     color: 'white'
110                     verticalAlignment:  Text.AlignVCenter
111 //                    Rectangle {
112 //                        anchors.fill: parent
113 //                        anchors.margins: 5
114 //                        color: 'red'
115 //                        border.color: 'blue'
116 //                        border.width: 1
117 //                        z: -1
118 //                    }
119                 }
120                 Label {
121                     id: labelTime
122                     Layout.fillWidth: true
123                     Layout.fillHeight: true
124                     text: Qt.formatTime(now, 'h:mm ap').toUpperCase()
125                     font.family: 'Roboto'
126                     font.pixelSize: 40
127                     color: 'white'
128                     horizontalAlignment:  Text.AlignHCenter
129                     verticalAlignment:  Text.AlignVCenter
130                 }
131                 RowLayout {
132                     Layout.fillWidth: true
133                     Layout.fillHeight: true
134                     Layout.preferredHeight: 20
135                     Image {
136                         source: './images/Weather/WeatherIcons_Rain-01.png'
137                     }
138                     Label {
139                         id: labelTemperature
140                         text: '64°F'
141                         color: 'white'
142                         font.family: 'Helvetica'
143                         font.pixelSize: 32
144                     }
145                 }
146             }
147             Component.onCompleted: root.languageChanged("en")
148         }
149         ColumnLayout {
150             id: icons
151             Layout.fillWidth: true
152             Layout.fillHeight: true
153             Layout.preferredWidth: 76
154             spacing: -10
155             Repeater {
156                 model: StatusBarModel {}
157                 delegate: Image {
158                     source: model.modelData
159                     fillMode: Image.PreserveAspectFit
160                 }
161             }
162         }
163     }
164 }