app/HVAC.qml: Use the Window width and height instead of using Screen
[apps/hvac.git] / app / HVAC.qml
1 /*
2  * Copyright (C) 2016 The Qt Company Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 import QtQuick 2.6
18 import QtQuick.Layouts 1.1
19 import QtQuick.Controls 2.0
20 import QtQuick.Window 2.11
21 import AGL.Demo.Controls 1.0
22 import Translator 1.0
23
24 ApplicationWindow {
25     id: root
26
27     width: container.width * container.scale
28     height: container.height * container.scale
29
30         Translator {
31                 id: translator
32                 language: "en_US"
33         }
34
35         Connections {
36                 target: hvac
37                 onFanSpeedChanged: fanSpeedSlider.value = fanSpeed
38                 onLanguageChanged: translator.language = language
39         }
40
41     Item {
42         id: container
43         anchors.centerIn: parent
44         width: Window.width
45         height: Window.height
46         scale: Window.scale
47
48         ColumnLayout {
49                 anchors.fill: parent
50                 anchors.topMargin: width / 10
51                 anchors.bottomMargin: width / 10
52                 RowLayout {
53                         Layout.fillHeight: true
54                         Layout.alignment: Qt.AlignHCenter
55                         Image {
56                                 source: './images/HMI_HVAC_Fan_Icon.svg'
57                         }
58                         Item {
59                                 width: 1080 * 0.8
60                                 Slider {
61                                         id: fanSpeedSlider
62                                         anchors.left: parent.left
63                                         anchors.right: parent.right
64                                         anchors.verticalCenter: parent.verticalCenter
65                                         from: 0.0
66                                         to: 255.0
67                                         stepSize: 1.0
68                                         onValueChanged: {
69                                                 hvac.fanSpeed = value
70                                         }
71                                 }
72                                 Label {
73                                         anchors.left: fanSpeedSlider.left
74                                         anchors.top: fanSpeedSlider.bottom
75                                         font.pixelSize: 32
76                                         text: translator.translate(qsTr('FAN SPEED'), translator.language)
77                                 }
78                         }
79                 }
80                 RowLayout {
81                         Layout.fillHeight: true
82                         Layout.fillWidth: true
83                         Layout.alignment: Layout.Center
84                         spacing: 20
85                         ColumnLayout {
86                                 Layout.fillWidth: true
87                                 spacing: 20
88                                 SeatHeatButton {
89                                         id: leftSeat
90                                         side: 'Left'
91                                 }
92                                 HeatDegree {
93                                         onCurrentItemChanged: {
94                                                 console.log("Left Temp changed",degree)
95                                                 hvac.leftTemperature = degree
96                                         }
97                                 }
98                         }
99                         ColumnLayout {
100                                 Layout.fillWidth: true
101                                 spacing: 20
102                                 ToggleButton {
103                                         onImage: './images/HMI_HVAC_Active.svg'
104                                         offImage: './images/HMI_HVAC_Inactive.svg'
105                                         Label {
106                                                 anchors.centerIn: parent
107                                                 color: parent.checked ? '#00ADDC' : '#848286'
108                                                 text: translator.translate(qsTr('A/C'), translator.language)
109                                                 font.pixelSize: parent.height / 3
110                                         }
111                                         onCheckedChanged: {
112                                                 console.debug('A/C', checked)
113                                         }
114                                 }
115                                 ToggleButton {
116                                         onImage: './images/HMI_HVAC_Active.svg'
117                                         offImage: './images/HMI_HVAC_Inactive.svg'
118                                         Label {
119                                                 anchors.centerIn: parent
120                                                 color: parent.checked ? '#00ADDC' : '#848286'
121                                                 text: translator.translate(qsTr('AUTO'), translator.language)
122                                                 font.pixelSize: parent.height / 3
123                                         }
124                                         onCheckedChanged: {
125                                                 console.debug('AUTO', checked)
126                                         }
127                                 }
128                                 ToggleButton {
129                                         onImage: './images/HMI_HVAC_Circulation_Active.svg'
130                                         offImage: './images/HMI_HVAC_Circulation_Inactive.svg'
131                                         onCheckedChanged: {
132                                                 console.debug('Circulation', checked)
133                                         }
134                                 }
135                         }
136
137                         ColumnLayout {
138                                 Layout.fillWidth: true
139                                 spacing: 20
140                                 SeatHeatButton {
141                                         id: rightSeat
142                                         side: 'Right'
143                                 }
144                                 HeatDegree {
145                                         onCurrentItemChanged: {
146                                                 console.log("Right Temp changed",degree)
147                                                 hvac.rightTemperature = degree
148                                         }
149                                 }
150                         }
151                 }
152
153                 RowLayout {
154                         Layout.fillHeight: true
155                         Layout.alignment: Qt.AlignHCenter
156                         spacing: root.width / 20
157                         Repeater {
158                                 model: ['AirDown', 'AirUp', 'AirRight', 'Rear', 'Front']
159                                 ToggleButton {
160                                         onImage: './images/HMI_HVAC_%1_Active.svg'.arg(model.modelData)
161                                         offImage: './images/HMI_HVAC_%1_Inactive.svg'.arg(model.modelData)
162                                         onCheckedChanged: {
163                                                 console.debug(model.modelData, checked)
164                                         }
165                                 }
166                         }
167                 }
168         }
169 }
170 }