aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-08-08 17:31:20 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-08-10 07:44:02 +0000
commitbf4761232edd938425cf70b140be8992e697bc5d (patch)
tree513ff062d26d955a1f3bb0534ad55ce057891a98
parentdcc6b454718c5e58c31d3699d2c7a5e8de195d5f (diff)
Restore version 2.0 for the .impl imports
It's a bit of extra hassle, but the type registration can be done so that we keep the old version available to avoid deliberately breaking apps that have had to import .impl to gain access to the internal goodies. For example, someone may have made a copy of one of the controls as our documentation suggests. :) Change-Id: I5308d7e74ecebf69da7fe9c6912380f72c3c9a2b Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--.gitignore1
-rw-r--r--src/imports/controls/material/qtquickcontrols2materialstyleplugin.cpp27
-rw-r--r--src/imports/controls/qtquickcontrols2plugin.cpp16
-rw-r--r--src/imports/controls/universal/qtquickcontrols2universalstyleplugin.cpp19
-rw-r--r--tests/auto/auto.pro1
-rw-r--r--tests/auto/revisions/data/dependencies.qml6
-rw-r--r--tests/auto/revisions/revisions.pro7
-rw-r--r--tests/auto/revisions/tst_revisions.cpp84
8 files changed, 131 insertions, 30 deletions
diff --git a/.gitignore b/.gitignore
index ad0c5e97..f5bbdd5b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,6 +28,7 @@
/tests/auto/qquickstyle/tst_qquickstyle
/tests/auto/qquickstyleselector/tst_qquickstyleselector
/tests/auto/qquickuniversalstyle/tst_qquickuniversalstyle
+/tests/auto/revisions/tst_revisions
/tests/auto/sanity/tst_sanity
/tests/auto/snippets/tst_snippets
/tests/auto/styles/tst_styles
diff --git a/src/imports/controls/material/qtquickcontrols2materialstyleplugin.cpp b/src/imports/controls/material/qtquickcontrols2materialstyleplugin.cpp
index 744d17a0..77dc67a5 100644
--- a/src/imports/controls/material/qtquickcontrols2materialstyleplugin.cpp
+++ b/src/imports/controls/material/qtquickcontrols2materialstyleplugin.cpp
@@ -78,7 +78,7 @@ QtQuickControls2MaterialStylePlugin::QtQuickControls2MaterialStylePlugin(QObject
void QtQuickControls2MaterialStylePlugin::registerTypes(const char *uri)
{
qmlRegisterUncreatableType<QQuickMaterialStyle>(uri, 2, 0, "Material", tr("Material is an attached property"));
- qmlRegisterUncreatableType<QQuickMaterialStyle, 1>(uri, 2, 1, "Material", tr("Material is an attached property"));
+ qmlRegisterRevision<QQuickMaterialStyle, 1>(uri, 2, 1);
}
void QtQuickControls2MaterialStylePlugin::initializeEngine(QQmlEngine *engine, const char *uri)
@@ -86,18 +86,19 @@ void QtQuickControls2MaterialStylePlugin::initializeEngine(QQmlEngine *engine, c
QQuickStylePlugin::initializeEngine(engine, uri);
QByteArray import = QByteArray(uri) + ".impl";
- qmlRegisterType<QQuickPaddedRectangle>(import, 2, 1, "PaddedRectangle");
- qmlRegisterType<QQuickMaterialProgressRing>(import, 2, 1, "ProgressRing");
- qmlRegisterType<QQuickMaterialProgressStrip>(import, 2, 1, "ProgressStrip");
- qmlRegisterType<QQuickMaterialRingAnimator>(import, 2, 1, "RingAnimator");
- qmlRegisterType<QQuickMaterialRipple>(import, 2, 1, "Ripple");
- qmlRegisterType<QQuickMaterialStripAnimator>(import, 2, 1, "StripAnimator");
- qmlRegisterType(typeUrl(QStringLiteral("BoxShadow.qml")), import, 2, 1, "BoxShadow");
- qmlRegisterType(typeUrl(QStringLiteral("CheckIndicator.qml")), import, 2, 1, "CheckIndicator");
- qmlRegisterType(typeUrl(QStringLiteral("ElevationEffect.qml")), import, 2, 1, "ElevationEffect");
- qmlRegisterType(typeUrl(QStringLiteral("RectangularGlow.qml")), import, 2, 1, "RectangularGlow");
- qmlRegisterType(typeUrl(QStringLiteral("SliderHandle.qml")), import, 2, 1, "SliderHandle");
- qmlRegisterType(typeUrl(QStringLiteral("SwitchIndicator.qml")), import, 2, 1, "SwitchIndicator");
+ qmlRegisterType<QQuickPaddedRectangle>(import, 2, 0, "PaddedRectangle");
+ qmlRegisterRevision<QQuickPaddedRectangle, 1>(import, 2, 1);
+ qmlRegisterType<QQuickMaterialProgressRing>(import, 2, 0, "ProgressRing");
+ qmlRegisterType<QQuickMaterialProgressStrip>(import, 2, 0, "ProgressStrip");
+ qmlRegisterType<QQuickMaterialRingAnimator>(import, 2, 0, "RingAnimator");
+ qmlRegisterType<QQuickMaterialRipple>(import, 2, 0, "Ripple");
+ qmlRegisterType<QQuickMaterialStripAnimator>(import, 2, 0, "StripAnimator");
+ qmlRegisterType(typeUrl(QStringLiteral("BoxShadow.qml")), import, 2, 0, "BoxShadow");
+ qmlRegisterType(typeUrl(QStringLiteral("CheckIndicator.qml")), import, 2, 0, "CheckIndicator");
+ qmlRegisterType(typeUrl(QStringLiteral("ElevationEffect.qml")), import, 2, 0, "ElevationEffect");
+ qmlRegisterType(typeUrl(QStringLiteral("RectangularGlow.qml")), import, 2, 0, "RectangularGlow");
+ qmlRegisterType(typeUrl(QStringLiteral("SliderHandle.qml")), import, 2, 0, "SliderHandle");
+ qmlRegisterType(typeUrl(QStringLiteral("SwitchIndicator.qml")), import, 2, 0, "SwitchIndicator");
}
QString QtQuickControls2MaterialStylePlugin::name() const
diff --git a/src/imports/controls/qtquickcontrols2plugin.cpp b/src/imports/controls/qtquickcontrols2plugin.cpp
index ee35d61a..0844dbef 100644
--- a/src/imports/controls/qtquickcontrols2plugin.cpp
+++ b/src/imports/controls/qtquickcontrols2plugin.cpp
@@ -152,16 +152,16 @@ void QtQuickControls2Plugin::initializeEngine(QQmlEngine *engine, const char *ur
engine->addImageProvider(QStringLiteral("default"), new QQuickColorImageProvider(QStringLiteral(":/qt-project.org/imports/QtQuick/Controls.2/images")));
const QByteArray import = QByteArray(uri) + ".impl";
- qmlRegisterType<QQuickBusyIndicatorRing>(import, 2, 1, "BusyRing");
- qmlRegisterType<QQuickBusyIndicatorAnimator>(import, 2, 1, "BusyRingAnimator");
- qmlRegisterType<QQuickProgressStrip>(import, 2, 1, "ProgressStrip");
- qmlRegisterType<QQuickProgressAnimator>(import, 2, 1, "ProgressStripAnimator");
- qmlRegisterType<QQuickDialRing>(import, 2, 1, "DialRing");
+ qmlRegisterType<QQuickBusyIndicatorRing>(import, 2, 0, "BusyRing");
+ qmlRegisterType<QQuickBusyIndicatorAnimator>(import, 2, 0, "BusyRingAnimator");
+ qmlRegisterType<QQuickProgressStrip>(import, 2, 0, "ProgressStrip");
+ qmlRegisterType<QQuickProgressAnimator>(import, 2, 0, "ProgressStripAnimator");
+ qmlRegisterType<QQuickDialRing>(import, 2, 0, "DialRing");
qmlRegisterType<QQuickTumblerView>(import, 2, 1, "TumblerView");
- qmlRegisterType(typeUrl(QStringLiteral("CheckIndicator.qml")), import, 2, 1, "CheckIndicator");
- qmlRegisterType(typeUrl(QStringLiteral("RadioIndicator.qml")), import, 2, 1, "RadioIndicator");
- qmlRegisterType(typeUrl(QStringLiteral("SwitchIndicator.qml")), import, 2, 1, "SwitchIndicator");
+ qmlRegisterType(typeUrl(QStringLiteral("CheckIndicator.qml")), import, 2, 0, "CheckIndicator");
+ qmlRegisterType(typeUrl(QStringLiteral("RadioIndicator.qml")), import, 2, 0, "RadioIndicator");
+ qmlRegisterType(typeUrl(QStringLiteral("SwitchIndicator.qml")), import, 2, 0, "SwitchIndicator");
}
QT_END_NAMESPACE
diff --git a/src/imports/controls/universal/qtquickcontrols2universalstyleplugin.cpp b/src/imports/controls/universal/qtquickcontrols2universalstyleplugin.cpp
index aa0aea34..394e9162 100644
--- a/src/imports/controls/universal/qtquickcontrols2universalstyleplugin.cpp
+++ b/src/imports/controls/universal/qtquickcontrols2universalstyleplugin.cpp
@@ -77,7 +77,7 @@ QtQuickControls2UniversalStylePlugin::QtQuickControls2UniversalStylePlugin(QObje
void QtQuickControls2UniversalStylePlugin::registerTypes(const char *uri)
{
qmlRegisterUncreatableType<QQuickUniversalStyle>(uri, 2, 0, "Universal", tr("Universal is an attached property"));
- qmlRegisterUncreatableType<QQuickUniversalStyle, 1>(uri, 2, 1, "Universal", tr("Universal is an attached property"));
+ qmlRegisterRevision<QQuickUniversalStyle, 1>(uri, 2, 1);
}
void QtQuickControls2UniversalStylePlugin::initializeEngine(QQmlEngine *engine, const char *uri)
@@ -87,14 +87,15 @@ void QtQuickControls2UniversalStylePlugin::initializeEngine(QQmlEngine *engine,
engine->addImageProvider(name(), new QQuickColorImageProvider(QStringLiteral(":/qt-project.org/imports/QtQuick/Controls.2/Universal/images")));
QByteArray import = QByteArray(uri) + ".impl";
- qmlRegisterType<QQuickUniversalFocusRectangle>(import, 2, 1, "FocusRectangle");
- qmlRegisterType<QQuickUniversalProgressRing>(import, 2, 1, "ProgressRing");
- qmlRegisterType<QQuickUniversalProgressRingAnimator>(import, 2, 1, "ProgressRingAnimator");
- qmlRegisterType<QQuickUniversalProgressStrip>(import, 2, 1, "ProgressStrip");
- qmlRegisterType<QQuickUniversalProgressStripAnimator>(import, 2, 1, "ProgressStripAnimator");
-
- qmlRegisterType(typeUrl(QStringLiteral("RadioIndicator.qml")), import, 2, 1, "RadioIndicator");
- qmlRegisterType(typeUrl(QStringLiteral("SwitchIndicator.qml")), import, 2, 1, "SwitchIndicator");
+ qmlRegisterType<QQuickUniversalFocusRectangle>(import, 2, 0, "FocusRectangle");
+ qmlRegisterRevision<QQuickUniversalFocusRectangle, 1>(import, 2, 1);
+ qmlRegisterType<QQuickUniversalProgressRing>(import, 2, 0, "ProgressRing");
+ qmlRegisterType<QQuickUniversalProgressRingAnimator>(import, 2, 0, "ProgressRingAnimator");
+ qmlRegisterType<QQuickUniversalProgressStrip>(import, 2, 0, "ProgressStrip");
+ qmlRegisterType<QQuickUniversalProgressStripAnimator>(import, 2, 0, "ProgressStripAnimator");
+
+ qmlRegisterType(typeUrl(QStringLiteral("RadioIndicator.qml")), import, 2, 0, "RadioIndicator");
+ qmlRegisterType(typeUrl(QStringLiteral("SwitchIndicator.qml")), import, 2, 0, "SwitchIndicator");
}
QString QtQuickControls2UniversalStylePlugin::name() const
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 437bfd71..8272dbe7 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -13,6 +13,7 @@ SUBDIRS += \
qquickstyle \
qquickstyleselector \
qquickuniversalstyle \
+ revisions \
sanity \
snippets
diff --git a/tests/auto/revisions/data/dependencies.qml b/tests/auto/revisions/data/dependencies.qml
new file mode 100644
index 00000000..6f21af18
--- /dev/null
+++ b/tests/auto/revisions/data/dependencies.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.8
+import QtQuick.Controls 2.0
+import QtQuick.Controls.Material 2.0
+import QtQuick.Controls.Universal 2.0
+
+Control { }
diff --git a/tests/auto/revisions/revisions.pro b/tests/auto/revisions/revisions.pro
new file mode 100644
index 00000000..b3c448da
--- /dev/null
+++ b/tests/auto/revisions/revisions.pro
@@ -0,0 +1,7 @@
+CONFIG += testcase
+TARGET = tst_revisions
+SOURCES += tst_revisions.cpp
+
+macos:CONFIG -= app_bundle
+
+QT += qml testlib
diff --git a/tests/auto/revisions/tst_revisions.cpp b/tests/auto/revisions/tst_revisions.cpp
new file mode 100644
index 00000000..33649d62
--- /dev/null
+++ b/tests/auto/revisions/tst_revisions.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/qtest.h>
+#include <QtTest/qsignalspy.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+
+class tst_revisions : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void revisions_data();
+ void revisions();
+};
+
+void tst_revisions::revisions_data()
+{
+ QTest::addColumn<int>("revision");
+
+ // In theory, this could be done in a loop from 5.7 to QT_VERSION, but
+ // the test would immediately fail when the Qt version was bumped up.
+ // Therefore it is better to just add these lines by hand when adding
+ // new revisions.
+ QTest::newRow("2.0") << 0; // Qt 5.7
+ QTest::newRow("2.1") << 1; // Qt 5.8
+}
+
+void tst_revisions::revisions()
+{
+ QFETCH(int, revision);
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QString("import QtQuick 2.0; \
+ import QtQuick.Controls 2.%1; \
+ import QtQuick.Controls.impl 2.%1; \
+ import QtQuick.Controls.Material 2.%1; \
+ import QtQuick.Controls.Material.impl 2.%1; \
+ import QtQuick.Controls.Universal 2.%1; \
+ import QtQuick.Controls.Universal.impl 2.%1; \
+ Control { }").arg(revision).toUtf8(), QUrl());
+
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY2(!object.isNull(), qPrintable(component.errorString()));
+}
+
+QTEST_MAIN(tst_revisions)
+
+#include "tst_revisions.moc"