summaryrefslogtreecommitdiffstats
path: root/examples/interfaceframework/climate/Main.qml
blob: 67b19b8c590f32aaaa608d984ec83677875eee72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Copyright (C) 2024 The Qt Company Ltd.
// Copyright (C) 2019 Luxoft Sweden AB
// Copyright (C) 2018 Pelagicore AG
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick.Window
import QtQuick.Controls.Basic
import QtQuick.Controls.impl
import QtQuick.Layouts
import Example.If.ClimateModule

Window {

    visible: true
    width: 670
    height: 60
    title: qsTr("Interface Framework Climate Example")
    color: "darkgrey"

    ClimateControl {
        id: climateCtrl
    }

    RowLayout {
        anchors.top: parent.top
        anchors.left: parent.left
        anchors.bottom: parent.bottom
        //! [0]
        TempControl {
            value: climateCtrl.zoneAt.FrontLeft.targetTemperature
            onValueModified: {
                climateCtrl.zoneAt.FrontLeft.targetTemperature = value
            }
        }
        //! [0]

        FanSpeedControl {
            value: climateCtrl.zoneAt.FrontLeft.fanSpeedLevel
            onValueModified: {
                climateCtrl.zoneAt.FrontLeft.fanSpeedLevel = value
            }
        }
    }

    RowLayout {
        anchors.top: parent.top
        anchors.bottom: parent.bottom
        anchors.horizontalCenter: parent.horizontalCenter

        Label {
            Layout.leftMargin: 25
            Layout.rightMargin: 5
            text: climateCtrl.outsideTemperature + " °C"
        }

        //! [1]
        Button {
            Layout.leftMargin: 5
            Layout.rightMargin: 5
            Layout.maximumWidth: 50
            text: "A/C"
            checkable: true
            checked: climateCtrl.airConditioning
            onToggled: {
                climateCtrl.airConditioning = checked
            }
        }
        //! [1]

        CheckBox {
            id: recirculationCheckBox
            Layout.rightMargin: 20

            tristate: true
            padding: 0

            indicator: Item {
                implicitWidth: 40
                implicitHeight: 40
                y: parent.topPadding + (parent.availableHeight - height) / 2

                IconImage {
                    anchors.centerIn: parent
                    source: recirculationCheckBox.checkState === Qt.Checked ? "assets/air_circulation.png" :
                            recirculationCheckBox.checkState === Qt.PartiallyChecked ? "assets/air_circulation_auto.png"
                                                                                     : "assets/air_circulation_off.png"
                }
            }

            checkState: climateCtrl.recirculationMode === ClimateModule.RecirculationOn ? Qt.Checked :
                        climateCtrl.recirculationMode === ClimateModule.AutoRecirculation ? Qt.PartiallyChecked : Qt.Unchecked

            onCheckStateChanged: {
                let mode = ClimateModule.RecirculationOff
                if (checkState === Qt.Checked)
                    mode = ClimateModule.RecirculationOn
                else if (checkState === Qt.PartiallyChecked)
                    mode = ClimateModule.AutoRecirculation

                climateCtrl.recirculationMode = mode
            }
        }
    }

    RowLayout {
        anchors.top: parent.top
        anchors.right: parent.right
        anchors.bottom: parent.bottom
        FanSpeedControl {
            value: climateCtrl.zoneAt.FrontRight.fanSpeedLevel
            onValueModified: {
                climateCtrl.zoneAt.FrontRight.fanSpeedLevel = value
            }
        }

        TempControl {
            value: climateCtrl.zoneAt.FrontRight.targetTemperature
            onValueModified: {
                climateCtrl.zoneAt.FrontRight.targetTemperature = value
            }
        }
    }
}