summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/CMakeLists.txt13
-rw-r--r--examples/examples.pro2
-rw-r--r--examples/scxml/CMakeLists.txt23
-rw-r--r--examples/scxml/calculator-common/doc/src/calculator-compiling.qdocinc16
-rw-r--r--examples/scxml/calculator-qml/Button.qml82
-rw-r--r--examples/scxml/calculator-qml/calculator-qml.cpp71
-rw-r--r--examples/scxml/calculator-qml/calculator-qml.pro13
-rw-r--r--examples/scxml/calculator-qml/calculator-qml.qrc6
-rw-r--r--examples/scxml/calculator-qml/doc/src/calculator-qml.qdoc77
-rw-r--r--examples/scxml/calculator-widgets/calculator-widgets.cpp66
-rw-r--r--examples/scxml/calculator-widgets/calculator-widgets.pro19
-rw-r--r--examples/scxml/calculator-widgets/doc/images/calculator.pngbin6272 -> 0 bytes
-rw-r--r--examples/scxml/calculator-widgets/doc/src/calculator.qdoc81
-rw-r--r--examples/scxml/calculator-widgets/mainwindow.cpp130
-rw-r--r--examples/scxml/calculator-widgets/mainwindow.h77
-rw-r--r--examples/scxml/calculator-widgets/mainwindow.ui177
-rw-r--r--examples/scxml/calculator/Button.qml35
-rw-r--r--examples/scxml/calculator/CMakeLists.txt52
-rw-r--r--examples/scxml/calculator/MainWindow.qml (renamed from examples/scxml/calculator-qml/calculator-qml.qml)67
-rw-r--r--examples/scxml/calculator/calculator-qml.h20
-rw-r--r--examples/scxml/calculator/calculator.cpp18
-rw-r--r--examples/scxml/calculator/calculator.pro26
-rw-r--r--examples/scxml/calculator/doc/images/calculator.png (renamed from examples/scxml/calculator-qml/doc/images/calculator-qml.png)bin6934 -> 6934 bytes
-rw-r--r--examples/scxml/calculator/doc/src/calculator.qdoc48
-rw-r--r--examples/scxml/calculator/qmldir5
-rw-r--r--examples/scxml/calculator/statemachine.scxml (renamed from examples/scxml/calculator-common/statemachine.scxml)0
-rw-r--r--examples/scxml/ftpclient/CMakeLists.txt47
-rw-r--r--examples/scxml/ftpclient/doc/src/ftpclient.qdoc59
-rw-r--r--examples/scxml/ftpclient/ftpcontrolchannel.cpp68
-rw-r--r--examples/scxml/ftpclient/ftpcontrolchannel.h60
-rw-r--r--examples/scxml/ftpclient/ftpdatachannel.cpp53
-rw-r--r--examples/scxml/ftpclient/ftpdatachannel.h62
-rw-r--r--examples/scxml/ftpclient/main.cpp60
-rw-r--r--examples/scxml/ftpclient/simpleftp.scxml51
-rw-r--r--examples/scxml/invoke-common/Button.qml82
-rw-r--r--examples/scxml/invoke-common/MainView.qml105
-rw-r--r--examples/scxml/invoke-common/SubView.qml73
-rw-r--r--examples/scxml/invoke-common/statemachine.scxml79
-rw-r--r--examples/scxml/invoke-dynamic/doc/images/invoke-dynamic.pngbin6580 -> 0 bytes
-rw-r--r--examples/scxml/invoke-dynamic/doc/src/invoke-dynamic.qdoc67
-rw-r--r--examples/scxml/invoke-dynamic/invoke-dynamic.cpp65
-rw-r--r--examples/scxml/invoke-dynamic/invoke-dynamic.pro12
-rw-r--r--examples/scxml/invoke-dynamic/invoke-dynamic.qml60
-rw-r--r--examples/scxml/invoke-dynamic/invoke-dynamic.qrc9
-rw-r--r--examples/scxml/invoke-static/doc/src/invoke-static.qdoc79
-rw-r--r--examples/scxml/invoke-static/invoke-static.cpp69
-rw-r--r--examples/scxml/invoke-static/invoke-static.pro14
-rw-r--r--examples/scxml/invoke-static/invoke-static.qml57
-rw-r--r--examples/scxml/invoke-static/invoke-static.qrc8
-rw-r--r--examples/scxml/invoke/Button.qml37
-rw-r--r--examples/scxml/invoke/CMakeLists.txt53
-rw-r--r--examples/scxml/invoke/MainView.qml63
-rw-r--r--examples/scxml/invoke/SubView.qml31
-rw-r--r--examples/scxml/invoke/doc/images/invoke.png (renamed from examples/scxml/invoke-static/doc/images/invoke-static.png)bin7170 -> 7170 bytes
-rw-r--r--examples/scxml/invoke/doc/src/invoke.qdoc75
-rw-r--r--examples/scxml/invoke/invoke-qml.h20
-rw-r--r--examples/scxml/invoke/invoke.cpp17
-rw-r--r--examples/scxml/invoke/invoke.pro27
-rw-r--r--examples/scxml/invoke/qmldir5
-rw-r--r--examples/scxml/invoke/statemachine.scxml32
-rw-r--r--examples/scxml/mediaplayer-common/Mediaplayer.qml142
-rw-r--r--examples/scxml/mediaplayer-common/doc/src/mediaplayer-compiling.qdocinc17
-rw-r--r--examples/scxml/mediaplayer-common/doc/src/mediaplayer-ecmascript-data-model.qdocinc9
-rw-r--r--examples/scxml/mediaplayer-common/doc/src/mediaplayer-widgets-connecting-to-states.qdocinc16
-rw-r--r--examples/scxml/mediaplayer-common/mainwindow.cpp102
-rw-r--r--examples/scxml/mediaplayer-common/mainwindow.h83
-rw-r--r--examples/scxml/mediaplayer-common/mainwindow.ui31
-rw-r--r--examples/scxml/mediaplayer-common/mediaplayer.scxml92
-rw-r--r--examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-cppdatamodel.scxml83
-rw-r--r--examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-qml-cppdatamodel.cpp69
-rw-r--r--examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-qml-cppdatamodel.pro17
-rw-r--r--examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-qml-cppdatamodel.qml63
-rw-r--r--examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-qml-cppdatamodel.qrc6
-rw-r--r--examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.cpp64
-rw-r--r--examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.h68
-rw-r--r--examples/scxml/mediaplayer-qml-dynamic/doc/src/mediaplayer-qml-dynamic.qdoc62
-rw-r--r--examples/scxml/mediaplayer-qml-dynamic/mediaplayer-qml-dynamic.cpp66
-rw-r--r--examples/scxml/mediaplayer-qml-dynamic/mediaplayer-qml-dynamic.pro12
-rw-r--r--examples/scxml/mediaplayer-qml-dynamic/mediaplayer-qml-dynamic.qml53
-rw-r--r--examples/scxml/mediaplayer-qml-dynamic/mediaplayer-qml-dynamic.qrc7
-rw-r--r--examples/scxml/mediaplayer-qml-static/doc/src/mediaplayer-qml-static.qdoc57
-rw-r--r--examples/scxml/mediaplayer-qml-static/mediaplayer-qml-static.cpp70
-rw-r--r--examples/scxml/mediaplayer-qml-static/mediaplayer-qml-static.pro14
-rw-r--r--examples/scxml/mediaplayer-qml-static/mediaplayer-qml-static.qml57
-rw-r--r--examples/scxml/mediaplayer-qml-static/mediaplayer-qml-static.qrc6
-rw-r--r--examples/scxml/mediaplayer-widgets-dynamic/doc/src/mediaplayer-widgets-dynamic.qdoc65
-rw-r--r--examples/scxml/mediaplayer-widgets-dynamic/mediaplayer-widgets-dynamic.cpp68
-rw-r--r--examples/scxml/mediaplayer-widgets-dynamic/mediaplayer-widgets-dynamic.pro21
-rw-r--r--examples/scxml/mediaplayer-widgets-dynamic/mediaplayer.qrc6
-rw-r--r--examples/scxml/mediaplayer-widgets-static/doc/src/mediaplayer-widgets-static.qdoc59
-rw-r--r--examples/scxml/mediaplayer-widgets-static/mediaplayer-widgets-static.cpp66
-rw-r--r--examples/scxml/mediaplayer-widgets-static/mediaplayer-widgets-static.pro20
-rw-r--r--examples/scxml/mediaplayer/CMakeLists.txt52
-rw-r--r--examples/scxml/mediaplayer/MainWindow.qml105
-rw-r--r--examples/scxml/mediaplayer/doc/images/mediaplayer.png (renamed from examples/scxml/mediaplayer-common/doc/images/mediaplayer.png)bin5951 -> 5951 bytes
-rw-r--r--examples/scxml/mediaplayer/doc/src/mediaplayer.qdoc (renamed from examples/scxml/mediaplayer-qml-cppdatamodel/doc/src/mediaplayer-qml-cppdatamodel.qdoc)44
-rw-r--r--examples/scxml/mediaplayer/main.cpp17
-rw-r--r--examples/scxml/mediaplayer/mediaplayer-qml.h20
-rw-r--r--examples/scxml/mediaplayer/mediaplayer.pro27
-rw-r--r--examples/scxml/mediaplayer/mediaplayer.scxml36
-rw-r--r--examples/scxml/mediaplayer/qmldir3
-rw-r--r--examples/scxml/mediaplayer/thedatamodel.cpp19
-rw-r--r--examples/scxml/mediaplayer/thedatamodel.h24
-rw-r--r--examples/scxml/pinball/doc/images/pinball-statechart-global.pngbin2925 -> 0 bytes
-rw-r--r--examples/scxml/pinball/doc/images/pinball-statechart-guicontrol.pngbin3618 -> 0 bytes
-rw-r--r--examples/scxml/pinball/doc/images/pinball-statechart-internalstate.pngbin2987 -> 0 bytes
-rw-r--r--examples/scxml/pinball/doc/images/pinball-statechart-logicalstate.pngbin7613 -> 0 bytes
-rw-r--r--examples/scxml/pinball/doc/images/pinball-statechart-modestate.pngbin3546 -> 0 bytes
-rw-r--r--examples/scxml/pinball/doc/images/pinball-statechart-onstate.pngbin7139 -> 0 bytes
-rw-r--r--examples/scxml/pinball/doc/images/pinball-statechart-workflow.pngbin4433 -> 0 bytes
-rw-r--r--examples/scxml/pinball/doc/images/pinball.pngbin44973 -> 0 bytes
-rw-r--r--examples/scxml/pinball/doc/src/pinball.qdoc502
-rw-r--r--examples/scxml/pinball/main.cpp66
-rw-r--r--examples/scxml/pinball/mainwindow.cpp133
-rw-r--r--examples/scxml/pinball/mainwindow.h78
-rw-r--r--examples/scxml/pinball/mainwindow.ui663
-rw-r--r--examples/scxml/pinball/pinball.pro19
-rw-r--r--examples/scxml/pinball/pinball.scxml353
-rw-r--r--examples/scxml/scxml.pro14
-rw-r--r--examples/scxml/sudoku/CMakeLists.txt57
-rw-r--r--examples/scxml/sudoku/doc/src/sudoku.qdoc45
-rw-r--r--examples/scxml/sudoku/main.cpp53
-rw-r--r--examples/scxml/sudoku/mainwindow.cpp109
-rw-r--r--examples/scxml/sudoku/mainwindow.h67
-rw-r--r--examples/scxml/sudoku/sudoku.js51
-rw-r--r--examples/scxml/sudoku/sudoku.scxml51
-rw-r--r--examples/scxml/trafficlight-common/Button.qml62
-rw-r--r--examples/scxml/trafficlight-common/Lights.ui.qml140
-rw-r--r--examples/scxml/trafficlight-common/TrafficLight.qml74
-rw-r--r--examples/scxml/trafficlight-common/doc/src/trafficlight-compiling.qdocinc25
-rw-r--r--examples/scxml/trafficlight-common/statemachine.scxml51
-rw-r--r--examples/scxml/trafficlight-common/trafficlight.cpp91
-rw-r--r--examples/scxml/trafficlight-common/trafficlight.h57
-rw-r--r--examples/scxml/trafficlight-qml-dynamic/Button.qml17
-rw-r--r--examples/scxml/trafficlight-qml-dynamic/CMakeLists.txt85
-rw-r--r--examples/scxml/trafficlight-qml-dynamic/Lights.ui.qml80
-rw-r--r--examples/scxml/trafficlight-qml-dynamic/MainView.qml29
-rw-r--r--examples/scxml/trafficlight-qml-dynamic/doc/src/trafficlight-qml-dynamic.qdoc49
-rw-r--r--examples/scxml/trafficlight-qml-dynamic/qmldir6
-rw-r--r--examples/scxml/trafficlight-qml-dynamic/trafficlight-qml-dynamic.cpp72
-rw-r--r--examples/scxml/trafficlight-qml-dynamic/trafficlight-qml-dynamic.pro20
-rw-r--r--examples/scxml/trafficlight-qml-dynamic/trafficlight-qml-dynamic.qml60
-rw-r--r--examples/scxml/trafficlight-qml-dynamic/trafficlight-qml-dynamic.qrc15
-rw-r--r--examples/scxml/trafficlight-qml-simple/CMakeLists.txt51
-rw-r--r--examples/scxml/trafficlight-qml-simple/Light.qml53
-rw-r--r--examples/scxml/trafficlight-qml-simple/MainView.qml62
-rw-r--r--examples/scxml/trafficlight-qml-simple/TrafficLight.qml110
-rw-r--r--examples/scxml/trafficlight-qml-simple/doc/src/trafficlight-qml-simple.qdoc37
-rw-r--r--examples/scxml/trafficlight-qml-simple/qmldir5
-rw-r--r--examples/scxml/trafficlight-qml-simple/trafficlight-qml-simple.cpp68
-rw-r--r--examples/scxml/trafficlight-qml-simple/trafficlight-qml-simple.pro22
-rw-r--r--examples/scxml/trafficlight-qml-simple/trafficlight-qml-simple.qrc6
-rw-r--r--examples/scxml/trafficlight-qml-simple/trafficlight-qml.h20
-rw-r--r--examples/scxml/trafficlight-qml-static/Button.qml17
-rw-r--r--examples/scxml/trafficlight-qml-static/CMakeLists.txt87
-rw-r--r--examples/scxml/trafficlight-qml-static/Lights.ui.qml77
-rw-r--r--examples/scxml/trafficlight-qml-static/MainView.qml22
-rw-r--r--examples/scxml/trafficlight-qml-static/doc/src/trafficlight-qml-static.qdoc37
-rw-r--r--examples/scxml/trafficlight-qml-static/qmldir6
-rw-r--r--examples/scxml/trafficlight-qml-static/trafficlight-qml-static.cpp67
-rw-r--r--examples/scxml/trafficlight-qml-static/trafficlight-qml-static.pro24
-rw-r--r--examples/scxml/trafficlight-qml-static/trafficlight-qml-static.qml57
-rw-r--r--examples/scxml/trafficlight-qml-static/trafficlight-qml-static.qrc14
-rw-r--r--examples/scxml/trafficlight-qml-static/trafficlight-qml.h20
-rw-r--r--examples/scxml/trafficlight-widgets-dynamic/CMakeLists.txt84
-rw-r--r--examples/scxml/trafficlight-widgets-dynamic/doc/src/trafficlight-widgets-dynamic.qdoc45
-rw-r--r--examples/scxml/trafficlight-widgets-dynamic/trafficlight-widgets-dynamic.cpp63
-rw-r--r--examples/scxml/trafficlight-widgets-static/CMakeLists.txt84
-rw-r--r--examples/scxml/trafficlight-widgets-static/doc/src/trafficlight-widgets-static.qdoc31
-rw-r--r--examples/scxml/trafficlight-widgets-static/trafficlight-widgets-static.cpp53
-rw-r--r--examples/statemachine/CMakeLists.txt13
-rw-r--r--examples/statemachine/doc/images/pingpong-example.pngbin0 -> 7843 bytes
-rw-r--r--examples/statemachine/doc/images/trafficlight-example1.pngbin0 -> 3694 bytes
-rw-r--r--examples/statemachine/doc/images/trafficlight-example2.pngbin0 -> 7257 bytes
-rw-r--r--examples/statemachine/doc/src/moveblocks.qdoc192
-rw-r--r--examples/statemachine/doc/src/pingpong.qdoc68
-rw-r--r--examples/statemachine/doc/src/rogue.qdoc185
-rw-r--r--examples/statemachine/doc/src/trafficlight.qdoc57
-rw-r--r--examples/statemachine/moveblocks/CMakeLists.txt37
-rw-r--r--examples/statemachine/moveblocks/main.cpp267
-rw-r--r--examples/statemachine/moveblocks/moveblocks.pro7
-rw-r--r--examples/statemachine/pingpong/CMakeLists.txt39
-rw-r--r--examples/statemachine/pingpong/main.cpp104
-rw-r--r--examples/statemachine/pingpong/pingpong.pro8
-rw-r--r--examples/statemachine/rogue/CMakeLists.txt39
-rw-r--r--examples/statemachine/rogue/main.cpp17
-rw-r--r--examples/statemachine/rogue/movementtransition.h77
-rw-r--r--examples/statemachine/rogue/rogue.pro10
-rw-r--r--examples/statemachine/rogue/window.cpp201
-rw-r--r--examples/statemachine/rogue/window.h50
-rw-r--r--examples/statemachine/statemachine.pro11
-rw-r--r--examples/statemachine/trafficlight/CMakeLists.txt37
-rw-r--r--examples/statemachine/trafficlight/main.cpp152
-rw-r--r--examples/statemachine/trafficlight/trafficlight.pro7
194 files changed, 3681 insertions, 6954 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
new file mode 100644
index 0000000..f765b17
--- /dev/null
+++ b/examples/CMakeLists.txt
@@ -0,0 +1,13 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+qt_examples_build_begin(EXTERNAL_BUILD)
+
+if(TARGET Qt::Scxml)
+ add_subdirectory(scxml)
+endif()
+if(TARGET Qt::StateMachine)
+ add_subdirectory(statemachine)
+endif()
+
+qt_examples_build_end()
diff --git a/examples/examples.pro b/examples/examples.pro
index 2d6d823..c7fbeb0 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -1,4 +1,4 @@
TEMPLATE = subdirs
qtHaveModule(scxml): SUBDIRS += scxml
-
+qtHaveModule(statemachine): SUBDIRS += statemachine
diff --git a/examples/scxml/CMakeLists.txt b/examples/scxml/CMakeLists.txt
new file mode 100644
index 0000000..d9e2ef2
--- /dev/null
+++ b/examples/scxml/CMakeLists.txt
@@ -0,0 +1,23 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+if (TARGET Qt::Network AND QT_FEATURE_scxml_ecmascriptdatamodel AND NOT ANDROID)
+ qt_internal_add_example(ftpclient)
+endif()
+
+if(TARGET Qt::Widgets)
+ qt_internal_add_example(trafficlight-widgets-static)
+ qt_internal_add_example(trafficlight-widgets-dynamic)
+ if(QT_FEATURE_scxml_ecmascriptdatamodel)
+ qt_internal_add_example(sudoku)
+ endif()
+endif()
+
+if(TARGET Qt::Qml AND TARGET Qt::Gui)
+ qt_internal_add_example(calculator)
+ qt_internal_add_example(trafficlight-qml-static)
+ qt_internal_add_example(trafficlight-qml-dynamic)
+ qt_internal_add_example(trafficlight-qml-simple)
+ qt_internal_add_example(mediaplayer)
+ qt_internal_add_example(invoke)
+endif()
diff --git a/examples/scxml/calculator-common/doc/src/calculator-compiling.qdocinc b/examples/scxml/calculator-common/doc/src/calculator-compiling.qdocinc
deleted file mode 100644
index 3e5982f..0000000
--- a/examples/scxml/calculator-common/doc/src/calculator-compiling.qdocinc
+++ /dev/null
@@ -1,16 +0,0 @@
- \section1 Compiling the State Machine
-
- We link against the Qt SCXML module by adding the following line to the
- \e .pro file:
-
- \quotefromfile calculator-widgets/calculator-widgets.pro
- \printuntil scxml
-
- We then specify the state machine to compile:
-
- \skipto STATECHARTS
- \printuntil statemachine.scxml
-
- The Qt SCXML Compiler, \c qscxmlc, is run automatically to generate
- \e statemachine.h and \e statemachine.cpp, and to add them to the \c HEADERS
- and \c SOURCES variables for compilation.
diff --git a/examples/scxml/calculator-qml/Button.qml b/examples/scxml/calculator-qml/Button.qml
deleted file mode 100644
index 84f4d0e..0000000
--- a/examples/scxml/calculator-qml/Button.qml
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.5
-
-Rectangle {
- id: button
- signal clicked
- property alias text: text.text
- border.width: 1
- border.color: "white"
- property real textHeight: height - 2
- property real fontHeight: 0.3
- property bool pressed: mouse.pressed
- property real implicitMargin: (width - text.implicitWidth) / 2
-
- Text {
- id: text
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.top: parent.top
- height: parent.textHeight
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- font.pixelSize: height * fontHeight
- color: "#1b1c1d"
- font.family: "Open Sans Regular"
- }
-
- MouseArea {
- id: mouse
- anchors.fill: parent
- onClicked: button.clicked()
- }
-}
diff --git a/examples/scxml/calculator-qml/calculator-qml.cpp b/examples/scxml/calculator-qml/calculator-qml.cpp
deleted file mode 100644
index 85b904e..0000000
--- a/examples/scxml/calculator-qml/calculator-qml.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QGuiApplication>
-#include <QQmlApplicationEngine>
-#include <QQmlContext>
-
-#include "statemachine.h"
-
-int main(int argc, char *argv[])
-{
- QGuiApplication app(argc, argv);
-
- qmlRegisterType<CalculatorStateMachine>("CalculatorStateMachine", 1, 0,
- "CalculatorStateMachine");
-
- QQmlApplicationEngine engine;
- engine.load(QUrl(QStringLiteral("qrc:/calculator-qml.qml")));
- if (engine.rootObjects().isEmpty())
- return -1;
-
- return app.exec();
-}
-
diff --git a/examples/scxml/calculator-qml/calculator-qml.pro b/examples/scxml/calculator-qml/calculator-qml.pro
deleted file mode 100644
index c40242f..0000000
--- a/examples/scxml/calculator-qml/calculator-qml.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-QT += qml scxml
-
-CONFIG += c++11
-
-SOURCES += calculator-qml.cpp
-
-RESOURCES += calculator-qml.qrc
-
-STATECHARTS = ../calculator-common/statemachine.scxml
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/scxml/calculator-qml
-INSTALLS += target
diff --git a/examples/scxml/calculator-qml/calculator-qml.qrc b/examples/scxml/calculator-qml/calculator-qml.qrc
deleted file mode 100644
index 55bc81c..0000000
--- a/examples/scxml/calculator-qml/calculator-qml.qrc
+++ /dev/null
@@ -1,6 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>calculator-qml.qml</file>
- <file>Button.qml</file>
- </qresource>
-</RCC>
diff --git a/examples/scxml/calculator-qml/doc/src/calculator-qml.qdoc b/examples/scxml/calculator-qml/doc/src/calculator-qml.qdoc
deleted file mode 100644
index e58fcfd..0000000
--- a/examples/scxml/calculator-qml/doc/src/calculator-qml.qdoc
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example calculator-qml
- \title Qt SCXML Calculator QML Example
- \ingroup examples-qtscxml
-
- \image calculator-qml.png
-
- \brief A Qt Quick application that implements the Calculator example
- presented in the SCXML Specification.
-
- \e {Calculator} uses Qt SCXML to implement the
- \l{SCXML Specification - Calculator Example}{Calculator Example}
- presented in the SCXML Specification.
-
- The state machine is specified in the \e statemachine.scxml file and
- compiled into the \c CalculatorStateMachine class. The user interface is
- created using Qt Quick.
-
- \include examples-run.qdocinc
-
- \include calculator-compiling.qdocinc
-
- \section1 Instantiating the State Machine
-
- We make the generated \c CalculatorStateMachine class available to QML by
- registering it as a QML type in the \e calculator-qml.cpp file:
-
- \quotefromfile calculator-qml/calculator-qml.cpp
- \skipto statemachine.h
- \printuntil }
-
- To use the CalculatorStateMachine type in a QML file, we import it:
-
- \quotefromfile calculator-qml/calculator-qml.qml
- \skipto CalculatorStateMachine
- \printline 1.0
-
- We instantiate a CalculatorStateMachine and listen to the \c updateDisplay
- event. When it occurs, we change the text on the calculator display:
-
- \skipto CalculatorStateMachine {
- \printuntil /^ {4}\}/
-
- When users press the calculator buttons, the buttons submit events to the
- state machine:
-
- \skipto DIGIT.
- \skipto Button
- \printuntil }
-*/
diff --git a/examples/scxml/calculator-widgets/calculator-widgets.cpp b/examples/scxml/calculator-widgets/calculator-widgets.cpp
deleted file mode 100644
index b127427..0000000
--- a/examples/scxml/calculator-widgets/calculator-widgets.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "statemachine.h"
-#include "mainwindow.h"
-
-#include <QApplication>
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
-
- CalculatorStateMachine machine;
- MainWindow mainWindow(&machine);
-
- machine.start();
- mainWindow.show();
- return app.exec();
-}
diff --git a/examples/scxml/calculator-widgets/calculator-widgets.pro b/examples/scxml/calculator-widgets/calculator-widgets.pro
deleted file mode 100644
index 238980b..0000000
--- a/examples/scxml/calculator-widgets/calculator-widgets.pro
+++ /dev/null
@@ -1,19 +0,0 @@
-QT += widgets scxml
-
-CONFIG += c++11
-
-STATECHARTS = ../calculator-common/statemachine.scxml
-
-SOURCES += \
- calculator-widgets.cpp \
- mainwindow.cpp
-
-HEADERS += \
- mainwindow.h
-
-FORMS += \
- mainwindow.ui
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/scxml/calculator-widgets
-INSTALLS += target
diff --git a/examples/scxml/calculator-widgets/doc/images/calculator.png b/examples/scxml/calculator-widgets/doc/images/calculator.png
deleted file mode 100644
index 0834d0a..0000000
--- a/examples/scxml/calculator-widgets/doc/images/calculator.png
+++ /dev/null
Binary files differ
diff --git a/examples/scxml/calculator-widgets/doc/src/calculator.qdoc b/examples/scxml/calculator-widgets/doc/src/calculator.qdoc
deleted file mode 100644
index 9463b53..0000000
--- a/examples/scxml/calculator-widgets/doc/src/calculator.qdoc
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example calculator-widgets
- \title Qt SCXML Calculator Example
- \ingroup examples-qtscxml
-
- \image calculator.png
-
- \brief A widget-based application that implements the Calculator example
- presented in the SCXML Specification.
-
- \e {Calculator} uses Qt SCXML to implement the
- \l{SCXML Specification - Calculator Example}{Calculator Example}
- presented in the SCXML Specification.
-
- The state machine is specified in the \e statemachine.scxml file and
- compiled into the \c CalculatorStateMachine class. The user interface is
- created using Qt Widgets.
-
- \include examples-run.qdocinc
-
- \include calculator-compiling.qdocinc
-
- \section1 Instantiating the State Machine
-
- We instantiate the generated \c CalculatorStateMachine class in the
- \e calculator-widgets.cpp file, as follows:
-
- \quotefromfile calculator-widgets/calculator-widgets.cpp
- \skipto #include
- \printuntil }
-
- \section1 Connecting to Active Properties
-
- After instantiating the state machine, we can connect to the active
- properties of the states, as follows:
-
- \quotefromfile calculator-widgets/mainwindow.cpp
- \skipto connect
- \printuntil digit2
- \printuntil }
-
- The state machine can notify other code when events occur:
-
- \quotefromfile calculator-common/statemachine.scxml
- \skipto transition event="DISPLAY.UPDATE
- \printuntil </transition
-
- We connect to the \c updateDisplay event to display the data passed by
- the events:
-
- \quotefromfile calculator-widgets/mainwindow.cpp
- \skipto connectToEvent
- \printuntil });
-*/
diff --git a/examples/scxml/calculator-widgets/mainwindow.cpp b/examples/scxml/calculator-widgets/mainwindow.cpp
deleted file mode 100644
index b742b95..0000000
--- a/examples/scxml/calculator-widgets/mainwindow.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "mainwindow.h"
-#include "ui_mainwindow.h"
-
-#include <QScxmlStateMachine>
-#include <QStringListModel>
-
-QT_USE_NAMESPACE
-
-MainWindow::MainWindow(QScxmlStateMachine *machine, QWidget *parent) :
- QWidget(parent),
- ui(new Ui::MainWindow),
- m_machine(machine)
-{
- ui->setupUi(this);
-
- connect(ui->digit0, &QAbstractButton::clicked, [this] {
- m_machine->submitEvent("DIGIT.0");
- });
- connect(ui->digit1, &QAbstractButton::clicked, [this] {
- m_machine->submitEvent("DIGIT.1");
- });
- connect(ui->digit2, &QAbstractButton::clicked, [this] {
- m_machine->submitEvent("DIGIT.2");
- });
- connect(ui->digit3, &QAbstractButton::clicked, [this] {
- m_machine->submitEvent("DIGIT.3");
- });
- connect(ui->digit4, &QAbstractButton::clicked, [this] {
- m_machine->submitEvent("DIGIT.4");
- });
- connect(ui->digit5, &QAbstractButton::clicked, [this] {
- m_machine->submitEvent("DIGIT.5");
- });
- connect(ui->digit6, &QAbstractButton::clicked, [this] {
- m_machine->submitEvent("DIGIT.6");
- });
- connect(ui->digit7, &QAbstractButton::clicked, [this] {
- m_machine->submitEvent("DIGIT.7");
- });
- connect(ui->digit8, &QAbstractButton::clicked, [this] {
- m_machine->submitEvent("DIGIT.8");
- });
- connect(ui->digit9, &QAbstractButton::clicked, [this] {
- m_machine->submitEvent("DIGIT.9");
- });
- connect(ui->point, &QAbstractButton::clicked, [this] {
- m_machine->submitEvent("POINT");
- });
- connect(ui->operPlus, &QAbstractButton::clicked, [this] {
- m_machine->submitEvent("OPER.PLUS");
- });
- connect(ui->operMinus, &QAbstractButton::clicked, [this] {
- m_machine->submitEvent("OPER.MINUS");
- });
- connect(ui->operStar, &QAbstractButton::clicked, [this] {
- m_machine->submitEvent("OPER.STAR");
- });
- connect(ui->operDiv, &QAbstractButton::clicked, [this] {
- m_machine->submitEvent("OPER.DIV");
- });
- connect(ui->equals, &QAbstractButton::clicked, [this] {
- m_machine->submitEvent("EQUALS");
- });
- connect(ui->c, &QAbstractButton::clicked, [this] {
- m_machine->submitEvent("C");
- });
-
- m_machine->connectToEvent(QLatin1String("updateDisplay"), this,
- [this](const QScxmlEvent &event) {
- const QString display = event.data().toMap()
- .value("display").toString();
- ui->display->setText(display);
- });
-}
-
-MainWindow::~MainWindow()
-{
- delete ui;
-}
-
diff --git a/examples/scxml/calculator-widgets/mainwindow.h b/examples/scxml/calculator-widgets/mainwindow.h
deleted file mode 100644
index fe34271..0000000
--- a/examples/scxml/calculator-widgets/mainwindow.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-namespace Ui {
-class MainWindow;
-}
-class QScxmlStateMachine;
-QT_END_NAMESPACE
-
-
-class MainWindow : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit MainWindow(QScxmlStateMachine *machine, QWidget *parent = nullptr);
- ~MainWindow();
-
-private:
- QT_PREPEND_NAMESPACE(Ui::MainWindow) *ui;
- QScxmlStateMachine *m_machine;
-};
-
-#endif // MAINWINDOW_H
diff --git a/examples/scxml/calculator-widgets/mainwindow.ui b/examples/scxml/calculator-widgets/mainwindow.ui
deleted file mode 100644
index 2ee3864..0000000
--- a/examples/scxml/calculator-widgets/mainwindow.ui
+++ /dev/null
@@ -1,177 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>MainWindow</class>
- <widget class="QWidget" name="MainWindow">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>364</width>
- <height>182</height>
- </rect>
- </property>
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="0" colspan="2">
- <widget class="QLabel" name="display">
- <property name="frameShape">
- <enum>QFrame::StyledPanel</enum>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="1" column="1">
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QPushButton" name="digit7">
- <property name="text">
- <string>7</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QPushButton" name="point">
- <property name="text">
- <string>.</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QPushButton" name="digit5">
- <property name="text">
- <string>5</string>
- </property>
- </widget>
- </item>
- <item row="0" column="2">
- <widget class="QPushButton" name="digit9">
- <property name="text">
- <string>9</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QPushButton" name="digit8">
- <property name="text">
- <string>8</string>
- </property>
- </widget>
- </item>
- <item row="4" column="2">
- <widget class="QPushButton" name="c">
- <property name="text">
- <string>C</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QPushButton" name="digit4">
- <property name="text">
- <string>4</string>
- </property>
- </widget>
- </item>
- <item row="2" column="3">
- <widget class="QPushButton" name="operStar">
- <property name="text">
- <string>*</string>
- </property>
- </widget>
- </item>
- <item row="2" column="2">
- <widget class="QPushButton" name="digit3">
- <property name="text">
- <string>3</string>
- </property>
- </widget>
- </item>
- <item row="4" column="3">
- <widget class="QPushButton" name="equals">
- <property name="text">
- <string>=</string>
- </property>
- </widget>
- </item>
- <item row="1" column="3">
- <widget class="QPushButton" name="operMinus">
- <property name="text">
- <string>-</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QPushButton" name="digit1">
- <property name="text">
- <string>1</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QPushButton" name="digit0">
- <property name="text">
- <string>0</string>
- </property>
- </widget>
- </item>
- <item row="3" column="3">
- <widget class="QPushButton" name="operDiv">
- <property name="text">
- <string>/</string>
- </property>
- </widget>
- </item>
- <item row="0" column="3">
- <widget class="QPushButton" name="operPlus">
- <property name="text">
- <string>+</string>
- </property>
- </widget>
- </item>
- <item row="1" column="2">
- <widget class="QPushButton" name="digit6">
- <property name="text">
- <string>6</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QPushButton" name="digit2">
- <property name="text">
- <string>2</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="2" column="1">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>10</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/examples/scxml/calculator/Button.qml b/examples/scxml/calculator/Button.qml
new file mode 100644
index 0000000..b2f0a79
--- /dev/null
+++ b/examples/scxml/calculator/Button.qml
@@ -0,0 +1,35 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Rectangle {
+ id: button
+ signal clicked
+ property alias text: text.text
+ border.width: 1
+ border.color: "white"
+ property real textHeight: height - 2
+ property real fontHeight: 0.3
+ property bool pressed: mouse.pressed
+ property real implicitMargin: (width - text.implicitWidth) / 2
+
+ Text {
+ id: text
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.top: parent.top
+ height: parent.textHeight
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ font.pixelSize: height * button.fontHeight
+ color: "#1b1c1d"
+ font.family: "Open Sans Regular"
+ }
+
+ MouseArea {
+ id: mouse
+ anchors.fill: parent
+ onClicked: button.clicked()
+ }
+}
diff --git a/examples/scxml/calculator/CMakeLists.txt b/examples/scxml/calculator/CMakeLists.txt
new file mode 100644
index 0000000..a8844f7
--- /dev/null
+++ b/examples/scxml/calculator/CMakeLists.txt
@@ -0,0 +1,52 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(calculator LANGUAGES CXX)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/scxml/calculator")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Scxml)
+
+qt_standard_project_setup(REQUIRES 6.5)
+
+qt_add_executable(calculatorscxml
+ calculator.cpp
+)
+
+set_target_properties(calculatorscxml PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(calculatorscxml PRIVATE
+ Qt::Core
+ Qt::Gui
+ Qt::Qml
+ Qt::Scxml
+)
+
+# Statecharts:
+qt6_add_statecharts(calculatorscxml
+ statemachine.scxml
+)
+
+qt_add_qml_module(calculatorscxml
+ URI Calculator
+ VERSION 1.0
+ QML_FILES
+ MainWindow.qml
+ Button.qml
+ SOURCES
+ calculator-qml.h
+)
+
+install(TARGETS calculatorscxml
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/scxml/calculator-qml/calculator-qml.qml b/examples/scxml/calculator/MainWindow.qml
index e4bb0b5..61a349d 100644
--- a/examples/scxml/calculator-qml/calculator-qml.qml
+++ b/examples/scxml/calculator/MainWindow.qml
@@ -1,57 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import CalculatorStateMachine 1.0
-import QtQuick 2.5
-import QtQuick.Window 2.2
-import QtScxml 5.8
+pragma ComponentBehavior: Bound
+
+import QtQuick
+import QtQuick.Window
+import QtScxml
+import Calculator
Window {
id: window
@@ -64,7 +19,7 @@ Window {
running: true
EventConnection {
events: ["updateDisplay"]
- onOccurred: resultText.text = event.data.display
+ onOccurred: (event)=> resultText.text = event.data.display
}
}
@@ -111,6 +66,8 @@ Window {
id: operations
model: ["÷", "×", "+", "-"]
Button {
+ required property int index
+ required property string modelData
y: 0
x: index * width
width: parent.width / 4
@@ -134,6 +91,8 @@ Window {
id: digits
model: ["7", "8", "9", "4", "5", "6", "1", "2", "3", "0", ".", "C"]
Button {
+ required property int index
+ required property string modelData
x: (index % 3) * width
y: Math.floor(index / 3 + 1) * height
width: parent.width / 4
diff --git a/examples/scxml/calculator/calculator-qml.h b/examples/scxml/calculator/calculator-qml.h
new file mode 100644
index 0000000..92a574c
--- /dev/null
+++ b/examples/scxml/calculator/calculator-qml.h
@@ -0,0 +1,20 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef CALCULATOR_QML
+#define CALCULATOR_QML
+
+#include "statemachine.h"
+
+#include <QtQml/qqml.h>
+#include <QtCore/qobject.h>
+
+struct CalculatorStateMachineRegistration
+{
+ Q_GADGET
+ QML_FOREIGN(CalculatorStateMachine)
+ QML_NAMED_ELEMENT(CalculatorStateMachine)
+ QML_ADDED_IN_VERSION(1, 0)
+};
+
+#endif // CALCULATOR_QML
diff --git a/examples/scxml/calculator/calculator.cpp b/examples/scxml/calculator/calculator.cpp
new file mode 100644
index 0000000..301b7c2
--- /dev/null
+++ b/examples/scxml/calculator/calculator.cpp
@@ -0,0 +1,18 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QtGui/qguiapplication.h>
+#include <QtQml/qqmlapplicationengine.h>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ QQmlApplicationEngine engine;
+ QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed, &app,
+ [](){ QCoreApplication::exit(EXIT_FAILURE); }, Qt::QueuedConnection);
+ engine.loadFromModule("Calculator", "MainWindow");
+
+ return app.exec();
+}
+
diff --git a/examples/scxml/calculator/calculator.pro b/examples/scxml/calculator/calculator.pro
new file mode 100644
index 0000000..ba7d343
--- /dev/null
+++ b/examples/scxml/calculator/calculator.pro
@@ -0,0 +1,26 @@
+QT += qml scxml
+
+CONFIG += c++11
+CONFIG += qmltypes
+
+SOURCES += calculator.cpp
+
+HEADERS += calculator-qml.h
+
+QML_IMPORT_NAME = Calculator
+QML_IMPORT_MAJOR_VERSION = 1
+
+qml_resources.files = \
+ qmldir \
+ MainWindow.qml \
+ Button.qml
+
+qml_resources.prefix = /qt/qml/Calculator
+
+RESOURCES += qml_resources
+
+STATECHARTS = statemachine.scxml
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/scxml/calculator
+INSTALLS += target
diff --git a/examples/scxml/calculator-qml/doc/images/calculator-qml.png b/examples/scxml/calculator/doc/images/calculator.png
index 021f56d..021f56d 100644
--- a/examples/scxml/calculator-qml/doc/images/calculator-qml.png
+++ b/examples/scxml/calculator/doc/images/calculator.png
Binary files differ
diff --git a/examples/scxml/calculator/doc/src/calculator.qdoc b/examples/scxml/calculator/doc/src/calculator.qdoc
new file mode 100644
index 0000000..5df6919
--- /dev/null
+++ b/examples/scxml/calculator/doc/src/calculator.qdoc
@@ -0,0 +1,48 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example calculator
+ \title SCXML Calculator
+ \examplecategory {Data Processing & I/O}
+ \ingroup examples-qtscxml
+ \meta tag {state machine}
+
+ \image calculator.png
+
+ \brief An application that implements the Calculator example
+ presented in the SCXML Specification.
+
+ \e {Calculator} uses Qt SCXML to implement the
+ \l{SCXML Specification - Calculator Example}{Calculator Example}
+ presented in the SCXML Specification.
+
+ The state machine is specified in the \e statemachine.scxml file and
+ compiled into the \c CalculatorStateMachine class. The user interface is
+ created using Qt Quick.
+
+ \include examples-run.qdocinc
+
+ \section1 Instantiating the State Machine
+
+ We make the generated \c CalculatorStateMachine class available to QML by
+ declaring it as a QML type in the \e calculator-qml.h file:
+
+ \quotefromfile calculator/calculator-qml.h
+ \skipto struct
+ \printuntil }
+
+ We instantiate a CalculatorStateMachine and listen to the \c updateDisplay
+ event. When it occurs, we change the text on the calculator display:
+
+ \quotefromfile calculator/MainWindow.qml
+ \skipto CalculatorStateMachine {
+ \printuntil /^ {4}\}/
+
+ When users press the calculator buttons, the buttons submit events to the
+ state machine:
+
+ \skipto DIGIT.
+ \skipto Button
+ \printuntil }
+*/
diff --git a/examples/scxml/calculator/qmldir b/examples/scxml/calculator/qmldir
new file mode 100644
index 0000000..1782b57
--- /dev/null
+++ b/examples/scxml/calculator/qmldir
@@ -0,0 +1,5 @@
+module Calculator
+prefer :/qt/qml/Calculator/
+MainWindow 1.0 MainWindow.qml
+Button 1.0 Button.qml
+
diff --git a/examples/scxml/calculator-common/statemachine.scxml b/examples/scxml/calculator/statemachine.scxml
index b1c6bb7..b1c6bb7 100644
--- a/examples/scxml/calculator-common/statemachine.scxml
+++ b/examples/scxml/calculator/statemachine.scxml
diff --git a/examples/scxml/ftpclient/CMakeLists.txt b/examples/scxml/ftpclient/CMakeLists.txt
new file mode 100644
index 0000000..adc9b7a
--- /dev/null
+++ b/examples/scxml/ftpclient/CMakeLists.txt
@@ -0,0 +1,47 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(ftpclient LANGUAGES CXX)
+
+if (ANDROID)
+ message(FATAL_ERROR "This project cannot be built on Android.")
+endif()
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/scxml/ftpclient")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Network Scxml)
+
+qt_standard_project_setup()
+
+qt_add_executable(ftpclient
+ ftpcontrolchannel.cpp ftpcontrolchannel.h
+ ftpdatachannel.cpp ftpdatachannel.h
+ main.cpp
+)
+
+set_target_properties(ftpclient PROPERTIES
+ WIN32_EXECUTABLE FALSE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(ftpclient PRIVATE
+ Qt6::Core
+ Qt6::Network
+ Qt6::Scxml
+)
+
+# Statecharts:
+qt6_add_statecharts(ftpclient
+ simpleftp.scxml
+)
+
+install(TARGETS ftpclient
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/scxml/ftpclient/doc/src/ftpclient.qdoc b/examples/scxml/ftpclient/doc/src/ftpclient.qdoc
index b69994d..9f3ce2a 100644
--- a/examples/scxml/ftpclient/doc/src/ftpclient.qdoc
+++ b/examples/scxml/ftpclient/doc/src/ftpclient.qdoc
@@ -1,34 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example ftpclient
- \title Qt SCXML FTP Client Example
+ \title SCXML FTP Client
\ingroup examples-qtscxml
+ \examplecategory {Networking}
\brief Implements a simple FTP client using a state machine.
@@ -67,19 +44,31 @@
\section1 Compiling the State Machine
We link against the Qt SCXML module by adding the following line to the
- \e .pro file:
+ project build files.
+ With qmake, we add the following to \e ftpclient.pro
\quotefromfile ftpclient/ftpclient.pro
- \printuntil scxml
+ \skipto QT
+ \printline scxml
We then specify the state machine to compile:
-
\skipto STATECHARTS
- \printuntil simpleftp.scxml
+ \printline scxml
+
+ With CMake, we add the following to \e CMakeLists.txt
+ \quotefromfile ftpclient/CMakeLists.txt
+ \skipto find_package
+ \printline Scxml
+ \skipto target_link_libraries
+ \printuntil )
+
+ We then specify the state machine to compile:
+ \skipto qt6_add_statecharts
+ \printuntil )
The Qt SCXML Compiler, \c qscxmlc, is run automatically to generate
- \e ftpclient.h and \e ftpclient.cpp, and to add them to the \c HEADERS
- and \c SOURCES variables for compilation.
+ \e simpleftp.h and \e simpleftp.cpp, and to add them appropriately to
+ the project as headers and sources.
\section1 Instantiating the State Machine
@@ -88,7 +77,7 @@
\quotefromfile ftpclient/main.cpp
\skipto #include
- \printuntil ftpdatachannel.h
+ \printuntil simpleftp
\dots
\skipto int main
\printuntil {
@@ -115,7 +104,7 @@
\printuntil }
We send commands to log into the FTP server as an anonymous user, to
- announce a port for the data connection, and to retrive a file:
+ announce a port for the data connection, and to retrieve a file:
\skipto QList
\printuntil });
diff --git a/examples/scxml/ftpclient/ftpcontrolchannel.cpp b/examples/scxml/ftpclient/ftpcontrolchannel.cpp
index 5f58105..d52a1e3 100644
--- a/examples/scxml/ftpclient/ftpcontrolchannel.cpp
+++ b/examples/scxml/ftpclient/ftpcontrolchannel.cpp
@@ -1,55 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "ftpcontrolchannel.h"
+#include <QtCore/qcoreapplication.h>
+
FtpControlChannel::FtpControlChannel(QObject *parent) : QObject(parent)
{
connect(&m_socket, &QIODevice::readyRead,
@@ -59,6 +14,8 @@ FtpControlChannel::FtpControlChannel(QObject *parent) : QObject(parent)
connect(&m_socket, &QAbstractSocket::connected, this, [this]() {
emit opened(m_socket.localAddress(), m_socket.localPort());
});
+ connect(&m_socket, &QAbstractSocket::errorOccurred,
+ this, &FtpControlChannel::error);
}
void FtpControlChannel::connectToServer(const QString &server)
@@ -85,12 +42,21 @@ void FtpControlChannel::onReadyRead()
int space = received.indexOf(' ');
if (space != -1) {
int code = received.mid(0, space).toInt();
- if (code == 0)
+ if (code == 0) {
+ qDebug() << "Info received: " << received.mid(space + 1);
emit info(received.mid(space + 1));
- else
+ } else {
+ qDebug() << "Reply received: " << received.mid(space + 1);
emit reply(code, received.mid(space + 1));
+ }
} else {
emit invalidReply(received);
}
}
}
+
+void FtpControlChannel::error(QAbstractSocket::SocketError error)
+{
+ qWarning() << "Socket error:" << error;
+ QCoreApplication::exit();
+}
diff --git a/examples/scxml/ftpclient/ftpcontrolchannel.h b/examples/scxml/ftpclient/ftpcontrolchannel.h
index 092f2a9..b577dd0 100644
--- a/examples/scxml/ftpclient/ftpcontrolchannel.h
+++ b/examples/scxml/ftpclient/ftpcontrolchannel.h
@@ -1,59 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef FTPCONTROLCHANNEL_H
#define FTPCONTROLCHANNEL_H
-#include <QHostAddress>
-#include <QObject>
-#include <QTcpSocket>
+#include <QtNetwork/qhostaddress.h>
+#include <QtNetwork/qtcpsocket.h>
+#include <QtCore/qobject.h>
class FtpControlChannel : public QObject
{
@@ -67,6 +20,9 @@ public:
// Send a command to the server
void command(const QByteArray &command, const QByteArray &params);
+public slots:
+ void error(QAbstractSocket::SocketError);
+
signals:
// Connection established. Local address and port are known.
diff --git a/examples/scxml/ftpclient/ftpdatachannel.cpp b/examples/scxml/ftpclient/ftpdatachannel.cpp
index f0a7aa4..83ef872 100644
--- a/examples/scxml/ftpclient/ftpdatachannel.cpp
+++ b/examples/scxml/ftpclient/ftpdatachannel.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "ftpdatachannel.h"
@@ -54,7 +7,7 @@ FtpDataChannel::FtpDataChannel(QObject *parent) : QObject(parent)
{
connect(&m_server, &QTcpServer::newConnection, this, [this]() {
m_socket.reset(m_server.nextPendingConnection());
- connect(m_socket.data(), &QTcpSocket::readyRead, [this]() {
+ connect(m_socket.get(), &QTcpSocket::readyRead, this, [this]() {
emit dataReceived(m_socket->readAll());
});
});
diff --git a/examples/scxml/ftpclient/ftpdatachannel.h b/examples/scxml/ftpclient/ftpdatachannel.h
index 2418196..da356a8 100644
--- a/examples/scxml/ftpclient/ftpdatachannel.h
+++ b/examples/scxml/ftpclient/ftpdatachannel.h
@@ -1,60 +1,14 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef FTPDATACHANNEL_H
#define FTPDATACHANNEL_H
-#include <QObject>
-#include <QScopedPointer>
-#include <QTcpServer>
-#include <QTcpSocket>
+#include <QtCore/qobject.h>
+#include <QtNetwork/qtcpserver.h>
+#include <QtNetwork/qtcpsocket.h>
+
+#include <memory>
class FtpDataChannel : public QObject
{
@@ -86,7 +40,7 @@ signals:
private:
QTcpServer m_server;
- QScopedPointer<QTcpSocket> m_socket;
+ std::unique_ptr<QTcpSocket> m_socket;
};
#endif // FTPDATACHANNEL_H
diff --git a/examples/scxml/ftpclient/main.cpp b/examples/scxml/ftpclient/main.cpp
index b285077..9159c2b 100644
--- a/examples/scxml/ftpclient/main.cpp
+++ b/examples/scxml/ftpclient/main.cpp
@@ -1,58 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "ftpcontrolchannel.h"
#include "ftpdatachannel.h"
#include "simpleftp.h"
-#include <QCoreApplication>
+#include <QtCore/qcoreapplication.h>
#include <iostream>
@@ -64,7 +17,8 @@ struct Command {
int main(int argc, char *argv[])
{
if (argc != 3) {
- qDebug() << "Usage: ftpclient <server> <file>";
+ qWarning() << "Usage: ftpclient <server> <file>";
+ qWarning() << "For example: ftpclient ftp.gnu.org welcome.msg";
return 1;
}
@@ -79,7 +33,7 @@ int main(int argc, char *argv[])
// Print all data retrieved from the server on the console.
QObject::connect(&dataChannel, &FtpDataChannel::dataReceived,
[](const QByteArray &data) {
- std::cout << data.constData();
+ std::cout << data.constData() << std::flush;
});
// Translate server replies into state machine events.
@@ -123,7 +77,7 @@ int main(int argc, char *argv[])
// Connect to our own local FTP server
controlChannel.connectToServer(server);
- QObject::connect(&controlChannel, &FtpControlChannel::opened,
+ QObject::connect(&controlChannel, &FtpControlChannel::opened, &dataChannel,
[&](const QHostAddress &address, int) {
dataChannel.listen(address);
commands[1].args = dataChannel.portspec();
diff --git a/examples/scxml/ftpclient/simpleftp.scxml b/examples/scxml/ftpclient/simpleftp.scxml
index 7d57040..0e788bc 100644
--- a/examples/scxml/ftpclient/simpleftp.scxml
+++ b/examples/scxml/ftpclient/simpleftp.scxml
@@ -1,54 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-->
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" name="FtpClient"
datamodel="ecmascript">
diff --git a/examples/scxml/invoke-common/Button.qml b/examples/scxml/invoke-common/Button.qml
deleted file mode 100644
index 4e92e32..0000000
--- a/examples/scxml/invoke-common/Button.qml
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.5
-
-Item {
- id: button
- signal clicked
- property string text: "hello"
- property bool enabled: true
- opacity: enabled ? 1.0 : 0.5
-
- Rectangle {
- x: 5
- y: 5
- width: parent.width - 10
- height: parent.height - 10
- radius: 5
- color: "lightsteelblue"
-
- Text {
- anchors.fill: parent
- color: "white"
- text: button.text
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- }
-
- MouseArea {
- id: mouse
- anchors.fill: parent
- onClicked: if (button.enabled) button.clicked()
- }
- }
-}
diff --git a/examples/scxml/invoke-common/MainView.qml b/examples/scxml/invoke-common/MainView.qml
deleted file mode 100644
index 8d8c3e3..0000000
--- a/examples/scxml/invoke-common/MainView.qml
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.5
-import QtQuick.Window 2.2
-import QtScxml 5.8
-
-Window {
- id: window
- visible: true
- property StateMachine stateMachine
-
- color: "black"
- width: 400
- height: 300
-
- 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 {
- source: "SubView.qml"
- active: stateMachine.somewhere
-
- x: parent.width / 2
- width: parent.width / 2
- height: parent.height
-
- InvokedServices {
- id: services
- stateMachine: window.stateMachine
- }
-
- property var anywhere: services.children.anywhere ? services.children.anywhere.stateMachine
- : undefined
- }
-}
-
diff --git a/examples/scxml/invoke-common/SubView.qml b/examples/scxml/invoke-common/SubView.qml
deleted file mode 100644
index 2c374d5..0000000
--- a/examples/scxml/invoke-common/SubView.qml
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.5
-
-Item {
- // "anywhere" is a context property, so we always have to check if it's null
- Button {
- id: here
- enabled: anywhere ? anywhere.here : false
- text: "Go There"
- width: parent.width / 2
- height: parent.height
- onClicked: anywhere.submitEvent("goThere")
- }
-
- Button {
- id: there
- enabled: anywhere ? anywhere.there : false
- text: "Go Here"
- width: parent.width / 2
- height: parent.height
- x: width
- onClicked: anywhere.submitEvent("goHere")
- }
-}
diff --git a/examples/scxml/invoke-common/statemachine.scxml b/examples/scxml/invoke-common/statemachine.scxml
deleted file mode 100644
index ad04cb3..0000000
--- a/examples/scxml/invoke-common/statemachine.scxml
+++ /dev/null
@@ -1,79 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
--->
-<scxml
- xmlns="http://www.w3.org/2005/07/scxml"
- version="1.0"
- name="Directions"
- initial="anyplace"
->
- <state id="anyplace">
- <transition event="goNowhere" target="nowhere"/>
- <transition event="goSomewhere" target="somewhere"/>
-
- <state id="nowhere"/>
- <state id="somewhere">
- <invoke type="http://www.w3.org/TR/scxml/">
- <content>
- <scxml name="anywhere" version="1.0">
- <state id="here">
- <transition event="goThere" target="there"/>
- </state>
- <state id="there">
- <transition event="goHere" target="here"/>
- </state>
- </scxml>
- </content>
- </invoke>
- </state>
- </state>
-</scxml>
diff --git a/examples/scxml/invoke-dynamic/doc/images/invoke-dynamic.png b/examples/scxml/invoke-dynamic/doc/images/invoke-dynamic.png
deleted file mode 100644
index 4efa912..0000000
--- a/examples/scxml/invoke-dynamic/doc/images/invoke-dynamic.png
+++ /dev/null
Binary files differ
diff --git a/examples/scxml/invoke-dynamic/doc/src/invoke-dynamic.qdoc b/examples/scxml/invoke-dynamic/doc/src/invoke-dynamic.qdoc
deleted file mode 100644
index bff773a..0000000
--- a/examples/scxml/invoke-dynamic/doc/src/invoke-dynamic.qdoc
+++ /dev/null
@@ -1,67 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example invoke-dynamic
- \title Qt SCXML Invoke Example (Dynamic)
- \ingroup examples-qtscxml
-
- \brief Invokes a dynamically loaded nested state machine.
-
- \image invoke-dynamic.png
-
- \e{Invoke Example (Dynamic)} demonstrates how to use the \c <invoke> element
- with generated nested state-machines, where the SCXML file is dynamically
- loaded. The \c <invoke> element is used to create an instance of an external
- service.
-
- \include examples-run.qdocinc
-
- \section1 Invoking the State Machine
-
- In \e statemachine.scxml, we specify a state machine with the name
- \e Directions of type \e http://www.w3.org/TR/scxml/ to invoke:
-
- \quotefromfile invoke-common/statemachine.scxml
- \skipto scxml
- \printuntil
-
- \section1 Dynamically Loading the State Machine
-
- We link against the Qt SCXML module by adding the following line to the
- \e invoke-dynamic.pro file:
-
- \quotefromfile invoke-dynamic/invoke-dynamic.pro
- \skipto QT
- \printline scxml
-
- We dynamically create the state machine, as follows:
-
- \quotefromfile invoke-dynamic/invoke-dynamic.qml
- \skipto import
- \printuntil }
-*/
diff --git a/examples/scxml/invoke-dynamic/invoke-dynamic.cpp b/examples/scxml/invoke-dynamic/invoke-dynamic.cpp
deleted file mode 100644
index 4d48e16..0000000
--- a/examples/scxml/invoke-dynamic/invoke-dynamic.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QGuiApplication>
-#include <QQmlApplicationEngine>
-#include <QQmlContext>
-
-int main(int argc, char *argv[])
-{
- QGuiApplication app(argc, argv);
-
- QQmlApplicationEngine engine;
- engine.load(QUrl(QStringLiteral("qrc:/invoke-dynamic.qml")));
- if (engine.rootObjects().isEmpty())
- return -1;
-
- return app.exec();
-}
diff --git a/examples/scxml/invoke-dynamic/invoke-dynamic.pro b/examples/scxml/invoke-dynamic/invoke-dynamic.pro
deleted file mode 100644
index e4f07da..0000000
--- a/examples/scxml/invoke-dynamic/invoke-dynamic.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-TEMPLATE = app
-
-QT += qml scxml
-CONFIG += c++11
-
-SOURCES += invoke-dynamic.cpp
-
-RESOURCES += invoke-dynamic.qrc
-
-target.path = $$[QT_INSTALL_EXAMPLES]/scxml/invoke-dynamic
-INSTALLS += target
-
diff --git a/examples/scxml/invoke-dynamic/invoke-dynamic.qml b/examples/scxml/invoke-dynamic/invoke-dynamic.qml
deleted file mode 100644
index 4ff85b4..0000000
--- a/examples/scxml/invoke-dynamic/invoke-dynamic.qml
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtScxml 5.8
-
-MainView {
- stateMachine: directions.stateMachine
-
- StateMachineLoader {
- id: directions
- source: "qrc:///statemachine.scxml"
- }
-}
diff --git a/examples/scxml/invoke-dynamic/invoke-dynamic.qrc b/examples/scxml/invoke-dynamic/invoke-dynamic.qrc
deleted file mode 100644
index ecf8bd1..0000000
--- a/examples/scxml/invoke-dynamic/invoke-dynamic.qrc
+++ /dev/null
@@ -1,9 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>invoke-dynamic.qml</file>
- <file alias="statemachine.scxml">../invoke-common/statemachine.scxml</file>
- <file alias="MainView.qml">../invoke-common/MainView.qml</file>
- <file alias="SubView.qml">../invoke-common/SubView.qml</file>
- <file alias="Button.qml">../invoke-common/Button.qml</file>
- </qresource>
-</RCC>
diff --git a/examples/scxml/invoke-static/doc/src/invoke-static.qdoc b/examples/scxml/invoke-static/doc/src/invoke-static.qdoc
deleted file mode 100644
index 099b904..0000000
--- a/examples/scxml/invoke-static/doc/src/invoke-static.qdoc
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example invoke-static
- \title Qt SCXML Invoke Example (Static)
- \ingroup examples-qtscxml
-
- \brief Invokes a compiled nested state machine.
-
- \image invoke-static.png
-
- \e{Invoke Example (Static)} demonstrates how to use the \c <invoke> element
- with generated nested state-machines, where the SCXML file is compiled to
- a C++ class. The \c <invoke> element is used to create an instance of an
- external service.
-
- \include examples-run.qdocinc
-
- \section1 Invoking the State Machine
-
- In \e statemachine.scxml, we specify a state machine with the name
- \e Directions of type \e http://www.w3.org/TR/scxml/ to invoke:
-
- \quotefromfile invoke-common/statemachine.scxml
- \skipto scxml
- \printuntil
-
- \section1 Compiling the State Machine
-
- We link against the Qt SCXML module by adding the following line to the
- \e invoke-static.pro file:
-
- \quotefromfile invoke-static/invoke-static.pro
- \skipto QT
- \printline scxml
-
- We then specify the state machine to compile:
-
- \skipto STATECHARTS
- \printline statemachine
-
- The Qt SCXML Compiler, \c qscxmlc, is run automatically to generate
- \e statemachine.h and \e statemachine.cpp, and to add them to the \c HEADERS
- and \c SOURCES variables for compilation.
-
- \section1 Instantiating the State Machine
-
- We instantiate the generated \c Directions class in the \e invoke-static.cpp
- file, as follows:
-
- \quotefromfile invoke-static/invoke-static.cpp
- \skipto statemachine.h
- \printuntil }
-*/
diff --git a/examples/scxml/invoke-static/invoke-static.cpp b/examples/scxml/invoke-static/invoke-static.cpp
deleted file mode 100644
index d53eb48..0000000
--- a/examples/scxml/invoke-static/invoke-static.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QGuiApplication>
-#include <QQmlApplicationEngine>
-#include <QQmlContext>
-
-#include "statemachine.h"
-
-int main(int argc, char *argv[])
-{
- QGuiApplication app(argc, argv);
-
- qmlRegisterType<Directions>("Directions", 1, 0, "Directions");
-
- QQmlApplicationEngine engine;
- engine.load(QUrl(QStringLiteral("qrc:/invoke-static.qml")));
- if (engine.rootObjects().isEmpty())
- return -1;
-
- return app.exec();
-}
diff --git a/examples/scxml/invoke-static/invoke-static.pro b/examples/scxml/invoke-static/invoke-static.pro
deleted file mode 100644
index e2e206c..0000000
--- a/examples/scxml/invoke-static/invoke-static.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-TEMPLATE = app
-
-QT += qml scxml
-CONFIG += c++11
-
-SOURCES += invoke-static.cpp
-
-RESOURCES += invoke-static.qrc
-
-STATECHARTS = ../invoke-common/statemachine.scxml
-
-target.path = $$[QT_INSTALL_EXAMPLES]/scxml/invoke-static
-INSTALLS += target
-
diff --git a/examples/scxml/invoke-static/invoke-static.qml b/examples/scxml/invoke-static/invoke-static.qml
deleted file mode 100644
index dc59e1b..0000000
--- a/examples/scxml/invoke-static/invoke-static.qml
+++ /dev/null
@@ -1,57 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import Directions 1.0
-
-MainView {
- stateMachine: Directions {
- running: true
- }
-}
diff --git a/examples/scxml/invoke-static/invoke-static.qrc b/examples/scxml/invoke-static/invoke-static.qrc
deleted file mode 100644
index cc5bcad..0000000
--- a/examples/scxml/invoke-static/invoke-static.qrc
+++ /dev/null
@@ -1,8 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>invoke-static.qml</file>
- <file alias="MainView.qml">../invoke-common/MainView.qml</file>
- <file alias="SubView.qml">../invoke-common/SubView.qml</file>
- <file alias="Button.qml">../invoke-common/Button.qml</file>
- </qresource>
-</RCC>
diff --git a/examples/scxml/invoke/Button.qml b/examples/scxml/invoke/Button.qml
new file mode 100644
index 0000000..5be5665
--- /dev/null
+++ b/examples/scxml/invoke/Button.qml
@@ -0,0 +1,37 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+pragma ComponentBehavior: Bound
+
+import QtQuick
+
+Item {
+ id: button
+ signal clicked
+ property string text: "hello"
+ property bool enabled: true
+ opacity: enabled ? 1.0 : 0.5
+
+ Rectangle {
+ x: 5
+ y: 5
+ width: parent.width - 10
+ height: parent.height - 10
+ radius: 5
+ color: "lightsteelblue"
+
+ Text {
+ anchors.fill: parent
+ color: "white"
+ text: button.text
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+
+ MouseArea {
+ id: mouse
+ anchors.fill: parent
+ onClicked: if (button.enabled) button.clicked()
+ }
+ }
+}
diff --git a/examples/scxml/invoke/CMakeLists.txt b/examples/scxml/invoke/CMakeLists.txt
new file mode 100644
index 0000000..d8c858a
--- /dev/null
+++ b/examples/scxml/invoke/CMakeLists.txt
@@ -0,0 +1,53 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(invoke LANGUAGES CXX)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/scxml/invoke")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Scxml)
+
+qt_standard_project_setup(REQUIRES 6.5)
+
+qt_add_executable(invoke
+ invoke.cpp
+)
+
+set_target_properties(invoke PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(invoke PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Qml
+ Qt6::Scxml
+)
+
+# Statecharts:
+qt6_add_statecharts(invoke
+ statemachine.scxml
+)
+
+qt_add_qml_module(invoke
+ URI InvokeExample
+ VERSION 1.0
+ QML_FILES
+ Button.qml
+ MainView.qml
+ SubView.qml
+ SOURCES
+ invoke-qml.h
+)
+
+install(TARGETS invoke
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/scxml/invoke/MainView.qml b/examples/scxml/invoke/MainView.qml
new file mode 100644
index 0000000..c7a4400
--- /dev/null
+++ b/examples/scxml/invoke/MainView.qml
@@ -0,0 +1,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
+ }
+ }
+}
+
diff --git a/examples/scxml/invoke/SubView.qml b/examples/scxml/invoke/SubView.qml
new file mode 100644
index 0000000..31dbf06
--- /dev/null
+++ b/examples/scxml/invoke/SubView.qml
@@ -0,0 +1,31 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+pragma ComponentBehavior: Bound
+
+import QtQuick
+import QtScxml
+
+Item {
+ id: root
+ required property StateMachine anywhere
+
+ Button {
+ id: here
+ enabled: root.anywhere ? root.anywhere.here : false
+ text: "Go There"
+ width: parent.width / 2
+ height: parent.height
+ onClicked: root.anywhere.submitEvent("goThere")
+ }
+
+ Button {
+ id: there
+ enabled: root.anywhere ? root.anywhere.there : false
+ text: "Go Here"
+ width: parent.width / 2
+ height: parent.height
+ x: width
+ onClicked: root.anywhere.submitEvent("goHere")
+ }
+}
diff --git a/examples/scxml/invoke-static/doc/images/invoke-static.png b/examples/scxml/invoke/doc/images/invoke.png
index fa73ebe..fa73ebe 100644
--- a/examples/scxml/invoke-static/doc/images/invoke-static.png
+++ b/examples/scxml/invoke/doc/images/invoke.png
Binary files differ
diff --git a/examples/scxml/invoke/doc/src/invoke.qdoc b/examples/scxml/invoke/doc/src/invoke.qdoc
new file mode 100644
index 0000000..8e8d903
--- /dev/null
+++ b/examples/scxml/invoke/doc/src/invoke.qdoc
@@ -0,0 +1,75 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example invoke
+ \title SCXML Invoke
+ \examplecategory {Data Processing & I/O}
+ \ingroup examples-qtscxml
+
+ \brief Invokes a compiled nested state machine.
+
+ \image invoke.png
+
+ \e{Invoke} demonstrates how to use the \c <invoke> element
+ with generated nested state-machines, where the SCXML file is compiled to
+ a C++ class. The \c <invoke> element is used to create an instance of an
+ external service.
+
+ \include examples-run.qdocinc
+
+ \section1 Invoking the State Machine
+
+ In \e statemachine.scxml, we specify a state machine with the name
+ \e DirectionsStateMachine of type \e http://www.w3.org/TR/scxml/ to invoke:
+
+ \quotefromfile invoke/statemachine.scxml
+ \skipto scxml
+ \printuntil
+
+ \section1 Compiling the State Machine
+ We link against the Qt SCXML module by adding the following lines to the
+ example's build files.
+
+ \section2 \e invoke.pro when using qmake:
+
+ \quotefromfile invoke/invoke.pro
+ \skipto QT
+ \printline scxml
+
+ We then specify the state machine to compile:
+ \skipto STATECHARTS
+ \printline scxml
+
+ \section2 \e CMakeLists.txt when using cmake:
+ \quotefromfile invoke/CMakeLists.txt
+ \skipto find_package
+ \printline Scxml
+ \skipto target_link_libraries
+ \printuntil )
+
+ We then specify the state machine to compile:
+ \skipto qt6_add_statecharts
+ \printuntil )
+
+ The statechart directives \e STATECHARTS or \e qt6_add_statecharts invoke the Qt SCXML
+ Compiler, \c qscxmlc, which is run automatically to generate \e statemachine.h and
+ \e statemachine.cpp, which are then added appropriately as headers and sources for
+ compilation.
+
+ \section1 Declaring the state machine as QML element
+
+ The state machine is declared as a QML element as follows:
+ \quotefromfile invoke/invoke-qml.h
+ \skipto struct
+ \printuntil }
+
+ \section1 Instantiating the State Machine
+
+ We instantiate the generated \c DirectionsStateMachine element in the \e MainView.qml
+ file, as follows:
+
+ \quotefromfile invoke/MainView.qml
+ \skipto DirectionsStateMachine
+ \printuntil }
+*/
diff --git a/examples/scxml/invoke/invoke-qml.h b/examples/scxml/invoke/invoke-qml.h
new file mode 100644
index 0000000..e0735a8
--- /dev/null
+++ b/examples/scxml/invoke/invoke-qml.h
@@ -0,0 +1,20 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef INVOKE_QML
+#define INVOKE_QML
+
+#include "statemachine.h"
+
+#include <QtQml/qqml.h>
+#include <QtCore/qobject.h>
+
+struct DirectionsStateMachineRegistration
+{
+ Q_GADGET
+ QML_FOREIGN(DirectionsStateMachine)
+ QML_NAMED_ELEMENT(DirectionsStateMachine)
+ QML_ADDED_IN_VERSION(1, 0)
+};
+
+#endif // INVOKE_QML
diff --git a/examples/scxml/invoke/invoke.cpp b/examples/scxml/invoke/invoke.cpp
new file mode 100644
index 0000000..6680396
--- /dev/null
+++ b/examples/scxml/invoke/invoke.cpp
@@ -0,0 +1,17 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QtGui/qguiapplication.h>
+#include <QtQml/qqmlapplicationengine.h>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ QQmlApplicationEngine engine;
+ QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed, &app,
+ [](){ QCoreApplication::exit(EXIT_FAILURE); }, Qt::QueuedConnection);
+ engine.loadFromModule("InvokeExample", "MainView");
+
+ return app.exec();
+}
diff --git a/examples/scxml/invoke/invoke.pro b/examples/scxml/invoke/invoke.pro
new file mode 100644
index 0000000..d23a0af
--- /dev/null
+++ b/examples/scxml/invoke/invoke.pro
@@ -0,0 +1,27 @@
+TEMPLATE = app
+
+QT += qml scxml
+CONFIG += c++11
+CONFIG += qmltypes
+
+SOURCES += invoke.cpp
+HEADERS += invoke-qml.h
+
+QML_IMPORT_NAME = InvokeExample
+QML_IMPORT_MAJOR_VERSION = 1
+
+qml_resources.files = \
+ qmldir \
+ Button.qml \
+ MainView.qml \
+ SubView.qml
+
+qml_resources.prefix = /qt/qml/InvokeExample
+
+RESOURCES += qml_resources
+
+STATECHARTS = statemachine.scxml
+
+target.path = $$[QT_INSTALL_EXAMPLES]/scxml/invoke
+INSTALLS += target
+
diff --git a/examples/scxml/invoke/qmldir b/examples/scxml/invoke/qmldir
new file mode 100644
index 0000000..6816682
--- /dev/null
+++ b/examples/scxml/invoke/qmldir
@@ -0,0 +1,5 @@
+module InvokeExample
+prefer :/qt/qml/InvokeExample/
+Button 1.0 Button.qml
+MainView 1.0 MainView.qml
+SubView 1.0 SubView.qml
diff --git a/examples/scxml/invoke/statemachine.scxml b/examples/scxml/invoke/statemachine.scxml
new file mode 100644
index 0000000..bd31dca
--- /dev/null
+++ b/examples/scxml/invoke/statemachine.scxml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+-->
+<scxml
+ xmlns="http://www.w3.org/2005/07/scxml"
+ version="1.0"
+ name="DirectionsStateMachine"
+ initial="anyplace"
+>
+ <state id="anyplace">
+ <transition event="goNowhere" target="nowhere"/>
+ <transition event="goSomewhere" target="somewhere"/>
+
+ <state id="nowhere"/>
+ <state id="somewhere">
+ <invoke type="http://www.w3.org/TR/scxml/">
+ <content>
+ <scxml name="anywhere" version="1.0">
+ <state id="here">
+ <transition event="goThere" target="there"/>
+ </state>
+ <state id="there">
+ <transition event="goHere" target="here"/>
+ </state>
+ </scxml>
+ </content>
+ </invoke>
+ </state>
+ </state>
+</scxml>
diff --git a/examples/scxml/mediaplayer-common/Mediaplayer.qml b/examples/scxml/mediaplayer-common/Mediaplayer.qml
deleted file mode 100644
index 42a948a..0000000
--- a/examples/scxml/mediaplayer-common/Mediaplayer.qml
+++ /dev/null
@@ -1,142 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.5
-import QtQuick.Window 2.2
-import QtScxml 5.8
-
-Window {
- id: root
- property StateMachine stateMachine: scxmlLoader.stateMachine
- property alias source: scxmlLoader.source
-
- visible: true
- width: 750
- height: 350
- color: "white"
-
- ListView {
- id: theList
- width: parent.width / 2
- height: parent.height
- keyNavigationWraps: true
- highlightMoveDuration: 0
- focus: true
- model: ListModel {
- id: theModel
- ListElement { media: "Song 1" }
- ListElement { media: "Song 2" }
- ListElement { media: "Song 3" }
- }
- highlight: Rectangle { color: "lightsteelblue" }
- currentIndex: -1
- delegate: Rectangle {
- height: 40
- width: parent.width
- color: "transparent"
- MouseArea {
- anchors.fill: parent;
- onClicked: tap(index)
- }
- Text {
- id: txt
- anchors.fill: parent
- text: media
- verticalAlignment: Text.AlignVCenter
- }
- }
- }
-
- Text {
- id: theLog
- anchors.left: theList.right
- anchors.top: theText.bottom
- anchors.right: parent.right
- anchors.bottom: parent.bottom
- }
-
- Text {
- id: theText
- anchors.left: theList.right
- anchors.right: parent.right;
- anchors.top: parent.top
- text: "Stopped"
- color: stateMachine.playing ? "green" : "red"
- }
-
- StateMachineLoader {
- id: scxmlLoader
- }
-
- EventConnection {
- stateMachine: root.stateMachine
- events: ["playbackStarted", "playbackStopped"]
- onOccurred: {
- var media = event.data.media;
- if (event.name === "playbackStarted") {
- theText.text = "Playing '" + media + "'";
- theLog.text = theLog.text + "\nplaybackStarted with data: "
- + JSON.stringify(event.data);
- } else if (event.name === "playbackStopped") {
- theText.text = "Stopped '" + media + "'";
- theLog.text = theLog.text + "\nplaybackStopped with data: "
- + JSON.stringify(event.data);
- }
- }
- }
-
- // Submit tap event to state machine.
- // "tap" toggles playing state of the current media.
- function tap(idx) {
- var media = theModel.get(idx).media;
- var data = { "media": media };
- stateMachine.submitEvent("tap", data);
- }
-}
diff --git a/examples/scxml/mediaplayer-common/doc/src/mediaplayer-compiling.qdocinc b/examples/scxml/mediaplayer-common/doc/src/mediaplayer-compiling.qdocinc
deleted file mode 100644
index 711a32f..0000000
--- a/examples/scxml/mediaplayer-common/doc/src/mediaplayer-compiling.qdocinc
+++ /dev/null
@@ -1,17 +0,0 @@
- \section1 Compiling the State Machine
-
- We link against the Qt SCXML module by adding the following line to the
- \e .pro file:
-
- \quotefromfile mediaplayer-widgets-static/mediaplayer-widgets-static.pro
- \skipto QT
- \printline scxml
-
- We then specify the state machine to compile:
-
- \skipto STATECHARTS
- \printline scxml
-
- The Qt SCXML Compiler, \c qscxmlc, is run automatically to generate
- \e statemachine.h and \e statemachine.cpp, and to add them to the \c HEADERS
- and \c SOURCES variables for compilation.
diff --git a/examples/scxml/mediaplayer-common/doc/src/mediaplayer-ecmascript-data-model.qdocinc b/examples/scxml/mediaplayer-common/doc/src/mediaplayer-ecmascript-data-model.qdocinc
deleted file mode 100644
index 98b33c7..0000000
--- a/examples/scxml/mediaplayer-common/doc/src/mediaplayer-ecmascript-data-model.qdocinc
+++ /dev/null
@@ -1,9 +0,0 @@
- \section1 Using the ECMAScript Data Model
-
- We specify the data model as a value of the \e datamodel attribute of the
- \c <scxml> element in \e mediaplayer-common/mediaplayer.scxml:
-
- \quotefromfile mediaplayer-common/mediaplayer.scxml
- \skipto scxml
- \printuntil </datamodel>
-
diff --git a/examples/scxml/mediaplayer-common/doc/src/mediaplayer-widgets-connecting-to-states.qdocinc b/examples/scxml/mediaplayer-common/doc/src/mediaplayer-widgets-connecting-to-states.qdocinc
deleted file mode 100644
index 207f47d..0000000
--- a/examples/scxml/mediaplayer-common/doc/src/mediaplayer-widgets-connecting-to-states.qdocinc
+++ /dev/null
@@ -1,16 +0,0 @@
- \section1 Connecting to States
-
- The media player state machine will send out events when users tap a control
- and when playback starts or stops, as specified in the SCXML file:
-
- \quotefromfile mediaplayer-common/mediaplayer.scxml
- \skipto <state
- \printuntil !==
- \printuntil </state
-
- To be notified when a state machine sends out an event, we connect to the
- corresponding signals:
-
- \quotefromfile mediaplayer-common/mainwindow.cpp
- \skipto connectToEvent
- \printuntil playbackStopped
diff --git a/examples/scxml/mediaplayer-common/mainwindow.cpp b/examples/scxml/mediaplayer-common/mainwindow.cpp
deleted file mode 100644
index cedb072..0000000
--- a/examples/scxml/mediaplayer-common/mainwindow.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "mainwindow.h"
-#include "ui_mainwindow.h"
-
-#include <QScxmlStateMachine>
-#include <QStringListModel>
-
-QT_USE_NAMESPACE
-
-MainWindow::MainWindow(QScxmlStateMachine *stateMachine, QWidget *parent) :
- QWidget(parent),
- ui(new Ui::MainWindow)
-{
- ui->setupUi(this);
-
- auto model = new QStringListModel(QStringList() << QStringLiteral("song 1")
- << QStringLiteral("song 2")
- << QStringLiteral("song 3"),
- this);
- ui->mediaListView->setModel(model);
-
- connect(ui->mediaListView, &QAbstractItemView::clicked,
- [model, stateMachine](const QModelIndex &index) {
- QVariantMap data;
- data.insert(QStringLiteral("media"),
- model->data(index, Qt::EditRole).toString());
- stateMachine->submitEvent("tap", data);
- });
-
- stateMachine->connectToEvent("playbackStarted", this, &MainWindow::started);
- stateMachine->connectToEvent("playbackStopped", this, &MainWindow::stopped);
-}
-
-MainWindow::~MainWindow()
-{
- delete ui;
-}
-
-void MainWindow::started(const QScxmlEvent &event)
-{
- const QString media = event.data().toMap().value("media").toString();
- ui->logText->appendPlainText(QStringLiteral(
- "call on slot started with media '%1'").arg(media));
- ui->statusLabel->setText(QStringLiteral("Playing %1").arg(media));
-}
-
-void MainWindow::stopped(const QScxmlEvent &event)
-{
- const QString media = event.data().toMap().value("media").toString();
- ui->logText->appendPlainText(QStringLiteral(
- "call on slot stopped with media '%1'").arg(media));
- ui->statusLabel->setText(QStringLiteral("Stopped"));
-}
diff --git a/examples/scxml/mediaplayer-common/mainwindow.h b/examples/scxml/mediaplayer-common/mainwindow.h
deleted file mode 100644
index 59ae27a..0000000
--- a/examples/scxml/mediaplayer-common/mainwindow.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-namespace Ui {
-class MainWindow;
-}
-
-class QScxmlEvent;
-class QScxmlStateMachine;
-
-QT_END_NAMESPACE
-
-class MainWindow : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit MainWindow(QScxmlStateMachine *stateMachine,
- QWidget *parent = nullptr);
- ~MainWindow();
-
-private slots:
- void started(const QScxmlEvent &event);
- void stopped(const QScxmlEvent &event);
-
-private:
- QT_PREPEND_NAMESPACE(Ui::MainWindow) *ui;
-};
-
-#endif // MAINWINDOW_H
diff --git a/examples/scxml/mediaplayer-common/mainwindow.ui b/examples/scxml/mediaplayer-common/mainwindow.ui
deleted file mode 100644
index 2e9e839..0000000
--- a/examples/scxml/mediaplayer-common/mainwindow.ui
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>MainWindow</class>
- <widget class="QWidget" name="MainWindow">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>750</width>
- <height>350</height>
- </rect>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0" rowspan="2">
- <widget class="QListView" name="mediaListView"/>
- </item>
- <item row="0" column="1">
- <widget class="QLabel" name="statusLabel">
- <property name="text">
- <string>Stopped</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QPlainTextEdit" name="logText"/>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/examples/scxml/mediaplayer-common/mediaplayer.scxml b/examples/scxml/mediaplayer-common/mediaplayer.scxml
deleted file mode 100644
index ca68039..0000000
--- a/examples/scxml/mediaplayer-common/mediaplayer.scxml
+++ /dev/null
@@ -1,92 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
--->
-<scxml
- xmlns="http://www.w3.org/2005/07/scxml"
- version="1.0"
- name="MediaPlayerStateMachine"
- initial="stopped"
- datamodel="ecmascript"
->
- <datamodel>
- <data id="media"/>
- </datamodel>
-
- <script>
- function isValidMedia() {
- var m = _event.data.media
- return (m + "").length > 0
- }
- </script>
-
- <state id="stopped">
- <transition event="tap" cond="isValidMedia()" target="playing"/>
- </state>
-
- <state id="playing">
- <onentry>
- <assign location="media" expr="_event.data.media"/>
- <send event="playbackStarted">
- <param name="media" expr="media"/>
- </send>
- </onentry>
-
- <onexit>
- <send event="playbackStopped">
- <param name="media" expr="media"/>
- </send>
- </onexit>
-
- <transition event="tap" cond="!isValidMedia() || media === _event.data.media" target="stopped"/>
- <transition event="tap" cond="isValidMedia() &amp;&amp; media !== _event.data.media" target="playing"/>
- </state>
-</scxml>
diff --git a/examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-cppdatamodel.scxml b/examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-cppdatamodel.scxml
deleted file mode 100644
index 4ca810e..0000000
--- a/examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-cppdatamodel.scxml
+++ /dev/null
@@ -1,83 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
--->
-<scxml
- xmlns="http://www.w3.org/2005/07/scxml"
- version="1.0"
- name="MediaPlayerStateMachine"
- initial="stopped"
- datamodel="cplusplus:TheDataModel:thedatamodel.h"
->
- <state id="stopped">
- <transition event="tap" cond="isValidMedia()" target="playing"/>
- </state>
-
- <state id="playing">
- <onentry>
- <script>
- media = eventData().value(QStringLiteral(&quot;media&quot;)).toString();
- </script>
- <send event="playbackStarted">
- <param name="media" expr="media"/>
- </send>
- </onentry>
-
- <onexit>
- <send event="playbackStopped">
- <param name="media" expr="media"/>
- </send>
- </onexit>
-
- <transition event="tap" cond="!isValidMedia() || media == eventData().value(QStringLiteral(&quot;media&quot;))" target="stopped"/>
- <transition event="tap" cond="isValidMedia() &amp;&amp; media != eventData().value(QStringLiteral(&quot;media&quot;))" target="playing"/>
- </state>
-</scxml>
diff --git a/examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-qml-cppdatamodel.cpp b/examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-qml-cppdatamodel.cpp
deleted file mode 100644
index e0d97b1..0000000
--- a/examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-qml-cppdatamodel.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QGuiApplication>
-#include <QQmlApplicationEngine>
-#include <QQmlContext>
-
-#include "mediaplayer-cppdatamodel.h"
-#include "thedatamodel.h"
-
-int main(int argc, char *argv[])
-{
- QGuiApplication app(argc, argv);
-
- qmlRegisterType<TheDataModel>("MediaPlayerDataModel", 1, 0, "MediaPlayerDataModel");
- qmlRegisterType<MediaPlayerStateMachine>("MediaPlayerStateMachine", 1, 0, "MediaPlayerStateMachine");
-
- QQmlApplicationEngine engine;
- engine.load(QUrl(QStringLiteral("qrc:///mediaplayer-qml-cppdatamodel.qml")));
-
- return app.exec();
-}
diff --git a/examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-qml-cppdatamodel.pro b/examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-qml-cppdatamodel.pro
deleted file mode 100644
index 2d21a37..0000000
--- a/examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-qml-cppdatamodel.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-TEMPLATE = app
-
-QT += qml scxml
-CONFIG += c++11
-
-SOURCES += mediaplayer-qml-cppdatamodel.cpp \
- thedatamodel.cpp
-
-HEADERS += thedatamodel.h
-
-RESOURCES += mediaplayer-qml-cppdatamodel.qrc
-
-STATECHARTS = mediaplayer-cppdatamodel.scxml
-
-target.path = $$[QT_INSTALL_EXAMPLES]/scxml/mediaplayer-qml-cppdatamodel
-INSTALLS += target
-
diff --git a/examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-qml-cppdatamodel.qml b/examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-qml-cppdatamodel.qml
deleted file mode 100644
index b1aacb1..0000000
--- a/examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-qml-cppdatamodel.qml
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import MediaPlayerStateMachine 1.0
-import MediaPlayerDataModel 1.0
-
-Mediaplayer {
- MediaPlayerDataModel {
- id: model
- }
-
- stateMachine: MediaPlayerStateMachine {
- onDataModelChanged: start()
- dataModel: model
- }
-}
diff --git a/examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-qml-cppdatamodel.qrc b/examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-qml-cppdatamodel.qrc
deleted file mode 100644
index 0de7eb7..0000000
--- a/examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-qml-cppdatamodel.qrc
+++ /dev/null
@@ -1,6 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file alias="Mediaplayer.qml">../mediaplayer-common/Mediaplayer.qml</file>
- <file>mediaplayer-qml-cppdatamodel.qml</file>
- </qresource>
-</RCC>
diff --git a/examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.cpp b/examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.cpp
deleted file mode 100644
index 0a3e200..0000000
--- a/examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "thedatamodel.h"
-
-#include <QScxmlEvent>
-
-bool TheDataModel::isValidMedia() const
-{
- QString eventMedia = eventData().value(QStringLiteral("media")).toString();
- return eventMedia.size() > 0;
-}
-
-QVariantMap TheDataModel::eventData() const
-{
- return scxmlEvent().data().value<QVariantMap>();
-}
diff --git a/examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.h b/examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.h
deleted file mode 100644
index e7a0e79..0000000
--- a/examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef THEDATAMODEL_H
-#define THEDATAMODEL_H
-
-#include "qscxmlcppdatamodel.h"
-
-class TheDataModel: public QScxmlCppDataModel
-{
- Q_OBJECT
- Q_SCXML_DATAMODEL
-
-private:
- bool isValidMedia() const;
- QVariantMap eventData() const;
-
- QString media;
-};
-
-#endif // THEDATAMODEL_H
diff --git a/examples/scxml/mediaplayer-qml-dynamic/doc/src/mediaplayer-qml-dynamic.qdoc b/examples/scxml/mediaplayer-qml-dynamic/doc/src/mediaplayer-qml-dynamic.qdoc
deleted file mode 100644
index 22d3ea2..0000000
--- a/examples/scxml/mediaplayer-qml-dynamic/doc/src/mediaplayer-qml-dynamic.qdoc
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example mediaplayer-qml-dynamic
- \title Qt SCXML Media Player QML Example (Dynamic)
- \ingroup examples-qtscxml
-
- \brief A Qt Quick application that sends data to and receives it from a
- dynamically loaded ECMAScript data model.
-
- \image mediaplayer.png
-
- \e {Media Player QML Example (Dynamic)} demonstrates how to access data from
- a dynamically loaded ECMAScript data model.
-
- The UI is created using Qt Quick.
-
- \include examples-run.qdocinc
-
- \include mediaplayer-ecmascript-data-model.qdocinc
-
- \section1 Dynamically Loading the State Machine
-
- We link against the Qt SCXML module by adding the following line to the
- example \e .pro file:
-
- \quotefromfile mediaplayer-qml-dynamic/mediaplayer-qml-dynamic.pro
- \skipto QT
- \printline scxml
-
- We dynamically create the state machine in
- \e mediaplayer-common\Mediaplayer.qml:
-
- \quotefromfile mediaplayer-common/Mediaplayer.qml
- \skipto import QtScxml
- \printuntil scxmlLoader.source
-*/
diff --git a/examples/scxml/mediaplayer-qml-dynamic/mediaplayer-qml-dynamic.cpp b/examples/scxml/mediaplayer-qml-dynamic/mediaplayer-qml-dynamic.cpp
deleted file mode 100644
index dce11c7..0000000
--- a/examples/scxml/mediaplayer-qml-dynamic/mediaplayer-qml-dynamic.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QGuiApplication>
-#include <QQmlApplicationEngine>
-#include <QQmlContext>
-
-int main(int argc, char *argv[])
-{
- QGuiApplication app(argc, argv);
-
- QQmlApplicationEngine engine;
- engine.load(QUrl(QStringLiteral("qrc:///mediaplayer-qml-dynamic.qml")));
- if (engine.rootObjects().isEmpty())
- return -1;
-
- return app.exec();
-}
-
diff --git a/examples/scxml/mediaplayer-qml-dynamic/mediaplayer-qml-dynamic.pro b/examples/scxml/mediaplayer-qml-dynamic/mediaplayer-qml-dynamic.pro
deleted file mode 100644
index f032bba..0000000
--- a/examples/scxml/mediaplayer-qml-dynamic/mediaplayer-qml-dynamic.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-TEMPLATE = app
-
-QT += qml scxml
-CONFIG += c++11
-
-SOURCES += mediaplayer-qml-dynamic.cpp
-
-RESOURCES += mediaplayer-qml-dynamic.qrc
-
-target.path = $$[QT_INSTALL_EXAMPLES]/scxml/mediaplayer-qml-dynamic
-INSTALLS += target
-
diff --git a/examples/scxml/mediaplayer-qml-dynamic/mediaplayer-qml-dynamic.qml b/examples/scxml/mediaplayer-qml-dynamic/mediaplayer-qml-dynamic.qml
deleted file mode 100644
index 864a76f..0000000
--- a/examples/scxml/mediaplayer-qml-dynamic/mediaplayer-qml-dynamic.qml
+++ /dev/null
@@ -1,53 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-Mediaplayer {
- source: "qrc:///mediaplayer.scxml"
-}
diff --git a/examples/scxml/mediaplayer-qml-dynamic/mediaplayer-qml-dynamic.qrc b/examples/scxml/mediaplayer-qml-dynamic/mediaplayer-qml-dynamic.qrc
deleted file mode 100644
index 0c7c40b..0000000
--- a/examples/scxml/mediaplayer-qml-dynamic/mediaplayer-qml-dynamic.qrc
+++ /dev/null
@@ -1,7 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file alias="Mediaplayer.qml">../mediaplayer-common/Mediaplayer.qml</file>
- <file>mediaplayer-qml-dynamic.qml</file>
- <file alias="mediaplayer.scxml">../mediaplayer-common/mediaplayer.scxml</file>
- </qresource>
-</RCC>
diff --git a/examples/scxml/mediaplayer-qml-static/doc/src/mediaplayer-qml-static.qdoc b/examples/scxml/mediaplayer-qml-static/doc/src/mediaplayer-qml-static.qdoc
deleted file mode 100644
index 4232ff1..0000000
--- a/examples/scxml/mediaplayer-qml-static/doc/src/mediaplayer-qml-static.qdoc
+++ /dev/null
@@ -1,57 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example mediaplayer-qml-static
- \title Qt SCXML Media Player QML Example (Static)
- \ingroup examples-qtscxml
-
- \brief A Qt Quick application that sends data to and receives it from a
- compiled ECMAScript data model.
-
- \image mediaplayer.png
-
- \e {Media Player QML Example (Static)} demonstrates how to access data from
- an ECMAScript data model that is compiled into a C++ class.
-
- The UI is created using Qt Quick.
-
- \include examples-run.qdocinc
-
- \include mediaplayer-ecmascript-data-model.qdocinc
-
- \include mediaplayer-compiling.qdocinc
-
- \section1 Instantiating the State Machine
-
- We instantiate the generated \c MediaPlayerStateMachine class in
- \e mediaplayer-qml-static.cpp:
-
- \quotefromfile mediaplayer-qml-static/mediaplayer-qml-static.cpp
- \skipto mediaplayer.h
- \printuntil }
-*/
diff --git a/examples/scxml/mediaplayer-qml-static/mediaplayer-qml-static.cpp b/examples/scxml/mediaplayer-qml-static/mediaplayer-qml-static.cpp
deleted file mode 100644
index 6dd263e..0000000
--- a/examples/scxml/mediaplayer-qml-static/mediaplayer-qml-static.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QGuiApplication>
-#include <QQmlApplicationEngine>
-#include <QQmlContext>
-
-#include "mediaplayer.h"
-
-int main(int argc, char *argv[])
-{
- QGuiApplication app(argc, argv);
-
- qmlRegisterType<MediaPlayerStateMachine>("MediaPlayerStateMachine", 1, 0, "MediaPlayerStateMachine");
-
- QQmlApplicationEngine engine;
- engine.load(QUrl(QStringLiteral("qrc:///mediaplayer-qml-static.qml")));
- if (engine.rootObjects().isEmpty())
- return -1;
-
- return app.exec();
-}
-
diff --git a/examples/scxml/mediaplayer-qml-static/mediaplayer-qml-static.pro b/examples/scxml/mediaplayer-qml-static/mediaplayer-qml-static.pro
deleted file mode 100644
index d8af563..0000000
--- a/examples/scxml/mediaplayer-qml-static/mediaplayer-qml-static.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-TEMPLATE = app
-
-QT += qml scxml
-CONFIG += c++11
-
-SOURCES += mediaplayer-qml-static.cpp
-
-RESOURCES += mediaplayer-qml-static.qrc
-
-STATECHARTS = ../mediaplayer-common/mediaplayer.scxml
-
-target.path = $$[QT_INSTALL_EXAMPLES]/scxml/mediaplayer-qml-static
-INSTALLS += target
-
diff --git a/examples/scxml/mediaplayer-qml-static/mediaplayer-qml-static.qml b/examples/scxml/mediaplayer-qml-static/mediaplayer-qml-static.qml
deleted file mode 100644
index 170b938..0000000
--- a/examples/scxml/mediaplayer-qml-static/mediaplayer-qml-static.qml
+++ /dev/null
@@ -1,57 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import MediaPlayerStateMachine 1.0
-
-Mediaplayer {
- stateMachine: MediaPlayerStateMachine {
- running: true
- }
-}
diff --git a/examples/scxml/mediaplayer-qml-static/mediaplayer-qml-static.qrc b/examples/scxml/mediaplayer-qml-static/mediaplayer-qml-static.qrc
deleted file mode 100644
index e65d449..0000000
--- a/examples/scxml/mediaplayer-qml-static/mediaplayer-qml-static.qrc
+++ /dev/null
@@ -1,6 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file alias="Mediaplayer.qml">../mediaplayer-common/Mediaplayer.qml</file>
- <file>mediaplayer-qml-static.qml</file>
- </qresource>
-</RCC>
diff --git a/examples/scxml/mediaplayer-widgets-dynamic/doc/src/mediaplayer-widgets-dynamic.qdoc b/examples/scxml/mediaplayer-widgets-dynamic/doc/src/mediaplayer-widgets-dynamic.qdoc
deleted file mode 100644
index 59ec84f..0000000
--- a/examples/scxml/mediaplayer-widgets-dynamic/doc/src/mediaplayer-widgets-dynamic.qdoc
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example mediaplayer-widgets-dynamic
- \title Qt SCXML Media Player Example (Dynamic)
- \ingroup examples-qtscxml
-
- \brief A widget-based application that sends data to and receives it from a
- dynamically loaded ECMAScript data model.
-
- \image mediaplayer.png
-
- \e {Media Player Example (Dynamic)} demonstrates how to access data from a
- dynamically loaded ECMAScript data model.
-
- The UI is created using Qt Widgets.
-
- \include examples-run.qdocinc
-
- \include mediaplayer-ecmascript-data-model.qdocinc
-
- \section1 Dynamically Loading the State Machine
-
- We link against the Qt SCXML module by adding the following line to the
- example \e .pro file:
-
- \quotefromfile mediaplayer-widgets-dynamic/mediaplayer-widgets-dynamic.pro
- \skipto QT
- \printuntil scxml
-
- \quotefromfile mediaplayer-widgets-dynamic/mediaplayer-widgets-dynamic.cpp
-
- We dynamically create and instantiate the state machine in
- \e mediaplayer-wigdets-dynamic/mediaplayer-widgets-dynamic.cpp:
-
- \skipto mainwindow.h
- \printuntil /^\}/
-
- \include mediaplayer-widgets-connecting-to-states.qdocinc
-*/
diff --git a/examples/scxml/mediaplayer-widgets-dynamic/mediaplayer-widgets-dynamic.cpp b/examples/scxml/mediaplayer-widgets-dynamic/mediaplayer-widgets-dynamic.cpp
deleted file mode 100644
index edc62e7..0000000
--- a/examples/scxml/mediaplayer-widgets-dynamic/mediaplayer-widgets-dynamic.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "../mediaplayer-common/mainwindow.h"
-
-#include <QApplication>
-#include <QScxmlStateMachine>
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
-
- auto machine = QScxmlStateMachine::fromFile(
- QStringLiteral(":mediaplayer.scxml"));
- MainWindow mainWindow(machine);
- machine->setParent(&mainWindow);
-
- machine->start();
- mainWindow.show();
- return app.exec();
-}
diff --git a/examples/scxml/mediaplayer-widgets-dynamic/mediaplayer-widgets-dynamic.pro b/examples/scxml/mediaplayer-widgets-dynamic/mediaplayer-widgets-dynamic.pro
deleted file mode 100644
index eb2949a..0000000
--- a/examples/scxml/mediaplayer-widgets-dynamic/mediaplayer-widgets-dynamic.pro
+++ /dev/null
@@ -1,21 +0,0 @@
-QT += widgets scxml
-requires(qtConfig(listview))
-
-CONFIG += c++11
-
-SOURCES += \
- mediaplayer-widgets-dynamic.cpp \
- ../mediaplayer-common/mainwindow.cpp
-
-FORMS += \
- ../mediaplayer-common/mainwindow.ui
-
-HEADERS += \
- ../mediaplayer-common/mainwindow.h
-
-RESOURCES += \
- mediaplayer.qrc
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/scxml/mediaplayer-widgets-dynamic
-INSTALLS += target
diff --git a/examples/scxml/mediaplayer-widgets-dynamic/mediaplayer.qrc b/examples/scxml/mediaplayer-widgets-dynamic/mediaplayer.qrc
deleted file mode 100644
index aecd468..0000000
--- a/examples/scxml/mediaplayer-widgets-dynamic/mediaplayer.qrc
+++ /dev/null
@@ -1,6 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file alias="mediaplayer.scxml">../mediaplayer-common/mediaplayer.scxml</file>
- </qresource>
-</RCC>
-
diff --git a/examples/scxml/mediaplayer-widgets-static/doc/src/mediaplayer-widgets-static.qdoc b/examples/scxml/mediaplayer-widgets-static/doc/src/mediaplayer-widgets-static.qdoc
deleted file mode 100644
index dfa1230..0000000
--- a/examples/scxml/mediaplayer-widgets-static/doc/src/mediaplayer-widgets-static.qdoc
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example mediaplayer-widgets-static
- \title Qt SCXML Media Player Example (Static)
- \ingroup examples-qtscxml
-
- \brief A widget-based application that sends data to and receives it from a
- compiled ECMAScript data model.
-
- \image mediaplayer.png
-
- \e {Media Player Example (Static)} demonstrates how to access data from an
- ECMAScript data model that is compiled into a C++ class.
-
- The UI is created using Qt Widgets.
-
- \include examples-run.qdocinc
-
- \include mediaplayer-ecmascript-data-model.qdocinc
-
- \include mediaplayer-compiling.qdocinc
-
- \section1 Instantiating the State Machine
-
- We instantiate the generated \c MediaPlayerStateMachine class in
- \e {mediaplayer-widgets-static.cpp}:
-
- \quotefromfile mediaplayer-widgets-static/mediaplayer-widgets-static.cpp
- \skipto mediaplayer.h
- \printuntil MainWindow mainWindow
-
- \include mediaplayer-widgets-connecting-to-states.qdocinc
-*/
diff --git a/examples/scxml/mediaplayer-widgets-static/mediaplayer-widgets-static.cpp b/examples/scxml/mediaplayer-widgets-static/mediaplayer-widgets-static.cpp
deleted file mode 100644
index 6a049d9..0000000
--- a/examples/scxml/mediaplayer-widgets-static/mediaplayer-widgets-static.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "mediaplayer.h"
-#include "../mediaplayer-common/mainwindow.h"
-
-#include <QApplication>
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
-
- MediaPlayerStateMachine machine;
- MainWindow mainWindow(&machine);
-
- machine.start();
- mainWindow.show();
- return app.exec();
-}
diff --git a/examples/scxml/mediaplayer-widgets-static/mediaplayer-widgets-static.pro b/examples/scxml/mediaplayer-widgets-static/mediaplayer-widgets-static.pro
deleted file mode 100644
index 8ea0076..0000000
--- a/examples/scxml/mediaplayer-widgets-static/mediaplayer-widgets-static.pro
+++ /dev/null
@@ -1,20 +0,0 @@
-QT += widgets scxml
-requires(qtConfig(listview))
-
-CONFIG += c++11
-
-STATECHARTS = ../mediaplayer-common/mediaplayer.scxml
-
-SOURCES += \
- mediaplayer-widgets-static.cpp \
- ../mediaplayer-common/mainwindow.cpp
-
-FORMS += \
- ../mediaplayer-common/mainwindow.ui
-
-HEADERS += \
- ../mediaplayer-common/mainwindow.h
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/scxml/mediaplayer-widgets-static
-INSTALLS += target
diff --git a/examples/scxml/mediaplayer/CMakeLists.txt b/examples/scxml/mediaplayer/CMakeLists.txt
new file mode 100644
index 0000000..7870054
--- /dev/null
+++ b/examples/scxml/mediaplayer/CMakeLists.txt
@@ -0,0 +1,52 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(mediaplayer LANGUAGES CXX)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/scxml/mediaplayer")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Scxml)
+
+qt_standard_project_setup(REQUIRES 6.5)
+
+qt_add_executable(mediaplayerscxml
+ main.cpp
+)
+
+set_target_properties(mediaplayerscxml PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(mediaplayerscxml PRIVATE
+ Qt::Core
+ Qt::Gui
+ Qt::Qml
+ Qt::Scxml
+)
+
+# Statecharts:
+qt6_add_statecharts(mediaplayerscxml
+ mediaplayer.scxml
+)
+
+qt_add_qml_module(mediaplayerscxml
+ URI Mediaplayer
+ VERSION 1.0
+ QML_FILES
+ MainWindow.qml
+ SOURCES
+ mediaplayer-qml.h
+ thedatamodel.h thedatamodel.cpp
+)
+
+install(TARGETS mediaplayerscxml
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/scxml/mediaplayer/MainWindow.qml b/examples/scxml/mediaplayer/MainWindow.qml
new file mode 100644
index 0000000..de4f710
--- /dev/null
+++ b/examples/scxml/mediaplayer/MainWindow.qml
@@ -0,0 +1,105 @@
+// 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 Mediaplayer
+
+Window {
+ id: root
+
+ MediaPlayerDataModel {
+ id: model
+ }
+
+ MediaPlayerStateMachine {
+ id: stateMachine
+ onDataModelChanged: stateMachine.start()
+ dataModel: model
+ }
+
+ visible: true
+ width: 750
+ height: 350
+ color: "white"
+
+ ListView {
+ id: theList
+ width: parent.width / 2
+ height: parent.height
+ keyNavigationWraps: true
+ highlightMoveDuration: 0
+ focus: true
+ model: ListModel {
+ id: theModel
+ ListElement { media: "Song 1" }
+ ListElement { media: "Song 2" }
+ ListElement { media: "Song 3" }
+ }
+ highlight: Rectangle { color: "lightsteelblue" }
+ currentIndex: -1
+ delegate: Rectangle {
+ id: delegateRect
+ required property string media
+ required property int index
+ height: 40
+ width: parent.width
+ color: "transparent"
+ MouseArea {
+ anchors.fill: parent;
+ onClicked: root.tap(delegateRect.index)
+ }
+ Text {
+ id: txt
+ anchors.fill: parent
+ text: delegateRect.media
+ verticalAlignment: Text.AlignVCenter
+ }
+ }
+ }
+
+ Text {
+ id: theLog
+ anchors.left: theList.right
+ anchors.top: theText.bottom
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ }
+
+ Text {
+ id: theText
+ anchors.left: theList.right
+ anchors.right: parent.right;
+ anchors.top: parent.top
+ text: "Stopped"
+ color: stateMachine.playing ? "green" : "red"
+ }
+
+ EventConnection {
+ stateMachine: stateMachine
+ events: ["playbackStarted", "playbackStopped"]
+ onOccurred: (event)=> {
+ var media = event.data.media;
+ if (event.name === "playbackStarted") {
+ theText.text = "Playing '" + media + "'";
+ theLog.text = theLog.text + "\nplaybackStarted with data: "
+ + JSON.stringify(event.data);
+ } else if (event.name === "playbackStopped") {
+ theText.text = "Stopped '" + media + "'";
+ theLog.text = theLog.text + "\nplaybackStopped with data: "
+ + JSON.stringify(event.data);
+ }
+ }
+ }
+
+ // Submit tap event to state machine.
+ // "tap" toggles playing state of the current media.
+ function tap(idx) {
+ var media = theModel.get(idx).media;
+ var data = { "media": media };
+ stateMachine.submitEvent("tap", data);
+ }
+}
diff --git a/examples/scxml/mediaplayer-common/doc/images/mediaplayer.png b/examples/scxml/mediaplayer/doc/images/mediaplayer.png
index b4c051e..b4c051e 100644
--- a/examples/scxml/mediaplayer-common/doc/images/mediaplayer.png
+++ b/examples/scxml/mediaplayer/doc/images/mediaplayer.png
Binary files differ
diff --git a/examples/scxml/mediaplayer-qml-cppdatamodel/doc/src/mediaplayer-qml-cppdatamodel.qdoc b/examples/scxml/mediaplayer/doc/src/mediaplayer.qdoc
index 421e72e..9862948 100644
--- a/examples/scxml/mediaplayer-qml-cppdatamodel/doc/src/mediaplayer-qml-cppdatamodel.qdoc
+++ b/examples/scxml/mediaplayer/doc/src/mediaplayer.qdoc
@@ -1,40 +1,18 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
- \example mediaplayer-qml-cppdatamodel
- \title Qt SCXML Media Player QML Example (C++ Data Model)
+ \example mediaplayer
+ \title SCXML Media Player
+ \examplecategory {Data Processing & I/O}
\ingroup examples-qtscxml
+ \meta tag {state machine}
\image mediaplayer.png
\brief Sends data to and receives it from a C++ data model.
- \e {Media Player QML Example (C++ Data Model)} demonstrates how to access
+ \e {Media Player} demonstrates how to access
data from a C++ data model. The data model enables writing C++ code for
\e expr attributes and \c <script> elements. The \e {data part} of the data
model is backed by a subclass of QScxmlCppDataModel, for which the Qt SCXML
@@ -49,7 +27,7 @@
We specify the data model as a value of the \e datamodel attribute of the
\c <scxml> element in the SCXML file:
- \quotefromfile mediaplayer-qml-cppdatamodel/mediaplayer-cppdatamodel.scxml
+ \quotefromfile mediaplayer/mediaplayer.scxml
\skipto scxml
\printuntil datamodel
@@ -57,7 +35,7 @@
\c {cplusplus:<class-name>:<classdef-header>}. Therefore, we need a file
called \e thedatamodel.h that contains a subclass of QScxmlCppDataModel:
- \quotefromfile mediaplayer-qml-cppdatamodel/thedatamodel.h
+ \quotefromfile mediaplayer/thedatamodel.h
\skipto qscxmlcppdatamodel.h
\printuntil Q_SCXML_DATAMODEL
@@ -70,14 +48,14 @@
In the SCXML file, we specify C++ statements in the \c <script> element and
use the \e expr attribute to access the data model:
- \quotefromfile mediaplayer-qml-cppdatamodel/mediaplayer-cppdatamodel.scxml
+ \quotefromfile mediaplayer/mediaplayer.scxml
\skipto state
\printuntil </state>
\printuntil </state>
The Qt SCXML compiler generates the various \c evaluateTo methods and
converts the expressions and scripts into lambdas inside those methods in
- \e mediaplayer-cppdatamodel.cpp:
+ \e mediaplayer.cpp:
\code
bool TheDataModel::evaluateToBool(QScxmlExecutableContent::EvaluatorId id, bool *ok) {
diff --git a/examples/scxml/mediaplayer/main.cpp b/examples/scxml/mediaplayer/main.cpp
new file mode 100644
index 0000000..66d9a75
--- /dev/null
+++ b/examples/scxml/mediaplayer/main.cpp
@@ -0,0 +1,17 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QtGui/qguiapplication.h>
+#include <QtQml/qqmlapplicationengine.h>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ QQmlApplicationEngine engine;
+ QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed, &app,
+ [](){ QCoreApplication::exit(EXIT_FAILURE); }, Qt::QueuedConnection);
+ engine.loadFromModule("Mediaplayer", "MainWindow");
+
+ return app.exec();
+}
diff --git a/examples/scxml/mediaplayer/mediaplayer-qml.h b/examples/scxml/mediaplayer/mediaplayer-qml.h
new file mode 100644
index 0000000..9d036b7
--- /dev/null
+++ b/examples/scxml/mediaplayer/mediaplayer-qml.h
@@ -0,0 +1,20 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef MEDIAPLAYER_QML
+#define MEDIAPLAYER_QML
+
+#include "mediaplayer.h"
+
+#include <QtQml/qqml.h>
+#include <QtCore/qobject.h>
+
+struct MediaPlayerStateMachineRegistration
+{
+ Q_GADGET
+ QML_FOREIGN(MediaPlayerStateMachine)
+ QML_NAMED_ELEMENT(MediaPlayerStateMachine)
+ QML_ADDED_IN_VERSION(1, 0)
+};
+
+#endif // MEDIAPLAYER_QML
diff --git a/examples/scxml/mediaplayer/mediaplayer.pro b/examples/scxml/mediaplayer/mediaplayer.pro
new file mode 100644
index 0000000..5aaf236
--- /dev/null
+++ b/examples/scxml/mediaplayer/mediaplayer.pro
@@ -0,0 +1,27 @@
+TEMPLATE = app
+
+QT += qml scxml
+CONFIG += c++11
+CONFIG += qmltypes
+
+SOURCES += main.cpp \
+ thedatamodel.cpp
+
+HEADERS += thedatamodel.h \
+ mediaplayer-qml.h
+
+QML_IMPORT_NAME = Mediaplayer
+QML_IMPORT_MAJOR_VERSION = 1
+
+qml_resources.files = \
+ qmldir \
+ MainWindow.qml
+
+qml_resources.prefix = /qt/qml/Mediaplayer
+
+RESOURCES += qml_resources
+
+STATECHARTS = mediaplayer.scxml
+
+target.path = $$[QT_INSTALL_EXAMPLES]/scxml/mediaplayer
+INSTALLS += target
diff --git a/examples/scxml/mediaplayer/mediaplayer.scxml b/examples/scxml/mediaplayer/mediaplayer.scxml
new file mode 100644
index 0000000..402f9d9
--- /dev/null
+++ b/examples/scxml/mediaplayer/mediaplayer.scxml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+-->
+<scxml
+ xmlns="http://www.w3.org/2005/07/scxml"
+ version="1.0"
+ name="MediaPlayerStateMachine"
+ initial="stopped"
+ datamodel="cplusplus:TheDataModel:thedatamodel.h"
+>
+ <state id="stopped">
+ <transition event="tap" cond="isValidMedia()" target="playing"/>
+ </state>
+
+ <state id="playing">
+ <onentry>
+ <script>
+ media = eventData().value(QStringLiteral(&quot;media&quot;)).toString();
+ </script>
+ <send event="playbackStarted">
+ <param name="media" expr="media"/>
+ </send>
+ </onentry>
+
+ <onexit>
+ <send event="playbackStopped">
+ <param name="media" expr="media"/>
+ </send>
+ </onexit>
+
+ <transition event="tap" cond="!isValidMedia() || media == eventData().value(QStringLiteral(&quot;media&quot;))" target="stopped"/>
+ <transition event="tap" cond="isValidMedia() &amp;&amp; media != eventData().value(QStringLiteral(&quot;media&quot;))" target="playing"/>
+ </state>
+</scxml>
diff --git a/examples/scxml/mediaplayer/qmldir b/examples/scxml/mediaplayer/qmldir
new file mode 100644
index 0000000..1a35a2a
--- /dev/null
+++ b/examples/scxml/mediaplayer/qmldir
@@ -0,0 +1,3 @@
+module Mediaplayer
+prefer :/qt/qml/Mediaplayer/
+MainWindow 1.0 MainWindow.qml
diff --git a/examples/scxml/mediaplayer/thedatamodel.cpp b/examples/scxml/mediaplayer/thedatamodel.cpp
new file mode 100644
index 0000000..ffff638
--- /dev/null
+++ b/examples/scxml/mediaplayer/thedatamodel.cpp
@@ -0,0 +1,19 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "thedatamodel.h"
+
+#include <QtScxml/qscxmlevent.h>
+
+using namespace Qt::Literals::StringLiterals;
+
+bool TheDataModel::isValidMedia() const
+{
+ QString eventMedia = eventData().value(u"media"_s).toString();
+ return eventMedia.size() > 0;
+}
+
+QVariantMap TheDataModel::eventData() const
+{
+ return scxmlEvent().data().value<QVariantMap>();
+}
diff --git a/examples/scxml/mediaplayer/thedatamodel.h b/examples/scxml/mediaplayer/thedatamodel.h
new file mode 100644
index 0000000..936deee
--- /dev/null
+++ b/examples/scxml/mediaplayer/thedatamodel.h
@@ -0,0 +1,24 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef THEDATAMODEL_H
+#define THEDATAMODEL_H
+
+#include "qscxmlcppdatamodel.h"
+#include <QtQml/qqml.h>
+
+class TheDataModel: public QScxmlCppDataModel
+{
+ Q_OBJECT
+ Q_SCXML_DATAMODEL
+ QML_NAMED_ELEMENT(MediaPlayerDataModel)
+ QML_ADDED_IN_VERSION(1, 0)
+
+private:
+ bool isValidMedia() const;
+ QVariantMap eventData() const;
+
+ QString media;
+};
+
+#endif // THEDATAMODEL_H
diff --git a/examples/scxml/pinball/doc/images/pinball-statechart-global.png b/examples/scxml/pinball/doc/images/pinball-statechart-global.png
deleted file mode 100644
index 630c678..0000000
--- a/examples/scxml/pinball/doc/images/pinball-statechart-global.png
+++ /dev/null
Binary files differ
diff --git a/examples/scxml/pinball/doc/images/pinball-statechart-guicontrol.png b/examples/scxml/pinball/doc/images/pinball-statechart-guicontrol.png
deleted file mode 100644
index b79e343..0000000
--- a/examples/scxml/pinball/doc/images/pinball-statechart-guicontrol.png
+++ /dev/null
Binary files differ
diff --git a/examples/scxml/pinball/doc/images/pinball-statechart-internalstate.png b/examples/scxml/pinball/doc/images/pinball-statechart-internalstate.png
deleted file mode 100644
index 3bd9d1b..0000000
--- a/examples/scxml/pinball/doc/images/pinball-statechart-internalstate.png
+++ /dev/null
Binary files differ
diff --git a/examples/scxml/pinball/doc/images/pinball-statechart-logicalstate.png b/examples/scxml/pinball/doc/images/pinball-statechart-logicalstate.png
deleted file mode 100644
index 7a3395a..0000000
--- a/examples/scxml/pinball/doc/images/pinball-statechart-logicalstate.png
+++ /dev/null
Binary files differ
diff --git a/examples/scxml/pinball/doc/images/pinball-statechart-modestate.png b/examples/scxml/pinball/doc/images/pinball-statechart-modestate.png
deleted file mode 100644
index e8b6df9..0000000
--- a/examples/scxml/pinball/doc/images/pinball-statechart-modestate.png
+++ /dev/null
Binary files differ
diff --git a/examples/scxml/pinball/doc/images/pinball-statechart-onstate.png b/examples/scxml/pinball/doc/images/pinball-statechart-onstate.png
deleted file mode 100644
index db9459c..0000000
--- a/examples/scxml/pinball/doc/images/pinball-statechart-onstate.png
+++ /dev/null
Binary files differ
diff --git a/examples/scxml/pinball/doc/images/pinball-statechart-workflow.png b/examples/scxml/pinball/doc/images/pinball-statechart-workflow.png
deleted file mode 100644
index dfcf3f2..0000000
--- a/examples/scxml/pinball/doc/images/pinball-statechart-workflow.png
+++ /dev/null
Binary files differ
diff --git a/examples/scxml/pinball/doc/images/pinball.png b/examples/scxml/pinball/doc/images/pinball.png
deleted file mode 100644
index bbd390e..0000000
--- a/examples/scxml/pinball/doc/images/pinball.png
+++ /dev/null
Binary files differ
diff --git a/examples/scxml/pinball/doc/src/pinball.qdoc b/examples/scxml/pinball/doc/src/pinball.qdoc
deleted file mode 100644
index 5cf9f1d..0000000
--- a/examples/scxml/pinball/doc/src/pinball.qdoc
+++ /dev/null
@@ -1,502 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example pinball
- \title Qt SCXML Pinball Example
- \ingroup examples-qtscxml
- \brief Encapsulates the internal logic of an application in an SCXML file.
-
- \e {Pinball} demonstrates a clear separation between the user interface,
- which may be easily replaced, and the internal logic encapsulated in an
- SCXML file, which could also be used with another user interface.
-
- \include examples-run.qdocinc
-
- \section1 Pinball Features
-
- \image pinball.png Screenshot of the Pinball example
-
- The Pinball example mimics a pinball game. The targets on the pinball table
- are substituted by GUI controls, mainly by push buttons. Display elements,
- including current score, highscore, and targets' lights, are substituted by
- labels. Usually, the state of the targets' lights changes very often during
- a game: the lights get turned on or off permanently or they blink at varying
- speed indicating a game (or a certain target) entered a temporary state. The
- state of each target light is presented as an enabled or a disabled label.
- There is no real ball, but clicking a target's button represents hitting a
- real pinball target with a ball.
-
- Our pinball contains the following features:
- \list
- \li Initially and when the game ends, the pinball table
- enters \c offState. In that state, all lights on the table
- blink slowly (at intervals of 1 second).
- \li After clicking the \uicontrol START button, the pinball table
- enters \c onState. All lights are turned off and the
- pinball table is ready to be played.
- \li When the table is in \c onState and the players
- click the \uicontrol {BALL OUT} button, the game ends
- and enters \c offState. If the players' score is
- higher than the current highscore, the highscore is updated.
- \li The goal is to collect the \uicontrol JACKPOT. In order to do that,
- the players must hit all five \uicontrol CRAZY letters twice.
- They have unlimited time for hitting them for the first time.
- However, after they have collected all the letters for the first time,
- they enter the \c hurryState and must collect
- them again within 5 seconds. If the time has passed and
- the letters were not collected again, the players must
- start collecting the letters from scratch.
- \li Scores:
- \list
- \li 1.000 per letter hit when not in \c hurryState.
- \li 10.000 per letter hit when in \c hurryState.
- \li 100.000 bonus for all 5 letters when not in \c hurryState.
- \li 1.000.000 bonus for all 5 letters when in \c hurryState
- (\uicontrol JACKPOT).
- \endlist
- \li When not in \c hurryState, the letters already hit should blink
- at intermediate speed (500ms). Letters not hit yet should stay off.
- \li When in \c hurryState, the letters already hit should
- stay on. Letters not hit yet should blink fast (200ms).
- In addition, the \uicontrol HURRY light should blink at the same speed.
- \li When the jackpot gets collected, the \uicontrol JACKPOT light should
- stay on.
- \endlist
-
- \section1 SCXML Part: Internal Logic Description
-
- The \e pinball.scxml file describes the internal logic implemented for the
- pinball game. In this example, we have chosen the ECMAScript data model:
-
- \quotefromfile pinball/pinball.scxml
- \skipto scxml
- \printuntil ecmascript
-
- The ECMAScript data model enables declaring variables with initial values
- that can be modified later. We declare the \c "highscore" and \c "score"
- variables with the initial values of 0:
-
- \printuntil </datamodel>
-
- We define a root parallel state \c "global", with two child states,
- \c guiControl and \c internalState, which are also parallel. Because the top
- \c global state is parallel, all of its direct children are active when it
- is active. In this example, the role of \c global is to collect the child
- states and make them both active at a time.
-
- \image pinball-statechart-global.png
-
- \section2 Maintaining Light State
-
- The \c guiControl element is responsible for maintaining the current
- state of each light control that is visible on the pinball table.
- Each light has a corresponding state.
-
- \image pinball-statechart-guicontrol.png
-
- For example, the light of the letter
- \uicontrol C corresponds to the \c cLight state. Each light state has two
- child states indicating whether the light is on or off:
-
- \printuntil target="cLightOn"
- \printuntil /^\ {12}<\//
-
- As mentioned before, the \c guiControl state is always active, and since
- it is of parallel type, all its direct children are always active too.
- Therefore, the \c cLight state is always active. However,
- only one of its children, \c cLightOn or \c cLightOff, is active at a time.
- The same applies to the other children of the \c guiControl state.
- In addition, we define transitions between on and off substates. For example,
- whenever the active state is \c cLightOn and a \c turnOffC event is received,
- we change the active substate of \c cLight to \c cLightOff.
- Whenever the active state is \c cLightOff and we receive a \c turnOnC event,
- we change the active substate of \c cLight to \c cLightOn.
-
- In our application, we use instances of QLabel class in C++
- to represent real lights on the table. When the light transitions
- into the \e on or \e off state, we enable or disable the particular label
- accordingly. The connection between the state machine and the GUI
- part of the application will be shown in the \l {cpp}{C++ code} later on. For now,
- it is enough to realize that changes to active states inside
- the state machine will serve as the external interface of the state machine
- that the other parts of the application (such as the GUI part) can listen to.
-
- All of the mentioned events that switch the state of a light
- will be generated by this state machine inside the \c internalState
- in reaction to running timers or external triggers.
-
- \section2 Maintaining Game State
-
- The \c internalState state consists of two main parts: \c logicalState and \c workflow.
-
- \image pinball-statechart-internalstate.png
-
- The \c logicalState state holds the definitions for the modes that the game is able
- to go into and for the logical states of collected targets. The \c workflow state
- implements a generator for light blinking and calculates most of the new states
- the machine should go into depending on incoming events and on currently active states.
- As mentioned already, \c internalState is always active, and since
- it is of a parallel type, \c logicalState and \c workflow are always active too.
-
- \section2 Maintaining Logical State of Buttons
-
- The \c logicalState state consist of two parts: \c letterState and \c modeState.
-
- \image pinball-statechart-logicalstate.png
-
- As previously mentioned, \c logicalState is always active, and since
- it is of parallel type, the \c letterState and \c modeState children are always
- active too. Now let us look at the first part, the \c letterState, which contains
- one parallel \c lettersState:
-
- \quotefromfile pinball/pinball.scxml
- \skipto letterState
- \printuntil lettersState
- \printuntil letter.R
- \dots 28
- \skipto /^\ {24}<\//
- \printuntil letter.A
- \dots 28
- \skipto /^\ {24}<\//
- \printuntil letter.Z
- \dots 28
- \skipto /^\ {24}<\//
- \printuntil letter.Y
- \dots 28
- \skipto /^\ {24}<\//
- \printuntil /^\ {16}<\//
-
- The \c lettersState state maintains the logical state of the buttons pretending to
- be targets that were clicked by the players. The letter state for the letter
- \uicontrol C holds whether the target for the letter \uicontrol C was hit,
- while the light state for the letter \uicontrol C holds whether the light
- for the target for the letter \uicontrol C should be currently on or off.
- In a real pinball game, these states are usually orthogonal,
- which means that if you have not hit a target yet, the target is blinking,
- indicating that it is currently worth hitting. This blinking
- means that the light state switches between on and off at short intervals,
- while the target state is continouosly off, because it has not been hit yet.
- The author of a pinball table can decide that
- after a target is hit (that is, after the target state switches to on)
- the target's light is continuously turned off or on or the intervals between
- lights blinking become shorter or longer.
-
- As mentioned before, \c letterState is always active, which means
- that its only child \c lettersState should always be active too. However,
- there is one exception: for a short while the \c lettersState may
- end up being \e {not active}. This happens when the transition for
- \c lettersState is being performed. This transition is triggered when
- the \c resetLetters event occurs, and it instructs the state machine
- to exit \c lettersState and all its descendant states and reenter
- \c lettersState and set up all its descendant states with their initial states.
- In short, the \c resetLetters event resets the \c lettersState and all its
- descendant states to the default configuration.
-
- The \c lettersState contains five direct substates that
- correspond to five different letters. The content for other letters' states
- than C is not shown here, but it is analogous to the content for C's state.
-
- The \c {letter.C} state contains two substates reflecting its off and on states:
- \c cLetterOff and \c cLetterOn. The \c {letter.C} state inside its parallel
- parent \c lettersState is always active (under the condition that
- \c lettersState is active, as described before). However,
- only one of its child states is active at a time: \c cLetterOff or \c cLetterOn.
- The initial substate of the \c {letter.C} state is \c cLetterOff meaning
- that whenever the \c {letter.C} state is being activated (which happens
- initially and after the \c resetLetters event) its active
- substate will be set to \c cLetterOff.
-
- The \c cLetterOff state defines a transition, which will be triggered by
- the \c {cLetterTriggered} event. This transition activates \c cLetterOn,
- the other child of \c {letter.C}, only when the machine is in \c onState
- (that is, when the pinball game is running).
- The \c {cLetterTriggered} event is expected to be an event posted into the state machine
- from outside of the state machine. This event should be generated when
- the ball hits the letter \uicontrol C target. In our example we mimic
- it by the clicking the letter \uicontrol C button.
-
- The \c cLetterOn state is defined as a final state, which means that
- whenever this state is activated the \c {done.state.letter.C} event
- will be automatically posted by the state machine. This event will be used
- later for updating the current score.
-
- Moreover, when all \c lettersState children reach their final state,
- the state machine will automatically post the \c {done.state.lettersState} event.
- This event will be used later, too, for updating the current score
- and for turning on or off the hurry state.
-
- \section2 Maintaining Game Modes
-
- The \c modeState state consists of two substates, \c offState and \c onState.
-
- \image pinball-statechart-modestate.png
-
- The \c offState state describes what should happen before the pinball game
- is started and when it is over,
- while \c onState represents the logic appropriate for the active game.
-
- \quotefromfile pinball/pinball.scxml
- \skipto offState
- \printuntil /^\ {20}<\//
-
- When the pinball application starts or a game ends, the machine goes into
- \c offState. Entering that state invokes some actions, which are
- enclosed inside an \c <onentry> element. First, we update the \c highScore
- variable in case the current \c highScore value is less than current \c score value.
- This is being checked inside the \c "cond" attribute of the \c <if> element
- (note that we need to escape the "<" character with "&lt;").
- Even in the \c off state, we want to show the last reached score,
- so we do not clear it here; we will do that when we enter the \c on state.
- Next, we raise two events: \c resetLetters to logically reset
- all letters that might have been hit during the last game and \c update
- to immediately activate the blinking and updating of all lights.
- When the machine is in \c offState, it is ready to transition into the
- \c onState if only the \c startTriggered event occurs, which is described
- by the <transition> element. This event is expected to be generated externally
- after clicking the \uicontrol START button on the pinball table.
-
- \skipto onState
- \printuntil /^\ {20}<\//
-
- \section2 Game On
-
- When the state machine enters \c onState, it first clears the current score
- variable. The \c onState state is of the parallel type and has two direct child states:
- \c hurryState and \c jackpotState. They are active as long as
- their parent, \c onState, is active. Both \c hurryState and \c jackpotState
- contain two substates that reflect their off and on states.
- Only one substate of \c hurryState and one substate of \c jackpotState
- can be active at a time. Initially, the off substates are active.
-
- \image pinball-statechart-onstate.png
-
- Whenever we enter \c hurryStateOff or \c hurryStateOn, we generate the same
- two events we generate when entering the \c onState state: \c resetLetters and
- \c update. In addition, when we enter the \c hurryStateOn state, we send a delayed
- event, \c goToHurryOff, with a delay of five seconds, marked with \c hurryId.
- This means that after five seconds we just
- switch the state back to \c hurryStateOff without granting the bonus points.
- In this way, we implement the five-second hurry feature of the pinball table.
- We also define transitions from \c hurryStateOff to \c hurryStateOn when the
- \c goToHurryOn event occurs and from \c hurryStateOn to \c hurryStateOff
- when the \c goToHurryOff event occurs. When we exit the \c hurryStateOn
- state, we cancel the possibly pending delayed event that was marked with
- \c hurryId. This is important in case the five secons have not elapsed yet,
- but players have collected all the five letters in the hurry state. We then
- collect the jackpot and want the pending timer to finish.
-
- The substates of \c jackpotState generate the request to update the state
- of lights. The \c jackpotStateOff state defines the transition to \c jackpotStateOn
- when the \c goForJackpot event occurs. The opposite transition is not
- needed, because when the jackpot gets collected, the corresponding light
- remains lit until the end of game. When a new game starts, the \c jackpotState
- is entered again which causes its initial active substate to be
- \c jackpotStateOff.
-
- In addition, the \c onState state defines one transition in reaction to the
- \c ballOutTriggered event which instructs the machine to go into the \c offState.
- The \c ballOutTriggered event is expected to be an event posted into the state machine
- from outside of the state machine. This event should be generated when
- the ball gets out of playing area of the table. In our example we mimic
- it by the clicking \uicontrol {BALL OUT} button. Posting the event from outside of state
- machine will be shown in the \l{cpp}{C++ code} later on.
-
- \section2 Generating Blinking Lights
-
- The \c workflow state is responsible for generating the blinking lights. The
- generator is defined in its \c lightImpulseGenerator substate. In addition,
- it is responsible for reacting to events that have been posted so far from
- the other parts of the state machine.
-
- \quotefromfile pinball/pinball.scxml
- \skipto workflow
- \printuntil done.state.letter.*
- \dots 20
- \skipto /^\ {16}<\//
- \printuntil done.state.lettersState
- \dots 20
- \skipto /^\ {16}<\//
- \printuntil updateLights
- \dots 20
- \skipto /^\ {16}<\//
- \printuntil updateLightsAccordingToLettersState
- \dots 20
- \skipto /^\ {16}<\//
- \printuntil turnOnLights
- \dots 20
- \skipto /^\ {16}<\//
- \printuntil turnOffLights
- \dots 20
- \skipto /^\ {16}<\//
- \printuntil /^\ {12}<\//
-
- The \c lightImpulseGenerator contains two child states:
- \c lightImpulseOn and \c lightImpulseOff, with only one active at a time.
-
- \image pinball-statechart-workflow.png
-
- Whenever the delayed \c lightImpulse event is being delivered, it immediately
- causes the transition from \c lightImpluseOn into \c lightImpulseOff or vice versa,
- depending on the state the machine was in. In effect, the \c lightImpulseGenerator
- toggles between its on and off state. These transitions are defined inside
- \c lightImpulseGenerator, so it means that during this toggling the machine
- also exits \c lightImpulseGenerator and reenters it immediately afterwards.
- Entering \c lightImpulseGenerator causes the generation of the \c update event.
- The \c update event triggers a targetless transition and posts two other
- events: \c scheduleNewImpulse and \c updateLights. The first one,
- \c scheduleNewImpulse, returns back to the \c lightImpulseGenerator, which
- posts a delayed \c lightImpulse event. After the delay,
- the \c lightImpulse event gets delivered back to \c lightImpulseGenerator,
- which causes it to toggle its substate again. In this way, the machine
- enters into a cycle. The current delay of the \c lightImpulse
- event depends on the state in which the machine was in the time of posting
- the delayed event. If a \c scheduleNewImpulse event occurs on demand, before
- the next delayed \c lightImpulse event gets delivered, we cancel any
- possible pending events.
-
- \quotefromfile pinball/pinball.scxml
- \skipto workflow
- \skipto done.state.letter.*
- \printuntil /^\ {16}<\//
- \printuntil /^\ {16}<\//
-
- Whenever we receive the event the name of which matches the
- \c {done.state.letter.*}, we update the current score.
- When the machine enters the final substate of the \c {letter.C},
- it emits the \c {done.state.letter.C} event. The same happens for
- all other letters we have previously defined. We capture the events for all
- letters, that is why we have used an asterisk
- after a dot in the event name.
- The transition above is targetless, since we just
- listen for matching events and update the internal data accordingly
- without changing any active state. The new score is being
- increased by 1.000 or 10.000 points, depending on whether we currently are
- in \c hurryStateOff or \c hurryStateOn.
- After the score is updated, we generate the \c updateLights event
- in order to immediately update the letters' lights accordingly.
- We do not generate the \c update event here, since we do not want to toggle
- the light impulse now, but just update the lights according to
- the current impulse state.
-
- We also intercept the \c {done.state.lettersState} event,
- which is being generated when all the letters have been hit.
- Depending on which state we are currently in, we grant the players either
- a small bonus of 100.000 or a big one of 1.000.000 (jackpot).
- In addition, we toggle the \c hurryState substate by
- sending the \c goToHurryOn or \c goToHurryOff event.
- When all letters have been collected while in \c hurryStateOn,
- we also raise the \c goForJackpot event which instructs
- the machine to activate the \c jackpotStateOn.
-
- \skipto updateLights
- \printuntil /^\ {16}<\//
- \printuntil updateLightsAccordingToLettersState
- \printuntil /^\ {16}<\//
- \printuntil turnOnLights
- \printuntil /^\ {16}<\//
- \printuntil turnOffLights
- \printuntil /^\ {16}<\//
-
- When we receive the \c updateLights event, we first want to send a
- \c updateScore event outside of the state machine. We pass
- the current values of the \c highScore and \c score variables to the event.
- This event is received by the C++ part.
-
- Next, depending on whether we are in \c jackpotStateOn or \c jackpotStateOff,
- we send the \c turnOnJackpot or the \c turnOffJackpot event,
- which instructs the \c guiControl state to transition to
- \c jackpotLightOn or \c jackpotLightOff, respectively.
-
- When the machine is in \e idle state, (that is, in the off state)
- or when the game is on, but no interaction occurs,
- the \c updateLights event is delivered periodically
- during the game, each time with the \c lightImpulseOn or
- \c lightImpulseOff state toggled. Depending on the
- current state of the light impulse and on the active state (\c offState,
- \c hurryStateOff or \c hurryStateOn), we turn on or off all the lights
- according to the description of the pinball table.
-
- \section1 GUI Part: User Interface Description
-
- The GUI part of the application consists of a \e mainwindow.ui
- file which describes the static user interface of the game.
-
- \target cpp
- \section1 C++ Part: Glue GUI with SCXML
-
- The C++ part of the application consists of a
- \c MainWindow class which glues the GUI part with the SCXML part.
- The class is declared in \e mainwindow.h.
-
- \quotefromfile pinball/mainwindow.h
- \skipto MainWindow
- \printuntil };
-
- The \c MainWindow class holds the pointer to the
- \c {QScxmlStateMachine *m_machine} which is the state machine
- class automatically generated by Qt out of SCMXL file
- and the pointer to the \c {Ui::MainWindow *m_ui} which
- describes the GUI part. It also declares two helper methods.
-
- \quotefromfile pinball/mainwindow.cpp
- \skipto #include
- \printuntil /\}$/
-
- The constructor of the \c MainWindow class
- instantiates the GUI part of the application
- and stores the pointer to the passed \c QScxmlStateMachine.
- It also initializes the GUI part and glues the
- GUI part to the state machine by connecting
- their communication interfaces together.
-
- The \c initAndConnect() method connects
- the state with the corresponding GUI widget by
- binding its activity with the enabling of the widget,
- so that whenever the state is active, its corresponding
- widget is enabled and whenever the state is inactive,
- the widget is disabled. We do that for all lights, targets,
- and description labels.
-
- We also intercept the \c updateScore event sent by the state machine,
- in order to update the score displays with the values
- passed with the event.
-
- The info about hitting any GUI target needs to be passed
- to the state machine and we do that by connecting
- all target buttons' \c clicked signals to the lambda expressions
- which submit the corresponding event into the state machine.
-
- \quotefromfile pinball/main.cpp
- \skipto #include
- \printuntil /\}$/
-
- In the \c main() function in the \e main.cpp file, we instantiate the
- \c app application object, \c Pinball state machine,
- and \c MainWindow GUI class. We initialize and start the state machine,
- show the main window, and execute the application.
-*/
diff --git a/examples/scxml/pinball/main.cpp b/examples/scxml/pinball/main.cpp
deleted file mode 100644
index 4bf058f..0000000
--- a/examples/scxml/pinball/main.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "mainwindow.h"
-#include "pinball.h"
-
-#include <QApplication>
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
-
- Pinball machine;
- MainWindow mainWindow(&machine);
-
- machine.start();
- mainWindow.show();
- return app.exec();
-}
diff --git a/examples/scxml/pinball/mainwindow.cpp b/examples/scxml/pinball/mainwindow.cpp
deleted file mode 100644
index e146e4d..0000000
--- a/examples/scxml/pinball/mainwindow.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "mainwindow.h"
-#include "ui_mainwindow.h"
-
-#include <QScxmlStateMachine>
-#include <QStringListModel>
-
-QT_USE_NAMESPACE
-
-MainWindow::MainWindow(QScxmlStateMachine *machine, QWidget *parent) :
- QWidget(parent),
- m_ui(new Ui::MainWindow),
- m_machine(machine)
-{
- m_ui->setupUi(this);
-
- // lights
- initAndConnect(QLatin1String("cLightOn"), m_ui->cLabel);
- initAndConnect(QLatin1String("rLightOn"), m_ui->rLabel);
- initAndConnect(QLatin1String("aLightOn"), m_ui->aLabel);
- initAndConnect(QLatin1String("zLightOn"), m_ui->zLabel);
- initAndConnect(QLatin1String("yLightOn"), m_ui->yLabel);
- initAndConnect(QLatin1String("hurryLightOn"), m_ui->hurryLabel);
- initAndConnect(QLatin1String("jackpotLightOn"), m_ui->jackpotLabel);
- initAndConnect(QLatin1String("gameOverLightOn"), m_ui->gameOverLabel);
-
- // help labels
- initAndConnect(QLatin1String("offState"), m_ui->offStateLabel);
- initAndConnect(QLatin1String("hurryStateOff"), m_ui->normalStateLabel);
- initAndConnect(QLatin1String("hurryStateOn"), m_ui->hurryStateLabel);
- initAndConnect(QLatin1String("jackpotStateOn"), m_ui->jackpotStateLabel);
-
- // context enablement
- initAndConnect(QLatin1String("offState"), m_ui->startButton);
- initAndConnect(QLatin1String("onState"), m_ui->cButton);
- initAndConnect(QLatin1String("onState"), m_ui->rButton);
- initAndConnect(QLatin1String("onState"), m_ui->aButton);
- initAndConnect(QLatin1String("onState"), m_ui->zButton);
- initAndConnect(QLatin1String("onState"), m_ui->yButton);
- initAndConnect(QLatin1String("onState"), m_ui->ballOutButton);
-
- // datamodel update
- m_machine->connectToEvent("updateScore", [this] (const QScxmlEvent &event) {
- const QVariant data = event.data();
- const QString highScore = data.toMap().value("highScore").toString();
- m_ui->highScoreLabel->setText(highScore);
- const QString score = data.toMap().value("score").toString();
- m_ui->scoreLabel->setText(score);
- });
-
- // gui interaction
- connect(m_ui->cButton, &QAbstractButton::clicked,
- [this] { m_machine->submitEvent("cLetterTriggered");
- });
- connect(m_ui->rButton, &QAbstractButton::clicked,
- [this] { m_machine->submitEvent("rLetterTriggered");
- });
- connect(m_ui->aButton, &QAbstractButton::clicked,
- [this] { m_machine->submitEvent("aLetterTriggered");
- });
- connect(m_ui->zButton, &QAbstractButton::clicked,
- [this] { m_machine->submitEvent("zLetterTriggered");
- });
- connect(m_ui->yButton, &QAbstractButton::clicked,
- [this] { m_machine->submitEvent("yLetterTriggered");
- });
- connect(m_ui->startButton, &QAbstractButton::clicked,
- [this] { m_machine->submitEvent("startTriggered");
- });
- connect(m_ui->ballOutButton, &QAbstractButton::clicked,
- [this] { m_machine->submitEvent("ballOutTriggered");
- });
-}
-
-MainWindow::~MainWindow()
-{
- delete m_ui;
-}
-
-void MainWindow::initAndConnect(const QString &state, QWidget *widget)
-{
- widget->setEnabled(m_machine->isActive(state));
- m_machine->connectToState(state, widget, &QWidget::setEnabled);
-}
diff --git a/examples/scxml/pinball/mainwindow.h b/examples/scxml/pinball/mainwindow.h
deleted file mode 100644
index daceb6e..0000000
--- a/examples/scxml/pinball/mainwindow.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-namespace Ui {
-class MainWindow;
-}
-class QScxmlStateMachine;
-QT_END_NAMESPACE
-
-
-class MainWindow : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit MainWindow(QScxmlStateMachine *machine, QWidget *parent = nullptr);
- ~MainWindow();
-
-private:
- void initAndConnect(const QString &state, QWidget *widget);
- QT_PREPEND_NAMESPACE(Ui::MainWindow) *m_ui;
- QScxmlStateMachine *m_machine;
-};
-
-#endif // MAINWINDOW_H
diff --git a/examples/scxml/pinball/mainwindow.ui b/examples/scxml/pinball/mainwindow.ui
deleted file mode 100644
index 601c23e..0000000
--- a/examples/scxml/pinball/mainwindow.ui
+++ /dev/null
@@ -1,663 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>MainWindow</class>
- <widget class="QWidget" name="MainWindow">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>476</width>
- <height>458</height>
- </rect>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0" colspan="5">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QLabel" name="highScoreTextLabel">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>HIGH SCORE:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="highScoreLabel">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>0</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="scoreTextLabel">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>SCORE:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="scoreLabel">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>0</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="0" column="5" rowspan="7">
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>1</width>
- <height>98</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QToolButton" name="startButton">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>^
-^
-^
-
-S
-T
-A
-R
-T
-
-^
-^
-^</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="1" column="0" colspan="5">
- <widget class="QLabel" name="gameOverLabel">
- <property name="palette">
- <palette>
- <active>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>0</green>
- <blue>4</blue>
- </color>
- </brush>
- </colorrole>
- </active>
- <inactive>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>0</green>
- <blue>4</blue>
- </color>
- </brush>
- </colorrole>
- </inactive>
- <disabled>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>190</red>
- <green>190</green>
- <blue>190</blue>
- </color>
- </brush>
- </colorrole>
- </disabled>
- </palette>
- </property>
- <property name="font">
- <font>
- <pointsize>20</pointsize>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>GAME OVER</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item row="2" column="0" colspan="5">
- <widget class="QLabel" name="jackpotLabel">
- <property name="palette">
- <palette>
- <active>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>55</red>
- <green>200</green>
- <blue>191</blue>
- </color>
- </brush>
- </colorrole>
- </active>
- <inactive>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>55</red>
- <green>200</green>
- <blue>191</blue>
- </color>
- </brush>
- </colorrole>
- </inactive>
- <disabled>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>190</red>
- <green>190</green>
- <blue>190</blue>
- </color>
- </brush>
- </colorrole>
- </disabled>
- </palette>
- </property>
- <property name="font">
- <font>
- <pointsize>20</pointsize>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>JACKPOT!</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item row="3" column="0" colspan="5">
- <widget class="QLabel" name="hurryLabel">
- <property name="palette">
- <palette>
- <active>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>67</red>
- <green>24</green>
- <blue>97</blue>
- </color>
- </brush>
- </colorrole>
- </active>
- <inactive>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>67</red>
- <green>24</green>
- <blue>97</blue>
- </color>
- </brush>
- </colorrole>
- </inactive>
- <disabled>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>190</red>
- <green>190</green>
- <blue>190</blue>
- </color>
- </brush>
- </colorrole>
- </disabled>
- </palette>
- </property>
- <property name="font">
- <font>
- <pointsize>20</pointsize>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>HURRY!</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="cLabel">
- <property name="palette">
- <palette>
- <active>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>7</red>
- <green>0</green>
- <blue>222</blue>
- </color>
- </brush>
- </colorrole>
- </active>
- <inactive>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>7</red>
- <green>0</green>
- <blue>222</blue>
- </color>
- </brush>
- </colorrole>
- </inactive>
- <disabled>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>190</red>
- <green>190</green>
- <blue>190</blue>
- </color>
- </brush>
- </colorrole>
- </disabled>
- </palette>
- </property>
- <property name="font">
- <font>
- <pointsize>20</pointsize>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>C</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="QLabel" name="rLabel">
- <property name="palette">
- <palette>
- <active>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>6</red>
- <green>208</green>
- <blue>36</blue>
- </color>
- </brush>
- </colorrole>
- </active>
- <inactive>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>6</red>
- <green>208</green>
- <blue>36</blue>
- </color>
- </brush>
- </colorrole>
- </inactive>
- <disabled>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>190</red>
- <green>190</green>
- <blue>190</blue>
- </color>
- </brush>
- </colorrole>
- </disabled>
- </palette>
- </property>
- <property name="font">
- <font>
- <pointsize>20</pointsize>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>R</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item row="4" column="2">
- <widget class="QLabel" name="aLabel">
- <property name="palette">
- <palette>
- <active>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>238</red>
- <green>17</green>
- <blue>1</blue>
- </color>
- </brush>
- </colorrole>
- </active>
- <inactive>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>238</red>
- <green>17</green>
- <blue>1</blue>
- </color>
- </brush>
- </colorrole>
- </inactive>
- <disabled>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>190</red>
- <green>190</green>
- <blue>190</blue>
- </color>
- </brush>
- </colorrole>
- </disabled>
- </palette>
- </property>
- <property name="font">
- <font>
- <pointsize>20</pointsize>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>A</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item row="4" column="3">
- <widget class="QLabel" name="zLabel">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="palette">
- <palette>
- <active>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>230</red>
- <green>10</green>
- <blue>230</blue>
- </color>
- </brush>
- </colorrole>
- </active>
- <inactive>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>230</red>
- <green>10</green>
- <blue>230</blue>
- </color>
- </brush>
- </colorrole>
- </inactive>
- <disabled>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>190</red>
- <green>190</green>
- <blue>190</blue>
- </color>
- </brush>
- </colorrole>
- </disabled>
- </palette>
- </property>
- <property name="font">
- <font>
- <pointsize>20</pointsize>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>Z</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item row="4" column="4">
- <widget class="QLabel" name="yLabel">
- <property name="palette">
- <palette>
- <active>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>239</red>
- <green>224</green>
- <blue>9</blue>
- </color>
- </brush>
- </colorrole>
- </active>
- <inactive>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>239</red>
- <green>224</green>
- <blue>9</blue>
- </color>
- </brush>
- </colorrole>
- </inactive>
- <disabled>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>190</red>
- <green>190</green>
- <blue>190</blue>
- </color>
- </brush>
- </colorrole>
- </disabled>
- </palette>
- </property>
- <property name="font">
- <font>
- <pointsize>20</pointsize>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>Y</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item row="5" column="0">
- <widget class="QPushButton" name="cButton">
- <property name="text">
- <string>C</string>
- </property>
- </widget>
- </item>
- <item row="5" column="1">
- <widget class="QPushButton" name="rButton">
- <property name="text">
- <string>R</string>
- </property>
- </widget>
- </item>
- <item row="5" column="2">
- <widget class="QPushButton" name="aButton">
- <property name="text">
- <string>A</string>
- </property>
- </widget>
- </item>
- <item row="5" column="3">
- <widget class="QPushButton" name="zButton">
- <property name="text">
- <string>Z</string>
- </property>
- </widget>
- </item>
- <item row="5" column="4">
- <widget class="QPushButton" name="yButton">
- <property name="text">
- <string>Y</string>
- </property>
- </widget>
- </item>
- <item row="6" column="0" colspan="5">
- <widget class="QPushButton" name="ballOutButton">
- <property name="text">
- <string>BALL OUT</string>
- </property>
- </widget>
- </item>
- <item row="7" column="0" colspan="6">
- <widget class="QLabel" name="offStateLabel">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Press START to release the ball.</string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="8" column="0" colspan="6">
- <widget class="QLabel" name="normalStateLabel">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Try to hit all CRAZY letters. Watch out for ball and avoid BALL OUT since the game will end.</string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="9" column="0" colspan="6">
- <widget class="QLabel" name="hurryStateLabel">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Now you need to hurry. Quickly hit all CRAZY letters again to gather the extra JACKPOT bonus. You have only 5 seconds. Otherwise you will need to start from scratch.</string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="10" column="0" colspan="6">
- <widget class="QLabel" name="jackpotStateLabel">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>You did that! You have collected JACKPOT! Congratulations. Now you can continue game until you BALL OUT.</string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/examples/scxml/pinball/pinball.pro b/examples/scxml/pinball/pinball.pro
deleted file mode 100644
index 549010d..0000000
--- a/examples/scxml/pinball/pinball.pro
+++ /dev/null
@@ -1,19 +0,0 @@
-QT += widgets scxml
-
-CONFIG += c++11
-
-STATECHARTS = pinball.scxml
-
-SOURCES += \
- main.cpp \
- mainwindow.cpp
-
-FORMS += \
- mainwindow.ui
-
-HEADERS += \
- mainwindow.h
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/scxml/pinball
-INSTALLS += target
diff --git a/examples/scxml/pinball/pinball.scxml b/examples/scxml/pinball/pinball.scxml
deleted file mode 100644
index 022f202..0000000
--- a/examples/scxml/pinball/pinball.scxml
+++ /dev/null
@@ -1,353 +0,0 @@
-<?xml version="1.0" ?>
-<!--
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
--->
-<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0"
- name="Pinball" datamodel="ecmascript">
- <datamodel>
- <data id="highScore" expr="0"/>
- <data id="score" expr="0"/>
- </datamodel>
- <parallel id="global">
- <parallel id="guiControl">
- <state id="cLight">
- <state id="cLightOn">
- <transition event="turnOffC" target="cLightOff"/>
- </state>
- <state id="cLightOff">
- <transition event="turnOnC" target="cLightOn"/>
- </state>
- </state>
- <state id="rLight">
- <state id="rLightOn">
- <transition event="turnOffR" target="rLightOff"/>
- </state>
- <state id="rLightOff">
- <transition event="turnOnR" target="rLightOn"/>
- </state>
- </state>
- <state id="aLight">
- <state id="aLightOn">
- <transition event="turnOffA" target="aLightOff"/>
- </state>
- <state id="aLightOff">
- <transition event="turnOnA" target="aLightOn"/>
- </state>
- </state>
- <state id="zLight">
- <state id="zLightOn">
- <transition event="turnOffZ" target="zLightOff"/>
- </state>
- <state id="zLightOff">
- <transition event="turnOnZ" target="zLightOn"/>
- </state>
- </state>
- <state id="yLight">
- <state id="yLightOn">
- <transition event="turnOffY" target="yLightOff"/>
- </state>
- <state id="yLightOff">
- <transition event="turnOnY" target="yLightOn"/>
- </state>
- </state>
- <state id="hurryLight">
- <state id="hurryLightOn">
- <transition event="turnOffHurry" target="hurryLightOff"/>
- </state>
- <state id="hurryLightOff">
- <transition event="turnOnHurry" target="hurryLightOn"/>
- </state>
- </state>
- <state id="jackpotLight">
- <state id="jackpotLightOn">
- <transition event="turnOffJackpot" target="jackpotLightOff"/>
- </state>
- <state id="jackpotLightOff">
- <transition event="turnOnJackpot" target="jackpotLightOn"/>
- </state>
- </state>
- <state id="gameOverLight">
- <state id="gameOverLightOn">
- <transition event="turnOffGameOver" target="gameOverLightOff"/>
- </state>
- <state id="gameOverLightOff">
- <transition event="turnOnGameOver" target="gameOverLightOn"/>
- </state>
- </state>
- </parallel>
-
- <parallel id="internalState">
- <parallel id="logicalState">
- <state id="letterState">
- <parallel id="lettersState">
- <state id="letter.C">
- <state id="cLetterOff">
- <transition event="cLetterTriggered" cond="In('onState')" target="cLetterOn"/>
- </state>
- <final id="cLetterOn"/>
- </state>
- <state id="letter.R">
- <state id="rLetterOff">
- <transition event="rLetterTriggered" cond="In('onState')" target="rLetterOn"/>
- </state>
- <final id="rLetterOn"/>
- </state>
- <state id="letter.A">
- <state id="aLetterOff">
- <transition event="aLetterTriggered" cond="In('onState')" target="aLetterOn"/>
- </state>
- <final id="aLetterOn"/>
- </state>
- <state id="letter.Z">
- <state id="zLetterOff">
- <transition event="zLetterTriggered" cond="In('onState')" target="zLetterOn"/>
- </state>
- <final id="zLetterOn"/>
- </state>
- <state id="letter.Y">
- <state id="yLetterOff">
- <transition event="yLetterTriggered" cond="In('onState')" target="yLetterOn"/>
- </state>
- <final id="yLetterOn"/>
- </state>
- <transition event="resetLetters" target="lettersState"/>
- </parallel>
- </state>
- <state id="modeState">
- <state id="offState">
- <onentry>
- <if cond="highScore &lt; score">
- <assign location="highScore" expr="score"/>
- </if>
- <raise event="resetLetters"/>
- <raise event="update"/>
- </onentry>
- <transition event="startTriggered" target="onState"/>
- </state>
- <parallel id="onState">
- <onentry>
- <assign location="score" expr="0"/>
- </onentry>
- <state id="hurryState">
- <state id="hurryStateOff">
- <onentry>
- <raise event="resetLetters"/>
- <raise event="update"/>
- </onentry>
- <transition event="goToHurryOn" target="hurryStateOn"/>
- </state>
- <state id="hurryStateOn">
- <onentry>
- <send event="goToHurryOff" id="hurryId" delay="5s"/>
- <raise event="resetLetters"/>
- <raise event="update"/>
- </onentry>
- <transition event="goToHurryOff" target="hurryStateOff"/>
- <onexit>
- <cancel sendid="hurryId"/>
- </onexit>
- </state>
- </state>
- <state id="jackpotState">
- <state id="jackpotStateOff">
- <onentry>
- <raise event="update"/>
- </onentry>
- <transition event="goForJackpot" target="jackpotStateOn"/>
- </state>
- <state id="jackpotStateOn">
- <onentry>
- <raise event="update"/>
- </onentry>
- </state>
- </state>
- <transition event="ballOutTriggered" target="offState"/>
- </parallel>
- </state>
- </parallel>
-
- <state id="workflow">
- <state id="lightImpulseGenerator">
- <state id="lightImpulseOn"/>
- <state id="lightImpulseOff"/>
-
- <onentry>
- <raise event="update"/>
- </onentry>
-
- <transition event="scheduleNewImpulse">
- <cancel sendid="lightId"/>
- <if cond="In('offState')">
- <send event="lightImpulse" id="lightId" delay="1s"/>
- <elseif cond="In('hurryStateOff')"/>
- <send event="lightImpulse" id="lightId" delay="500ms"/>
- <else/>
- <send event="lightImpulse" id="lightId" delay="200ms"/>
- </if>
- </transition>
-
- <transition event="update">
- <raise event="scheduleNewImpulse"/>
- <raise event="updateLights"/>
- </transition>
-
- <transition event="lightImpulse" cond="In('lightImpulseOn')" target="lightImpulseOff"/>
- <transition event="lightImpulse" cond="In('lightImpulseOff')" target="lightImpulseOn"/>
- </state>
-
- <transition event="done.state.letter.*">
- <if cond="In('hurryStateOff')">
- <assign location="score" expr="score + 1000"/>
- <elseif cond="In('hurryStateOn')"/>
- <assign location="score" expr="score + 10000"/>
- </if>
- <raise event="updateLights"/>
- </transition>
-
- <transition event="done.state.lettersState">
- <if cond="In('hurryStateOff')">
- <assign location="score" expr="score + 100000"/>
- <raise event="goToHurryOn"/>
- <elseif cond="In('hurryStateOn')"/>
- <assign location="score" expr="score + 1000000"/>
- <raise event="goToHurryOff"/>
- <raise event="goForJackpot"/>
- </if>
- </transition>
-
- <transition event="updateLights">
- <send event="updateScore">
- <param name="highScore" expr="highScore"/>
- <param name="score" expr="score"/>
- </send>
- <if cond="In('jackpotStateOn')">
- <raise event="turnOnJackpot"/>
- <else/>
- <raise event="turnOffJackpot"/>
- </if>
-
- <if cond="In('lightImpulseOn')">
- <if cond="In('offState')">
- <raise event="turnOnLights"/>
- <raise event="turnOnHurry"/>
- <raise event="turnOnJackpot"/>
- <raise event="turnOnGameOver"/>
- <elseif cond="In('hurryStateOff')"/>
- <raise event="updateLightsAccordingToLettersState"/>
- <raise event="turnOffHurry"/>
- <raise event="turnOffGameOver"/>
- <else/>
- <raise event="turnOnLights"/>
- <raise event="turnOnHurry"/>
- <raise event="turnOffGameOver"/>
- </if>
- <else/>
- <if cond="In('offState')">
- <raise event="turnOffLights"/>
- <raise event="turnOffHurry"/>
- <raise event="turnOffJackpot"/>
- <elseif cond="In('hurryStateOff')"/>
- <raise event="turnOffLights"/>
- <else/>
- <raise event="updateLightsAccordingToLettersState"/>
- </if>
- <raise event="turnOffHurry"/>
- <raise event="turnOffGameOver"/>
- </if>
- </transition>
-
- <transition event="updateLightsAccordingToLettersState">
- <if cond="In('cLetterOn')">
- <raise event="turnOnC"/>
- <else/>
- <raise event="turnOffC"/>
- </if>
- <if cond="In('rLetterOn')">
- <raise event="turnOnR"/>
- <else/>
- <raise event="turnOffR"/>
- </if>
- <if cond="In('aLetterOn')">
- <raise event="turnOnA"/>
- <else/>
- <raise event="turnOffA"/>
- </if>
- <if cond="In('zLetterOn')">
- <raise event="turnOnZ"/>
- <else/>
- <raise event="turnOffZ"/>
- </if>
- <if cond="In('yLetterOn')">
- <raise event="turnOnY"/>
- <else/>
- <raise event="turnOffY"/>
- </if>
- </transition>
-
- <transition event="turnOnLights">
- <raise event="turnOnC"/>
- <raise event="turnOnR"/>
- <raise event="turnOnA"/>
- <raise event="turnOnZ"/>
- <raise event="turnOnY"/>
- </transition>
-
- <transition event="turnOffLights">
- <raise event="turnOffC"/>
- <raise event="turnOffR"/>
- <raise event="turnOffA"/>
- <raise event="turnOffZ"/>
- <raise event="turnOffY"/>
- </transition>
- </state>
- </parallel>
- </parallel>
-</scxml>
diff --git a/examples/scxml/scxml.pro b/examples/scxml/scxml.pro
index 2f80c60..d467fb4 100644
--- a/examples/scxml/scxml.pro
+++ b/examples/scxml/scxml.pro
@@ -3,24 +3,16 @@ TEMPLATE = subdirs
qtHaveModule(widgets) {
SUBDIRS += trafficlight-widgets-static
SUBDIRS += trafficlight-widgets-dynamic
- SUBDIRS += mediaplayer-widgets-static
- SUBDIRS += mediaplayer-widgets-dynamic
- SUBDIRS += calculator-widgets
- SUBDIRS += pinball
SUBDIRS += sudoku
}
qtHaveModule(quick) {
- SUBDIRS += calculator-qml
+ SUBDIRS += calculator
SUBDIRS += trafficlight-qml-static
SUBDIRS += trafficlight-qml-dynamic
SUBDIRS += trafficlight-qml-simple
- SUBDIRS += mediaplayer-qml-static
- SUBDIRS += mediaplayer-qml-dynamic
-
- SUBDIRS += mediaplayer-qml-cppdatamodel
- SUBDIRS += invoke-static
- SUBDIRS += invoke-dynamic
+ SUBDIRS += mediaplayer
+ SUBDIRS += invoke
}
SUBDIRS += ftpclient
diff --git a/examples/scxml/sudoku/CMakeLists.txt b/examples/scxml/sudoku/CMakeLists.txt
new file mode 100644
index 0000000..d3e80dd
--- /dev/null
+++ b/examples/scxml/sudoku/CMakeLists.txt
@@ -0,0 +1,57 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(sudoku LANGUAGES CXX)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/scxml/sudoku")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Scxml Widgets)
+
+qt_standard_project_setup()
+
+qt_add_executable(sudoku
+ main.cpp
+ mainwindow.cpp mainwindow.h
+)
+
+set_target_properties(sudoku PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(sudoku PRIVATE
+ Qt::Core
+ Qt::Gui
+ Qt::Scxml
+ Qt::Widgets
+)
+
+# Resources:
+set(sudoku_resource_files
+ "data/nearly-solved-sudoku.data"
+ "data/sudoku.data"
+ "sudoku.js"
+)
+
+qt6_add_resources(sudoku "sudoku"
+ PREFIX
+ "/"
+ FILES
+ ${sudoku_resource_files}
+)
+
+# Statecharts:
+qt6_add_statecharts(sudoku
+ sudoku.scxml
+)
+
+install(TARGETS sudoku
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/scxml/sudoku/doc/src/sudoku.qdoc b/examples/scxml/sudoku/doc/src/sudoku.qdoc
index c3d8971..45a2967 100644
--- a/examples/scxml/sudoku/doc/src/sudoku.qdoc
+++ b/examples/scxml/sudoku/doc/src/sudoku.qdoc
@@ -1,37 +1,14 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example sudoku
- \title Qt SCXML Sudoku Example
+ \title SCXML Sudoku
+ \examplecategory {Data Processing & I/O}
\ingroup examples-qtscxml
- \brief Presents the use of SCXML in a sudoku game.
+ \meta tag {state machine}
- \e {Sudoku} demonstrates how an SCXML file may be used in a game.
+ \brief Demonstrates the use of separate javascript file with SCXML.
\include examples-run.qdocinc
@@ -106,10 +83,10 @@
remains unchanged.
\row
\li \c undoStack
- \li Holds the history of players' moves. It is a vector of
+ \li Holds the history of players' moves. It is a list of
the cells' coordinates that were touched last. Each
new modification during a game adds a pair of
- x and y coordinates to that vector.
+ x and y coordinates to that list.
\endtable
The variables above are shared with the script helper functions
@@ -257,12 +234,12 @@
grid is properly solved. Since we need to check
each row, each column, and each 3x3 square, we define
the \c isOK() helper function. This function takes
- the vector of numbers and returns \c true if the passed vector
+ the list of numbers and returns \c true if the passed list
contains unique numbers and no number equals zero, meaning
there is no empty cell. The main loop of the \c isSolved() is invoked
- nine times. In every iteration, we construct three vectors of numbers
+ nine times. In every iteration, we construct three lists of numbers
representing a row, a column, and a square of the grid and call \c isOK()
- for them. When all 27 vectors are OK, the grid is solved properly
+ for them. When all 27 lists are OK, the grid is solved properly
and we return \c true.
Coming back to our SCXML file, in case \c isSolved()
diff --git a/examples/scxml/sudoku/main.cpp b/examples/scxml/sudoku/main.cpp
index c65efa3..8cd790d 100644
--- a/examples/scxml/sudoku/main.cpp
+++ b/examples/scxml/sudoku/main.cpp
@@ -1,57 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
#include "sudoku.h"
-#include <QApplication>
+#include <QtWidgets/qapplication.h>
int main(int argc, char **argv)
{
diff --git a/examples/scxml/sudoku/mainwindow.cpp b/examples/scxml/sudoku/mainwindow.cpp
index 8b521ae..63a8f25 100644
--- a/examples/scxml/sudoku/mainwindow.cpp
+++ b/examples/scxml/sudoku/mainwindow.cpp
@@ -1,68 +1,21 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
-#include <QComboBox>
-#include <QDir>
-#include <QFile>
-#include <QGridLayout>
-#include <QLabel>
-#include <QScxmlStateMachine>
-#include <QStringListModel>
-#include <QTextStream>
-#include <QToolButton>
+#include <QtCore/qdir.h>
+#include <QtCore/qfile.h>
+#include <QtCore/qstringlistmodel.h>
+#include <QtCore/qtextstream.h>
+#include <QtWidgets/qcombobox.h>
+#include <QtWidgets/qgridlayout.h>
+#include <QtWidgets/qlabel.h>
+#include <QtWidgets/qtoolbutton.h>
+#include <QtScxml/qscxmlstatemachine.h>
static int Size = 9;
-QT_USE_NAMESPACE
+using namespace Qt::Literals::StringLiterals;
static QVariantList emptyRow()
{
@@ -80,11 +33,11 @@ static QVariantMap readSudoku(const QString &fileName)
const QString data = str.readAll();
QVariantList initRowsVariant;
- const QStringList rows = data.split(QLatin1Char('\n'));
+ const QStringList rows = data.split('\n'_L1);
for (int i = 0; i < Size; i++) {
if (i < rows.count()) {
QVariantList initRowVariant;
- const QStringList row = rows.at(i).split(QLatin1Char(','));
+ const QStringList row = rows.at(i).split(','_L1);
for (int j = 0; j < Size; j++) {
const int val = j < row.count()
? row.at(j).toInt() % (Size + 1) : 0;
@@ -97,7 +50,7 @@ static QVariantMap readSudoku(const QString &fileName)
}
QVariantMap dataVariant;
- dataVariant.insert(QStringLiteral("initState"), initRowsVariant);
+ dataVariant.insert(u"initState"_s, initRowsVariant);
return dataVariant;
}
@@ -106,8 +59,8 @@ MainWindow::MainWindow(QScxmlStateMachine *machine, QWidget *parent) :
QWidget(parent),
m_machine(machine)
{
- const QVector<QToolButton *> initVector(Size, nullptr);
- m_buttons = QVector<QVector<QToolButton *> >(Size, initVector);
+ const QList<QToolButton *> initVector(Size, nullptr);
+ m_buttons = QList<QList<QToolButton *>>(Size, initVector);
QGridLayout *layout = new QGridLayout(this);
@@ -118,10 +71,10 @@ MainWindow::MainWindow(QScxmlStateMachine *machine, QWidget *parent) :
QSizePolicy::Expanding);
layout->addWidget(button, i + i / 3, j + j / 3);
m_buttons[i][j] = button;
- connect(button, &QToolButton::clicked, [this, i, j] () {
+ connect(button, &QToolButton::clicked, this, [this, i, j]() {
QVariantMap data;
- data.insert(QStringLiteral("x"), i);
- data.insert(QStringLiteral("y"), j);
+ data.insert(u"x"_s, i);
+ data.insert(u"y"_s, j);
m_machine->submitEvent("tap", data);
});
}
@@ -145,8 +98,7 @@ MainWindow::MainWindow(QScxmlStateMachine *machine, QWidget *parent) :
m_startButton->setText(tr("Start"));
layout->addWidget(m_startButton, Size + 3, 0, 1, 3);
- connect(m_startButton, &QAbstractButton::clicked,
- [this] {
+ connect(m_startButton, &QAbstractButton::clicked, this, [this]() {
if (m_machine->isActive("playing"))
m_machine->submitEvent("stop");
else
@@ -164,15 +116,14 @@ MainWindow::MainWindow(QScxmlStateMachine *machine, QWidget *parent) :
m_undoButton->setEnabled(false);
layout->addWidget(m_undoButton, Size + 3, 8, 1, 3);
- connect(m_undoButton, &QAbstractButton::clicked,
- [this] {
+ connect(m_undoButton, &QAbstractButton::clicked, this, [this]() {
m_machine->submitEvent("undo");
});
m_chooser = new QComboBox(this);
layout->addWidget(m_chooser, Size + 4, 0, 1, 11);
- QDir dataDir(QLatin1String(":/data"));
+ QDir dataDir(":/data"_L1);
QFileInfoList sudokuFiles = dataDir.entryInfoList(QStringList()
<< "*.data");
for (const QFileInfo &sudokuFile : sudokuFiles) {
@@ -180,8 +131,7 @@ MainWindow::MainWindow(QScxmlStateMachine *machine, QWidget *parent) :
sudokuFile.absoluteFilePath());
}
- connect(m_chooser, QOverload<int>::of(&QComboBox::currentIndexChanged),
- [this] (int index) {
+ connect(m_chooser, &QComboBox::currentIndexChanged, this, [this](int index) {
const QString sudokuFile = m_chooser->itemData(index).toString();
const QVariantMap initValues = readSudoku(sudokuFile);
m_machine->submitEvent("setup", initValues);
@@ -203,14 +153,14 @@ MainWindow::MainWindow(QScxmlStateMachine *machine, QWidget *parent) :
}
});
- m_machine->connectToState("solved", [this] (bool solved) {
+ m_machine->connectToState("solved", [this](bool solved) {
if (solved)
m_label->setText(tr("SOLVED !!!"));
else
m_label->setText(tr("unsolved"));
});
- m_machine->connectToEvent("updateGUI", [this] (const QScxmlEvent &event) {
+ m_machine->connectToEvent("updateGUI", [this](const QScxmlEvent &event) {
const QVariant data = event.data();
const QVariantList currentRows = data.toMap().value(
@@ -237,11 +187,4 @@ MainWindow::MainWindow(QScxmlStateMachine *machine, QWidget *parent) :
}
}
});
-
- setLayout(layout);
}
-
-MainWindow::~MainWindow()
-{
-}
-
diff --git a/examples/scxml/sudoku/mainwindow.h b/examples/scxml/sudoku/mainwindow.h
index b37279e..b12a6dd 100644
--- a/examples/scxml/sudoku/mainwindow.h
+++ b/examples/scxml/sudoku/mainwindow.h
@@ -1,57 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
-#include <QWidget>
+#include <QtWidgets/qwidget.h>
QT_BEGIN_NAMESPACE
class QToolButton;
@@ -60,22 +13,20 @@ class QLabel;
class QComboBox;
QT_END_NAMESPACE
-
class MainWindow : public QWidget
{
Q_OBJECT
public:
explicit MainWindow(QScxmlStateMachine *machine, QWidget *parent = nullptr);
- ~MainWindow();
private:
- QScxmlStateMachine *m_machine;
- QVector<QVector<QToolButton *> > m_buttons;
- QToolButton *m_startButton;
- QToolButton *m_undoButton;
- QLabel *m_label;
- QComboBox *m_chooser;
+ QScxmlStateMachine *m_machine = nullptr;
+ QList<QList<QToolButton *>> m_buttons;
+ QToolButton *m_startButton = nullptr;
+ QToolButton *m_undoButton = nullptr;
+ QLabel *m_label = nullptr;
+ QComboBox *m_chooser = nullptr;
};
#endif // MAINWINDOW_H
diff --git a/examples/scxml/sudoku/sudoku.js b/examples/scxml/sudoku/sudoku.js
index 21a1ed8..98abe0a 100644
--- a/examples/scxml/sudoku/sudoku.js
+++ b/examples/scxml/sudoku/sudoku.js
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
function restart() {
for (var i = 0; i < initState.length; i++)
diff --git a/examples/scxml/sudoku/sudoku.scxml b/examples/scxml/sudoku/sudoku.scxml
index eb36283..0184c12 100644
--- a/examples/scxml/sudoku/sudoku.scxml
+++ b/examples/scxml/sudoku/sudoku.scxml
@@ -1,54 +1,7 @@
<?xml version="1.0" ?>
<!--
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-->
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0"
name="Sudoku" datamodel="ecmascript">
diff --git a/examples/scxml/trafficlight-common/Button.qml b/examples/scxml/trafficlight-common/Button.qml
deleted file mode 100644
index 24512ce..0000000
--- a/examples/scxml/trafficlight-common/Button.qml
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.5
-
-Image {
- id: button
- signal clicked
-
- MouseArea {
- id: mouse
- anchors.fill: parent
- onClicked: button.clicked()
- }
-}
diff --git a/examples/scxml/trafficlight-common/Lights.ui.qml b/examples/scxml/trafficlight-common/Lights.ui.qml
deleted file mode 100644
index a385eae..0000000
--- a/examples/scxml/trafficlight-common/Lights.ui.qml
+++ /dev/null
@@ -1,140 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-import QtQuick 2.5
-import QtQuick.Window 2.2
-import TrafficLightStateMachine 1.0
-
-Image {
- id: lights
-
- property alias button: button
- property TrafficLightStateMachine stateMachine
-
- source: "background.png"
-
- Column {
- y: 40
- spacing: 27
- anchors.horizontalCenter: parent.horizontalCenter
-
- Image {
- id: redLight
- opacity: 0.2
- source: "red.png"
- }
-
- Image {
- id: yellowLight
- opacity: 0.2
- source: "yellow.png"
- }
-
- Image {
- id: greenLight
- opacity: 0.2
- source: "green.png"
- }
- }
-
- Button {
- id: button
-
- anchors.right: parent.right
- anchors.bottom: parent.bottom
- anchors.margins: 20
- source: "pause.png"
- }
-
- states: [
- State {
- name: "Red"
- when: stateMachine.red
-
- PropertyChanges {
- target: redLight
- opacity: 1
- }
- },
- State {
- name: "RedGoingGreen"
- when: stateMachine.redGoingGreen
-
- PropertyChanges {
- target: redLight
- opacity: 1
- }
-
- PropertyChanges {
- target: yellowLight
- opacity: 1
- }
- },
- State {
- name: "Yellow"
- when: stateMachine.yellow || stateMachine.blinking
-
- PropertyChanges {
- target: yellowLight
- opacity: 1
- }
- },
- State {
- name: "Green"
- when: stateMachine.green
-
- PropertyChanges {
- target: greenLight
- opacity: 1
- }
- }
- ]
-}
diff --git a/examples/scxml/trafficlight-common/TrafficLight.qml b/examples/scxml/trafficlight-common/TrafficLight.qml
deleted file mode 100644
index ec11ed5..0000000
--- a/examples/scxml/trafficlight-common/TrafficLight.qml
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.5
-import QtQuick.Window 2.2
-import TrafficLightStateMachine 1.0
-
-Window {
- id: root
-
- property TrafficLightStateMachine stateMachine
-
- visible: true
- width: lights.width
- height: lights.height
- maximumWidth: lights.implicitWidth
- maximumHeight: lights.implicitHeight
-
- Lights {
- id: lights
-
- stateMachine: root.stateMachine
- button.source: stateMachine.working ? "pause.png" : "play.png"
-
- button.onClicked: stateMachine.submitEvent(stateMachine.working ? "smash" : "repair");
- }
-}
diff --git a/examples/scxml/trafficlight-common/doc/src/trafficlight-compiling.qdocinc b/examples/scxml/trafficlight-common/doc/src/trafficlight-compiling.qdocinc
index ac16203..1410dcb 100644
--- a/examples/scxml/trafficlight-common/doc/src/trafficlight-compiling.qdocinc
+++ b/examples/scxml/trafficlight-common/doc/src/trafficlight-compiling.qdocinc
@@ -1,17 +1,30 @@
\section1 Compiling the State Machine
- We link against the Qt SCXML module by adding the following line to the
- \e .pro file:
+ We link against the Qt SCXML module by adding the following lines to the
+ example's build files.
+
+ \section2 \e .pro when using qmake:
\quotefromfile trafficlight-qml-static/trafficlight-qml-static.pro
\skipto QT
\printline scxml
We then specify the state machine to compile:
-
\skipto STATECHARTS
\printline scxml
- The Qt SCXML Compiler, \c qscxmlc, is run automatically to generate
- \e statemachine.h and \e statemachine.cpp, and to add them to the \c HEADERS
- and \c SOURCES variables for compilation.
+ \section2 \e CMakeLists.txt when using cmake:
+ \quotefromfile trafficlight-qml-static/CMakeLists.txt
+ \skipto find_package
+ \printline Scxml
+ \skipto target_link_libraries
+ \printuntil )
+
+ We then specify the state machine to compile:
+ \skipto qt6_add_statecharts
+ \printuntil )
+
+ The statechart directives \e STATECHARTS or \e qt6_add_statecharts invoke the Qt SCXML
+ Compiler, \c qscxmlc, which is run automatically to generate \e statemachine.h and
+ \e statemachine.cpp, which are then added appropriately as headers and sources for
+ compilation.
diff --git a/examples/scxml/trafficlight-common/statemachine.scxml b/examples/scxml/trafficlight-common/statemachine.scxml
index 3cf023e..9afe664 100644
--- a/examples/scxml/trafficlight-common/statemachine.scxml
+++ b/examples/scxml/trafficlight-common/statemachine.scxml
@@ -1,54 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-->
<scxml
xmlns="http://www.w3.org/2005/07/scxml"
diff --git a/examples/scxml/trafficlight-common/trafficlight.cpp b/examples/scxml/trafficlight-common/trafficlight.cpp
index 52be91d..e29f2b5 100644
--- a/examples/scxml/trafficlight-common/trafficlight.cpp
+++ b/examples/scxml/trafficlight-common/trafficlight.cpp
@@ -1,71 +1,26 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "trafficlight.h"
-#include <QPainter>
-#include <QVBoxLayout>
+#include <QtWidgets/qboxlayout.h>
+#include <QtGui/qpainter.h>
+
+using namespace Qt::Literals::StringLiterals;
class TrafficLightWidget : public QWidget
{
public:
TrafficLightWidget(QWidget *parent = nullptr)
- : QWidget(parent), m_background(QLatin1String(":/background.png"))
+ : QWidget(parent), m_background(":/background.png"_L1)
{
QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->setContentsMargins(0, 40, 0, 80);
- m_red = new LightWidget(QLatin1String(":/red.png"));
+ m_red = new LightWidget(":/red.png"_L1);
vbox->addWidget(m_red, 0, Qt::AlignHCenter);
- m_yellow = new LightWidget(QLatin1String(":/yellow.png"));
+ m_yellow = new LightWidget(":/yellow.png"_L1);
vbox->addWidget(m_yellow, 0, Qt::AlignHCenter);
- m_green = new LightWidget(QLatin1String(":/green.png"));
+ m_green = new LightWidget(":/green.png"_L1);
vbox->addWidget(m_green, 0, Qt::AlignHCenter);
setLayout(vbox);
}
@@ -103,16 +58,11 @@ TrafficLight::TrafficLight(QScxmlStateMachine *machine, QWidget *parent)
TrafficLightWidget *widget = new TrafficLightWidget(this);
setFixedSize(widget->sizeHint());
- machine->connectToState(QStringLiteral("red"),
- widget->redLight(), &LightWidget::switchLight);
- machine->connectToState(QStringLiteral("redGoingGreen"),
- widget->redLight(), &LightWidget::switchLight);
- machine->connectToState(QStringLiteral("yellow"),
- widget->yellowLight(), &LightWidget::switchLight);
- machine->connectToState(QStringLiteral("blinking"),
- widget->yellowLight(), &LightWidget::switchLight);
- machine->connectToState(QStringLiteral("green"),
- widget->greenLight(), &LightWidget::switchLight);
+ machine->connectToState(u"red"_s, widget->redLight(), &LightWidget::switchLight);
+ machine->connectToState(u"redGoingGreen"_s, widget->redLight(), &LightWidget::switchLight);
+ machine->connectToState(u"yellow"_s, widget->yellowLight(), &LightWidget::switchLight);
+ machine->connectToState(u"blinking"_s, widget->yellowLight(), &LightWidget::switchLight);
+ machine->connectToState(u"green"_s, widget->greenLight(), &LightWidget::switchLight);
QAbstractButton *button = new ButtonWidget(this);
auto setButtonGeometry = [this, button](){
@@ -124,8 +74,7 @@ TrafficLight::TrafficLight(QScxmlStateMachine *machine, QWidget *parent)
connect(button, &QAbstractButton::toggled, this, setButtonGeometry);
setButtonGeometry();
- connect(button, &QAbstractButton::toggled,
- this, &TrafficLight::toggleWorking);
+ connect(button, &QAbstractButton::toggled, this, &TrafficLight::toggleWorking);
}
void TrafficLight::toggleWorking(bool pause)
@@ -150,7 +99,9 @@ void LightWidget::setOn(bool on)
}
void LightWidget::switchLight(bool onoff)
-{ setOn(onoff); }
+{
+ setOn(onoff);
+}
void LightWidget::paintEvent(QPaintEvent *)
{
@@ -167,8 +118,8 @@ QSize LightWidget::sizeHint() const
}
ButtonWidget::ButtonWidget(QWidget *parent) :
- QAbstractButton(parent), m_playIcon(QLatin1String(":/play.png")),
- m_pauseIcon(QLatin1String(":/pause.png"))
+ QAbstractButton(parent), m_playIcon(":/play.png"_L1),
+ m_pauseIcon(":/pause.png"_L1)
{
setCheckable(true);
}
diff --git a/examples/scxml/trafficlight-common/trafficlight.h b/examples/scxml/trafficlight-common/trafficlight.h
index 78e2c8d..97da67b 100644
--- a/examples/scxml/trafficlight-common/trafficlight.h
+++ b/examples/scxml/trafficlight-common/trafficlight.h
@@ -1,59 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef TRAFFICLIGHT_H
#define TRAFFICLIGHT_H
-#include <QAbstractButton>
-#include <QScxmlStateMachine>
-#include <QWidget>
+#include <QtWidgets/qwidget.h>
+#include <QtWidgets/qabstractbutton.h>
+#include <QtScxml/qscxmlstatemachine.h>
class TrafficLight : public QWidget
{
diff --git a/examples/scxml/trafficlight-qml-dynamic/Button.qml b/examples/scxml/trafficlight-qml-dynamic/Button.qml
new file mode 100644
index 0000000..1333193
--- /dev/null
+++ b/examples/scxml/trafficlight-qml-dynamic/Button.qml
@@ -0,0 +1,17 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+pragma ComponentBehavior: Bound
+
+import QtQuick
+
+Image {
+ id: button
+ signal clicked
+
+ MouseArea {
+ id: mouse
+ anchors.fill: parent
+ onClicked: button.clicked()
+ }
+}
diff --git a/examples/scxml/trafficlight-qml-dynamic/CMakeLists.txt b/examples/scxml/trafficlight-qml-dynamic/CMakeLists.txt
new file mode 100644
index 0000000..023edbf
--- /dev/null
+++ b/examples/scxml/trafficlight-qml-dynamic/CMakeLists.txt
@@ -0,0 +1,85 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(trafficlight-qml-dynamic LANGUAGES CXX)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/scxml/trafficlight-qml-dynamic")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Scxml)
+qt_standard_project_setup(REQUIRES 6.5)
+
+qt_add_executable(trafficlight-qml-dynamic
+ trafficlight-qml-dynamic.cpp
+)
+
+set_target_properties(trafficlight-qml-dynamic PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(trafficlight-qml-dynamic PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Qml
+ Qt6::Scxml
+)
+
+set_source_files_properties("../trafficlight-common/statemachine.scxml"
+ PROPERTIES QT_RESOURCE_ALIAS "statemachine.scxml"
+)
+
+set_source_files_properties(../trafficlight-common/play.png
+ PROPERTIES QT_RESOURCE_ALIAS "play.png"
+)
+
+set_source_files_properties(../trafficlight-common/play.png
+ PROPERTIES QT_RESOURCE_ALIAS "play.png"
+)
+
+set_source_files_properties(../trafficlight-common/yellow.png
+ PROPERTIES QT_RESOURCE_ALIAS "yellow.png"
+)
+
+set_source_files_properties(../trafficlight-common/red.png
+ PROPERTIES QT_RESOURCE_ALIAS "red.png"
+)
+
+set_source_files_properties(../trafficlight-common/green.png
+ PROPERTIES QT_RESOURCE_ALIAS "green.png"
+)
+
+set_source_files_properties(../trafficlight-common/background.png
+ PROPERTIES QT_RESOURCE_ALIAS "background.png"
+)
+
+set_source_files_properties(../trafficlight-common/pause.png
+ PROPERTIES QT_RESOURCE_ALIAS "pause.png"
+)
+
+qt_add_qml_module(trafficlight-qml-dynamic
+ URI TrafficLightApplication
+ VERSION 1.0
+ QML_FILES
+ MainView.qml
+ Button.qml
+ Lights.ui.qml
+ RESOURCES
+ ../trafficlight-common/statemachine.scxml
+ ../trafficlight-common/play.png
+ ../trafficlight-common/yellow.png
+ ../trafficlight-common/red.png
+ ../trafficlight-common/green.png
+ ../trafficlight-common/background.png
+ ../trafficlight-common/pause.png
+)
+
+install(TARGETS trafficlight-qml-dynamic
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/scxml/trafficlight-qml-dynamic/Lights.ui.qml b/examples/scxml/trafficlight-qml-dynamic/Lights.ui.qml
new file mode 100644
index 0000000..ef683f9
--- /dev/null
+++ b/examples/scxml/trafficlight-qml-dynamic/Lights.ui.qml
@@ -0,0 +1,80 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+pragma ComponentBehavior: Bound
+
+import QtQuick
+import QtScxml
+
+Image {
+ id: lights
+
+ property alias button: button
+ required property StateMachine stateMachine
+
+ source: "background.png"
+
+ Column {
+ y: 40
+ spacing: 27
+ anchors.horizontalCenter: parent.horizontalCenter
+
+ Image {
+ id: redLight
+ opacity: 0.2
+ source: "red.png"
+ }
+
+ Image {
+ id: yellowLight
+ opacity: 0.2
+ source: "yellow.png"
+ }
+
+ Image {
+ id: greenLight
+ opacity: 0.2
+ source: "green.png"
+ }
+ }
+
+ Button {
+ id: button
+
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ anchors.margins: 20
+ source: "pause.png"
+ }
+
+ states: [
+ // Suppress qmllint warning, dynamic statemachine properties not known at compile-time
+ // qmllint disable missing-property
+ State {
+ name: "Red"
+ when: lights.stateMachine.red
+
+ PropertyChanges { redLight.opacity: 1 }
+ },
+ State {
+ name: "RedGoingGreen"
+ when: lights.stateMachine.redGoingGreen
+
+ PropertyChanges { redLight.opacity: 1 }
+ PropertyChanges { yellowLight.opacity: 1 }
+ },
+ State {
+ name: "Yellow"
+ when: lights.stateMachine.yellow || lights.stateMachine.blinking
+
+ PropertyChanges { yellowLight.opacity: 1 }
+ },
+ State {
+ name: "Green"
+ when: lights.stateMachine.green
+
+ PropertyChanges { greenLight.opacity: 1 }
+ }
+ // qmllint enable missing-property
+ ]
+}
diff --git a/examples/scxml/trafficlight-qml-dynamic/MainView.qml b/examples/scxml/trafficlight-qml-dynamic/MainView.qml
new file mode 100644
index 0000000..2923568
--- /dev/null
+++ b/examples/scxml/trafficlight-qml-dynamic/MainView.qml
@@ -0,0 +1,29 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+pragma ComponentBehavior: Bound
+
+import QtQuick
+import QtScxml
+import TrafficLightApplication
+
+Window {
+ width: lights.width
+ height: lights.height
+ visible: true
+
+ Lights {
+ id: lights
+ stateMachine: loader.stateMachine
+ // Suppress qmllint warning, dynamic statemachine properties not known at compile-time
+ // qmllint disable missing-property
+ button.source: stateMachine.working ? "pause.png" : "play.png"
+ button.onClicked: stateMachine.submitEvent(stateMachine.working ? "smash" : "repair");
+ // qmllint enable missing-property
+ }
+
+ StateMachineLoader {
+ id: loader
+ source: Qt.resolvedUrl("statemachine.scxml")
+ }
+}
diff --git a/examples/scxml/trafficlight-qml-dynamic/doc/src/trafficlight-qml-dynamic.qdoc b/examples/scxml/trafficlight-qml-dynamic/doc/src/trafficlight-qml-dynamic.qdoc
index 0316508..37bb634 100644
--- a/examples/scxml/trafficlight-qml-dynamic/doc/src/trafficlight-qml-dynamic.qdoc
+++ b/examples/scxml/trafficlight-qml-dynamic/doc/src/trafficlight-qml-dynamic.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example trafficlight-qml-dynamic
- \title Qt SCXML Traffic Light QML Example (Dynamic)
+ \title SCXML Traffic Light (Dynamic, QML)
+ \examplecategory {Data Processing & I/O}
\ingroup examples-qtscxml
\brief A Qt Quick application that uses a dynamically loaded state machine
@@ -35,7 +12,7 @@
\image trafficlight.png
- \e{Traffic Light QML Example (Dynamic)} demonstrates how to connect to the
+ \e{Traffic Light QML} demonstrates how to connect to the
active properties of a state in a dynamically loaded state machine.
The UI is created using Qt Quick.
@@ -44,16 +21,24 @@
\section1 Dynamically Loading the State Machine
- We link against the Qt SCXML module by adding the following line to the
- example \e .pro file:
+ We link against the Qt SCXML module by adding the following lines to the
+ example's build files.
+ To \e .pro when using qmake:
\quotefromfile trafficlight-qml-dynamic/trafficlight-qml-dynamic.pro
\skipto QT
\printline scxml
+ To \e CMakeLists.txt when using cmake:
+ \quotefromfile trafficlight-qml-dynamic/CMakeLists.txt
+ \skipto find_package
+ \printline Scxml
+ \skipto target_link_libraries
+ \printuntil )
+
We dynamically create the state machine in the main QML file:
- \quotefromfile trafficlight-qml-dynamic/trafficlight-qml-dynamic.qml
+ \quotefromfile trafficlight-qml-dynamic/MainView.qml
\skipto import QtScxml
\printuntil /^\}/
@@ -61,7 +46,7 @@
We connect to the states as follows:
- \quotefromfile trafficlight-common/Lights.ui.qml
+ \quotefromfile trafficlight-qml-dynamic/Lights.ui.qml
\skipto states
\printuntil ]
*/
diff --git a/examples/scxml/trafficlight-qml-dynamic/qmldir b/examples/scxml/trafficlight-qml-dynamic/qmldir
new file mode 100644
index 0000000..c375025
--- /dev/null
+++ b/examples/scxml/trafficlight-qml-dynamic/qmldir
@@ -0,0 +1,6 @@
+module TrafficLightApplication
+prefer :/qt/qml/TrafficLightApplication/
+MainView 1.0 MainView.qml
+Button 1.0 Button.qml
+Lights 1.0 Lights.ui.qml
+
diff --git a/examples/scxml/trafficlight-qml-dynamic/trafficlight-qml-dynamic.cpp b/examples/scxml/trafficlight-qml-dynamic/trafficlight-qml-dynamic.cpp
index a8bf00e..5b945b7 100644
--- a/examples/scxml/trafficlight-qml-dynamic/trafficlight-qml-dynamic.cpp
+++ b/examples/scxml/trafficlight-qml-dynamic/trafficlight-qml-dynamic.cpp
@@ -1,75 +1,17 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-#include <QGuiApplication>
-#include <QQmlApplicationEngine>
-#include <QQmlContext>
-#include <QScxmlStateMachine>
+#include <QtGui/qguiapplication.h>
+#include <QtQml/qqmlapplicationengine.h>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
- /* Register QScxmlStateMachine as TrafficLightStateMachine. This is required to have a type
- * for the state machine and allows full code completion in the static case, since we
- * share the QML code. */
- qmlRegisterUncreatableType<QScxmlStateMachine>("TrafficLightStateMachine",
- 1, 0,
- "TrafficLightStateMachine",
- QLatin1String("TrafficLightStateMachine is not creatable."));
-
QQmlApplicationEngine engine;
- engine.load(QUrl(QStringLiteral("qrc:///trafficlight-qml-dynamic.qml")));
- if (engine.rootObjects().isEmpty())
- return -1;
+ QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed, &app,
+ [](){ QCoreApplication::exit(EXIT_FAILURE); }, Qt::QueuedConnection);
+ engine.loadFromModule("TrafficLightApplication", "MainView");
return app.exec();
}
-
diff --git a/examples/scxml/trafficlight-qml-dynamic/trafficlight-qml-dynamic.pro b/examples/scxml/trafficlight-qml-dynamic/trafficlight-qml-dynamic.pro
index c03a7ef..f562c79 100644
--- a/examples/scxml/trafficlight-qml-dynamic/trafficlight-qml-dynamic.pro
+++ b/examples/scxml/trafficlight-qml-dynamic/trafficlight-qml-dynamic.pro
@@ -4,7 +4,25 @@ QT += qml scxml
SOURCES += trafficlight-qml-dynamic.cpp
-RESOURCES += trafficlight-qml-dynamic.qrc
+QML_IMPORT_NAME = TrafficLightApplication
+QML_IMPORT_MAJOR_VERSION = 1
+
+qml_resources.files = \
+ qmldir \
+ MainView.qml \
+ Button.qml \
+ Lights.ui.qml \
+ ../trafficlight-common/statemachine.scxml \
+ ../trafficlight-common/play.png \
+ ../trafficlight-common/yellow.png \
+ ../trafficlight-common/red.png \
+ ../trafficlight-common/green.png \
+ ../trafficlight-common/background.png \
+ ../trafficlight-common/pause.png \
+
+qml_resources.prefix = /qt/qml/TrafficLightApplication
+
+RESOURCES += qml_resources
target.path = $$[QT_INSTALL_EXAMPLES]/scxml/trafficlight-qml-dynamic
INSTALLS += target
diff --git a/examples/scxml/trafficlight-qml-dynamic/trafficlight-qml-dynamic.qml b/examples/scxml/trafficlight-qml-dynamic/trafficlight-qml-dynamic.qml
deleted file mode 100644
index aef249a..0000000
--- a/examples/scxml/trafficlight-qml-dynamic/trafficlight-qml-dynamic.qml
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtScxml 5.8
-
-TrafficLight {
- StateMachineLoader {
- id: loader
- source: "qrc:///statemachine.scxml"
- }
-
- stateMachine: loader.stateMachine
-}
diff --git a/examples/scxml/trafficlight-qml-dynamic/trafficlight-qml-dynamic.qrc b/examples/scxml/trafficlight-qml-dynamic/trafficlight-qml-dynamic.qrc
deleted file mode 100644
index 547935b..0000000
--- a/examples/scxml/trafficlight-qml-dynamic/trafficlight-qml-dynamic.qrc
+++ /dev/null
@@ -1,15 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file alias="TrafficLight.qml">../trafficlight-common/TrafficLight.qml</file>
- <file alias="Button.qml">../trafficlight-common/Button.qml</file>
- <file alias="Lights.ui.qml">../trafficlight-common/Lights.ui.qml</file>
- <file>trafficlight-qml-dynamic.qml</file>
- <file alias="statemachine.scxml">../trafficlight-common/statemachine.scxml</file>
- <file alias="green.png">../trafficlight-common/green.png</file>
- <file alias="yellow.png">../trafficlight-common/yellow.png</file>
- <file alias="red.png">../trafficlight-common/red.png</file>
- <file alias="pause.png">../trafficlight-common/pause.png</file>
- <file alias="play.png">../trafficlight-common/play.png</file>
- <file alias="background.png">../trafficlight-common/background.png</file>
- </qresource>
-</RCC>
diff --git a/examples/scxml/trafficlight-qml-simple/CMakeLists.txt b/examples/scxml/trafficlight-qml-simple/CMakeLists.txt
new file mode 100644
index 0000000..b3d2bfe
--- /dev/null
+++ b/examples/scxml/trafficlight-qml-simple/CMakeLists.txt
@@ -0,0 +1,51 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(trafficlight-qml-simple LANGUAGES CXX)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/scxml/trafficlight-qml-simple")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Scxml)
+qt_standard_project_setup(REQUIRES 6.5)
+
+qt_add_executable(trafficlight-qml-simple
+ trafficlight-qml-simple.cpp
+)
+
+set_target_properties(trafficlight-qml-simple PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(trafficlight-qml-simple PRIVATE
+ Qt::Core
+ Qt::Gui
+ Qt::Qml
+ Qt::Scxml
+)
+
+# Statecharts:
+qt6_add_statecharts(trafficlight-qml-simple
+ ../trafficlight-common/statemachine.scxml
+)
+
+qt_add_qml_module(trafficlight-qml-simple
+ URI TrafficLightApplication
+ VERSION 1.0
+ QML_FILES
+ MainView.qml
+ Light.qml
+ SOURCES
+ trafficlight-qml.h
+)
+
+install(TARGETS trafficlight-qml-simple
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/scxml/trafficlight-qml-simple/Light.qml b/examples/scxml/trafficlight-qml-simple/Light.qml
index 8502d35..da6b30e 100644
--- a/examples/scxml/trafficlight-qml-simple/Light.qml
+++ b/examples/scxml/trafficlight-qml-simple/Light.qml
@@ -1,54 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.5
+import QtQuick
Item {
property color color
diff --git a/examples/scxml/trafficlight-qml-simple/MainView.qml b/examples/scxml/trafficlight-qml-simple/MainView.qml
new file mode 100644
index 0000000..3e66f19
--- /dev/null
+++ b/examples/scxml/trafficlight-qml-simple/MainView.qml
@@ -0,0 +1,62 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import TrafficLightApplication
+
+Window {
+ id: root
+ visible: true
+ width: 100
+ height: 350
+
+ TrafficLightStateMachine {
+ id: stateMachine
+ running: true
+ }
+
+ Item {
+ id: lights
+ width: parent.width
+ height: 300
+
+ Light {
+ anchors.top: parent.top
+ anchors.horizontalCenter: parent.horizontalCenter
+ color: "red"
+ visible: stateMachine.red || stateMachine.redGoingGreen
+ }
+
+ Light {
+ anchors.centerIn: parent
+ color: "yellow"
+ visible: stateMachine.yellow || stateMachine.blinking
+ }
+
+ Light {
+ anchors.bottom: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ color: "green"
+ visible: stateMachine.green
+ }
+ }
+
+ Rectangle {
+ anchors.top: lights.bottom
+ anchors.bottom: parent.bottom
+ width: parent.width
+ border.color: "black"
+
+ Text {
+ anchors.fill: parent
+ text: stateMachine.working ? "Pause" : "Unpause"
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: stateMachine.submitEvent(stateMachine.working ? "smash" : "repair");
+ }
+ }
+}
diff --git a/examples/scxml/trafficlight-qml-simple/TrafficLight.qml b/examples/scxml/trafficlight-qml-simple/TrafficLight.qml
deleted file mode 100644
index d2f9948..0000000
--- a/examples/scxml/trafficlight-qml-simple/TrafficLight.qml
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.5
-import QtQuick.Window 2.2
-import TrafficLightStateMachine 1.0
-
-Window {
- id: root
- visible: true
- width: 100
- height: 350
-
- TrafficLightStateMachine {
- id: stateMachine
- running: true
- }
-
- Item {
- id: lights
- width: parent.width
- height: 300
-
- Light {
- anchors.top: parent.top
- anchors.horizontalCenter: parent.horizontalCenter
- color: "red"
- visible: stateMachine.red || stateMachine.redGoingGreen
- }
-
- Light {
- anchors.centerIn: parent
- color: "yellow"
- visible: stateMachine.yellow || stateMachine.blinking
- }
-
- Light {
- anchors.bottom: parent.bottom
- anchors.horizontalCenter: parent.horizontalCenter
- color: "green"
- visible: stateMachine.green
- }
- }
-
- Rectangle {
- anchors.top: lights.bottom
- anchors.bottom: parent.bottom
- width: parent.width
- border.color: "black"
-
- Text {
- anchors.fill: parent
- text: stateMachine.working ? "Pause" : "Unpause"
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- }
-
- MouseArea {
- anchors.fill: parent
- onClicked: stateMachine.submitEvent(stateMachine.working ? "smash" : "repair");
- }
- }
-}
diff --git a/examples/scxml/trafficlight-qml-simple/doc/src/trafficlight-qml-simple.qdoc b/examples/scxml/trafficlight-qml-simple/doc/src/trafficlight-qml-simple.qdoc
index f66f5f7..d4bd8ef 100644
--- a/examples/scxml/trafficlight-qml-simple/doc/src/trafficlight-qml-simple.qdoc
+++ b/examples/scxml/trafficlight-qml-simple/doc/src/trafficlight-qml-simple.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example trafficlight-qml-simple
- \title Qt SCXML Traffic Light QML Example (Simple)
+ \title SCXML Traffic Light (Simple, QML)
+ \examplecategory {Data Processing & I/O}
\ingroup examples-qtscxml
\brief A Qt Quick application that uses a compiled state machine to
@@ -35,7 +12,7 @@
\image trafficlight.png
- \e{Traffic Light QML Example (Simple)} demonstrates how to connect to the
+ \e{Traffic Light} demonstrates how to connect to the
active properties of a state in a state machine that is compiled to a class.
The UI is created using Qt Quick.
@@ -48,7 +25,7 @@
We instantiate the state machine as follows:
- \quotefromfile trafficlight-qml-simple/TrafficLight.qml
+ \quotefromfile trafficlight-qml-simple/MainView.qml
\skipto TrafficLightStateMachine {
\printuntil }
@@ -57,7 +34,7 @@
We connect to the states as follows:
- \quotefromfile trafficlight-qml-simple/TrafficLight.qml
+ \quotefromfile trafficlight-qml-simple/MainView.qml
\skipto Light {
\printuntil /^ {4}\}/
*/
diff --git a/examples/scxml/trafficlight-qml-simple/qmldir b/examples/scxml/trafficlight-qml-simple/qmldir
new file mode 100644
index 0000000..179aefa
--- /dev/null
+++ b/examples/scxml/trafficlight-qml-simple/qmldir
@@ -0,0 +1,5 @@
+module TrafficLightApplication
+prefer :/qt/qml/TrafficLightApplication/
+MainView 1.0 MainView.qml
+Light 1.0 Light.qml
+
diff --git a/examples/scxml/trafficlight-qml-simple/trafficlight-qml-simple.cpp b/examples/scxml/trafficlight-qml-simple/trafficlight-qml-simple.cpp
index c9950c4..5b945b7 100644
--- a/examples/scxml/trafficlight-qml-simple/trafficlight-qml-simple.cpp
+++ b/examples/scxml/trafficlight-qml-simple/trafficlight-qml-simple.cpp
@@ -1,71 +1,17 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-#include <QGuiApplication>
-#include <QQmlApplicationEngine>
-#include <QQmlContext>
-
-#include "statemachine.h"
+#include <QtGui/qguiapplication.h>
+#include <QtQml/qqmlapplicationengine.h>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
- qmlRegisterType<TrafficLightStateMachine>("TrafficLightStateMachine", 1, 0,
- "TrafficLightStateMachine");
-
QQmlApplicationEngine engine;
- engine.load(QUrl(QStringLiteral("qrc:/TrafficLight.qml")));
- if (engine.rootObjects().isEmpty())
- return -1;
+ QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed, &app,
+ [](){ QCoreApplication::exit(EXIT_FAILURE); }, Qt::QueuedConnection);
+ engine.loadFromModule("TrafficLightApplication", "MainView");
return app.exec();
}
-
diff --git a/examples/scxml/trafficlight-qml-simple/trafficlight-qml-simple.pro b/examples/scxml/trafficlight-qml-simple/trafficlight-qml-simple.pro
index 4de04ea..0424432 100644
--- a/examples/scxml/trafficlight-qml-simple/trafficlight-qml-simple.pro
+++ b/examples/scxml/trafficlight-qml-simple/trafficlight-qml-simple.pro
@@ -2,13 +2,31 @@ TEMPLATE = app
QT += qml scxml
CONFIG += c++11
+CONFIG += qmltypes
SOURCES += trafficlight-qml-simple.cpp
-RESOURCES += trafficlight-qml-simple.qrc
+HEADERS += trafficlight-qml.h
STATECHARTS = ../trafficlight-common/statemachine.scxml
+QML_IMPORT_NAME = TrafficLightApplication
+QML_IMPORT_MAJOR_VERSION = 1
+
+qml_resources.files = \
+ qmldir \
+ MainView.qml \
+ Light.qml \
+ ../trafficlight-common/play.png \
+ ../trafficlight-common/yellow.png \
+ ../trafficlight-common/red.png \
+ ../trafficlight-common/green.png \
+ ../trafficlight-common/background.png \
+ ../trafficlight-common/pause.png \
+
+qml_resources.prefix = /qt/qml/TrafficLightApplication
+
+RESOURCES += qml_resources
+
target.path = $$[QT_INSTALL_EXAMPLES]/scxml/trafficlight-qml-simple
INSTALLS += target
-
diff --git a/examples/scxml/trafficlight-qml-simple/trafficlight-qml-simple.qrc b/examples/scxml/trafficlight-qml-simple/trafficlight-qml-simple.qrc
deleted file mode 100644
index bb75dba..0000000
--- a/examples/scxml/trafficlight-qml-simple/trafficlight-qml-simple.qrc
+++ /dev/null
@@ -1,6 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>TrafficLight.qml</file>
- <file>Light.qml</file>
- </qresource>
-</RCC>
diff --git a/examples/scxml/trafficlight-qml-simple/trafficlight-qml.h b/examples/scxml/trafficlight-qml-simple/trafficlight-qml.h
new file mode 100644
index 0000000..ac309bd
--- /dev/null
+++ b/examples/scxml/trafficlight-qml-simple/trafficlight-qml.h
@@ -0,0 +1,20 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef TRAFFICLIGHT_QML
+#define TRAFFICLIGHT_QML
+
+#include "statemachine.h"
+
+#include <QtQml/qqml.h>
+#include <QtCore/qobject.h>
+
+struct TrafficLightStateMachineRegistration
+{
+ Q_GADGET
+ QML_FOREIGN(TrafficLightStateMachine)
+ QML_NAMED_ELEMENT(TrafficLightStateMachine)
+ QML_ADDED_IN_VERSION(1, 0)
+};
+
+#endif // TRAFFICLIGHT_QML
diff --git a/examples/scxml/trafficlight-qml-static/Button.qml b/examples/scxml/trafficlight-qml-static/Button.qml
new file mode 100644
index 0000000..1333193
--- /dev/null
+++ b/examples/scxml/trafficlight-qml-static/Button.qml
@@ -0,0 +1,17 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+pragma ComponentBehavior: Bound
+
+import QtQuick
+
+Image {
+ id: button
+ signal clicked
+
+ MouseArea {
+ id: mouse
+ anchors.fill: parent
+ onClicked: button.clicked()
+ }
+}
diff --git a/examples/scxml/trafficlight-qml-static/CMakeLists.txt b/examples/scxml/trafficlight-qml-static/CMakeLists.txt
new file mode 100644
index 0000000..676a482
--- /dev/null
+++ b/examples/scxml/trafficlight-qml-static/CMakeLists.txt
@@ -0,0 +1,87 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(trafficlight-qml-static LANGUAGES CXX)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/scxml/trafficlight-qml-static")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Scxml)
+qt_standard_project_setup(REQUIRES 6.5)
+
+qt_add_executable(trafficlight-qml-static
+ trafficlight-qml-static.cpp
+)
+
+set_target_properties(trafficlight-qml-static PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(trafficlight-qml-static PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Qml
+ Qt6::Scxml
+)
+
+# Statecharts:
+qt6_add_statecharts(trafficlight-qml-static
+ ../trafficlight-common/statemachine.scxml
+)
+
+set_source_files_properties(../trafficlight-common/play.png
+ PROPERTIES QT_RESOURCE_ALIAS "play.png"
+)
+
+set_source_files_properties(../trafficlight-common/play.png
+ PROPERTIES QT_RESOURCE_ALIAS "play.png"
+)
+
+set_source_files_properties(../trafficlight-common/yellow.png
+ PROPERTIES QT_RESOURCE_ALIAS "yellow.png"
+)
+
+set_source_files_properties(../trafficlight-common/red.png
+ PROPERTIES QT_RESOURCE_ALIAS "red.png"
+)
+
+set_source_files_properties(../trafficlight-common/green.png
+ PROPERTIES QT_RESOURCE_ALIAS "green.png"
+)
+
+set_source_files_properties(../trafficlight-common/background.png
+ PROPERTIES QT_RESOURCE_ALIAS "background.png"
+)
+
+set_source_files_properties(../trafficlight-common/pause.png
+ PROPERTIES QT_RESOURCE_ALIAS "pause.png"
+)
+
+qt_add_qml_module(trafficlight-qml-static
+ URI TrafficLightApplication
+ VERSION 1.0
+ QML_FILES
+ MainView.qml
+ Button.qml
+ Lights.ui.qml
+ SOURCES
+ trafficlight-qml.h
+ RESOURCES
+ ../trafficlight-common/play.png
+ ../trafficlight-common/yellow.png
+ ../trafficlight-common/red.png
+ ../trafficlight-common/green.png
+ ../trafficlight-common/background.png
+ ../trafficlight-common/pause.png
+)
+
+install(TARGETS trafficlight-qml-static
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/scxml/trafficlight-qml-static/Lights.ui.qml b/examples/scxml/trafficlight-qml-static/Lights.ui.qml
new file mode 100644
index 0000000..ace9cbc
--- /dev/null
+++ b/examples/scxml/trafficlight-qml-static/Lights.ui.qml
@@ -0,0 +1,77 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+pragma ComponentBehavior: Bound
+
+import QtQuick
+import TrafficLightApplication
+
+Image {
+ id: lights
+
+ property alias button: button
+ property TrafficLightStateMachine stateMachine
+
+ source: "background.png"
+
+ Column {
+ y: 40
+ spacing: 27
+ anchors.horizontalCenter: parent.horizontalCenter
+
+ Image {
+ id: redLight
+ opacity: 0.2
+ source: "red.png"
+ }
+
+ Image {
+ id: yellowLight
+ opacity: 0.2
+ source: "yellow.png"
+ }
+
+ Image {
+ id: greenLight
+ opacity: 0.2
+ source: "green.png"
+ }
+ }
+
+ Button {
+ id: button
+
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ anchors.margins: 20
+ source: "pause.png"
+ }
+
+ states: [
+ State {
+ name: "Red"
+ when: lights.stateMachine.red
+
+ PropertyChanges { redLight.opacity: 1 }
+ },
+ State {
+ name: "RedGoingGreen"
+ when: lights.stateMachine.redGoingGreen
+
+ PropertyChanges { redLight.opacity: 1 }
+ PropertyChanges { yellowLight.opacity: 1 }
+ },
+ State {
+ name: "Yellow"
+ when: lights.stateMachine.yellow || lights.stateMachine.blinking
+
+ PropertyChanges { yellowLight.opacity: 1 }
+ },
+ State {
+ name: "Green"
+ when: lights.stateMachine.green
+
+ PropertyChanges { greenLight.opacity: 1 }
+ }
+ ]
+}
diff --git a/examples/scxml/trafficlight-qml-static/MainView.qml b/examples/scxml/trafficlight-qml-static/MainView.qml
new file mode 100644
index 0000000..d4dce03
--- /dev/null
+++ b/examples/scxml/trafficlight-qml-static/MainView.qml
@@ -0,0 +1,22 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+pragma ComponentBehavior: Bound
+
+import QtQuick
+import TrafficLightApplication
+
+Window {
+ width: lights.width
+ height: lights.height
+ visible: true
+
+ Lights {
+ id: lights
+ stateMachine: TrafficLightStateMachine {
+ running: true
+ }
+ button.source: stateMachine.working ? "pause.png" : "play.png"
+ button.onClicked: stateMachine.submitEvent(stateMachine.working ? "smash" : "repair");
+ }
+}
diff --git a/examples/scxml/trafficlight-qml-static/doc/src/trafficlight-qml-static.qdoc b/examples/scxml/trafficlight-qml-static/doc/src/trafficlight-qml-static.qdoc
index 814f410..17a4fda 100644
--- a/examples/scxml/trafficlight-qml-static/doc/src/trafficlight-qml-static.qdoc
+++ b/examples/scxml/trafficlight-qml-static/doc/src/trafficlight-qml-static.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example trafficlight-qml-static
- \title Qt SCXML Traffic Light QML Example (Static)
+ \title SCXML Traffic Light (Static, QML)
+ \examplecategory {Data Processing & I/O}
\ingroup examples-qtscxml
\brief A Qt Quick application that uses a compiled state machine to
@@ -35,7 +12,7 @@
\image trafficlight.png
- \e{Traffic Light QML Example (Static)} demonstrates how to connect to the
+ \e{Traffic Light} demonstrates how to connect to the
active properties of a state in a state machine that is compiled to a class.
The UI is created using Qt Quick.
@@ -48,7 +25,7 @@
We instantiate the state machine as follows:
- \quotefromfile trafficlight-qml-static/trafficlight-qml-static.qml
+ \quotefromfile trafficlight-qml-static/MainView.qml
\skipto TrafficLight
\printuntil }
@@ -57,7 +34,7 @@
We connect to the states as follows:
- \quotefromfile trafficlight-common/Lights.ui.qml
+ \quotefromfile trafficlight-qml-static/Lights.ui.qml
\skipto states
\printuntil ]
*/
diff --git a/examples/scxml/trafficlight-qml-static/qmldir b/examples/scxml/trafficlight-qml-static/qmldir
new file mode 100644
index 0000000..c375025
--- /dev/null
+++ b/examples/scxml/trafficlight-qml-static/qmldir
@@ -0,0 +1,6 @@
+module TrafficLightApplication
+prefer :/qt/qml/TrafficLightApplication/
+MainView 1.0 MainView.qml
+Button 1.0 Button.qml
+Lights 1.0 Lights.ui.qml
+
diff --git a/examples/scxml/trafficlight-qml-static/trafficlight-qml-static.cpp b/examples/scxml/trafficlight-qml-static/trafficlight-qml-static.cpp
index 30b5950..5b945b7 100644
--- a/examples/scxml/trafficlight-qml-static/trafficlight-qml-static.cpp
+++ b/examples/scxml/trafficlight-qml-static/trafficlight-qml-static.cpp
@@ -1,70 +1,17 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-#include <QGuiApplication>
-#include <QQmlApplicationEngine>
-#include <QQmlContext>
-
-#include "statemachine.h"
+#include <QtGui/qguiapplication.h>
+#include <QtQml/qqmlapplicationengine.h>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
- qmlRegisterType<TrafficLightStateMachine>("TrafficLightStateMachine", 1, 0, "TrafficLightStateMachine");
-
QQmlApplicationEngine engine;
- engine.load(QUrl(QStringLiteral("qrc:/trafficlight-qml-static.qml")));
- if (engine.rootObjects().isEmpty())
- return -1;
+ QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed, &app,
+ [](){ QCoreApplication::exit(EXIT_FAILURE); }, Qt::QueuedConnection);
+ engine.loadFromModule("TrafficLightApplication", "MainView");
return app.exec();
}
-
diff --git a/examples/scxml/trafficlight-qml-static/trafficlight-qml-static.pro b/examples/scxml/trafficlight-qml-static/trafficlight-qml-static.pro
index e5dd64c..2cc86aa 100644
--- a/examples/scxml/trafficlight-qml-static/trafficlight-qml-static.pro
+++ b/examples/scxml/trafficlight-qml-static/trafficlight-qml-static.pro
@@ -1,14 +1,34 @@
TEMPLATE = app
QT += qml scxml
+
CONFIG += c++11
+CONFIG += qmltypes
SOURCES += trafficlight-qml-static.cpp
-RESOURCES += trafficlight-qml-static.qrc
+HEADERS += trafficlight-qml.h
STATECHARTS = ../trafficlight-common/statemachine.scxml
+QML_IMPORT_NAME = TrafficLightApplication
+QML_IMPORT_MAJOR_VERSION = 1
+
+qml_resources.files = \
+ qmldir \
+ MainView.qml \
+ Button.qml \
+ Lights.ui.qml \
+ ../trafficlight-common/play.png \
+ ../trafficlight-common/yellow.png \
+ ../trafficlight-common/red.png \
+ ../trafficlight-common/green.png \
+ ../trafficlight-common/background.png \
+ ../trafficlight-common/pause.png \
+
+qml_resources.prefix = /qt/qml/TrafficLightApplication
+
+RESOURCES += qml_resources
+
target.path = $$[QT_INSTALL_EXAMPLES]/scxml/trafficlight-qml-static
INSTALLS += target
-
diff --git a/examples/scxml/trafficlight-qml-static/trafficlight-qml-static.qml b/examples/scxml/trafficlight-qml-static/trafficlight-qml-static.qml
deleted file mode 100644
index e0bd89d..0000000
--- a/examples/scxml/trafficlight-qml-static/trafficlight-qml-static.qml
+++ /dev/null
@@ -1,57 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import TrafficLightStateMachine 1.0
-
-TrafficLight {
- stateMachine: TrafficLightStateMachine {
- running: true
- }
-}
diff --git a/examples/scxml/trafficlight-qml-static/trafficlight-qml-static.qrc b/examples/scxml/trafficlight-qml-static/trafficlight-qml-static.qrc
deleted file mode 100644
index 890b4a7..0000000
--- a/examples/scxml/trafficlight-qml-static/trafficlight-qml-static.qrc
+++ /dev/null
@@ -1,14 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>trafficlight-qml-static.qml</file>
- <file alias="TrafficLight.qml">../trafficlight-common/TrafficLight.qml</file>
- <file alias="Button.qml">../trafficlight-common/Button.qml</file>
- <file alias="Lights.ui.qml">../trafficlight-common/Lights.ui.qml</file>
- <file alias="green.png">../trafficlight-common/green.png</file>
- <file alias="yellow.png">../trafficlight-common/yellow.png</file>
- <file alias="red.png">../trafficlight-common/red.png</file>
- <file alias="pause.png">../trafficlight-common/pause.png</file>
- <file alias="play.png">../trafficlight-common/play.png</file>
- <file alias="background.png">../trafficlight-common/background.png</file>
- </qresource>
-</RCC>
diff --git a/examples/scxml/trafficlight-qml-static/trafficlight-qml.h b/examples/scxml/trafficlight-qml-static/trafficlight-qml.h
new file mode 100644
index 0000000..ac309bd
--- /dev/null
+++ b/examples/scxml/trafficlight-qml-static/trafficlight-qml.h
@@ -0,0 +1,20 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef TRAFFICLIGHT_QML
+#define TRAFFICLIGHT_QML
+
+#include "statemachine.h"
+
+#include <QtQml/qqml.h>
+#include <QtCore/qobject.h>
+
+struct TrafficLightStateMachineRegistration
+{
+ Q_GADGET
+ QML_FOREIGN(TrafficLightStateMachine)
+ QML_NAMED_ELEMENT(TrafficLightStateMachine)
+ QML_ADDED_IN_VERSION(1, 0)
+};
+
+#endif // TRAFFICLIGHT_QML
diff --git a/examples/scxml/trafficlight-widgets-dynamic/CMakeLists.txt b/examples/scxml/trafficlight-widgets-dynamic/CMakeLists.txt
new file mode 100644
index 0000000..022e2a3
--- /dev/null
+++ b/examples/scxml/trafficlight-widgets-dynamic/CMakeLists.txt
@@ -0,0 +1,84 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(trafficlight-widgets-dynamic LANGUAGES CXX)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/scxml/trafficlight-widgets-dynamic")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Scxml Widgets)
+
+qt_standard_project_setup()
+
+qt_add_executable(trafficlight-widgets-dynamic
+ ../trafficlight-common/trafficlight.cpp ../trafficlight-common/trafficlight.h
+ trafficlight-widgets-dynamic.cpp
+)
+
+set_target_properties(trafficlight-widgets-dynamic PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(trafficlight-widgets-dynamic PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Scxml
+ Qt6::Widgets
+)
+
+# Resources:
+set_source_files_properties("../trafficlight-common/background.png"
+ PROPERTIES QT_RESOURCE_ALIAS "background.png"
+)
+
+set_source_files_properties("../trafficlight-common/green.png"
+ PROPERTIES QT_RESOURCE_ALIAS "green.png"
+)
+
+set_source_files_properties("../trafficlight-common/pause.png"
+ PROPERTIES QT_RESOURCE_ALIAS "pause.png"
+)
+
+set_source_files_properties("../trafficlight-common/play.png"
+ PROPERTIES QT_RESOURCE_ALIAS "play.png"
+)
+
+set_source_files_properties("../trafficlight-common/red.png"
+ PROPERTIES QT_RESOURCE_ALIAS "red.png"
+)
+
+set_source_files_properties("../trafficlight-common/statemachine.scxml"
+ PROPERTIES QT_RESOURCE_ALIAS "statemachine.scxml"
+)
+
+set_source_files_properties("../trafficlight-common/yellow.png"
+ PROPERTIES QT_RESOURCE_ALIAS "yellow.png"
+)
+
+set(trafficlight-widgets-dynamic_resource_files
+ "../trafficlight-common/background.png"
+ "../trafficlight-common/green.png"
+ "../trafficlight-common/pause.png"
+ "../trafficlight-common/play.png"
+ "../trafficlight-common/red.png"
+ "../trafficlight-common/statemachine.scxml"
+ "../trafficlight-common/yellow.png"
+)
+
+qt6_add_resources(trafficlight-widgets-dynamic "trafficlight-widgets-dynamic"
+ PREFIX
+ "/"
+ FILES
+ ${trafficlight-widgets-dynamic_resource_files}
+)
+
+install(TARGETS trafficlight-widgets-dynamic
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/scxml/trafficlight-widgets-dynamic/doc/src/trafficlight-widgets-dynamic.qdoc b/examples/scxml/trafficlight-widgets-dynamic/doc/src/trafficlight-widgets-dynamic.qdoc
index de37ae0..45f9733 100644
--- a/examples/scxml/trafficlight-widgets-dynamic/doc/src/trafficlight-widgets-dynamic.qdoc
+++ b/examples/scxml/trafficlight-widgets-dynamic/doc/src/trafficlight-widgets-dynamic.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example trafficlight-widgets-dynamic
- \title Qt SCXML Traffic Light Example (Dynamic)
+ \title SCXML Traffic Light (Dynamic, Widgets)
+ \examplecategory {Data Processing & I/O}
\ingroup examples-qtscxml
\brief A widget-based application that uses a dynamically loaded state
@@ -35,7 +12,7 @@
\image trafficlight.png
- \e{Traffic Light Example (Dynamic)} demonstrates how to connect to the
+ \e{Traffic Light} demonstrates how to connect to the
active properties of a state in a dynamically loaded state machine.
The UI is created using Qt Widgets.
@@ -44,13 +21,21 @@
\section1 Dynamically Loading the State Machine
- We link against the Qt SCXML module by adding the following line to the
- example \e .pro file:
+ We link against the Qt SCXML module by adding the following lines to the
+ example's build files.
+ To \e .pro when using qmake:
\quotefromfile trafficlight-widgets-dynamic/trafficlight-widgets-dynamic.pro
\skipto QT
\printline scxml
+ To \e CMakeLists.txt when using cmake:
+ \quotefromfile trafficlight-widgets-dynamic/CMakeLists.txt
+ \skipto find_package
+ \printline Scxml
+ \skipto target_link_libraries
+ \printuntil )
+
We dynamically create the state machine in
\e trafficlight-widgets-dynamic.cpp:
diff --git a/examples/scxml/trafficlight-widgets-dynamic/trafficlight-widgets-dynamic.cpp b/examples/scxml/trafficlight-widgets-dynamic/trafficlight-widgets-dynamic.cpp
index 10f52dc..fbd02dd 100644
--- a/examples/scxml/trafficlight-widgets-dynamic/trafficlight-widgets-dynamic.cpp
+++ b/examples/scxml/trafficlight-widgets-dynamic/trafficlight-widgets-dynamic.cpp
@@ -1,71 +1,26 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "../trafficlight-common/trafficlight.h"
-#include <QApplication>
-#include <QTextStream>
+#include <QtWidgets/qapplication.h>
+#include <QtCore/qiodevice.h>
+#include <QtCore/qtextstream.h>
+
+using namespace Qt::Literals::StringLiterals;
int main(int argc, char **argv)
{
QApplication app(argc, argv);
- QScxmlStateMachine *machine = QScxmlStateMachine::fromFile(
- QStringLiteral(":statemachine.scxml"));
+ QScxmlStateMachine *machine = QScxmlStateMachine::fromFile(u":statemachine.scxml"_s);
+
if (!machine->parseErrors().isEmpty()) {
QTextStream errs(stderr, QIODevice::WriteOnly);
const auto errors = machine->parseErrors();
for (const QScxmlError &error : errors) {
errs << error.toString();
}
-
return -1;
}
diff --git a/examples/scxml/trafficlight-widgets-static/CMakeLists.txt b/examples/scxml/trafficlight-widgets-static/CMakeLists.txt
new file mode 100644
index 0000000..a133229
--- /dev/null
+++ b/examples/scxml/trafficlight-widgets-static/CMakeLists.txt
@@ -0,0 +1,84 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(trafficlight-widgets-static LANGUAGES CXX)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/scxml/trafficlight-widgets-static")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Scxml Widgets)
+
+qt_standard_project_setup()
+
+qt_add_executable(trafficlight-widgets-static
+ ../trafficlight-common/trafficlight.cpp ../trafficlight-common/trafficlight.h
+ trafficlight-widgets-static.cpp
+)
+
+set_target_properties(trafficlight-widgets-static PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(trafficlight-widgets-static PRIVATE
+ Qt::Core
+ Qt::Gui
+ Qt::Scxml
+ Qt::Widgets
+)
+
+# Resources:
+set_source_files_properties("../trafficlight-common/background.png"
+ PROPERTIES QT_RESOURCE_ALIAS "background.png"
+)
+
+set_source_files_properties("../trafficlight-common/green.png"
+ PROPERTIES QT_RESOURCE_ALIAS "green.png"
+)
+
+set_source_files_properties("../trafficlight-common/pause.png"
+ PROPERTIES QT_RESOURCE_ALIAS "pause.png"
+)
+
+set_source_files_properties("../trafficlight-common/play.png"
+ PROPERTIES QT_RESOURCE_ALIAS "play.png"
+)
+
+set_source_files_properties("../trafficlight-common/red.png"
+ PROPERTIES QT_RESOURCE_ALIAS "red.png"
+)
+
+set_source_files_properties("../trafficlight-common/yellow.png"
+ PROPERTIES QT_RESOURCE_ALIAS "yellow.png"
+)
+
+set(trafficlight-widgets-static_resource_files
+ "../trafficlight-common/background.png"
+ "../trafficlight-common/green.png"
+ "../trafficlight-common/pause.png"
+ "../trafficlight-common/play.png"
+ "../trafficlight-common/red.png"
+ "../trafficlight-common/yellow.png"
+)
+
+qt6_add_resources(trafficlight-widgets-static "trafficlight-widgets-static"
+ PREFIX
+ "/"
+ FILES
+ ${trafficlight-widgets-static_resource_files}
+)
+
+# Statecharts:
+qt6_add_statecharts(trafficlight-widgets-static
+ ../trafficlight-common/statemachine.scxml
+)
+
+install(TARGETS trafficlight-widgets-static
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/scxml/trafficlight-widgets-static/doc/src/trafficlight-widgets-static.qdoc b/examples/scxml/trafficlight-widgets-static/doc/src/trafficlight-widgets-static.qdoc
index a807f22..a79da0f 100644
--- a/examples/scxml/trafficlight-widgets-static/doc/src/trafficlight-widgets-static.qdoc
+++ b/examples/scxml/trafficlight-widgets-static/doc/src/trafficlight-widgets-static.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example trafficlight-widgets-static
- \title Qt SCXML Traffic Light Example (Static)
+ \title SCXML Traffic Light (Static, Widgets)
+ \examplecategory {Data Processing & I/O}
\ingroup examples-qtscxml
\brief A widget-based application that uses a compiled state machine to
diff --git a/examples/scxml/trafficlight-widgets-static/trafficlight-widgets-static.cpp b/examples/scxml/trafficlight-widgets-static/trafficlight-widgets-static.cpp
index 67b5018..905a3c9 100644
--- a/examples/scxml/trafficlight-widgets-static/trafficlight-widgets-static.cpp
+++ b/examples/scxml/trafficlight-widgets-static/trafficlight-widgets-static.cpp
@@ -1,57 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtScxml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "statemachine.h"
#include "../trafficlight-common/trafficlight.h"
-#include <QApplication>
+#include <QtWidgets/qapplication.h>
int main(int argc, char **argv)
{
diff --git a/examples/statemachine/CMakeLists.txt b/examples/statemachine/CMakeLists.txt
new file mode 100644
index 0000000..1e5c452
--- /dev/null
+++ b/examples/statemachine/CMakeLists.txt
@@ -0,0 +1,13 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+if(NOT ANDROID)
+ qt_internal_add_example(pingpong)
+endif()
+if(TARGET Qt::Widgets)
+ qt_internal_add_example(rogue)
+ qt_internal_add_example(trafficlight)
+ if(QT_FEATURE_animation)
+ qt_internal_add_example(moveblocks)
+ endif()
+endif()
diff --git a/examples/statemachine/doc/images/pingpong-example.png b/examples/statemachine/doc/images/pingpong-example.png
new file mode 100644
index 0000000..af707e4
--- /dev/null
+++ b/examples/statemachine/doc/images/pingpong-example.png
Binary files differ
diff --git a/examples/statemachine/doc/images/trafficlight-example1.png b/examples/statemachine/doc/images/trafficlight-example1.png
new file mode 100644
index 0000000..ec8c7ff
--- /dev/null
+++ b/examples/statemachine/doc/images/trafficlight-example1.png
Binary files differ
diff --git a/examples/statemachine/doc/images/trafficlight-example2.png b/examples/statemachine/doc/images/trafficlight-example2.png
new file mode 100644
index 0000000..a12e4db
--- /dev/null
+++ b/examples/statemachine/doc/images/trafficlight-example2.png
Binary files differ
diff --git a/examples/statemachine/doc/src/moveblocks.qdoc b/examples/statemachine/doc/src/moveblocks.qdoc
new file mode 100644
index 0000000..d8645bb
--- /dev/null
+++ b/examples/statemachine/doc/src/moveblocks.qdoc
@@ -0,0 +1,192 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example moveblocks
+ \title Move Blocks
+ \ingroup examples-qtstatemachine
+ \examplecategory {Data Processing & I/O}
+
+ \brief The Move Blocks example shows how to animate items in a
+ QGraphicsScene using a QStateMachine with a custom transition.
+
+ \image moveblocks-example.png
+
+ The example animates the blue blocks that you can see in the image
+ above. The animation moves the blocks between four preset positions.
+
+ The example consists of the following classes:
+
+ \list
+ \li \c StateSwitcher inherits QState and can add
+ \c {StateSwitchTransition}s to other states.
+ When entered, it will randomly transition to one of these
+ states.
+ \li \c StateSwitchTransition is a custom transition that
+ triggers on \c{StateSwitchEvent}s.
+ \li \c StateSwitchEvent is a QEvent that triggers \c{StateSwitchTransition}s.
+ \li \c QGraphicsRectWidget is a QGraphicsWidget that simply
+ paints its background in a solid \l{Qt::}{blue} color.
+ \endlist
+
+ The blocks are instances of \c QGraphicsRectWidget and are
+ animated in a QGraphicsScene. We do this by building a state
+ graph, which we insert animations into. The graph is then executed
+ in a QStateMachine. All this is done in \c main().
+ Let's look at the \c main() function first.
+
+ \section1 The \c main() Function
+
+ After QApplication has been initialized, we set up the
+ QGraphicsScene with its \c{QGraphicsRectWidget}s.
+
+ \snippet moveblocks/main.cpp 1
+
+ After adding the scene to a QGraphicsView, it is time to build the
+ state graph. Let's first look at a statechart of what we are
+ trying to build.
+
+ \image move-blocks-chart.png
+
+ Note that the \c group has seven sub states, but we have only
+ included three of them in the diagram. The code that builds this
+ graph will be examined line-by-line, and will show how the graph
+ works. First off, we construct the \c group state:
+
+ \snippet moveblocks/main.cpp 2
+
+ The timer is used to add a delay between each time the blocks are
+ moved. The timer is started when \c group is entered. As we will
+ see later, \c group has a transition back to the \c StateSwitcher
+ when the timer times out. \c group is the initial state in the
+ machine, so an animation will be scheduled when the example is
+ started.
+
+ \snippet moveblocks/main.cpp 3
+ \dots
+ \snippet moveblocks/main.cpp 4
+
+ \c createGeometryState() returns a QState that will set the
+ geometry of our items upon entry. It also assigns \c group as the
+ parent of this state.
+
+ A QPropertyAnimation inserted into a transition will use the
+ values assigned to a QState (with QState::assignProperty()), i.e.,
+ the animation will interpolate between the current values of the
+ properties and the values in the target state. We add animated
+ transitions to the state graph later.
+
+ \snippet moveblocks/main.cpp 5
+
+ We move the items in parallel. Each item is added to \c
+ animationGroup, which is the animation that is inserted into the
+ transitions.
+
+ \snippet moveblocks/main.cpp 6
+
+ The sequential animation group, \c subGroup, helps us insert a
+ delay between the animation of each item.
+
+ \snippet moveblocks/main.cpp 7
+ \dots
+ \snippet moveblocks/main.cpp 8
+
+ A StateSwitchTransition is added to the state switcher
+ in \c StateSwitcher::addState(). We also add the animation in this
+ function. Since QPropertyAnimation uses the values from the
+ states, we can insert the same QPropertyAnimation instance in all
+ \c {StateSwitchTransition}s.
+
+ As mentioned previously, we add a transition to the state switcher
+ that triggers when the timer times out.
+
+ \snippet moveblocks/main.cpp 9
+
+ Finally, we can create the state machine, add our initial state,
+ and start execution of the state graph.
+
+ \section2 The \c createGeometryState() Function
+
+ In \c createGeometryState(), we set up the geometry for each
+ graphics item.
+
+ \snippet moveblocks/main.cpp 13
+
+ As mentioned before, QAbstractTransition will set up an animation
+ added with \l [CPP] {QAbstractTransition::}{addAnimation()} using
+ property values set with \l{QState::}{assignProperty()}.
+
+ \section1 The StateSwitcher Class
+
+ \c StateSwitcher has state switch transitions to each \l{QState}s
+ we created with \c createGeometryState(). Its job is to transition
+ to one of these states at random when it is entered.
+
+ All functions in \c StateSwitcher are inlined. We'll step through
+ its definition.
+
+ \snippet moveblocks/main.cpp 10
+
+ \c StateSwitcher is a state designed for a particular purpose and
+ will always be a top-level state. We use \c m_stateCount to keep
+ track of how many states we are managing, and \c m_lastIndex to
+ remember which state was the last state to which we transitioned.
+
+ \snippet moveblocks/main.cpp 11
+
+ We select the next state we are going to transition to, and post a
+ \c StateSwitchEvent, which we know will trigger the \c
+ StateSwitchTransition to the selected state.
+
+ \snippet moveblocks/main.cpp 12
+
+ This is where the magic happens. We assign a number to each state
+ added. This number is given to both a StateSwitchTransition and to
+ StateSwitchEvents. As we have seen, state switch events will
+ trigger a transition with the same number.
+
+ \section1 The StateSwitchTransition Class
+
+ \c StateSwitchTransition inherits QAbstractTransition and triggers
+ on \c{StateSwitchEvent}s. It contains only inline functions, so
+ let's take a look at its \l [CPP] {QAbstractTransition::}{eventTest()}
+ function, which is the only function that we define..
+
+ \snippet moveblocks/main.cpp 14
+
+ \c eventTest is called by QStateMachine when it checks whether a
+ transition should be triggered--a return value of true means that
+ it will. We simply check if our assigned number is equal to the
+ event's number (in which case we fire away).
+
+ \section1 The StateSwitchEvent Class
+
+ \c StateSwitchEvent inherits QEvent, and holds a number that has
+ been assigned to a state and state switch transition by
+ \c StateSwitcher. We have already seen how it is used to trigger
+ \c{StateSwitchTransition}s in \c StateSwitcher.
+
+ \snippet moveblocks/main.cpp 15
+
+ We only have inlined functions in this class, so a look at its
+ definition will do.
+
+ \section1 The QGraphicsRectWidget Class
+
+ QGraphicsRectWidget inherits QGraphicsWidget and simply paints its
+ \l{QWidget::}{rect()} blue. We inline \l{QWidget::}{paintEvent()},
+ which is the only function we define. Here is the
+ QGraphicsRectWidget class definition:
+
+ \snippet moveblocks/main.cpp 16
+
+ \section1 Moving On
+
+ The technique shown in this example works equally well for all
+ \l{QPropertyAnimation}s. As long as the value to be animated is a
+ Qt property, you can insert an animation of it into a state graph.
+
+ QState::addAnimation() takes a QAbstractAnimation, so any type
+ of animation can be inserted into the graph.
+*/
+
diff --git a/examples/statemachine/doc/src/pingpong.qdoc b/examples/statemachine/doc/src/pingpong.qdoc
new file mode 100644
index 0000000..71cfb2e
--- /dev/null
+++ b/examples/statemachine/doc/src/pingpong.qdoc
@@ -0,0 +1,68 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example pingpong
+ \title Ping Pong States
+ \ingroup examples-qtstatemachine
+ \examplecategory {Data Processing & I/O}
+
+ \brief The Ping Pong States example shows how to use parallel states together
+ with custom events and transitions in \l{Qt State Machine Overview}{Qt State Machine Framework}.
+
+ This example implements a statechart where two states communicate by
+ posting events to the state machine. The state chart looks as follows:
+
+ \image pingpong-example.png
+
+ The \c pinger and \c ponger states are parallel states, i.e. they are
+ entered simultaneously and will take transitions independently of
+ each other.
+
+ The \c pinger state will post the first \c ping event upon entry; the \c
+ ponger state will respond by posting a \c pong event; this will cause the
+ \c pinger state to post a new \c ping event; and so on.
+
+ \snippet pingpong/main.cpp 0
+
+ Two custom events are defined, \c PingEvent and \c PongEvent.
+
+ \snippet pingpong/main.cpp 1
+
+ The \c Pinger class defines a state that posts a \c PingEvent to the state
+ machine when the state is entered.
+
+ \snippet pingpong/main.cpp 2
+
+ The \c PingTransition class defines a transition that is triggered by
+ events of type \c PingEvent, and that posts a \c PongEvent (with a delay
+ of 500 milliseconds) to the state machine when the transition is
+ triggered.
+
+ \snippet pingpong/main.cpp 3
+
+ The \c PongTransition class defines a transition that is triggered by
+ events of type \c PongEvent, and that posts a \c PingEvent (with a delay
+ of 500 milliseconds) to the state machine when the transition is
+ triggered.
+
+ \snippet pingpong/main.cpp 4
+
+ The main() function begins by creating a state machine and a parallel
+ state group.
+
+ \snippet pingpong/main.cpp 5
+
+ Next, the \c pinger and \c ponger states are created, with the parallel
+ state group as their parent state. Note that the transitions are \e
+ targetless. When such a transition is triggered, the source state won't be
+ exited and re-entered; only the transition's onTransition() function will
+ be called, and the state machine's configuration will remain the same,
+ which is precisely what we want in this case.
+
+ \snippet pingpong/main.cpp 6
+
+ Finally, the group is added to the state machine, the machine is started,
+ and the application event loop is entered.
+
+ */
diff --git a/examples/statemachine/doc/src/rogue.qdoc b/examples/statemachine/doc/src/rogue.qdoc
new file mode 100644
index 0000000..be1a7e1
--- /dev/null
+++ b/examples/statemachine/doc/src/rogue.qdoc
@@ -0,0 +1,185 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example rogue
+ \title Rogue
+ \ingroup examples-qtstatemachine
+ \examplecategory {Data Processing & I/O}
+
+ \brief The Rogue example shows how to use the Qt state machine for event
+ handling.
+
+ \image rogue-example.png
+
+ This example implements a simple text based game. Do you see the
+ \c{@} in the screenshot? That's you, the rogue. The \c{#}
+ characters are walls, and the dots represent floor. In a real
+ game, other ASCII characters would represent all kinds of objects
+ and creatures, for instance, ancient dragons (\c{D}s) or food
+ rations (\c{%}s). But let's not get carried away. In this game,
+ the rogue is simply running around in an empty room.
+
+ The rogue is moved with the keypad (2, 4, 8, 6). That aside, we
+ have implemented a \c quit command that triggers if the player
+ types \c {q}. The player is then asked if he/she really wants to
+ quit.
+
+ Most games have commands that need more than one key press (we
+ think of consecutive presses, i.e., not of several keys being
+ pressed at the same time). In this game, only the \c quit command
+ falls under this category, but for the sake of argument, let's
+ imagine a fully-fledged game with a rich set of commands. If we
+ were to implement these by catching key events in
+ \l{QWidget::}{keyPressEvent()}, we would have to keep a lot of
+ class member variables to track the sequence of keys already typed
+ (or find some other way of deducing the current state of a
+ command). This can easily lead to spaghetti, which is--as we all
+ well know, I'm sure--unpleasant. With a state machine, on the
+ other hand, separate states can wait for a single key press, and
+ that makes our lives a lot simpler.
+
+ The example consists of two classes:
+
+ \list
+ \li \c Window draws the text display of the game and sets
+ up the state machine. The window also has a status bar
+ above the area in which the rouge moves.
+ \li \c MovementTransition is a transition that carries out
+ a single move of the rogue.
+ \endlist
+
+ Before we embark on a code walkthrough, it is necessary to take a
+ closer look at the design of the machine. Here is a state chart
+ that shows what we want to achieve:
+
+ \image rogue-statechart.png
+
+ The input state waits for a key press to start a new command.
+ When receiving a key it recognizes, it transitions to one of the
+ two commands of the game; though, as we will see, movement is
+ handled by the transition itself. The quit state waits for the
+ player to answer yes or no (by typing \c y or \c n) when asked
+ whether he/she really wants to quit the game.
+
+ The chart demonstrates how we use one state to wait for a single
+ key press. The press received may trigger one of the transitions
+ connected to the state.
+
+ \section1 Window Class Definition
+
+ The \c Window class is a widget that draws the text display of the
+ game. It also sets up the state machine, i.e., creates and
+ connects the states in the machine. It is the key events from this
+ widget that are used by the machine.
+
+ \snippet rogue/window.h 0
+
+ \c Direction specifies the direction in which the rogue is to
+ move. We use this in \c movePlayer(), which moves the rogue and
+ repaints the window. The game has a status line above the area in
+ which the rogue moves. The \c status property contains the text of
+ this line. We use a property because the QState class allows
+ setting any Qt \l{Qt's Property System}{property} when entered.
+ More on this later.
+
+ \snippet rogue/window.h 1
+
+ The \c map is an array with the characters that are currently
+ displayed. We set up the array in \c setupMap(), and update it
+ when the rogue is moved. \c pX and \c pY is the current position
+ of the rogue, initially set to (5, 5). \c WIDTH and \c HEIGHT are
+ constants specifying the dimensions of the map.
+
+ The \c paintEvent() function is left out of this walkthrough. We
+ also do not discuss other code that does not concern the state
+ machine (the \c setupMap(), \c status(), \c setStatus(), \c
+ movePlayer(), and \c sizeHint() functions). If you wish to take a
+ look at the code, click on the link for the \c window.cpp file at
+ the top of this page.
+
+ \section1 Window Class Implementation
+
+ Here is the constructor of \c Window:
+
+ \snippet rogue/window.cpp 0
+ \dots
+ \snippet rogue/window.cpp 1
+
+ Here we set up the map and statemachine. Let's proceed with the
+ \c buildMachine() function:
+
+ \snippet rogue/window.cpp 2
+
+ We enter \c inputState when the machine is started and from the \c
+ quitState if the user wants to continue playing. We then set the
+ status to a helpful reminder of how to play the game.
+
+ First, the \c Movement transition is added to the input state.
+ This will enable the rogue to be moved with the keypad. Notice
+ that we don't set a target state for the movement transition. This
+ will cause the transition to be triggered (and the
+ \l [CPP] {QAbstractTransition::}{onTransition()} function to be invoked),
+ but the machine will not leave the \c inputState. If we had set \c
+ inputState as the target state, we would first have left and then
+ entered the \c inputState again.
+
+ \snippet rogue/window.cpp 3
+
+ When we enter \c quitState, we update the status bar of the
+ window.
+
+ \c QKeyEventTransition is a utility class that removes the hassle
+ of implementing transitions for \l{QKeyEvent}s. We simply need to
+ specify the key on which the transition should trigger and the
+ target state of the transition.
+
+ \snippet rogue/window.cpp 4
+
+ The transition from \c inputState allows triggering the quit state
+ when the player types \c {q}.
+
+ \snippet rogue/window.cpp 5
+
+ The machine is set up, so it's time to start it.
+
+ \section1 The MovementTransition Class
+
+ \c MovementTransition is triggered when the player request the
+ rogue to be moved (by typing 2, 4, 6, or 8) when the machine is in
+ the \c inputState.
+
+ \snippet rogue/movementtransition.h 0
+
+ In the constructor, we tell QEventTransition to only send
+ \l{QEvent::}{KeyPress} events to the
+ \l [CPP] {QAbstractTransition::}{eventTest()} function:
+
+ \snippet rogue/movementtransition.h 1
+
+ The KeyPress events come wrapped in \l{QStateMachine::WrappedEvent}s. \c event
+ must be confirmed to be a wrapped event because Qt uses other
+ events internally. After that, it is simply a matter of checking
+ which key has been pressed.
+
+ Let's move on to the \c onTransition() function:
+
+ \snippet rogue/movementtransition.h 2
+
+ When \c onTransition() is invoked, we know that we have a
+ \l{QEvent::}{KeyPress} event with 2, 4, 6, or 8, and can ask \c
+ Window to move the player.
+
+ \section1 The Roguelike Tradition
+
+ You might have been wondering why the game features a rogue. Well,
+ these kinds of text based dungeon exploration games date back to a
+ game called, yes, "Rogue". Although outflanked by the technology
+ of modern 3D computer games, roguelikes have a solid community of
+ hard-core, devoted followers.
+
+ Playing these games can be surprisingly addictive (despite the
+ lack of graphics). Angband, the perhaps most well-known rougelike,
+ is found here: \l{http://rephial.org/}.
+*/
+
diff --git a/examples/statemachine/doc/src/trafficlight.qdoc b/examples/statemachine/doc/src/trafficlight.qdoc
new file mode 100644
index 0000000..cb5cfd1
--- /dev/null
+++ b/examples/statemachine/doc/src/trafficlight.qdoc
@@ -0,0 +1,57 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example trafficlight
+ \title Traffic Light
+ \ingroup examples-qtstatemachine
+ \examplecategory {Data Processing & I/O}
+
+ \brief The Traffic Light example shows how to use \l{Qt State Machine Overview}
+ to implement the control flow of a traffic light.
+
+ \image trafficlight-example.png
+
+ In this example we write a TrafficLightWidget class. The traffic light has
+ three lights: Red, yellow and green. The traffic light transitions from
+ one light to another (red to yellow to green to yellow to red again) at
+ certain intervals.
+
+ \snippet trafficlight/main.cpp 0
+
+ The LightWidget class represents a single light of the traffic light. It
+ provides an \c on property and two slots, turnOn() and turnOff(), to turn
+ the light on and off, respectively. The widget paints itself in the color
+ that's passed to the constructor.
+
+ \snippet trafficlight/main.cpp 1
+
+ The TrafficLightWidget class represents the visual part of the traffic
+ light; it's a widget that contains three lights arranged vertically, and
+ provides accessor functions for these.
+
+ \snippet trafficlight/main.cpp 2
+
+ The createLightState() function creates a state that turns a light on when
+ the state is entered, and off when the state is exited. The state uses a
+ timer, and as we shall see the timeout is used to transition from one
+ LightState to another. Here is the statechart for the light state:
+
+ \image trafficlight-example1.png
+
+ \snippet trafficlight/main.cpp 3
+
+ The TrafficLight class combines the TrafficLightWidget with a state
+ machine. The state graph has four states: red-to-yellow, yellow-to-green,
+ green-to-yellow and yellow-to-red. The initial state is red-to-yellow;
+ when the state's timer times out, the state machine transitions to
+ yellow-to-green. The same process repeats through the other states.
+ This is what the statechart looks like:
+
+ \image trafficlight-example2.png
+
+ \snippet trafficlight/main.cpp 4
+
+ The main() function constructs a TrafficLight and shows it.
+
+*/
diff --git a/examples/statemachine/moveblocks/CMakeLists.txt b/examples/statemachine/moveblocks/CMakeLists.txt
new file mode 100644
index 0000000..1832dce
--- /dev/null
+++ b/examples/statemachine/moveblocks/CMakeLists.txt
@@ -0,0 +1,37 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(moveblocks LANGUAGES CXX)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/animation/moveblocks")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui StateMachine Widgets)
+
+qt_standard_project_setup()
+
+qt_add_executable(moveblocks
+ main.cpp
+)
+
+set_target_properties(moveblocks PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(moveblocks PRIVATE
+ Qt::Core
+ Qt::Gui
+ Qt::StateMachine
+ Qt::Widgets
+)
+
+install(TARGETS moveblocks
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/statemachine/moveblocks/main.cpp b/examples/statemachine/moveblocks/main.cpp
new file mode 100644
index 0000000..294cda6
--- /dev/null
+++ b/examples/statemachine/moveblocks/main.cpp
@@ -0,0 +1,267 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QtCore/QEvent>
+#include <QtCore/QParallelAnimationGroup>
+#include <QtCore/QPropertyAnimation>
+#include <QtCore/QRandomGenerator>
+#include <QtCore/QSequentialAnimationGroup>
+#include <QtCore/QTimer>
+#include <QtGui/QPainter>
+#include <QtStateMachine/QAbstractTransition>
+#include <QtStateMachine/QState>
+#include <QtStateMachine/QStateMachine>
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QGraphicsView>
+#include <QtWidgets/QGraphicsWidget>
+
+//![15]
+class StateSwitchEvent: public QEvent
+{
+public:
+ explicit StateSwitchEvent(int rand) : QEvent(StateSwitchType), m_rand(rand) { }
+
+ static constexpr QEvent::Type StateSwitchType = QEvent::Type(QEvent::User + 256);
+
+ int rand() const { return m_rand; }
+
+private:
+ int m_rand;
+};
+//![15]
+
+//![16]
+class QGraphicsRectWidget : public QGraphicsWidget
+{
+public:
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override
+ {
+ painter->fillRect(rect(), Qt::blue);
+ }
+};
+//![16]
+
+class StateSwitchTransition: public QAbstractTransition
+{
+public:
+ explicit StateSwitchTransition(int rand) : QAbstractTransition(), m_rand(rand) { }
+
+protected:
+//![14]
+ bool eventTest(QEvent *event) override
+ {
+ return (event->type() == QEvent::Type(StateSwitchEvent::StateSwitchType))
+ && (static_cast<StateSwitchEvent *>(event)->rand() == m_rand);
+ }
+//![14]
+
+ void onTransition(QEvent *) override {}
+
+private:
+ int m_rand;
+};
+
+//![10]
+class StateSwitcher : public QState
+{
+ Q_OBJECT
+public:
+ explicit StateSwitcher(QStateMachine *machine) : QState(machine) { }
+//![10]
+
+//![11]
+ void onEntry(QEvent *) override
+ {
+ int n;
+ while ((n = QRandomGenerator::global()->bounded(m_stateCount) + 1) == m_lastIndex)
+ { }
+ m_lastIndex = n;
+ machine()->postEvent(new StateSwitchEvent(n));
+ }
+ void onExit(QEvent *) override {}
+//![11]
+
+//![12]
+ void addState(QState *state, QAbstractAnimation *animation) {
+ auto trans = new StateSwitchTransition(++m_stateCount);
+ trans->setTargetState(state);
+ addTransition(trans);
+ trans->addAnimation(animation);
+ }
+//![12]
+
+private:
+ int m_stateCount = 0;
+ int m_lastIndex = 0;
+};
+
+//![13]
+static QState *createGeometryState(QObject *w1, const QRect &rect1, QObject *w2, const QRect &rect2,
+ QObject *w3, const QRect &rect3, QObject *w4, const QRect &rect4,
+ QState *parent)
+{
+ auto result = new QState(parent);
+ result->assignProperty(w1, "geometry", rect1);
+ result->assignProperty(w2, "geometry", rect2);
+ result->assignProperty(w3, "geometry", rect3);
+ result->assignProperty(w4, "geometry", rect4);
+
+ return result;
+}
+//![13]
+
+
+class GraphicsView : public QGraphicsView
+{
+ Q_OBJECT
+public:
+ explicit GraphicsView(QGraphicsScene *scene, QWidget *parent = nullptr)
+ : QGraphicsView(scene, parent)
+ {
+ }
+
+protected:
+ void resizeEvent(QResizeEvent *event) override
+ {
+ fitInView(scene()->sceneRect());
+ QGraphicsView::resizeEvent(event);
+ }
+};
+
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+//![1]
+ auto button1 = new QGraphicsRectWidget;
+ auto button2 = new QGraphicsRectWidget;
+ auto button3 = new QGraphicsRectWidget;
+ auto button4 = new QGraphicsRectWidget;
+ button2->setZValue(1);
+ button3->setZValue(2);
+ button4->setZValue(3);
+ QGraphicsScene scene(0, 0, 300, 300);
+ scene.setBackgroundBrush(Qt::black);
+ scene.addItem(button1);
+ scene.addItem(button2);
+ scene.addItem(button3);
+ scene.addItem(button4);
+//![1]
+ GraphicsView window(&scene);
+ window.setFrameStyle(0);
+ window.setAlignment(Qt::AlignLeft | Qt::AlignTop);
+ window.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ window.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+//![2]
+ QStateMachine machine;
+
+ auto group = new QState;
+ group->setObjectName("group");
+ QTimer timer;
+ timer.setInterval(1250);
+ timer.setSingleShot(true);
+ QObject::connect(group, &QState::entered, &timer, QOverload<>::of(&QTimer::start));
+//![2]
+
+//![3]
+ auto state1 = createGeometryState(button1, QRect(100, 0, 50, 50),
+ button2, QRect(150, 0, 50, 50),
+ button3, QRect(200, 0, 50, 50),
+ button4, QRect(250, 0, 50, 50),
+ group);
+//![3]
+ auto state2 = createGeometryState(button1, QRect(250, 100, 50, 50),
+ button2, QRect(250, 150, 50, 50),
+ button3, QRect(250, 200, 50, 50),
+ button4, QRect(250, 250, 50, 50),
+ group);
+ auto state3 = createGeometryState(button1, QRect(150, 250, 50, 50),
+ button2, QRect(100, 250, 50, 50),
+ button3, QRect(50, 250, 50, 50),
+ button4, QRect(0, 250, 50, 50),
+ group);
+ auto state4 = createGeometryState(button1, QRect(0, 150, 50, 50),
+ button2, QRect(0, 100, 50, 50),
+ button3, QRect(0, 50, 50, 50),
+ button4, QRect(0, 0, 50, 50),
+ group);
+ auto state5 = createGeometryState(button1, QRect(100, 100, 50, 50),
+ button2, QRect(150, 100, 50, 50),
+ button3, QRect(100, 150, 50, 50),
+ button4, QRect(150, 150, 50, 50),
+ group);
+ auto state6 = createGeometryState(button1, QRect(50, 50, 50, 50),
+ button2, QRect(200, 50, 50, 50),
+ button3, QRect(50, 200, 50, 50),
+ button4, QRect(200, 200, 50, 50),
+ group);
+//![4]
+ auto state7 = createGeometryState(button1, QRect(0, 0, 50, 50),
+ button2, QRect(250, 0, 50, 50),
+ button3, QRect(0, 250, 50, 50),
+ button4, QRect(250, 250, 50, 50),
+ group);
+ group->setInitialState(state1);
+//![4]
+
+//![5]
+ QParallelAnimationGroup animationGroup;
+
+ auto anim = new QPropertyAnimation(button4, "geometry");
+ anim->setDuration(1000);
+ anim->setEasingCurve(QEasingCurve::OutElastic);
+ animationGroup.addAnimation(anim);
+//![5]
+
+//![6]
+ auto subGroup = new QSequentialAnimationGroup(&animationGroup);
+ subGroup->addPause(100);
+ anim = new QPropertyAnimation(button3, "geometry");
+ anim->setDuration(1000);
+ anim->setEasingCurve(QEasingCurve::OutElastic);
+ subGroup->addAnimation(anim);
+//![6]
+
+ subGroup = new QSequentialAnimationGroup(&animationGroup);
+ subGroup->addPause(150);
+ anim = new QPropertyAnimation(button2, "geometry");
+ anim->setDuration(1000);
+ anim->setEasingCurve(QEasingCurve::OutElastic);
+ subGroup->addAnimation(anim);
+
+ subGroup = new QSequentialAnimationGroup(&animationGroup);
+ subGroup->addPause(200);
+ anim = new QPropertyAnimation(button1, "geometry");
+ anim->setDuration(1000);
+ anim->setEasingCurve(QEasingCurve::OutElastic);
+ subGroup->addAnimation(anim);
+
+//![7]
+ auto stateSwitcher = new StateSwitcher(&machine);
+ stateSwitcher->setObjectName("stateSwitcher");
+ group->addTransition(&timer, &QTimer::timeout, stateSwitcher);
+ stateSwitcher->addState(state1, &animationGroup);
+ stateSwitcher->addState(state2, &animationGroup);
+//![7]
+ stateSwitcher->addState(state3, &animationGroup);
+ stateSwitcher->addState(state4, &animationGroup);
+ stateSwitcher->addState(state5, &animationGroup);
+ stateSwitcher->addState(state6, &animationGroup);
+//![8]
+ stateSwitcher->addState(state7, &animationGroup);
+//![8]
+
+//![9]
+ machine.addState(group);
+ machine.setInitialState(group);
+ machine.start();
+//![9]
+
+ window.resize(300, 300);
+ window.show();
+
+ return app.exec();
+}
+
+#include "main.moc"
diff --git a/examples/statemachine/moveblocks/moveblocks.pro b/examples/statemachine/moveblocks/moveblocks.pro
new file mode 100644
index 0000000..405a949
--- /dev/null
+++ b/examples/statemachine/moveblocks/moveblocks.pro
@@ -0,0 +1,7 @@
+QT += statemachine widgets
+
+SOURCES = main.cpp
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/animation/moveblocks
+INSTALLS += target
diff --git a/examples/statemachine/pingpong/CMakeLists.txt b/examples/statemachine/pingpong/CMakeLists.txt
new file mode 100644
index 0000000..db1324e
--- /dev/null
+++ b/examples/statemachine/pingpong/CMakeLists.txt
@@ -0,0 +1,39 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(pingpong LANGUAGES CXX)
+
+if (ANDROID)
+ message(FATAL_ERROR "This project cannot be built on Android.")
+endif()
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/statemachine/pingpong")
+
+find_package(Qt6 REQUIRED COMPONENTS Core StateMachine)
+
+qt_standard_project_setup()
+
+qt_add_executable(pingpong
+ main.cpp
+)
+
+set_target_properties(pingpong PROPERTIES
+ WIN32_EXECUTABLE FALSE
+ MACOSX_BUNDLE FALSE
+)
+
+target_link_libraries(pingpong PRIVATE
+ Qt::Core
+ Qt::StateMachine
+)
+
+install(TARGETS pingpong
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/statemachine/pingpong/main.cpp b/examples/statemachine/pingpong/main.cpp
new file mode 100644
index 0000000..a042e8b
--- /dev/null
+++ b/examples/statemachine/pingpong/main.cpp
@@ -0,0 +1,104 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDebug>
+#include <QtCore/QEvent>
+#include <QtStateMachine/QAbstractTransition>
+#include <QtStateMachine/QState>
+#include <QtStateMachine/QStateMachine>
+
+static constexpr QEvent::Type PingEventType = QEvent::Type(QEvent::User + 2);
+static constexpr QEvent::Type PongEventType = QEvent::Type(QEvent::User + 3);
+
+//! [0]
+class PingEvent : public QEvent
+{
+public:
+ PingEvent() : QEvent(PingEventType) { }
+};
+
+class PongEvent : public QEvent
+{
+public:
+ PongEvent() : QEvent(PongEventType) { }
+};
+//! [0]
+
+//! [1]
+class Pinger : public QState
+{
+public:
+ explicit Pinger(QState *parent) : QState(parent) { }
+
+protected:
+ void onEntry(QEvent *) override
+ {
+ machine()->postEvent(new PingEvent);
+ qInfo() << "ping?";
+ }
+};
+//! [1]
+
+//! [3]
+class PongTransition : public QAbstractTransition
+{
+public:
+ PongTransition() {}
+
+protected:
+ bool eventTest(QEvent *e) override { return (e->type() == PingEventType); }
+
+ void onTransition(QEvent *) override
+ {
+ machine()->postDelayedEvent(new PingEvent, 500);
+ qInfo() << "ping?";
+ }
+};
+//! [3]
+
+//! [2]
+class PingTransition : public QAbstractTransition
+{
+public:
+ PingTransition() {}
+
+protected:
+ bool eventTest(QEvent *e) override { return e->type() == PingEventType; }
+
+ void onTransition(QEvent *) override
+ {
+ machine()->postDelayedEvent(new PongEvent, 500);
+ qInfo() << "pong!";
+ }
+};
+//! [2]
+
+//! [4]
+int main(int argc, char **argv)
+{
+ QCoreApplication app(argc, argv);
+
+ QStateMachine machine;
+ auto group = new QState(QState::ParallelStates);
+ group->setObjectName("group");
+//! [4]
+
+//! [5]
+ auto pinger = new Pinger(group);
+ pinger->setObjectName("pinger");
+ pinger->addTransition(new PongTransition);
+
+ auto ponger = new QState(group);
+ ponger->setObjectName("ponger");
+ ponger->addTransition(new PingTransition);
+//! [5]
+
+//! [6]
+ machine.addState(group);
+ machine.setInitialState(group);
+ machine.start();
+
+ return app.exec();
+}
+//! [6]
diff --git a/examples/statemachine/pingpong/pingpong.pro b/examples/statemachine/pingpong/pingpong.pro
new file mode 100644
index 0000000..5c569bb
--- /dev/null
+++ b/examples/statemachine/pingpong/pingpong.pro
@@ -0,0 +1,8 @@
+QT = statemachine core
+CONFIG += cmdline
+
+SOURCES = main.cpp
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/statemachine/pingpong
+INSTALLS += target
diff --git a/examples/statemachine/rogue/CMakeLists.txt b/examples/statemachine/rogue/CMakeLists.txt
new file mode 100644
index 0000000..870a682
--- /dev/null
+++ b/examples/statemachine/rogue/CMakeLists.txt
@@ -0,0 +1,39 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(rogue LANGUAGES CXX)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/statemachine/rogue")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui StateMachine Widgets)
+
+qt_standard_project_setup()
+
+qt_add_executable(rogue
+ main.cpp
+ movementtransition.h
+ window.cpp window.h
+)
+
+set_target_properties(rogue PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(rogue PRIVATE
+ Qt::Core
+ Qt::Gui
+ Qt::StateMachine
+ Qt::Widgets
+)
+
+install(TARGETS rogue
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/statemachine/rogue/main.cpp b/examples/statemachine/rogue/main.cpp
new file mode 100644
index 0000000..a6e4012
--- /dev/null
+++ b/examples/statemachine/rogue/main.cpp
@@ -0,0 +1,17 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QtWidgets/QApplication>
+
+#include "window.h"
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+
+ Window window;
+ window.show();
+
+ return app.exec();
+}
+
diff --git a/examples/statemachine/rogue/movementtransition.h b/examples/statemachine/rogue/movementtransition.h
new file mode 100644
index 0000000..62b82c1
--- /dev/null
+++ b/examples/statemachine/rogue/movementtransition.h
@@ -0,0 +1,77 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef MOVEMENTTRANSITION_H
+#define MOVEMENTTRANSITION_H
+
+#include <QtGui/QKeyEvent>
+#include <QtStateMachine/QEventTransition>
+#include <QtStateMachine/QStateMachine>
+
+#include "window.h"
+
+//![0]
+class MovementTransition : public QEventTransition
+{
+ Q_OBJECT
+
+public:
+ explicit MovementTransition(Window *window)
+ : QEventTransition(window, QEvent::KeyPress), window(window)
+ {
+ }
+//![0]
+
+//![1]
+protected:
+ bool eventTest(QEvent *event) override {
+ if (event->type() == QEvent::StateMachineWrapped &&
+ static_cast<QStateMachine::WrappedEvent *>(event)->event()->type() == QEvent::KeyPress) {
+ auto wrappedEvent = static_cast<QStateMachine::WrappedEvent *>(event)->event();
+
+ auto keyEvent = static_cast<QKeyEvent *>(wrappedEvent);
+ int key = keyEvent->key();
+
+ return key == Qt::Key_2 || key == Qt::Key_8 || key == Qt::Key_6 ||
+ key == Qt::Key_4 || key == Qt::Key_Down || key == Qt::Key_Up ||
+ key == Qt::Key_Right || key == Qt::Key_Left;
+ }
+ return false;
+ }
+//![1]
+
+//![2]
+ void onTransition(QEvent *event) override {
+ auto keyEvent = static_cast<QKeyEvent *>(
+ static_cast<QStateMachine::WrappedEvent *>(event)->event());
+
+ int key = keyEvent->key();
+ switch (key) {
+ case Qt::Key_Left:
+ case Qt::Key_4:
+ window->movePlayer(Window::Left);
+ break;
+ case Qt::Key_Up:
+ case Qt::Key_8:
+ window->movePlayer(Window::Up);
+ break;
+ case Qt::Key_Right:
+ case Qt::Key_6:
+ window->movePlayer(Window::Right);
+ break;
+ case Qt::Key_Down:
+ case Qt::Key_2:
+ window->movePlayer(Window::Down);
+ break;
+ default:
+ ;
+ }
+ }
+//![2]
+
+private:
+ Window *window;
+};
+
+#endif
+
diff --git a/examples/statemachine/rogue/rogue.pro b/examples/statemachine/rogue/rogue.pro
new file mode 100644
index 0000000..7260d76
--- /dev/null
+++ b/examples/statemachine/rogue/rogue.pro
@@ -0,0 +1,10 @@
+QT += statemachine widgets
+
+HEADERS = window.h \
+ movementtransition.h
+SOURCES = main.cpp \
+ window.cpp
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/statemachine/rogue
+INSTALLS += target
diff --git a/examples/statemachine/rogue/window.cpp b/examples/statemachine/rogue/window.cpp
new file mode 100644
index 0000000..40761bd
--- /dev/null
+++ b/examples/statemachine/rogue/window.cpp
@@ -0,0 +1,201 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "window.h"
+
+#include <QtCore/QRandomGenerator>
+#include <QtGui/QFont>
+#include <QtGui/QPainter>
+#include <QtStateMachine/QFinalState>
+#include <QtStateMachine/QKeyEventTransition>
+#include <QtWidgets/QApplication>
+
+#include <cmath>
+
+#include "movementtransition.h"
+
+//![0]
+Window::Window()
+{
+//![0]
+ QFont font("Monospace");
+ font.setStyleHint(QFont::TypeWriter);
+ font.setPointSize(12);
+ setFont(font);
+//![1]
+ setupMap();
+ buildMachine();
+}
+//![1]
+
+void Window::setStatus(const QString &status)
+{
+ myStatus = status;
+ repaint();
+}
+
+QString Window::status() const
+{
+ return myStatus;
+}
+
+void Window::paintEvent(QPaintEvent * /* event */)
+{
+ QFontMetrics metrics(font());
+ QPainter painter(this);
+ int fontHeight = metrics.height();
+ int fontWidth = metrics.horizontalAdvance('X');
+ int yPos = fontHeight;
+ int xPos;
+
+ painter.fillRect(rect(), Qt::black);
+ painter.setPen(Qt::white);
+
+ painter.drawText(QPoint(0, yPos), status());
+
+ for (int y = 0; y < HEIGHT; ++y) {
+ yPos += fontHeight;
+ xPos = 0;
+
+ for (int x = 0; x < WIDTH; ++x) {
+ if (y == pY && x == pX) {
+ xPos += fontWidth;
+ continue;
+ }
+
+ painter.setPen(Qt::white);
+
+ double x1 = static_cast<double>(pX);
+ double y1 = static_cast<double>(pY);
+ double x2 = static_cast<double>(x);
+ double y2 = static_cast<double>(y);
+
+ if (x2 < x1) {
+ x2 += 0.5;
+ } else if (x2 > x1) {
+ x2 -= 0.5;
+ }
+
+ if (y2 < y1) {
+ y2 += 0.5;
+ } else if (y2 > y1) {
+ y2 -= 0.5;
+ }
+
+ double dx = x2 - x1;
+ double dy = y2 - y1;
+
+ double length = std::hypot(dx, dy);
+
+ dx /= length;
+ dy /= length;
+
+ double xi = x1;
+ double yi = y1;
+
+ while (length > 0) {
+ int cx = static_cast<int>(xi + 0.5);
+ int cy = static_cast<int>(yi + 0.5);
+
+ if (x2 == cx && y2 == cy)
+ break;
+
+ if (!(x1 == cx && y1 == cy) && (map[cx][cy] == '#' || (length - 10) > 0)) {
+ painter.setPen(QColor(60, 60, 60));
+ break;
+ }
+
+ xi += dx;
+ yi += dy;
+ --length;
+ }
+
+ painter.drawText(QPoint(xPos, yPos), map[x][y]);
+ xPos += fontWidth;
+ }
+ }
+ painter.setPen(Qt::white);
+ painter.drawText(QPoint(pX * fontWidth, (pY + 2) * fontHeight), QChar('@'));
+}
+
+QSize Window::sizeHint() const
+{
+ QFontMetrics metrics(font());
+
+ return QSize(metrics.horizontalAdvance('X') * WIDTH, metrics.height() * (HEIGHT + 1));
+}
+
+//![2]
+void Window::buildMachine()
+{
+ machine = new QStateMachine;
+
+ auto inputState = new QState(machine);
+ inputState->assignProperty(this, "status", "Move the rogue with 2, 4, 6, and 8");
+
+ auto transition = new MovementTransition(this);
+ inputState->addTransition(transition);
+//![2]
+
+//![3]
+ auto quitState = new QState(machine);
+ quitState->assignProperty(this, "status", "Really quit(y/n)?");
+
+ auto yesTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Y);
+ yesTransition->setTargetState(new QFinalState(machine));
+ quitState->addTransition(yesTransition);
+
+ auto noTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_N);
+ noTransition->setTargetState(inputState);
+ quitState->addTransition(noTransition);
+//![3]
+
+//![4]
+ auto quitTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Q);
+ quitTransition->setTargetState(quitState);
+ inputState->addTransition(quitTransition);
+//![4]
+
+//![5]
+ machine->setInitialState(inputState);
+
+ connect(machine, &QStateMachine::finished, qApp, &QApplication::quit);
+
+ machine->start();
+}
+//![5]
+
+void Window::movePlayer(Direction direction)
+{
+ switch (direction) {
+ case Left:
+ if (map[pX - 1][pY] != '#')
+ --pX;
+ break;
+ case Right:
+ if (map[pX + 1][pY] != '#')
+ ++pX;
+ break;
+ case Up:
+ if (map[pX][pY - 1] != '#')
+ --pY;
+ break;
+ case Down:
+ if (map[pX][pY + 1] != '#')
+ ++pY;
+ break;
+ }
+ repaint();
+}
+
+void Window::setupMap()
+{
+ for (int x = 0; x < WIDTH; ++x)
+ for (int y = 0; y < HEIGHT; ++y) {
+ if (x == 0 || x == WIDTH - 1 || y == 0 || y == HEIGHT - 1 || QRandomGenerator::global()->bounded(40) == 0)
+ map[x][y] = '#';
+ else
+ map[x][y] = '.';
+ }
+}
+
diff --git a/examples/statemachine/rogue/window.h b/examples/statemachine/rogue/window.h
new file mode 100644
index 0000000..2db57ff
--- /dev/null
+++ b/examples/statemachine/rogue/window.h
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QtWidgets/QWidget>
+
+QT_FORWARD_DECLARE_CLASS(QStateMachine);
+
+//![0]
+class Window : public QWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(QString status READ status WRITE setStatus)
+
+public:
+ enum Direction { Up, Down, Left, Right };
+
+ Window();
+
+ void movePlayer(Direction direction);
+ void setStatus(const QString &status);
+ QString status() const;
+
+ QSize sizeHint() const override;
+
+protected:
+ void paintEvent(QPaintEvent *event) override;
+//![0]
+
+//![1]
+private:
+ void buildMachine();
+ void setupMap();
+
+ static constexpr int WIDTH = 35;
+ static constexpr int HEIGHT = 20;
+
+ QChar map[WIDTH][HEIGHT];
+ int pX = 5;
+ int pY = 5;
+
+ QStateMachine *machine;
+ QString myStatus;
+};
+//![1]
+
+#endif
+
diff --git a/examples/statemachine/statemachine.pro b/examples/statemachine/statemachine.pro
new file mode 100644
index 0000000..b635f8c
--- /dev/null
+++ b/examples/statemachine/statemachine.pro
@@ -0,0 +1,11 @@
+TEMPLATE = subdirs
+
+SUBDIRS += pingpong
+
+qtHaveModule(widgets) {
+ SUBDIRS += rogue \
+ trafficlight
+ qtConfig(animation) {
+ SUBDIRS += moveblocks
+ }
+}
diff --git a/examples/statemachine/trafficlight/CMakeLists.txt b/examples/statemachine/trafficlight/CMakeLists.txt
new file mode 100644
index 0000000..4338e8f
--- /dev/null
+++ b/examples/statemachine/trafficlight/CMakeLists.txt
@@ -0,0 +1,37 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(trafficlight LANGUAGES CXX)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/statemachine/trafficlight")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui StateMachine Widgets)
+
+qt_standard_project_setup()
+
+qt_add_executable(trafficlight
+ main.cpp
+)
+
+set_target_properties(trafficlight PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(trafficlight PRIVATE
+ Qt::Core
+ Qt::Gui
+ Qt::StateMachine
+ Qt::Widgets
+)
+
+install(TARGETS trafficlight
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/statemachine/trafficlight/main.cpp b/examples/statemachine/trafficlight/main.cpp
new file mode 100644
index 0000000..5c85921
--- /dev/null
+++ b/examples/statemachine/trafficlight/main.cpp
@@ -0,0 +1,152 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QtCore/QTimer>
+#include <QtGui/QPainter>
+#include <QtStateMachine/QFinalState>
+#include <QtStateMachine/QStateMachine>
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QVBoxLayout>
+#include <QtWidgets/QWidget>
+
+//! [0]
+class LightWidget : public QWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(bool on READ isOn WRITE setOn)
+public:
+ explicit LightWidget(const QColor &color, QWidget *parent = nullptr)
+ : QWidget(parent), m_color(color)
+ {
+ }
+
+ bool isOn() const { return m_on; }
+
+ void setOn(bool on)
+ {
+ if (on == m_on)
+ return;
+ m_on = on;
+ update();
+ }
+
+public slots:
+ void turnOff() { setOn(false); }
+ void turnOn() { setOn(true); }
+
+protected:
+ void paintEvent(QPaintEvent *) override
+ {
+ if (!m_on)
+ return;
+ QPainter painter(this);
+ painter.setRenderHint(QPainter::Antialiasing);
+ painter.setBrush(m_color);
+ painter.drawEllipse(rect());
+ }
+
+private:
+ QColor m_color;
+ bool m_on = false;
+};
+//! [0]
+
+//! [1]
+class TrafficLightWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit TrafficLightWidget(QWidget *parent = nullptr) : QWidget(parent)
+ {
+ auto vbox = new QVBoxLayout(this);
+ m_red = new LightWidget(Qt::red);
+ vbox->addWidget(m_red);
+ m_yellow = new LightWidget(Qt::yellow);
+ vbox->addWidget(m_yellow);
+ m_green = new LightWidget(Qt::green);
+ vbox->addWidget(m_green);
+ auto pal = palette();
+ pal.setColor(QPalette::Window, Qt::black);
+ setPalette(pal);
+ setAutoFillBackground(true);
+ }
+
+ LightWidget *redLight() const { return m_red; }
+ LightWidget *yellowLight() const { return m_yellow; }
+ LightWidget *greenLight() const { return m_green; }
+
+private:
+ LightWidget *m_red;
+ LightWidget *m_yellow;
+ LightWidget *m_green;
+};
+//! [1]
+
+//! [2]
+QState *createLightState(LightWidget *light, int duration, QState *parent = nullptr)
+{
+ auto lightState = new QState(parent);
+ auto timer = new QTimer(lightState);
+ timer->setInterval(duration);
+ timer->setSingleShot(true);
+ auto timing = new QState(lightState);
+ QObject::connect(timing, &QAbstractState::entered, light, &LightWidget::turnOn);
+ QObject::connect(timing, &QAbstractState::entered, timer, QOverload<>::of(&QTimer::start));
+ QObject::connect(timing, &QAbstractState::exited, light, &LightWidget::turnOff);
+ auto done = new QFinalState(lightState);
+ timing->addTransition(timer, &QTimer::timeout, done);
+ lightState->setInitialState(timing);
+ return lightState;
+}
+//! [2]
+
+//! [3]
+class TrafficLight : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit TrafficLight(QWidget *parent = nullptr) : QWidget(parent)
+ {
+ auto vbox = new QVBoxLayout(this);
+ auto widget = new TrafficLightWidget;
+ vbox->addWidget(widget);
+ vbox->setContentsMargins(QMargins());
+
+ auto machine = new QStateMachine(this);
+ auto redGoingYellow = createLightState(widget->redLight(), 3000);
+ redGoingYellow->setObjectName("redGoingYellow");
+ auto yellowGoingGreen = createLightState(widget->yellowLight(), 1000);
+ yellowGoingGreen->setObjectName("yellowGoingGreen");
+ redGoingYellow->addTransition(redGoingYellow, &QState::finished, yellowGoingGreen);
+ auto greenGoingYellow = createLightState(widget->greenLight(), 3000);
+ greenGoingYellow->setObjectName("greenGoingYellow");
+ yellowGoingGreen->addTransition(yellowGoingGreen, &QState::finished, greenGoingYellow);
+ auto yellowGoingRed = createLightState(widget->yellowLight(), 1000);
+ yellowGoingRed->setObjectName("yellowGoingRed");
+ greenGoingYellow->addTransition(greenGoingYellow, &QState::finished, yellowGoingRed);
+ yellowGoingRed->addTransition(yellowGoingRed, &QState::finished, redGoingYellow);
+
+ machine->addState(redGoingYellow);
+ machine->addState(yellowGoingGreen);
+ machine->addState(greenGoingYellow);
+ machine->addState(yellowGoingRed);
+ machine->setInitialState(redGoingYellow);
+ machine->start();
+ }
+};
+//! [3]
+
+//! [4]
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ TrafficLight widget;
+ widget.resize(110, 300);
+ widget.show();
+
+ return app.exec();
+}
+//! [4]
+
+#include "main.moc"
diff --git a/examples/statemachine/trafficlight/trafficlight.pro b/examples/statemachine/trafficlight/trafficlight.pro
new file mode 100644
index 0000000..1288f1f
--- /dev/null
+++ b/examples/statemachine/trafficlight/trafficlight.pro
@@ -0,0 +1,7 @@
+QT += statemachine widgets
+
+SOURCES = main.cpp
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/statemachine/trafficlight
+INSTALLS += target