summaryrefslogtreecommitdiffstats
path: root/examples/ifvehiclefunctions/window-qml/main.qml
blob: c465bcf1ac4ef63dbac0109a3952173851aec49a (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
// 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

ApplicationWindow {
    title: "Window Control"
    visible: true
    width: Math.min(mainLayout.width + 20, Screen.desktopAvailableWidth)
    height: Math.min(mainLayout.height + 20, Screen.desktopAvailableHeight)

    WindowControl {
        id: windowControl
        discoveryMode: WindowControl.LoadOnlySimulationBackends
    }

    ScrollView {
        anchors.fill: parent
        anchors.margins: 10
        ColumnLayout {
            id: mainLayout
            WindowItem {
                title: "Roof"
                Layout.alignment: Qt.AlignHCenter
                zone: windowControl.zoneAt.Roof
            }

            Grid {
                id: grid
                columns: firstItem.width * 2 <= Screen.desktopAvailableWidth ? 2 : 1
                WindowItem {
                    id: firstItem
                    title: "Front Left Zone"
                    zone: windowControl.zoneAt.FrontLeft
                }
                WindowItem {
                    title: "Front Right Zone"
                    zone: windowControl.zoneAt.FrontRight
                }
                WindowItem {
                    title: "Rear Left Zone"
                    zone: windowControl.zoneAt.RearLeft
                }
                WindowItem {
                    title: "Rear Right Zone"
                    zone: windowControl.zoneAt.RearRight
                }
            }

            WindowItem {
                title: "Rear"
                Layout.alignment: Qt.AlignHCenter
                zone: windowControl.zoneAt.Rear
            }
        }
    }

    Dialog {
        id: messageDialog
        anchors.centerIn: parent
        title: "Auto Discovery Failed !"
        standardButtons: Dialog.Ok

        Label {
            text: "No WindowControl Backend available"
        }
    }

    Component.onCompleted: {
        if (!windowControl.isValid)
            messageDialog.open()
    }
}