aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlvaluetype_p.h
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-04-29 10:32:26 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-05-19 08:36:04 +0200
commit19ea4e630c70cdab1f7eec4f1a8f278df8915720 (patch)
treecb5ad929688d5eb5becd74964862db6127b857af /src/qml/qml/qqmlvaluetype_p.h
parentd29f3d7a62780d74f62330b0e3a0703a72155852 (diff)
Clean up registration of QEasingCurve
We don't need to register the Type enum for both QtQml and QtQuick. QtQml is enough. Removing this makes the whole manual value type registration obsolete. Furthermore, we want QEasingCurve as QML_FOREIGN as we have several classes with properties of that type. To keep it nice and tidy, we make the uppercase-named enum holder class a separate type. Unfortunately, the Type enums differ in one entry: QEasingCurve::BezierSpline is called Easing.Bezier in QML. Therefore, we need to keep the custom enum around. We can change all users in qtdeclarative to use the name from QEasingCurve, though. Change-Id: Ibbc78d8bbf8938e2a8722f8c09833a0c73394c3d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlvaluetype_p.h')
-rw-r--r--src/qml/qml/qqmlvaluetype_p.h55
1 files changed, 20 insertions, 35 deletions
diff --git a/src/qml/qml/qqmlvaluetype_p.h b/src/qml/qml/qqmlvaluetype_p.h
index 056baf87d0..73e6d37908 100644
--- a/src/qml/qml/qqmlvaluetype_p.h
+++ b/src/qml/qml/qqmlvaluetype_p.h
@@ -123,8 +123,6 @@ public:
static bool isValueType(int idx);
static QQmlValueType *valueType(int idx);
static const QMetaObject *metaObjectForMetaType(int type);
-
- static void registerValueTypes(const char *uri, int versionMajor, int versionMinor);
};
struct QQmlPointFValueType
@@ -265,19 +263,13 @@ public:
};
#if QT_CONFIG(easingcurve)
-struct QQmlEasingValueType
+struct QQmlEasingEnums
{
- QEasingCurve v;
Q_GADGET
QML_NAMED_ELEMENT(Easing)
QML_ADDED_IN_VERSION(2, 0)
QML_UNCREATABLE("Use the Type enum.")
- Q_PROPERTY(QQmlEasingValueType::Type type READ type WRITE setType FINAL)
- Q_PROPERTY(qreal amplitude READ amplitude WRITE setAmplitude FINAL)
- Q_PROPERTY(qreal overshoot READ overshoot WRITE setOvershoot FINAL)
- Q_PROPERTY(qreal period READ period WRITE setPeriod FINAL)
- Q_PROPERTY(QVariantList bezierCurve READ bezierCurve WRITE setBezierCurve FINAL)
public:
enum Type {
Linear = QEasingCurve::Linear,
@@ -303,10 +295,28 @@ public:
InOutBounce = QEasingCurve::InOutBounce, OutInBounce = QEasingCurve::OutInBounce,
InCurve = QEasingCurve::InCurve, OutCurve = QEasingCurve::OutCurve,
SineCurve = QEasingCurve::SineCurve, CosineCurve = QEasingCurve::CosineCurve,
- Bezier = QEasingCurve::BezierSpline
+ BezierSpline = QEasingCurve::BezierSpline,
+
+ Bezier = BezierSpline // Evil! Don't use this!
};
Q_ENUM(Type)
+};
+struct QQmlEasingValueType : public QQmlEasingEnums
+{
+ QEasingCurve v;
+ Q_GADGET
+ QML_ANONYMOUS
+ QML_FOREIGN(QEasingCurve)
+ QML_ADDED_IN_VERSION(2, 0)
+
+ Q_PROPERTY(Type type READ type WRITE setType FINAL)
+ Q_PROPERTY(qreal amplitude READ amplitude WRITE setAmplitude FINAL)
+ Q_PROPERTY(qreal overshoot READ overshoot WRITE setOvershoot FINAL)
+ Q_PROPERTY(qreal period READ period WRITE setPeriod FINAL)
+ Q_PROPERTY(QVariantList bezierCurve READ bezierCurve WRITE setBezierCurve FINAL)
+
+public:
Type type() const;
qreal amplitude() const;
qreal overshoot() const;
@@ -335,31 +345,6 @@ public:
QString name() const;
};
-template<typename T>
-int qmlRegisterValueTypeEnums(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
-{
- QQmlPrivate::RegisterType type = {
- 0,
-
- QMetaType::fromType<T*>(), QMetaType(), 0, nullptr,
-
- QString(),
-
- uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName, &T::staticMetaObject,
-
- nullptr, nullptr,
-
- 0, 0, 0,
-
- nullptr, nullptr,
-
- nullptr,
- QTypeRevision::zero()
- };
-
- return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
-}
-
QT_END_NAMESPACE
#endif // QQMLVALUETYPE_P_H