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