summaryrefslogtreecommitdiffstats
path: root/examples/ifvehiclefunctions/window-qml/WindowItem.qml
blob: cf9c8329b179607c4c4799c14d3b669de593dab7 (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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// Copyright (C) 2021 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.Controls
import QtQuick.Window
import QtQuick.Layouts

import QtInterfaceFramework.VehicleFunctions

GroupBox {
    property WindowControl zone

    function stateToString(state) {
        if (state === WindowControl.FullyOpen)
            return "Fully Open";
        else if (state === WindowControl.Open)
            return "Open";
        else
            return "Closed";
    }

    ColumnLayout {
        RowLayout {

            Label {
                text: "Window state: "
            }

            Label {
                text: stateToString(zone.state)
            }
        }

        Button {
            text: "open"
            onClicked: zone.open().then(function(){console.error(zone.zone + " window opened")}, function(){console.error("opening " + zone.zone + " window failed!")})
        }

        Button {
            text: "close"
            onClicked: zone.close().then(function(){console.error(zone.zone + " window closed")}, function(){console.error("closing " + zone.zone + " window failed!")})
        }

        RowLayout {
            GroupBox {
                title: "Window blind"

                ColumnLayout {
                    RowLayout {

                        Label {
                            text: "State: "
                        }

                        Label {
                            text: stateToString(zone.blindState)
                        }
                    }

                    ButtonGroup {
                        id: blindGroup
                    }

                    RadioButton {
                        text: "Open"
                        ButtonGroup.group: blindGroup
                        checked: zone.blindMode === WindowControl.BlindOpen
                        onCheckedChanged: {
                            if (checked)
                                zone.blindMode = WindowControl.BlindOpen
                        }
                    }

                    RadioButton {
                        text: "Closed"
                        ButtonGroup.group: blindGroup
                        checked: zone.blindMode === WindowControl.BlindClosed
                        onCheckedChanged: {
                            if (checked)
                                zone.blindMode = WindowControl.BlindClosed
                        }
                    }

                    RadioButton {
                        text: "Automatic"
                        ButtonGroup.group: blindGroup
                        checked: zone.blindMode === WindowControl.AutoBlind
                        onCheckedChanged: {
                            if (checked)
                                zone.blindMode = WindowControl.AutoBlind
                        }
                    }
                }
            }

            GroupBox {
                title: "Heater"

                ColumnLayout {

                    RowLayout {

                        Label {
                            text: "Running: "
                        }

                        Label {
                            text: zone.heater
                        }
                    }

                    ButtonGroup {
                        id: heaterGroup
                    }

                    RadioButton {
                        text: "On"
                        ButtonGroup.group: heaterGroup
                        checked: zone.heaterMode === WindowControl.HeaterOn
                        onCheckedChanged: {
                            if (checked)
                                zone.heaterMode = WindowControl.HeaterOn
                        }
                    }

                    RadioButton {
                        text: "Off"
                        ButtonGroup.group: heaterGroup
                        checked: zone.heaterMode === WindowControl.HeaterOff
                        onCheckedChanged: {
                            if (checked)
                                zone.heaterMode = WindowControl.HeaterOff
                        }
                    }

                    RadioButton {
                        text: "Automatic"
                        ButtonGroup.group: heaterGroup
                        checked: zone.heaterMode === WindowControl.AutoHeater
                        onCheckedChanged: {
                            if (checked)
                                zone.heaterMode = WindowControl.AutoHeater
                        }
                    }
                }
            }
        }
    }
}