diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-10-14 18:46:38 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-10-14 19:02:37 +0200 |
commit | c2f8b9535d34da6948ccf45b7d5fd90de2f1bc9e (patch) | |
tree | c6f7e058a985d7c18b51cadc76283caf555071c9 /src/imports/statemachine | |
parent | 9e633bbda7608ac0231809e2a6a97ae8f2d849d6 (diff) | |
parent | 803f18f02e5609a1ca00a5b78ea6d3613d44e1a0 (diff) |
Merge remote-tracking branch 'origin/dev' into wip/cmake
Removed dependencies.yaml because we don't use it yet in wip/cmake.
Fixed conflict in qmlcachegen.cpp.
Change-Id: Ie1060c737bee1daa85779903598e5b6d5020d922
Diffstat (limited to 'src/imports/statemachine')
-rw-r--r-- | src/imports/statemachine/finalstate.h | 2 | ||||
-rw-r--r-- | src/imports/statemachine/plugin.cpp | 14 | ||||
-rw-r--r-- | src/imports/statemachine/plugins.qmltypes | 14 | ||||
-rw-r--r-- | src/imports/statemachine/signaltransition.h | 7 | ||||
-rw-r--r-- | src/imports/statemachine/state.h | 2 | ||||
-rw-r--r-- | src/imports/statemachine/statemachine.h | 2 | ||||
-rw-r--r-- | src/imports/statemachine/statemachine.pro | 3 | ||||
-rw-r--r-- | src/imports/statemachine/statemachineforeign.h | 80 | ||||
-rw-r--r-- | src/imports/statemachine/timeouttransition.h | 2 |
9 files changed, 112 insertions, 14 deletions
diff --git a/src/imports/statemachine/finalstate.h b/src/imports/statemachine/finalstate.h index 974d8a8fac..9cdbb51584 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); diff --git a/src/imports/statemachine/plugin.cpp b/src/imports/statemachine/plugin.cpp index 0ec2c353fc..993e91afea 100644 --- a/src/imports/statemachine/plugin.cpp +++ b/src/imports/statemachine/plugin.cpp @@ -42,6 +42,7 @@ #include "state.h" #include "statemachine.h" #include "timeouttransition.h" +#include "statemachineforeign.h" #include <QHistoryState> #include <QQmlExtensionPlugin> @@ -58,15 +59,10 @@ public: QtQmlStateMachinePlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { } void registerTypes(const char *uri) override { - 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"); + qmlRegisterTypesAndRevisions< + State, StateMachine, FinalState, TimeoutTransition, SignalTransition, + QHistoryStateForeign, QStateForeign, QAbstractStateForeign, QSignalTransitionForeign + >(uri, 1); qmlProtectModule(uri, 1); qmlRegisterModule(uri, 1, 15); diff --git a/src/imports/statemachine/plugins.qmltypes b/src/imports/statemachine/plugins.qmltypes index 541b1cc114..206159f057 100644 --- a/src/imports/statemachine/plugins.qmltypes +++ b/src/imports/statemachine/plugins.qmltypes @@ -137,8 +137,11 @@ Module { Component { name: "SignalTransition" prototype: "QSignalTransition" - exports: ["QtQml.StateMachine/SignalTransition 1.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQml.StateMachine/SignalTransition 1.0", + "QtQml.StateMachine/SignalTransition 1.1" + ] + exportMetaObjectRevisions: [0, 1] Property { name: "signal"; type: "QJSValue" } Property { name: "guard"; type: "QQmlScriptString" } Signal { name: "invokeYourself" } @@ -166,8 +169,11 @@ Module { Component { name: "TimeoutTransition" prototype: "QSignalTransition" - exports: ["QtQml.StateMachine/TimeoutTransition 1.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQml.StateMachine/TimeoutTransition 1.0", + "QtQml.StateMachine/TimeoutTransition 1.1" + ] + exportMetaObjectRevisions: [0, 1] Property { name: "timeout"; type: "int" } } } 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.h b/src/imports/statemachine/state.h index 8e8cefab19..4b17ea0e5f 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); diff --git a/src/imports/statemachine/statemachine.h b/src/imports/statemachine/statemachine.h index 1fa7a9da43..04894477b3 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); diff --git a/src/imports/statemachine/statemachine.pro b/src/imports/statemachine/statemachine.pro index 926a9d4a5e..7affc768e2 100644 --- a/src/imports/statemachine/statemachine.pro +++ b/src/imports/statemachine/statemachine.pro @@ -19,6 +19,7 @@ HEADERS = \ $$PWD/signaltransition.h \ $$PWD/state.h \ $$PWD/statemachine.h \ - $$PWD/timeouttransition.h + $$PWD/timeouttransition.h \ + $$PWD/statemachineforeign.h 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); |