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