f5cd76bcba40d154eaf46aa61ddee0aa532f91b2
[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 'api' as API
22
23 ApplicationWindow {
24     id: root
25
26     API.Binding {
27         id: binding
28         url: bindingAddress
29         onFanSpeedChanged: fanSpeedSlider.value = fanSpeed
30     }
31
32     ColumnLayout {
33         anchors.fill: parent
34         anchors.topMargin: width / 10
35         anchors.bottomMargin: width / 10
36         RowLayout {
37             Layout.fillHeight: true
38             Layout.alignment: Qt.AlignHCenter
39             Image {
40                 source: './images/HMI_HVAC_Fan_Icon.svg'
41             }
42             Item {
43                 width: root.width * 0.8
44                 Slider {
45                     id: fanSpeedSlider
46                     anchors.left: parent.left
47                     anchors.right: parent.right
48                     anchors.verticalCenter: parent.verticalCenter
49                     onValueChanged: {
50                         binding.fanSpeed = value
51                     }
52                 }
53                 Label {
54                     anchors.left: fanSpeedSlider.left
55                     anchors.top: fanSpeedSlider.bottom
56                     font.pixelSize: 32
57                     text: 'FAN SPEED'
58                 }
59             }
60         }
61         RowLayout {
62             Layout.fillHeight: true
63             Layout.fillWidth: true
64             Layout.alignment: Layout.Center
65             spacing: 20
66             ColumnLayout {
67                 Layout.fillWidth: true
68                 spacing: 20
69                 SeatHeatButton {
70                     id: leftSeat
71                     side: 'Left'
72                 }
73                 HeatDegree {
74                     enabled: leftSeat.headLevel > 0
75                 }
76             }
77             ColumnLayout {
78                 Layout.fillWidth: true
79                 spacing: 20
80                 ToggleButton {
81                     onImage: './images/HMI_HVAC_Active.svg'
82                     offImage: './images/HMI_HVAC_Inactive.svg'
83                     Label {
84                         anchors.centerIn: parent
85                         color: parent.checked ? '#66FF99' : '#848286'
86                         text: 'A/C'
87                         font.pixelSize: parent.height / 3
88                     }
89                     onCheckedChanged: {
90                         console.debug('A/C', checked)
91                     }
92                 }
93                 ToggleButton {
94                     onImage: './images/HMI_HVAC_Active.svg'
95                     offImage: './images/HMI_HVAC_Inactive.svg'
96                     Label {
97                         anchors.centerIn: parent
98                         color: parent.checked ? '#66FF99' : '#848286'
99                         text: 'AUTO'
100                         font.pixelSize: parent.height / 3
101                     }
102                     onCheckedChanged: {
103                         console.debug('AUTO', checked)
104                     }
105                 }
106                 ToggleButton {
107                     onImage: './images/HMI_HVAC_Circulation_Active.svg'
108                     offImage: './images/HMI_HVAC_Circulation_Inactive.svg'
109                     onCheckedChanged: {
110                         console.debug('Circulation', checked)
111                     }
112                 }
113             }
114
115             ColumnLayout {
116                 Layout.fillWidth: true
117                 spacing: 20
118                 SeatHeatButton {
119                     id: rightSeat
120                     side: 'Right'
121                 }
122                 HeatDegree {
123                     enabled: rightSeat.headLevel > 0
124                 }
125             }
126         }
127
128         RowLayout {
129             Layout.fillHeight: true
130             Layout.alignment: Qt.AlignHCenter
131             spacing: root.width / 20
132             Repeater {
133                 model: ['AirDown', 'AirUp', 'AirRight', 'Rear', 'Front']
134                 ToggleButton {
135                     onImage: './images/HMI_HVAC_%1_Active.svg'.arg(model.modelData)
136                     offImage: './images/HMI_HVAC_%1_Inactive.svg'.arg(model.modelData)
137                     onCheckedChanged: {
138                         console.debug(model.modelData, checked)
139                     }
140                 }
141             }
142         }
143     }
144 }