diff options
author | Juan José Casafranca <juan.casafranca@kdab.com> | 2017-09-08 15:49:57 +0200 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-09-08 14:40:18 +0000 |
commit | 8a4b9ebadb9e63ae367694f04786c7faf6306f27 (patch) | |
tree | f47a427328eb71c316c01638cb4843985d7891e8 | |
parent | 018c3756649c8ce3219ca9c99de2a754e7e3a00a (diff) |
Add sceneChangeEvent to QClock backend nodev5.10.0-alpha1
QClock backend node didn't implement sceneChangeEvent, so there was no
communication from frontend to backend node.
Change-Id: Idf72cba7b7c1834d80694d28a6df4826f8e279aa
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r-- | src/animation/backend/clock.cpp | 17 | ||||
-rw-r--r-- | src/animation/backend/clock_p.h | 1 | ||||
-rw-r--r-- | tests/auto/animation/clock/tst_clock.cpp | 29 |
3 files changed, 47 insertions, 0 deletions
diff --git a/src/animation/backend/clock.cpp b/src/animation/backend/clock.cpp index 84dc88ea1..f5b2bd1d3 100644 --- a/src/animation/backend/clock.cpp +++ b/src/animation/backend/clock.cpp @@ -59,6 +59,23 @@ void Clock::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change m_playbackRate = data.playbackRate; } +void Clock::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) +{ + switch (e->type()) { + case Qt3DCore::PropertyUpdated: { + const auto change = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e); + if (change->propertyName() == QByteArrayLiteral("playbackRate")) { + m_playbackRate = change.data()->value().toDouble(); + } + break; + } + + default: + break; + } + QBackendNode::sceneChangeEvent(e); +} + void Clock::cleanup() { m_playbackRate = 1.f; diff --git a/src/animation/backend/clock_p.h b/src/animation/backend/clock_p.h index d5b6b86da..77f664d33 100644 --- a/src/animation/backend/clock_p.h +++ b/src/animation/backend/clock_p.h @@ -61,6 +61,7 @@ class Q_AUTOTEST_EXPORT Clock : public BackendNode public: Clock(); + void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e); void cleanup(); void setPlaybackRate(double playbackRate) { m_playbackRate = playbackRate; } diff --git a/tests/auto/animation/clock/tst_clock.cpp b/tests/auto/animation/clock/tst_clock.cpp index 547ec6a12..a81adfe7b 100644 --- a/tests/auto/animation/clock/tst_clock.cpp +++ b/tests/auto/animation/clock/tst_clock.cpp @@ -75,6 +75,35 @@ private Q_SLOTS: // THEN QCOMPARE(backendClock.playbackRate(), 1.0); } + + void checkSceneChangeEvents() + { + // GIVEN + Qt3DAnimation::Animation::Clock backendClock; + + { + // WHEN + const bool newValue = false; + const auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(Qt3DCore::QNodeId()); + change->setPropertyName("enabled"); + change->setValue(newValue); + backendClock.sceneChangeEvent(change); + + // THEN + QCOMPARE(backendClock.isEnabled(), newValue); + } + { + // WHEN + const double newPlaybackRateValue = 2.0; + const auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(Qt3DCore::QNodeId()); + change->setPropertyName("playbackRate"); + change->setValue(newPlaybackRateValue); + backendClock.sceneChangeEvent(change); + + // THEN + QCOMPARE(backendClock.playbackRate(), newPlaybackRateValue); + } + } }; QTEST_APPLESS_MAIN(tst_Clock) |