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