summaryrefslogtreecommitdiffstats
path: root/examples/scxml/invoke/MainView.qml
blob: c7a4400e9458a283dbe494849a8f65554d8edfe5 (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
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

pragma ComponentBehavior: Bound

import QtQuick
import QtQuick.Window
import QtScxml
import InvokeExample

Window {
    id: window
    visible: true
    color: "black"
    width: 400
    height: 300

    DirectionsStateMachine {
        id: stateMachine
        running: true
    }

    Item {
        width: parent.width / 2
        height: parent.height

        Button {
            id: nowhere
            text: "Go Nowhere"
            width: parent.width
            height: parent.height / 2
            onClicked: stateMachine.submitEvent("goNowhere")
            enabled: stateMachine.somewhere
        }

        Button {
            id: somewhere
            text: "Go Somewhere"
            width: parent.width
            height: parent.height / 2
            y: parent.height / 2
            onClicked: stateMachine.submitEvent("goSomewhere")
            enabled: stateMachine.nowhere
        }
    }

    Loader {
        sourceComponent: SubView {
            anywhere: services.children.anywhere ? services.children.anywhere.stateMachine : null
        }
        active: stateMachine.somewhere

        x: parent.width / 2
        width: parent.width / 2
        height: parent.height

        InvokedServices {
            id: services
            stateMachine: stateMachine
        }
    }
}