From 8dbfad334fd56356d6190a0e645f974567c90183 Mon Sep 17 00:00:00 2001 From: Juha Vuolle Date: Mon, 20 Feb 2023 12:50:46 +0200 Subject: 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 (cherry picked from commit 1eb77736b2e72bfcbdc356e183e3cbb0f09d71a1) Reviewed-by: Qt Cherry-pick Bot --- examples/scxml/CMakeLists.txt | 9 +- examples/scxml/mediaplayer-common/Mediaplayer.qml | 95 ------------------- .../mediaplayer-common/doc/images/mediaplayer.png | Bin 5951 -> 0 bytes .../doc/src/mediaplayer-compiling.qdocinc | 29 ------ .../src/mediaplayer-ecmascript-data-model.qdocinc | 9 -- ...ediaplayer-widgets-connecting-to-states.qdocinc | 16 ---- examples/scxml/mediaplayer-common/mainwindow.cpp | 55 ----------- examples/scxml/mediaplayer-common/mainwindow.h | 36 -------- examples/scxml/mediaplayer-common/mainwindow.ui | 31 ------- .../scxml/mediaplayer-common/mediaplayer.scxml | 45 --------- .../mediaplayer-qml-cppdatamodel/CMakeLists.txt | 62 ------------- .../doc/src/mediaplayer-qml-cppdatamodel.qdoc | 77 ---------------- .../mediaplayer-cppdatamodel.scxml | 36 -------- .../mediaplayer-qml-cppdatamodel.cpp | 22 ----- .../mediaplayer-qml-cppdatamodel.pro | 17 ---- .../mediaplayer-qml-cppdatamodel.qml | 16 ---- .../mediaplayer-qml-cppdatamodel.qrc | 6 -- .../mediaplayer-qml-cppdatamodel/thedatamodel.cpp | 17 ---- .../mediaplayer-qml-cppdatamodel/thedatamodel.h | 21 ----- .../scxml/mediaplayer-qml-dynamic/CMakeLists.txt | 59 ------------ .../doc/src/mediaplayer-qml-dynamic.qdoc | 47 ---------- .../mediaplayer-qml-dynamic.cpp | 19 ---- .../mediaplayer-qml-dynamic.pro | 12 --- .../mediaplayer-qml-dynamic.qml | 6 -- .../mediaplayer-qml-dynamic.qrc | 7 -- .../scxml/mediaplayer-qml-static/CMakeLists.txt | 59 ------------ .../doc/src/mediaplayer-qml-static.qdoc | 33 ------- .../mediaplayer-qml-static.cpp | 23 ----- .../mediaplayer-qml-static.pro | 14 --- .../mediaplayer-qml-static.qml | 10 -- .../mediaplayer-qml-static.qrc | 6 -- .../mediaplayer-widgets-dynamic/CMakeLists.txt | 55 ----------- .../doc/src/mediaplayer-widgets-dynamic.qdoc | 50 ---------- .../mediaplayer-widgets-dynamic.cpp | 21 ----- .../mediaplayer-widgets-dynamic.pro | 21 ----- .../mediaplayer-widgets-dynamic/mediaplayer.qrc | 6 -- .../mediaplayer-widgets-static/CMakeLists.txt | 44 --------- .../doc/src/mediaplayer-widgets-static.qdoc | 35 ------- .../mediaplayer-widgets-static.cpp | 19 ---- .../mediaplayer-widgets-static.pro | 20 ---- examples/scxml/mediaplayer/CMakeLists.txt | 56 ++++++++++++ examples/scxml/mediaplayer/Mediaplayer.qml | 101 +++++++++++++++++++++ .../scxml/mediaplayer/doc/images/mediaplayer.png | Bin 0 -> 5951 bytes .../scxml/mediaplayer/doc/src/mediaplayer.qdoc | 77 ++++++++++++++++ examples/scxml/mediaplayer/main.cpp | 22 +++++ examples/scxml/mediaplayer/mediaplayer.pro | 17 ++++ examples/scxml/mediaplayer/mediaplayer.qrc | 5 + examples/scxml/mediaplayer/mediaplayer.scxml | 36 ++++++++ examples/scxml/mediaplayer/thedatamodel.cpp | 17 ++++ examples/scxml/mediaplayer/thedatamodel.h | 21 +++++ examples/scxml/scxml.pro | 7 +- src/scxml/qscxmlcppdatamodel.cpp | 2 +- 52 files changed, 355 insertions(+), 1171 deletions(-) delete mode 100644 examples/scxml/mediaplayer-common/Mediaplayer.qml delete mode 100644 examples/scxml/mediaplayer-common/doc/images/mediaplayer.png delete mode 100644 examples/scxml/mediaplayer-common/doc/src/mediaplayer-compiling.qdocinc delete mode 100644 examples/scxml/mediaplayer-common/doc/src/mediaplayer-ecmascript-data-model.qdocinc delete mode 100644 examples/scxml/mediaplayer-common/doc/src/mediaplayer-widgets-connecting-to-states.qdocinc delete mode 100644 examples/scxml/mediaplayer-common/mainwindow.cpp delete mode 100644 examples/scxml/mediaplayer-common/mainwindow.h delete mode 100644 examples/scxml/mediaplayer-common/mainwindow.ui delete mode 100644 examples/scxml/mediaplayer-common/mediaplayer.scxml delete mode 100644 examples/scxml/mediaplayer-qml-cppdatamodel/CMakeLists.txt delete mode 100644 examples/scxml/mediaplayer-qml-cppdatamodel/doc/src/mediaplayer-qml-cppdatamodel.qdoc delete mode 100644 examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-cppdatamodel.scxml delete mode 100644 examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-qml-cppdatamodel.cpp delete mode 100644 examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-qml-cppdatamodel.pro delete mode 100644 examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-qml-cppdatamodel.qml delete mode 100644 examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-qml-cppdatamodel.qrc delete mode 100644 examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.cpp delete mode 100644 examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.h delete mode 100644 examples/scxml/mediaplayer-qml-dynamic/CMakeLists.txt delete mode 100644 examples/scxml/mediaplayer-qml-dynamic/doc/src/mediaplayer-qml-dynamic.qdoc delete mode 100644 examples/scxml/mediaplayer-qml-dynamic/mediaplayer-qml-dynamic.cpp delete mode 100644 examples/scxml/mediaplayer-qml-dynamic/mediaplayer-qml-dynamic.pro delete mode 100644 examples/scxml/mediaplayer-qml-dynamic/mediaplayer-qml-dynamic.qml delete mode 100644 examples/scxml/mediaplayer-qml-dynamic/mediaplayer-qml-dynamic.qrc delete mode 100644 examples/scxml/mediaplayer-qml-static/CMakeLists.txt delete mode 100644 examples/scxml/mediaplayer-qml-static/doc/src/mediaplayer-qml-static.qdoc delete mode 100644 examples/scxml/mediaplayer-qml-static/mediaplayer-qml-static.cpp delete mode 100644 examples/scxml/mediaplayer-qml-static/mediaplayer-qml-static.pro delete mode 100644 examples/scxml/mediaplayer-qml-static/mediaplayer-qml-static.qml delete mode 100644 examples/scxml/mediaplayer-qml-static/mediaplayer-qml-static.qrc delete mode 100644 examples/scxml/mediaplayer-widgets-dynamic/CMakeLists.txt delete mode 100644 examples/scxml/mediaplayer-widgets-dynamic/doc/src/mediaplayer-widgets-dynamic.qdoc delete mode 100644 examples/scxml/mediaplayer-widgets-dynamic/mediaplayer-widgets-dynamic.cpp delete mode 100644 examples/scxml/mediaplayer-widgets-dynamic/mediaplayer-widgets-dynamic.pro delete mode 100644 examples/scxml/mediaplayer-widgets-dynamic/mediaplayer.qrc delete mode 100644 examples/scxml/mediaplayer-widgets-static/CMakeLists.txt delete mode 100644 examples/scxml/mediaplayer-widgets-static/doc/src/mediaplayer-widgets-static.qdoc delete mode 100644 examples/scxml/mediaplayer-widgets-static/mediaplayer-widgets-static.cpp delete mode 100644 examples/scxml/mediaplayer-widgets-static/mediaplayer-widgets-static.pro create mode 100644 examples/scxml/mediaplayer/CMakeLists.txt create mode 100644 examples/scxml/mediaplayer/Mediaplayer.qml create mode 100644 examples/scxml/mediaplayer/doc/images/mediaplayer.png create mode 100644 examples/scxml/mediaplayer/doc/src/mediaplayer.qdoc create mode 100644 examples/scxml/mediaplayer/main.cpp create mode 100644 examples/scxml/mediaplayer/mediaplayer.pro create mode 100644 examples/scxml/mediaplayer/mediaplayer.qrc create mode 100644 examples/scxml/mediaplayer/mediaplayer.scxml create mode 100644 examples/scxml/mediaplayer/thedatamodel.cpp create mode 100644 examples/scxml/mediaplayer/thedatamodel.h 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/Mediaplayer.qml b/examples/scxml/mediaplayer-common/Mediaplayer.qml deleted file mode 100644 index 7767c95..0000000 --- a/examples/scxml/mediaplayer-common/Mediaplayer.qml +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -import QtQuick -import QtQuick.Window -import QtScxml - -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: (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-common/doc/images/mediaplayer.png deleted file mode 100644 index b4c051e..0000000 Binary files a/examples/scxml/mediaplayer-common/doc/images/mediaplayer.png and /dev/null differ 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 element in \e mediaplayer-common/mediaplayer.scxml: - - \quotefromfile mediaplayer-common/mediaplayer.scxml - \skipto scxml - \printuntil - 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 -#include - -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 - -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 @@ - - - MainWindow - - - - 0 - 0 - 750 - 350 - - - - - - - - - - Stopped - - - - - - - - - - - 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 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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/doc/src/mediaplayer-qml-cppdatamodel.qdoc b/examples/scxml/mediaplayer-qml-cppdatamodel/doc/src/mediaplayer-qml-cppdatamodel.qdoc deleted file mode 100644 index 5616d2b..0000000 --- a/examples/scxml/mediaplayer-qml-cppdatamodel/doc/src/mediaplayer-qml-cppdatamodel.qdoc +++ /dev/null @@ -1,77 +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-cppdatamodel - \title Qt SCXML Media Player QML Example (C++ Data Model) - \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 - data from a C++ data model. The data model enables writing C++ code for - \e expr attributes and \c - - - - - - - - - - - - - - - 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 d1cf1bf..0000000 --- a/examples/scxml/mediaplayer-qml-cppdatamodel/mediaplayer-qml-cppdatamodel.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#include -#include -#include - -#include "mediaplayer-cppdatamodel.h" -#include "thedatamodel.h" - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - - qmlRegisterType("MediaPlayerDataModel", 1, 0, "MediaPlayerDataModel"); - qmlRegisterType("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 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 @@ - - - ../mediaplayer-common/Mediaplayer.qml - mediaplayer-qml-cppdatamodel.qml - - diff --git a/examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.cpp b/examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.cpp deleted file mode 100644 index 641d31d..0000000 --- a/examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#include "thedatamodel.h" - -#include - -bool TheDataModel::isValidMedia() const -{ - QString eventMedia = eventData().value(QStringLiteral("media")).toString(); - return eventMedia.size() > 0; -} - -QVariantMap TheDataModel::eventData() const -{ - return scxmlEvent().data().value(); -} diff --git a/examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.h b/examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.h deleted file mode 100644 index fc09c66..0000000 --- a/examples/scxml/mediaplayer-qml-cppdatamodel/thedatamodel.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#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/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 -#include -#include - -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 @@ - - - ../mediaplayer-common/Mediaplayer.qml - mediaplayer-qml-dynamic.qml - ../mediaplayer-common/mediaplayer.scxml - - 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 -#include -#include - -#include "mediaplayer.h" - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - - qmlRegisterType("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 @@ - - - ../mediaplayer-common/Mediaplayer.qml - mediaplayer-qml-static.qml - - 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 -#include - -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 @@ - - - ../mediaplayer-common/mediaplayer.scxml - - - 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 - -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/Mediaplayer.qml b/examples/scxml/mediaplayer/Mediaplayer.qml new file mode 100644 index 0000000..c966e4e --- /dev/null +++ b/examples/scxml/mediaplayer/Mediaplayer.qml @@ -0,0 +1,101 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +import QtQuick +import QtQuick.Window +import QtScxml + +import MediaPlayerStateMachine +import MediaPlayerDataModel + +Window { + id: root + + MediaPlayerDataModel { + id: model + } + + property StateMachine stateMachine: MediaPlayerStateMachine { + onDataModelChanged: 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 { + 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" + } + + EventConnection { + stateMachine: root.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/doc/images/mediaplayer.png b/examples/scxml/mediaplayer/doc/images/mediaplayer.png new file mode 100644 index 0000000..b4c051e Binary files /dev/null and b/examples/scxml/mediaplayer/doc/images/mediaplayer.png differ diff --git a/examples/scxml/mediaplayer/doc/src/mediaplayer.qdoc b/examples/scxml/mediaplayer/doc/src/mediaplayer.qdoc new file mode 100644 index 0000000..87e7ffd --- /dev/null +++ b/examples/scxml/mediaplayer/doc/src/mediaplayer.qdoc @@ -0,0 +1,77 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only + +/*! + \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 Example} demonstrates how to access + data from a C++ data model. The data model enables writing C++ code for + \e expr attributes and \c + + + + + + + + + + + + + + + diff --git a/examples/scxml/mediaplayer/thedatamodel.cpp b/examples/scxml/mediaplayer/thedatamodel.cpp new file mode 100644 index 0000000..641d31d --- /dev/null +++ b/examples/scxml/mediaplayer/thedatamodel.cpp @@ -0,0 +1,17 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#include "thedatamodel.h" + +#include + +bool TheDataModel::isValidMedia() const +{ + QString eventMedia = eventData().value(QStringLiteral("media")).toString(); + return eventMedia.size() > 0; +} + +QVariantMap TheDataModel::eventData() const +{ + return scxmlEvent().data().value(); +} diff --git a/examples/scxml/mediaplayer/thedatamodel.h b/examples/scxml/mediaplayer/thedatamodel.h new file mode 100644 index 0000000..fc09c66 --- /dev/null +++ b/examples/scxml/mediaplayer/thedatamodel.h @@ -0,0 +1,21 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#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/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}. */ /*! -- cgit v1.2.3