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