Add basic translation support
[apps/hvac.git] / app / HeatDegree.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.Controls 2.0
19
20 ListView {
21     id: root
22     clip: true
23     width: 318
24     height: 219 * 2 + 20
25     spacing: 20
26     opacity: enabled ? 1 : 0.5
27
28     property int degree: currentIndex > -1 ? model.get(currentIndex).value : -1
29     model: ListModel {
30         Component.onCompleted: {
31             append({value: 15, modelData: translator.translate(qsTr('LO'), translator.language)})
32             for (var d = 16; d < 30; d++) {
33                 append({value: d, modelData: translator.translate(qsTr('%1\u00b0'), translator.language).arg(d.toFixed(0))})
34             }
35             append({value: 30, modelData: translator.translate(qsTr('HI'), translator.language)})
36         }
37     }
38     delegate: Label {
39         width: ListView.view.width
40         height: 219
41         horizontalAlignment: Label.AlignHCenter
42         verticalAlignment: Label.AlignVCenter
43         text: model.modelData
44         font.pixelSize: height * 0.7
45         color: (ListView.view.enabled && ListView.isCurrentItem) ? '#00ADDC' : 'white'
46     }
47
48     preferredHighlightBegin: 0.5
49     preferredHighlightEnd: 0.5
50     highlightRangeMode: ListView.StrictlyEnforceRange
51     highlight: Rectangle {
52         color: 'white'
53         opacity: 0.2
54     }
55 }