diff options
author | Juha Vuolle <juha.vuolle@qt.io> | 2023-02-20 12:50:46 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-02-23 06:38:55 +0000 |
commit | 8dbfad334fd56356d6190a0e645f974567c90183 (patch) | |
tree | b4188c107c11095538595654d99f4c4a60153c75 | |
parent | 8b43bc98abe124529e672cd79624351bccd2c9f2 (diff) |
Remove other than "cpp model" mediaplayer example variants
The most unique aspect the mediaplayer demonstrates is the use
of cpp data model. This commit removes the other variants and renames
the remaining one as plain "mediaplayer".
The two QML files (one from common and one from the original cpp-model
example) were united as one, as there is now just one example.
Task-number: QTBUG-111090
Change-Id: I450ce5b23df072be34dcbc3c109d10e6b45709da
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit 1eb77736b2e72bfcbdc356e183e3cbb0f09d71a1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
45 files changed, 102 insertions, 918 deletions
diff --git a/examples/scxml/CMakeLists.txt b/examples/scxml/CMakeLists.txt index a0f3867..257fe22 100644 --- a/examples/scxml/CMakeLists.txt +++ b/examples/scxml/CMakeLists.txt @@ -9,11 +9,6 @@ if(TARGET Qt::Widgets) qt_internal_add_example(trafficlight-widgets-static) qt_internal_add_example(trafficlight-widgets-dynamic) if(QT_FEATURE_scxml_ecmascriptdatamodel) - # Work around QTBUG-95305 - if(NOT (CMAKE_GENERATOR STREQUAL "Ninja Multi-Config" AND CMAKE_CROSS_CONFIGS)) - qt_internal_add_example(mediaplayer-widgets-static) - qt_internal_add_example(mediaplayer-widgets-dynamic) - endif() qt_internal_add_example(calculator-widgets) qt_internal_add_example(sudoku) endif() @@ -24,9 +19,7 @@ if(TARGET Qt::Qml AND TARGET Qt::Gui) 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-qml-static) - qt_internal_add_example(mediaplayer-qml-dynamic) - qt_internal_add_example(mediaplayer-qml-cppdatamodel) + qt_internal_add_example(mediaplayer) qt_internal_add_example(invoke-static) qt_internal_add_example(invoke-dynamic) endif() 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 8e8cfbe..0000000 --- a/examples/scxml/mediaplayer-common/doc/src/mediaplayer-compiling.qdocinc +++ /dev/null @@ -1,29 +0,0 @@ - \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 .pro when using qmake: - - \quotefromfile mediaplayer-widgets-static/mediaplayer-widgets-static.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 mediaplayer-widgets-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 a header and a source file, - which are then added appropriately 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 a83e5e3..0000000 --- a/examples/scxml/mediaplayer-common/mainwindow.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#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 4003880..0000000 --- a/examples/scxml/mediaplayer-common/mainwindow.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#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 a27eecd..0000000 --- a/examples/scxml/mediaplayer-common/mediaplayer.scxml +++ /dev/null @@ -1,45 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -// Copyright (C) 2016 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="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() && media !== _event.data.media" target="playing"/> - </state> -</scxml> diff --git a/examples/scxml/mediaplayer-qml-cppdatamodel/CMakeLists.txt b/examples/scxml/mediaplayer-qml-cppdatamodel/CMakeLists.txt deleted file mode 100644 index d276626..0000000 --- a/examples/scxml/mediaplayer-qml-cppdatamodel/CMakeLists.txt +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required(VERSION 3.16) -project(mediaplayer-qml-cppdatamodel LANGUAGES CXX) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOMOC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/scxml/mediaplayer-qml-cppdatamodel") - -find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Scxml) - -qt_add_executable(mediaplayer-qml-cppdatamodel - mediaplayer-qml-cppdatamodel.cpp - thedatamodel.cpp thedatamodel.h -) - -set_target_properties(mediaplayer-qml-cppdatamodel PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) - -target_link_libraries(mediaplayer-qml-cppdatamodel PUBLIC - Qt::Core - Qt::Gui - Qt::Qml - Qt::Scxml -) - -# Resources: -set_source_files_properties("../mediaplayer-common/Mediaplayer.qml" - PROPERTIES QT_RESOURCE_ALIAS "Mediaplayer.qml" -) - -set(mediaplayer-qml-cppdatamodel_resource_files - "../mediaplayer-common/Mediaplayer.qml" - "mediaplayer-qml-cppdatamodel.qml" -) - -qt6_add_resources(mediaplayer-qml-cppdatamodel "mediaplayer-qml-cppdatamodel" - PREFIX - "/" - FILES - ${mediaplayer-qml-cppdatamodel_resource_files} -) - -# Statecharts: -qt6_add_statecharts(mediaplayer-qml-cppdatamodel - mediaplayer-cppdatamodel.scxml -) - -install(TARGETS mediaplayer-qml-cppdatamodel - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) 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 cd1a3ae..0000000 --- a/examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-qml-cppdatamodel.qml +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -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-dynamic/CMakeLists.txt b/examples/scxml/mediaplayer-qml-dynamic/CMakeLists.txt deleted file mode 100644 index f262e6e..0000000 --- a/examples/scxml/mediaplayer-qml-dynamic/CMakeLists.txt +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required(VERSION 3.16) -project(mediaplayer-qml-dynamic LANGUAGES CXX) - -set(CMAKE_AUTOMOC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/scxml/mediaplayer-qml-dynamic") - -find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Scxml) - -qt_add_executable(mediaplayer-qml-dynamic - mediaplayer-qml-dynamic.cpp -) - -set_target_properties(mediaplayer-qml-dynamic PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) - -target_link_libraries(mediaplayer-qml-dynamic PUBLIC - Qt6::Core - Qt6::Gui - Qt6::Qml - Qt6::Scxml -) - -# Resources: -set_source_files_properties("../mediaplayer-common/Mediaplayer.qml" - PROPERTIES QT_RESOURCE_ALIAS "Mediaplayer.qml" -) - -set_source_files_properties("../mediaplayer-common/mediaplayer.scxml" - PROPERTIES QT_RESOURCE_ALIAS "mediaplayer.scxml" -) - -set(mediaplayer-qml-dynamic_resource_files - "../mediaplayer-common/Mediaplayer.qml" - "../mediaplayer-common/mediaplayer.scxml" - "mediaplayer-qml-dynamic.qml" -) - -qt6_add_resources(mediaplayer-qml-dynamic "mediaplayer-qml-dynamic" - PREFIX - "/" - FILES - ${mediaplayer-qml-dynamic_resource_files} -) - -install(TARGETS mediaplayer-qml-dynamic - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) 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 345a558..0000000 --- a/examples/scxml/mediaplayer-qml-dynamic/doc/src/mediaplayer-qml-dynamic.qdoc +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only - -/*! - \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 - project build files. - - With qmake to the \e mediaplayer-qml-dynamic.pro - - \quotefromfile mediaplayer-qml-dynamic/mediaplayer-qml-dynamic.pro - \skipto QT - \printline scxml - - With cmake to the \e CMakeLists.txt - \quotefromfile mediaplayer-qml-dynamic/CMakeLists.txt - \skipto find_package - \printline Scxml - \skipto target_link_libraries - \printuntil ) - - 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 bdd3bd1..0000000 --- a/examples/scxml/mediaplayer-qml-dynamic/mediaplayer-qml-dynamic.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#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 d613495..0000000 --- a/examples/scxml/mediaplayer-qml-dynamic/mediaplayer-qml-dynamic.qml +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -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/CMakeLists.txt b/examples/scxml/mediaplayer-qml-static/CMakeLists.txt deleted file mode 100644 index 8bd63c2..0000000 --- a/examples/scxml/mediaplayer-qml-static/CMakeLists.txt +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required(VERSION 3.16) -project(mediaplayer-qml-static LANGUAGES CXX) - -set(CMAKE_AUTOMOC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/scxml/mediaplayer-qml-static") - -find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Scxml) - -qt_add_executable(mediaplayer-qml-static - mediaplayer-qml-static.cpp -) - -set_target_properties(mediaplayer-qml-static PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) - -target_link_libraries(mediaplayer-qml-static PUBLIC - Qt::Core - Qt::Gui - Qt::Qml - Qt::Scxml -) - -# Resources: -set_source_files_properties("../mediaplayer-common/Mediaplayer.qml" - PROPERTIES QT_RESOURCE_ALIAS "Mediaplayer.qml" -) - -set(mediaplayer-qml-static_resource_files - "../mediaplayer-common/Mediaplayer.qml" - "mediaplayer-qml-static.qml" -) - -qt6_add_resources(mediaplayer-qml-static "mediaplayer-qml-static" - PREFIX - "/" - FILES - ${mediaplayer-qml-static_resource_files} -) - -# Statecharts: -qt6_add_statecharts(mediaplayer-qml-static - ../mediaplayer-common/mediaplayer.scxml -) - -install(TARGETS mediaplayer-qml-static - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) 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 dee47f0..0000000 --- a/examples/scxml/mediaplayer-qml-static/doc/src/mediaplayer-qml-static.qdoc +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only - -/*! - \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 3d4a770..0000000 --- a/examples/scxml/mediaplayer-qml-static/mediaplayer-qml-static.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#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 8bb809a..0000000 --- a/examples/scxml/mediaplayer-qml-static/mediaplayer-qml-static.qml +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -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/CMakeLists.txt b/examples/scxml/mediaplayer-widgets-dynamic/CMakeLists.txt deleted file mode 100644 index 09963fb..0000000 --- a/examples/scxml/mediaplayer-widgets-dynamic/CMakeLists.txt +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required(VERSION 3.16) -project(mediaplayer-widgets-dynamic LANGUAGES CXX) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/scxml/mediaplayer-widgets-dynamic") - -find_package(Qt6 REQUIRED COMPONENTS Core Gui Scxml Widgets) - -qt_add_executable(mediaplayer-widgets-dynamic - ../mediaplayer-common/mainwindow.cpp ../mediaplayer-common/mainwindow.h ../mediaplayer-common/mainwindow.ui - mediaplayer-widgets-dynamic.cpp -) - -set_target_properties(mediaplayer-widgets-dynamic PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) - -target_link_libraries(mediaplayer-widgets-dynamic PUBLIC - Qt6::Core - Qt6::Gui - Qt6::Scxml - Qt6::Widgets -) - -# Resources: -set_source_files_properties("../mediaplayer-common/mediaplayer.scxml" - PROPERTIES QT_RESOURCE_ALIAS "mediaplayer.scxml" -) - -set(mediaplayer_resource_files - "../mediaplayer-common/mediaplayer.scxml" -) - -qt6_add_resources(mediaplayer-widgets-dynamic "mediaplayer" - PREFIX - "/" - FILES - ${mediaplayer_resource_files} -) - -install(TARGETS mediaplayer-widgets-dynamic - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) 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 b173833..0000000 --- a/examples/scxml/mediaplayer-widgets-dynamic/doc/src/mediaplayer-widgets-dynamic.qdoc +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only - -/*! - \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 - project build files. - - With qmake to the \e mediaplayer-widgets-dynamic.pro - - \quotefromfile mediaplayer-widgets-dynamic/mediaplayer-widgets-dynamic.pro - \skipto QT - \printline scxml - - With cmake to the \e CMakeLists.txt - \quotefromfile mediaplayer-widgets-dynamic/CMakeLists.txt - \skipto find_package - \printline Scxml - \skipto target_link_libraries - \printuntil ) - - \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 c19dd8d..0000000 --- a/examples/scxml/mediaplayer-widgets-dynamic/mediaplayer-widgets-dynamic.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#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/CMakeLists.txt b/examples/scxml/mediaplayer-widgets-static/CMakeLists.txt deleted file mode 100644 index 8b1f1dd..0000000 --- a/examples/scxml/mediaplayer-widgets-static/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required(VERSION 3.16) -project(mediaplayer-widgets-static LANGUAGES CXX) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/scxml/mediaplayer-widgets-static") - -find_package(Qt6 REQUIRED COMPONENTS Core Gui Scxml Widgets) - -qt_add_executable(mediaplayer-widgets-static - ../mediaplayer-common/mainwindow.cpp ../mediaplayer-common/mainwindow.h ../mediaplayer-common/mainwindow.ui - mediaplayer-widgets-static.cpp -) - -set_target_properties(mediaplayer-widgets-static PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) - -target_link_libraries(mediaplayer-widgets-static PUBLIC - Qt6::Core - Qt6::Gui - Qt6::Scxml - Qt6::Widgets -) - -# Statecharts: -qt6_add_statecharts(mediaplayer-widgets-static - ../mediaplayer-common/mediaplayer.scxml -) - -install(TARGETS mediaplayer-widgets-static - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) 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 37db7ba..0000000 --- a/examples/scxml/mediaplayer-widgets-static/doc/src/mediaplayer-widgets-static.qdoc +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only - -/*! - \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 3819e17..0000000 --- a/examples/scxml/mediaplayer-widgets-static/mediaplayer-widgets-static.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#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..1a072c1 --- /dev/null +++ b/examples/scxml/mediaplayer/CMakeLists.txt @@ -0,0 +1,56 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +project(mediaplayer LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) + +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_add_executable(mediaplayer + main.cpp + thedatamodel.cpp thedatamodel.h +) + +set_target_properties(mediaplayer PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE +) + +target_link_libraries(mediaplayer PUBLIC + Qt::Core + Qt::Gui + Qt::Qml + Qt::Scxml +) + +set(mediaplayer_resource_files + "Mediaplayer.qml" +) + +qt6_add_resources(mediaplayer "mediaplayer" + PREFIX + "/" + FILES + ${mediaplayer_resource_files} +) + +# Statecharts: +qt6_add_statecharts(mediaplayer + mediaplayer.scxml +) + +install(TARGETS mediaplayer + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/scxml/mediaplayer-common/Mediaplayer.qml b/examples/scxml/mediaplayer/Mediaplayer.qml index 7767c95..c966e4e 100644 --- a/examples/scxml/mediaplayer-common/Mediaplayer.qml +++ b/examples/scxml/mediaplayer/Mediaplayer.qml @@ -5,10 +5,20 @@ import QtQuick import QtQuick.Window import QtScxml +import MediaPlayerStateMachine +import MediaPlayerDataModel + Window { id: root - property StateMachine stateMachine: scxmlLoader.stateMachine - property alias source: scxmlLoader.source + + MediaPlayerDataModel { + id: model + } + + property StateMachine stateMachine: MediaPlayerStateMachine { + onDataModelChanged: start() + dataModel: model + } visible: true width: 750 @@ -64,10 +74,6 @@ Window { color: stateMachine.playing ? "green" : "red" } - StateMachineLoader { - id: scxmlLoader - } - EventConnection { stateMachine: root.stateMachine events: ["playbackStarted", "playbackStopped"] diff --git a/examples/scxml/mediaplayer-common/doc/images/mediaplayer.png b/examples/scxml/mediaplayer/doc/images/mediaplayer.png Binary files differindex b4c051e..b4c051e 100644 --- a/examples/scxml/mediaplayer-common/doc/images/mediaplayer.png +++ b/examples/scxml/mediaplayer/doc/images/mediaplayer.png diff --git a/examples/scxml/mediaplayer-qml-cppdatamodel/doc/src/mediaplayer-qml-cppdatamodel.qdoc b/examples/scxml/mediaplayer/doc/src/mediaplayer.qdoc index 5616d2b..87e7ffd 100644 --- a/examples/scxml/mediaplayer-qml-cppdatamodel/doc/src/mediaplayer-qml-cppdatamodel.qdoc +++ b/examples/scxml/mediaplayer/doc/src/mediaplayer.qdoc @@ -2,15 +2,15 @@ // 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 Qt SCXML Media Player Example \ingroup examples-qtscxml \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 Example} 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 @@ -25,7 +25,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 @@ -33,7 +33,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 @@ -46,14 +46,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-qml-cppdatamodel/mediaplayer-qml-cppdatamodel.cpp b/examples/scxml/mediaplayer/main.cpp index d1cf1bf..2468b66 100644 --- a/examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-qml-cppdatamodel.cpp +++ b/examples/scxml/mediaplayer/main.cpp @@ -5,7 +5,7 @@ #include <QQmlApplicationEngine> #include <QQmlContext> -#include "mediaplayer-cppdatamodel.h" +#include "mediaplayer.h" #include "thedatamodel.h" int main(int argc, char *argv[]) @@ -16,7 +16,7 @@ int main(int argc, char *argv[]) qmlRegisterType<MediaPlayerStateMachine>("MediaPlayerStateMachine", 1, 0, "MediaPlayerStateMachine"); QQmlApplicationEngine engine; - engine.load(QUrl(QStringLiteral("qrc:///mediaplayer-qml-cppdatamodel.qml"))); + engine.load(QUrl(QStringLiteral("qrc:///Mediaplayer.qml"))); return app.exec(); } diff --git a/examples/scxml/mediaplayer/mediaplayer.pro b/examples/scxml/mediaplayer/mediaplayer.pro new file mode 100644 index 0000000..3a9a5c8 --- /dev/null +++ b/examples/scxml/mediaplayer/mediaplayer.pro @@ -0,0 +1,17 @@ +TEMPLATE = app + +QT += qml scxml +CONFIG += c++11 + +SOURCES += main.cpp \ + thedatamodel.cpp + +HEADERS += thedatamodel.h + +RESOURCES += mediaplayer.qrc + +STATECHARTS = mediaplayer.scxml + +target.path = $$[QT_INSTALL_EXAMPLES]/scxml/mediaplayer +INSTALLS += target + diff --git a/examples/scxml/mediaplayer/mediaplayer.qrc b/examples/scxml/mediaplayer/mediaplayer.qrc new file mode 100644 index 0000000..8ab4fbe --- /dev/null +++ b/examples/scxml/mediaplayer/mediaplayer.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>Mediaplayer.qml</file> + </qresource> +</RCC> diff --git a/examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-cppdatamodel.scxml b/examples/scxml/mediaplayer/mediaplayer.scxml index 1f89c5e..1f89c5e 100644 --- a/examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-cppdatamodel.scxml +++ b/examples/scxml/mediaplayer/mediaplayer.scxml diff --git a/examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.cpp b/examples/scxml/mediaplayer/thedatamodel.cpp index 641d31d..641d31d 100644 --- a/examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.cpp +++ b/examples/scxml/mediaplayer/thedatamodel.cpp diff --git a/examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.h b/examples/scxml/mediaplayer/thedatamodel.h index fc09c66..fc09c66 100644 --- a/examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.h +++ b/examples/scxml/mediaplayer/thedatamodel.h diff --git a/examples/scxml/scxml.pro b/examples/scxml/scxml.pro index 974b0bb..c7415a5 100644 --- a/examples/scxml/scxml.pro +++ b/examples/scxml/scxml.pro @@ -3,8 +3,6 @@ TEMPLATE = subdirs qtHaveModule(widgets) { SUBDIRS += trafficlight-widgets-static SUBDIRS += trafficlight-widgets-dynamic - SUBDIRS += mediaplayer-widgets-static - SUBDIRS += mediaplayer-widgets-dynamic SUBDIRS += calculator-widgets SUBDIRS += sudoku } @@ -14,10 +12,7 @@ qtHaveModule(quick) { 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 += mediaplayer SUBDIRS += invoke-static SUBDIRS += invoke-dynamic } diff --git a/src/scxml/qscxmlcppdatamodel.cpp b/src/scxml/qscxmlcppdatamodel.cpp index 3c00cfe..48a2af2 100644 --- a/src/scxml/qscxmlcppdatamodel.cpp +++ b/src/scxml/qscxmlcppdatamodel.cpp @@ -87,7 +87,7 @@ void TheDataModel::evaluateToVoid(QScxmlExecutableContent::EvaluatorId id, bool statements, and in \e cond or \e expr attributes you can use any C++ expression that can be converted to the respective bool or QVariant. And, as the \c this pointer is also captured, you can call or access the data model (the \e media attribute in the example above). For the full - example, see \l {Qt SCXML: Media Player QML Example (C++ Data Model)}. + example, see \l {Qt SCXML: Media Player Example}. */ /*! |