From 201ea73049229b67b5899d362bb98c2f7e3d587c Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 9 Sep 2019 17:09:36 +0200 Subject: [PATCH] Quick: Move BoundaryRule into labsanimation We don't want to mix multiple modules in the same library anymore. QtQuick should only contain types to be registered under QtQuick. Otherwise we cannot automatically generate the type registrations. Change-Id: I6a8e20fe8f7d01600232439a10168ef4298fc6b4 Reviewed-by: Simon Hausmann --- src/imports/labsanimation/labsanimation.pro | 4 ++++ src/imports/labsanimation/plugin.cpp | 2 +- .../labsanimation}/qquickboundaryrule.cpp | 0 .../labsanimation}/qquickboundaryrule_p.h | 2 +- src/quick/util/util.pri | 2 -- .../qquickboundaryrule/data/dragHandler.qml | 1 + .../qquickboundaryrule/qquickboundaryrule.pro | 2 +- .../tst_qquickboundaryrule.cpp | 24 +++++++++++-------- 8 files changed, 22 insertions(+), 15 deletions(-) rename src/{quick/util => imports/labsanimation}/qquickboundaryrule.cpp (100%) rename src/{quick/util => imports/labsanimation}/qquickboundaryrule_p.h (98%) diff --git a/src/imports/labsanimation/labsanimation.pro b/src/imports/labsanimation/labsanimation.pro index 64e076401f..128bc28ddb 100644 --- a/src/imports/labsanimation/labsanimation.pro +++ b/src/imports/labsanimation/labsanimation.pro @@ -4,8 +4,12 @@ TARGETPATH = Qt/labs/animation IMPORT_VERSION = 1.0 SOURCES += \ + qquickboundaryrule.cpp \ plugin.cpp +HEADERS += \ + qquickboundaryrule_p.h + QT = qml-private quick-private load(qml_plugin) diff --git a/src/imports/labsanimation/plugin.cpp b/src/imports/labsanimation/plugin.cpp index 7b84cf59f2..a74a30663a 100644 --- a/src/imports/labsanimation/plugin.cpp +++ b/src/imports/labsanimation/plugin.cpp @@ -40,7 +40,7 @@ #include #include -#include +#include "qquickboundaryrule_p.h" QT_BEGIN_NAMESPACE diff --git a/src/quick/util/qquickboundaryrule.cpp b/src/imports/labsanimation/qquickboundaryrule.cpp similarity index 100% rename from src/quick/util/qquickboundaryrule.cpp rename to src/imports/labsanimation/qquickboundaryrule.cpp diff --git a/src/quick/util/qquickboundaryrule_p.h b/src/imports/labsanimation/qquickboundaryrule_p.h similarity index 98% rename from src/quick/util/qquickboundaryrule_p.h rename to src/imports/labsanimation/qquickboundaryrule_p.h index d13031b173..1681558304 100644 --- a/src/quick/util/qquickboundaryrule_p.h +++ b/src/imports/labsanimation/qquickboundaryrule_p.h @@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE class QQuickAbstractAnimation; class QQuickBoundaryRulePrivate; -class Q_QUICK_PRIVATE_EXPORT QQuickBoundaryRule : public QObject, public QQmlPropertyValueInterceptor +class QQuickBoundaryRule : public QObject, public QQmlPropertyValueInterceptor { Q_OBJECT Q_DECLARE_PRIVATE(QQuickBoundaryRule) diff --git a/src/quick/util/util.pri b/src/quick/util/util.pri index ae06f7a7fe..3a1addfcd4 100644 --- a/src/quick/util/util.pri +++ b/src/quick/util/util.pri @@ -15,7 +15,6 @@ SOURCES += \ $$PWD/qquicktimeline.cpp \ $$PWD/qquickpixmapcache.cpp \ $$PWD/qquickbehavior.cpp \ - $$PWD/qquickboundaryrule.cpp \ $$PWD/qquickfontloader.cpp \ $$PWD/qquickstyledtext.cpp \ $$PWD/qquickimageprovider.cpp \ @@ -51,7 +50,6 @@ HEADERS += \ $$PWD/qquicktimeline_p_p.h \ $$PWD/qquickpixmapcache_p.h \ $$PWD/qquickbehavior_p.h \ - $$PWD/qquickboundaryrule_p.h \ $$PWD/qquickfontloader_p.h \ $$PWD/qquickstyledtext_p.h \ $$PWD/qquickimageprovider.h \ diff --git a/tests/auto/quick/qquickboundaryrule/data/dragHandler.qml b/tests/auto/quick/qquickboundaryrule/data/dragHandler.qml index c66fd76ff1..769a5b2c7d 100644 --- a/tests/auto/quick/qquickboundaryrule/data/dragHandler.qml +++ b/tests/auto/quick/qquickboundaryrule/data/dragHandler.qml @@ -14,6 +14,7 @@ Rectangle { } BoundaryRule on x { + objectName: "boundaryRule" id: xbr minimum: -50 maximum: 100 diff --git a/tests/auto/quick/qquickboundaryrule/qquickboundaryrule.pro b/tests/auto/quick/qquickboundaryrule/qquickboundaryrule.pro index ef43f4526a..c41f798d33 100644 --- a/tests/auto/quick/qquickboundaryrule/qquickboundaryrule.pro +++ b/tests/auto/quick/qquickboundaryrule/qquickboundaryrule.pro @@ -9,4 +9,4 @@ include (../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private qml-private quick-private testlib +QT += quick-private qml testlib diff --git a/tests/auto/quick/qquickboundaryrule/tst_qquickboundaryrule.cpp b/tests/auto/quick/qquickboundaryrule/tst_qquickboundaryrule.cpp index 44f1c9a2f9..75639dba49 100644 --- a/tests/auto/quick/qquickboundaryrule/tst_qquickboundaryrule.cpp +++ b/tests/auto/quick/qquickboundaryrule/tst_qquickboundaryrule.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include "../../shared/util.h" #include "../shared/viewtestutil.h" @@ -57,7 +56,7 @@ void tst_qquickboundaryrule::dragHandler() QVERIFY(target); QQuickDragHandler *dragHandler = target->findChild(); QVERIFY(dragHandler); - QQuickBoundaryRule *boundaryRule = target->findChild(); + QObject *boundaryRule = target->findChild(QLatin1String("boundaryRule")); QVERIFY(boundaryRule); QSignalSpy overshootChangedSpy(boundaryRule, SIGNAL(currentOvershootChanged())); @@ -68,29 +67,34 @@ void tst_qquickboundaryrule::dragHandler() QTest::mouseMove(&window, p1); QTRY_VERIFY(dragHandler->active()); QCOMPARE(target->position().x(), 100); - QCOMPARE(boundaryRule->currentOvershoot(), 0); - QCOMPARE(boundaryRule->peakOvershoot(), 0); + bool ok = false; + QCOMPARE(boundaryRule->property("currentOvershoot").toReal(&ok), 0); + QVERIFY(ok); + QCOMPARE(boundaryRule->property("peakOvershoot").toReal(&ok), 0); + QVERIFY(ok); QCOMPARE(overshootChangedSpy.count(), 0); // restricted drag: halfway into overshoot p1 += QPoint(20, 0); QTest::mouseMove(&window, p1); QCOMPARE(target->position().x(), 117.5); - QCOMPARE(boundaryRule->currentOvershoot(), 20); - QCOMPARE(boundaryRule->peakOvershoot(), 20); + QCOMPARE(boundaryRule->property("currentOvershoot").toReal(), 20); + QCOMPARE(boundaryRule->property("peakOvershoot").toReal(), 20); QCOMPARE(overshootChangedSpy.count(), 1); // restricted drag: maximum overshoot p1 += QPoint(80, 0); QTest::mouseMove(&window, p1); QCOMPARE(target->position().x(), 140); - QCOMPARE(boundaryRule->currentOvershoot(), 100); - QCOMPARE(boundaryRule->peakOvershoot(), 100); + QCOMPARE(boundaryRule->property("currentOvershoot").toReal(), 100); + QCOMPARE(boundaryRule->property("peakOvershoot").toReal(), 100); QCOMPARE(overshootChangedSpy.count(), 2); // release and let it return to bounds QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, p1); QTRY_COMPARE(dragHandler->active(), false); QTRY_COMPARE(overshootChangedSpy.count(), 3); - QCOMPARE(boundaryRule->currentOvershoot(), 0); - QCOMPARE(boundaryRule->peakOvershoot(), 0); + QCOMPARE(boundaryRule->property("currentOvershoot").toReal(&ok), 0); + QVERIFY(ok); + QCOMPARE(boundaryRule->property("peakOvershoot").toReal(&ok), 0); + QVERIFY(ok); QCOMPARE(target->position().x(), 100); }