8aa88c146a4551379e0055a9169c0d6e8f456a1b
[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 AGL.Demo.Controls 1.0
21 import Translator 1.0
22
23 ApplicationWindow {
24     id: root
25
26     width: container.width * container.scale
27     height: container.height * container.scale
28
29         Translator {
30                 id: translator
31                 language: "en_US"
32         }
33
34         Connections {
35                 target: hvac
36                 onFanSpeedChanged: fanSpeedSlider.value = fanSpeed
37                 onLanguageChanged: translator.language = language
38         }
39
40     Item {
41         id: container
42         anchors.centerIn: parent
43         width: 1080
44         height: 1487
45         scale: screenInfo.scale_factor()
46
47         ColumnLayout {
48                 anchors.fill: parent
49                 anchors.topMargin: width / 10
50                 anchors.bottomMargin: width / 10
51                 RowLayout {
52                         Layout.fillHeight: true
53                         Layout.alignment: Qt.AlignHCenter
54                         Image {
55                                 source: './images/HMI_HVAC_Fan_Icon.svg'
56                         }
57                         Item {
58                                 width: container.width * 0.8
59                                 Slider {
60                                         id: fanSpeedSlider
61                                         anchors.left: parent.left
62                                         anchors.right: parent.right
63                                         anchors.verticalCenter: parent.verticalCenter
64                                         from: 0.0
65                                         to: 255.0
66                                         stepSize: 1.0
67                                         onValueChanged: {
68                                                 hvac.fanSpeed = value
69                                         }
70                                 }
71                                 Label {
72                                         anchors.left: fanSpeedSlider.left
73                                         anchors.top: fanSpeedSlider.bottom
74                                         font.pixelSize: 32
75                                         text: translator.translate(qsTr('FAN SPEED'), translator.language)
76                                 }
77                         }
78                 }
79                 RowLayout {
80                         Layout.fillHeight: true
81                         Layout.fillWidth: true
82                         Layout.alignment: Layout.Center
83                         spacing: 20
84                         ColumnLayout {
85                                 Layout.fillWidth: true
86                                 spacing: 20
87                                 SeatHeatButton {
88                                         id: leftSeat
89                                         side: 'Left'
90                                 }
91                                 HeatDegree {
92                                         onCurrentItemChanged: {
93                                                 console.log("Left Temp changed",degree)
94                                                 hvac.leftTemperature = degree
95                                         }
96                                 }
97                         }
98                         ColumnLayout {
99                                 Layout.fillWidth: true
100                                 spacing: 20
101                                 ToggleButton {
102                                         onImage: './images/HMI_HVAC_Active.svg'
103                                         offImage: './images/HMI_HVAC_Inactive.svg'
104                                         Label {
105                                                 anchors.centerIn: parent
106                                                 color: parent.checked ? '#00ADDC' : '#848286'
107                                                 text: translator.translate(qsTr('A/C'), translator.language)
108                                                 font.pixelSize: parent.height / 3
109                                         }
110                                         onCheckedChanged: {
111                                                 console.debug('A/C', checked)
112                                         }
113                                 }
114                                 ToggleButton {
115                                         onImage: './images/HMI_HVAC_Active.svg'
116                                         offImage: './images/HMI_HVAC_Inactive.svg'
117                                         Label {
118                                                 anchors.centerIn: parent
119                                                 color: parent.checked ? '#00ADDC' : '#848286'
120                                                 text: translator.translate(qsTr('AUTO'), translator.language)
121                                                 font.pixelSize: parent.height / 3
122                                         }
123                                         onCheckedChanged: {
124                                                 console.debug('AUTO', checked)
125                                         }
126                                 }
127                                 ToggleButton {
128                                         onImage: './images/HMI_HVAC_Circulation_Active.svg'
129                                         offImage: './images/HMI_HVAC_Circulation_Inactive.svg'
130                                         onCheckedChanged: {
131                                                 console.debug('Circulation', checked)
132                                         }
133                                 }
134                         }
135
136                         ColumnLayout {
137                                 Layout.fillWidth: true
138                                 spacing: 20
139                                 SeatHeatButton {
140                                         id: rightSeat
141                                         side: 'Right'
142                                 }
143                                 HeatDegree {
144                                         onCurrentItemChanged: {
145                                                 console.log("Right Temp changed",degree)
146                                                 hvac.rightTemperature = degree
147                                         }
148                                 }
149                         }
150                 }
151
152                 RowLayout {
153                         Layout.fillHeight: true
154                         Layout.alignment: Qt.AlignHCenter
155                         spacing: root.width / 20
156                         Repeater {
157                                 model: ['AirDown', 'AirUp', 'AirRight', 'Rear', 'Front']
158                                 ToggleButton {
159                                         onImage: './images/HMI_HVAC_%1_Active.svg'.arg(model.modelData)
160                                         offImage: './images/HMI_HVAC_%1_Inactive.svg'.arg(model.modelData)
161                                         onCheckedChanged: {
162                                                 console.debug(model.modelData, checked)
163                                         }
164                                 }
165                         }
166                 }
167         }
168 }
169 }