aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/statemachine
diff options
context:
space:
mode:
Diffstat (limited to 'src/imports/statemachine')
-rw-r--r--src/imports/statemachine/childrenprivate.h138
-rw-r--r--src/imports/statemachine/finalstate.cpp4
-rw-r--r--src/imports/statemachine/finalstate.h4
-rw-r--r--src/imports/statemachine/plugin.cpp25
-rw-r--r--src/imports/statemachine/plugins.qmltypes173
-rw-r--r--src/imports/statemachine/signaltransition.cpp2
-rw-r--r--src/imports/statemachine/signaltransition.h7
-rw-r--r--src/imports/statemachine/state.cpp11
-rw-r--r--src/imports/statemachine/state.h4
-rw-r--r--src/imports/statemachine/statemachine.cpp8
-rw-r--r--src/imports/statemachine/statemachine.h4
-rw-r--r--src/imports/statemachine/statemachine.pro5
-rw-r--r--src/imports/statemachine/statemachineforeign.h80
-rw-r--r--src/imports/statemachine/timeouttransition.h2
14 files changed, 232 insertions, 235 deletions
diff --git a/src/imports/statemachine/childrenprivate.h b/src/imports/statemachine/childrenprivate.h
index 57cda1c796..2dcecd6531 100644
--- a/src/imports/statemachine/childrenprivate.h
+++ b/src/imports/statemachine/childrenprivate.h
@@ -46,54 +46,142 @@
#include <QQmlInfo>
#include <QQmlListProperty>
-template <class T>
-class ChildrenPrivate
+enum class ChildrenMode {
+ None = 0x0,
+ State = 0x1,
+ Transition = 0x2,
+ StateOrTransition = State | Transition
+};
+
+template<typename T>
+static T *parentObject(QQmlListProperty<QObject> *prop) { return static_cast<T *>(prop->object); }
+
+template<class T, ChildrenMode Mode>
+struct ParentHandler
{
-public:
- ChildrenPrivate()
- {}
+ static bool unparentItem(QQmlListProperty<QObject> *prop, QObject *oldItem);
+ static bool parentItem(QQmlListProperty<QObject> *prop, QObject *item);
+};
- static void append(QQmlListProperty<QObject> *prop, QObject *item)
+template<class T>
+struct ParentHandler<T, ChildrenMode::None>
+{
+ static bool unparentItem(QQmlListProperty<QObject> *, QObject *) { return true; }
+ static bool parentItem(QQmlListProperty<QObject> *, QObject *) { return true; }
+};
+
+template<class T>
+struct ParentHandler<T, ChildrenMode::State>
+{
+ static bool parentItem(QQmlListProperty<QObject> *prop, QObject *item)
+ {
+ if (QAbstractState *state = qobject_cast<QAbstractState *>(item)) {
+ state->setParent(parentObject<T>(prop));
+ return true;
+ }
+ return false;
+ }
+
+ static bool unparentItem(QQmlListProperty<QObject> *, QObject *oldItem)
+ {
+ if (QAbstractState *state = qobject_cast<QAbstractState *>(oldItem)) {
+ state->setParent(nullptr);
+ return true;
+ }
+ return false;
+ }
+};
+
+template<class T>
+struct ParentHandler<T, ChildrenMode::Transition>
+{
+ static bool parentItem(QQmlListProperty<QObject> *prop, QObject *item)
{
- QAbstractState *state = qobject_cast<QAbstractState*>(item);
- if (state) {
- item->setParent(prop->object);
- } else {
- QAbstractTransition *trans = qobject_cast<QAbstractTransition*>(item);
- if (trans)
- static_cast<T *>(prop->object)->addTransition(trans);
+ if (QAbstractTransition *trans = qobject_cast<QAbstractTransition *>(item)) {
+ parentObject<T>(prop)->addTransition(trans);
+ return true;
}
- static_cast<ChildrenPrivate<T>*>(prop->data)->children.append(item);
- emit static_cast<T *>(prop->object)->childrenChanged();
+ return false;
}
- static void appendNoTransition(QQmlListProperty<QObject> *prop, QObject *item)
+ static bool unparentItem(QQmlListProperty<QObject> *prop, QObject *oldItem)
{
- QAbstractState *state = qobject_cast<QAbstractState*>(item);
- if (state) {
- item->setParent(prop->object);
+ if (QAbstractTransition *trans = qobject_cast<QAbstractTransition *>(oldItem)) {
+ parentObject<T>(prop)->removeTransition(trans);
+ return true;
}
- static_cast<ChildrenPrivate<T>*>(prop->data)->children.append(item);
- emit static_cast<T *>(prop->object)->childrenChanged();
+ return false;
+ }
+};
+
+template<class T>
+struct ParentHandler<T, ChildrenMode::StateOrTransition>
+{
+ static bool parentItem(QQmlListProperty<QObject> *prop, QObject *oldItem)
+ {
+ return ParentHandler<T, ChildrenMode::State>::parentItem(prop, oldItem)
+ || ParentHandler<T, ChildrenMode::Transition>::parentItem(prop, oldItem);
+ }
+
+ static bool unparentItem(QQmlListProperty<QObject> *prop, QObject *oldItem)
+ {
+ return ParentHandler<T, ChildrenMode::State>::unparentItem(prop, oldItem)
+ || ParentHandler<T, ChildrenMode::Transition>::unparentItem(prop, oldItem);
+ }
+};
+
+template <class T, ChildrenMode Mode>
+class ChildrenPrivate
+{
+public:
+ static void append(QQmlListProperty<QObject> *prop, QObject *item)
+ {
+ Handler::parentItem(prop, item);
+ static_cast<Self *>(prop->data)->children.append(item);
+ emit parentObject<T>(prop)->childrenChanged();
}
static int count(QQmlListProperty<QObject> *prop)
{
- return static_cast<ChildrenPrivate<T>*>(prop->data)->children.count();
+ return static_cast<Self *>(prop->data)->children.count();
}
static QObject *at(QQmlListProperty<QObject> *prop, int index)
{
- return static_cast<ChildrenPrivate<T>*>(prop->data)->children.at(index);
+ return static_cast<Self *>(prop->data)->children.at(index);
}
static void clear(QQmlListProperty<QObject> *prop)
{
- static_cast<ChildrenPrivate<T>*>(prop->data)->children.clear();
- emit static_cast<T *>(prop->object)->childrenChanged();
+ auto &children = static_cast<Self *>(prop->data)->children;
+ for (QObject *oldItem : qAsConst(children))
+ Handler::unparentItem(prop, oldItem);
+
+ children.clear();
+ emit parentObject<T>(prop)->childrenChanged();
+ }
+
+ static void replace(QQmlListProperty<QObject> *prop, int index, QObject *item)
+ {
+ auto &children = static_cast<Self *>(prop->data)->children;
+
+ Handler::unparentItem(prop, children.at(index));
+ Handler::parentItem(prop, item);
+
+ children.replace(index, item);
+ emit parentObject<T>(prop)->childrenChanged();
+ }
+
+ static void removeLast(QQmlListProperty<QObject> *prop)
+ {
+ Handler::unparentItem(prop, static_cast<Self *>(prop->data)->children.takeLast());
+ emit parentObject<T>(prop)->childrenChanged();
}
private:
+ using Self = ChildrenPrivate<T, Mode>;
+ using Handler = ParentHandler<T, Mode>;
+
QList<QObject *> children;
};
diff --git a/src/imports/statemachine/finalstate.cpp b/src/imports/statemachine/finalstate.cpp
index 54dcc82bae..4d4c6b2cc7 100644
--- a/src/imports/statemachine/finalstate.cpp
+++ b/src/imports/statemachine/finalstate.cpp
@@ -50,7 +50,9 @@ FinalState::FinalState(QState *parent)
QQmlListProperty<QObject> FinalState::children()
{
- return QQmlListProperty<QObject>(this, &m_children, m_children.appendNoTransition, m_children.count, m_children.at, m_children.clear);
+ return QQmlListProperty<QObject>(this, &m_children,
+ m_children.append, m_children.count, m_children.at,
+ m_children.clear, m_children.replace, m_children.removeLast);
}
/*!
diff --git a/src/imports/statemachine/finalstate.h b/src/imports/statemachine/finalstate.h
index 974d8a8fac..117a358e53 100644
--- a/src/imports/statemachine/finalstate.h
+++ b/src/imports/statemachine/finalstate.h
@@ -45,6 +45,7 @@
#include <QtCore/QFinalState>
#include <QtQml/QQmlListProperty>
+#include <QtQml/qqml.h>
QT_BEGIN_NAMESPACE
@@ -54,6 +55,7 @@ class FinalState : public QFinalState
Q_OBJECT
Q_PROPERTY(QQmlListProperty<QObject> children READ children NOTIFY childrenChanged)
Q_CLASSINFO("DefaultProperty", "children")
+ QML_ELEMENT
public:
explicit FinalState(QState *parent = 0);
@@ -64,7 +66,7 @@ Q_SIGNALS:
void childrenChanged();
private:
- ChildrenPrivate<FinalState> m_children;
+ ChildrenPrivate<FinalState, ChildrenMode::State> m_children;
};
QT_END_NAMESPACE
diff --git a/src/imports/statemachine/plugin.cpp b/src/imports/statemachine/plugin.cpp
index bf7499b31a..c370504029 100644
--- a/src/imports/statemachine/plugin.cpp
+++ b/src/imports/statemachine/plugin.cpp
@@ -42,35 +42,26 @@
#include "state.h"
#include "statemachine.h"
#include "timeouttransition.h"
+#include "statemachineforeign.h"
#include <QHistoryState>
#include <QQmlExtensionPlugin>
#include <qqml.h>
+extern void qml_register_types_QtQml_StateMachine();
+
QT_BEGIN_NAMESPACE
-class QtQmlStateMachinePlugin : public QQmlExtensionPlugin
+class QtQmlStateMachinePlugin : public QQmlEngineExtensionPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
+ Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid)
public:
- QtQmlStateMachinePlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { }
- void registerTypes(const char *uri) override
+ QtQmlStateMachinePlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent)
{
- qmlRegisterType<State>(uri, 1, 0, "State");
- qmlRegisterType<StateMachine>(uri, 1, 0, "StateMachine");
- qmlRegisterType<QHistoryState>(uri, 1, 0, "HistoryState");
- qmlRegisterType<FinalState>(uri, 1, 0, "FinalState");
- qmlRegisterUncreatableType<QState>(uri, 1, 0, "QState", "Don't use this, use State instead");
- qmlRegisterUncreatableType<QAbstractState>(uri, 1, 0, "QAbstractState", "Don't use this, use State instead");
- qmlRegisterUncreatableType<QSignalTransition>(uri, 1, 0, "QSignalTransition", "Don't use this, use SignalTransition instead");
- qmlRegisterCustomType<SignalTransition>(uri, 1, 0, "SignalTransition", new SignalTransitionParser);
- qmlRegisterType<TimeoutTransition>(uri, 1, 0, "TimeoutTransition");
- qmlProtectModule(uri, 1);
-
- // Auto-increment the import to stay in sync with ALL future QtQuick minor versions from 5.11 onward
- qmlRegisterModule(uri, 1, QT_VERSION_MINOR);
+ volatile auto registration = &qml_register_types_QtQml_StateMachine;
+ Q_UNUSED(registration);
}
};
diff --git a/src/imports/statemachine/plugins.qmltypes b/src/imports/statemachine/plugins.qmltypes
deleted file mode 100644
index 541b1cc114..0000000000
--- a/src/imports/statemachine/plugins.qmltypes
+++ /dev/null
@@ -1,173 +0,0 @@
-import QtQuick.tooling 1.2
-
-// This file describes the plugin-supplied types contained in the library.
-// It is used for QML tooling purposes only.
-//
-// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable -dependencies dependencies.json QtQml.StateMachine 1.14'
-
-Module {
- dependencies: []
- Component {
- name: "FinalState"
- defaultProperty: "children"
- prototype: "QFinalState"
- exports: ["QtQml.StateMachine/FinalState 1.0"]
- exportMetaObjectRevisions: [0]
- Property { name: "children"; type: "QObject"; isList: true; isReadonly: true }
- }
- Component {
- name: "QAbstractState"
- prototype: "QObject"
- exports: ["QtQml.StateMachine/QAbstractState 1.0"]
- isCreatable: false
- exportMetaObjectRevisions: [0]
- Property { name: "active"; type: "bool"; isReadonly: true }
- Signal { name: "entered" }
- Signal { name: "exited" }
- Signal {
- name: "activeChanged"
- Parameter { name: "active"; type: "bool" }
- }
- }
- Component {
- name: "QAbstractTransition"
- prototype: "QObject"
- Enum {
- name: "TransitionType"
- values: {
- "ExternalTransition": 0,
- "InternalTransition": 1
- }
- }
- Property { name: "sourceState"; type: "QState"; isReadonly: true; isPointer: true }
- Property { name: "targetState"; type: "QAbstractState"; isPointer: true }
- Property { name: "targetStates"; type: "QList<QAbstractState*>" }
- Property { name: "transitionType"; revision: 1; type: "TransitionType" }
- Signal { name: "triggered" }
- }
- Component { name: "QFinalState"; prototype: "QAbstractState" }
- Component {
- name: "QHistoryState"
- prototype: "QAbstractState"
- exports: ["QtQml.StateMachine/HistoryState 1.0"]
- exportMetaObjectRevisions: [0]
- Enum {
- name: "HistoryType"
- values: {
- "ShallowHistory": 0,
- "DeepHistory": 1
- }
- }
- Property { name: "defaultState"; type: "QAbstractState"; isPointer: true }
- Property { name: "defaultTransition"; type: "QAbstractTransition"; isPointer: true }
- Property { name: "historyType"; type: "HistoryType" }
- }
- Component {
- name: "QSignalTransition"
- prototype: "QAbstractTransition"
- exports: ["QtQml.StateMachine/QSignalTransition 1.0"]
- isCreatable: false
- exportMetaObjectRevisions: [0]
- Property { name: "senderObject"; type: "QObject"; isPointer: true }
- Property { name: "signal"; type: "QByteArray" }
- }
- Component {
- name: "QState"
- prototype: "QAbstractState"
- exports: ["QtQml.StateMachine/QState 1.0"]
- isCreatable: false
- exportMetaObjectRevisions: [0]
- Enum {
- name: "ChildMode"
- values: {
- "ExclusiveStates": 0,
- "ParallelStates": 1
- }
- }
- Enum {
- name: "RestorePolicy"
- values: {
- "DontRestoreProperties": 0,
- "RestoreProperties": 1
- }
- }
- Property { name: "initialState"; type: "QAbstractState"; isPointer: true }
- Property { name: "errorState"; type: "QAbstractState"; isPointer: true }
- Property { name: "childMode"; type: "ChildMode" }
- Signal { name: "finished" }
- Signal { name: "propertiesAssigned" }
- }
- Component {
- name: "QStateMachine"
- prototype: "QState"
- Property { name: "errorString"; type: "string"; isReadonly: true }
- Property { name: "globalRestorePolicy"; type: "QState::RestorePolicy" }
- Property { name: "running"; type: "bool" }
- Property { name: "animated"; type: "bool" }
- Signal { name: "started" }
- Signal { name: "stopped" }
- Signal {
- name: "runningChanged"
- Parameter { name: "running"; type: "bool" }
- }
- Method { name: "start" }
- Method { name: "stop" }
- Method {
- name: "setRunning"
- Parameter { name: "running"; type: "bool" }
- }
- }
- Component {
- name: "QTimer"
- prototype: "QObject"
- Property { name: "singleShot"; type: "bool" }
- Property { name: "interval"; type: "int" }
- Property { name: "remainingTime"; type: "int"; isReadonly: true }
- Property { name: "timerType"; type: "Qt::TimerType" }
- Property { name: "active"; type: "bool"; isReadonly: true }
- Signal { name: "timeout" }
- Method {
- name: "start"
- Parameter { name: "msec"; type: "int" }
- }
- Method { name: "start" }
- Method { name: "stop" }
- }
- Component {
- name: "SignalTransition"
- prototype: "QSignalTransition"
- exports: ["QtQml.StateMachine/SignalTransition 1.0"]
- exportMetaObjectRevisions: [0]
- Property { name: "signal"; type: "QJSValue" }
- Property { name: "guard"; type: "QQmlScriptString" }
- Signal { name: "invokeYourself" }
- Signal { name: "qmlSignalChanged" }
- Method { name: "invoke" }
- }
- Component {
- name: "State"
- defaultProperty: "children"
- prototype: "QState"
- exports: ["QtQml.StateMachine/State 1.0"]
- exportMetaObjectRevisions: [0]
- Property { name: "children"; type: "QObject"; isList: true; isReadonly: true }
- }
- Component {
- name: "StateMachine"
- defaultProperty: "children"
- prototype: "QStateMachine"
- exports: ["QtQml.StateMachine/StateMachine 1.0"]
- exportMetaObjectRevisions: [0]
- Property { name: "children"; type: "QObject"; isList: true; isReadonly: true }
- Property { name: "running"; type: "bool" }
- Signal { name: "qmlRunningChanged" }
- }
- Component {
- name: "TimeoutTransition"
- prototype: "QSignalTransition"
- exports: ["QtQml.StateMachine/TimeoutTransition 1.0"]
- exportMetaObjectRevisions: [0]
- Property { name: "timeout"; type: "int" }
- }
-}
diff --git a/src/imports/statemachine/signaltransition.cpp b/src/imports/statemachine/signaltransition.cpp
index 468f2020c7..69edaa4e48 100644
--- a/src/imports/statemachine/signaltransition.cpp
+++ b/src/imports/statemachine/signaltransition.cpp
@@ -268,8 +268,6 @@ void SignalTransitionParser::applyBindings(
\qmlsignal QAbstractTransition::triggered()
This signal is emitted when the transition has been triggered.
-
- The corresponding handler is \c onTriggered.
*/
/*!
diff --git a/src/imports/statemachine/signaltransition.h b/src/imports/statemachine/signaltransition.h
index f005c5e9b1..748e230b3e 100644
--- a/src/imports/statemachine/signaltransition.h
+++ b/src/imports/statemachine/signaltransition.h
@@ -57,6 +57,7 @@ class SignalTransition : public QSignalTransition, public QQmlParserStatus
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(QJSValue signal READ signal WRITE setSignal NOTIFY qmlSignalChanged)
Q_PROPERTY(QQmlScriptString guard READ guard WRITE setGuard NOTIFY guardChanged)
+ QML_ELEMENT
public:
explicit SignalTransition(QState *parent = nullptr);
@@ -101,6 +102,12 @@ public:
void applyBindings(QObject *object, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override;
};
+template<>
+inline QQmlCustomParser *qmlCreateCustomParser<SignalTransition>()
+{
+ return new SignalTransitionParser;
+}
+
QT_END_NAMESPACE
#endif
diff --git a/src/imports/statemachine/state.cpp b/src/imports/statemachine/state.cpp
index af76087256..ff0f55f197 100644
--- a/src/imports/statemachine/state.cpp
+++ b/src/imports/statemachine/state.cpp
@@ -61,7 +61,9 @@ void State::componentComplete()
QQmlListProperty<QObject> State::children()
{
- return QQmlListProperty<QObject>(this, &m_children, m_children.append, m_children.count, m_children.at, m_children.clear);
+ return QQmlListProperty<QObject>(this, &m_children,
+ m_children.append, m_children.count, m_children.at,
+ m_children.clear, m_children.replace, m_children.removeLast);
}
/*!
@@ -95,8 +97,6 @@ QQmlListProperty<QObject> State::children()
This signal is emitted when the State becomes active.
- The corresponding handler is \c onEntered.
-
\sa active, exited
*/
@@ -105,8 +105,6 @@ QQmlListProperty<QObject> State::children()
This signal is emitted when the State becomes inactive.
- The corresponding handler is \c onExited.
-
\sa active, entered
*/
@@ -119,7 +117,6 @@ QQmlListProperty<QObject> State::children()
\brief Provides a general-purpose state for StateMachine.
-
State objects can have child states as well as transitions to other
states. State is part of \l{The Declarative State Machine Framework}.
@@ -178,8 +175,6 @@ QQmlListProperty<QObject> State::children()
This signal is emitted when a final child state of this state is entered.
- The corresponding handler is \c onFinished.
-
\sa QAbstractState::active, QAbstractState::entered, QAbstractState::exited
*/
diff --git a/src/imports/statemachine/state.h b/src/imports/statemachine/state.h
index 8e8cefab19..68184775ab 100644
--- a/src/imports/statemachine/state.h
+++ b/src/imports/statemachine/state.h
@@ -45,6 +45,7 @@
#include <QtCore/QState>
#include <QtQml/QQmlParserStatus>
#include <QtQml/QQmlListProperty>
+#include <QtQml/qqml.h>
QT_BEGIN_NAMESPACE
@@ -54,6 +55,7 @@ class State : public QState, public QQmlParserStatus
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(QQmlListProperty<QObject> children READ children NOTIFY childrenChanged)
Q_CLASSINFO("DefaultProperty", "children")
+ QML_ELEMENT
public:
explicit State(QState *parent = 0);
@@ -67,7 +69,7 @@ Q_SIGNALS:
void childrenChanged();
private:
- ChildrenPrivate<State> m_children;
+ ChildrenPrivate<State, ChildrenMode::StateOrTransition> m_children;
};
QT_END_NAMESPACE
diff --git a/src/imports/statemachine/statemachine.cpp b/src/imports/statemachine/statemachine.cpp
index a983644018..de6c84227d 100644
--- a/src/imports/statemachine/statemachine.cpp
+++ b/src/imports/statemachine/statemachine.cpp
@@ -90,7 +90,9 @@ void StateMachine::componentComplete()
QQmlListProperty<QObject> StateMachine::children()
{
- return QQmlListProperty<QObject>(this, &m_children, m_children.append, m_children.count, m_children.at, m_children.clear);
+ return QQmlListProperty<QObject>(this, &m_children,
+ m_children.append, m_children.count, m_children.at,
+ m_children.clear, m_children.replace, m_children.removeLast);
}
/*!
@@ -209,8 +211,6 @@ QQmlListProperty<QObject> StateMachine::children()
This signal is emitted when the state machine has entered its initial state
(State::initialState).
- The corresponding handler is \c onStarted.
-
\sa running, start(), State::finished
*/
@@ -228,8 +228,6 @@ QQmlListProperty<QObject> StateMachine::children()
This signal is emitted when the state machine has stopped.
- The corresponding handler is \c onStopped.
-
\sa running, stop(), State::finished
*/
diff --git a/src/imports/statemachine/statemachine.h b/src/imports/statemachine/statemachine.h
index 1fa7a9da43..cc0360db54 100644
--- a/src/imports/statemachine/statemachine.h
+++ b/src/imports/statemachine/statemachine.h
@@ -45,6 +45,7 @@
#include <QtCore/QStateMachine>
#include <QtQml/QQmlParserStatus>
#include <QtQml/QQmlListProperty>
+#include <QtQml/qqml.h>
QT_BEGIN_NAMESPACE
@@ -58,6 +59,7 @@ class StateMachine : public QStateMachine, public QQmlParserStatus
Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY qmlRunningChanged)
Q_CLASSINFO("DefaultProperty", "children")
+ QML_ELEMENT
public:
explicit StateMachine(QObject *parent = 0);
@@ -80,7 +82,7 @@ Q_SIGNALS:
void qmlRunningChanged();
private:
- ChildrenPrivate<StateMachine> m_children;
+ ChildrenPrivate<StateMachine, ChildrenMode::StateOrTransition> m_children;
bool m_completed;
bool m_running;
};
diff --git a/src/imports/statemachine/statemachine.pro b/src/imports/statemachine/statemachine.pro
index 926a9d4a5e..d4977d8eb8 100644
--- a/src/imports/statemachine/statemachine.pro
+++ b/src/imports/statemachine/statemachine.pro
@@ -19,6 +19,9 @@ HEADERS = \
$$PWD/signaltransition.h \
$$PWD/state.h \
$$PWD/statemachine.h \
- $$PWD/timeouttransition.h
+ $$PWD/timeouttransition.h \
+ $$PWD/statemachineforeign.h
+
+CONFIG += qmltypes install_qmltypes
load(qml_plugin)
diff --git a/src/imports/statemachine/statemachineforeign.h b/src/imports/statemachine/statemachineforeign.h
new file mode 100644
index 0000000000..363c9d0e31
--- /dev/null
+++ b/src/imports/statemachine/statemachineforeign.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef STATEMACHINEFOREIGN_H
+#define STATEMACHINEFOREIGN_H
+
+#include <QtQml/qqml.h>
+#include <QtCore/qhistorystate.h>
+#include <QtCore/qstate.h>
+#include <QtCore/qabstractstate.h>
+#include <QtCore/qsignaltransition.h>
+
+struct QHistoryStateForeign
+{
+ Q_GADGET
+ QML_FOREIGN(QHistoryState)
+ QML_NAMED_ELEMENT(HistoryState)
+};
+
+struct QStateForeign
+{
+ Q_GADGET
+ QML_FOREIGN(QState)
+ QML_NAMED_ELEMENT(QState)
+ QML_UNCREATABLE("Don't use this, use State instead.")
+};
+
+struct QAbstractStateForeign
+{
+ Q_GADGET
+ QML_FOREIGN(QAbstractState)
+ QML_NAMED_ELEMENT(QAbstractState)
+ QML_UNCREATABLE("Don't use this, use State instead.")
+};
+
+struct QSignalTransitionForeign
+{
+ Q_GADGET
+ QML_FOREIGN(QSignalTransition)
+ QML_NAMED_ELEMENT(QSignalTransition)
+ QML_UNCREATABLE("Don't use this, use SignalTransition instead.")
+};
+
+#endif // STATEMACHINEFOREIGN_H
diff --git a/src/imports/statemachine/timeouttransition.h b/src/imports/statemachine/timeouttransition.h
index 2fc850fc70..cc3a22e0e5 100644
--- a/src/imports/statemachine/timeouttransition.h
+++ b/src/imports/statemachine/timeouttransition.h
@@ -42,6 +42,7 @@
#include <QtCore/QSignalTransition>
#include <QtQml/QQmlParserStatus>
+#include <QtQml/qqml.h>
QT_BEGIN_NAMESPACE
class QTimer;
@@ -51,6 +52,7 @@ class TimeoutTransition : public QSignalTransition, public QQmlParserStatus
Q_OBJECT
Q_PROPERTY(int timeout READ timeout WRITE setTimeout NOTIFY timeoutChanged)
Q_INTERFACES(QQmlParserStatus)
+ QML_ELEMENT
public:
TimeoutTransition(QState *parent = nullptr);