diff options
author | Mike Krus <mike.krus@kdab.com> | 2019-09-30 12:18:23 +0100 |
---|---|---|
committer | Mike Krus <mike.krus@kdab.com> | 2019-10-01 07:03:47 +0100 |
commit | ecd455dc00ced212a156f678cd022c10652c8422 (patch) | |
tree | 7cde7cb85e4f67a18b85ad298332fb4479e13e26 /src/input/backend | |
parent | dc53660a03d8fd78a565428a351a23752d763036 (diff) |
Update QAxisSetting to use direct sync
Change-Id: Ib8067fe61bb0fc1994a4cdfff912e454a0799d44
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/input/backend')
-rw-r--r-- | src/input/backend/axissetting.cpp | 32 | ||||
-rw-r--r-- | src/input/backend/axissetting_p.h | 8 |
2 files changed, 13 insertions, 27 deletions
diff --git a/src/input/backend/axissetting.cpp b/src/input/backend/axissetting.cpp index b3c81f84d..de5c3f3ca 100644 --- a/src/input/backend/axissetting.cpp +++ b/src/input/backend/axissetting.cpp @@ -50,22 +50,13 @@ namespace Qt3DInput { namespace Input { AxisSetting::AxisSetting() - : Qt3DCore::QBackendNode() + : BackendNode() , m_deadZoneRadius(0.0f) , m_axes(0) , m_smooth(false) { } -void AxisSetting::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) -{ - const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QAxisSettingData>>(change); - const auto &data = typedChange->data; - m_deadZoneRadius = data.deadZoneRadius; - m_axes = data.axes; - m_smooth = data.smooth; -} - void AxisSetting::cleanup() { QBackendNode::setEnabled(false); @@ -74,19 +65,16 @@ void AxisSetting::cleanup() m_smooth = false; } -void AxisSetting::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) +void AxisSetting::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) { - if (e->type() == Qt3DCore::PropertyUpdated) { - Qt3DCore::QPropertyUpdatedChangePtr propertyChange = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e); - if (propertyChange->propertyName() == QByteArrayLiteral("deadZoneRadius")) { - m_deadZoneRadius = propertyChange->value().toFloat(); - } else if (propertyChange->propertyName() == QByteArrayLiteral("axes")) { - m_axes = propertyChange->value().value<QVector<int>>(); - } else if (propertyChange->propertyName() == QByteArrayLiteral("smooth")) { - m_smooth = propertyChange->value().toBool(); - } - } - QBackendNode::sceneChangeEvent(e); + BackendNode::syncFromFrontEnd(frontEnd, firstTime); + const QAxisSetting *node = qobject_cast<const QAxisSetting *>(frontEnd); + if (!node) + return; + + m_deadZoneRadius = node->deadZoneRadius(); + m_axes = node->axes(); + m_smooth = node->isSmoothEnabled(); } } // namespace Input diff --git a/src/input/backend/axissetting_p.h b/src/input/backend/axissetting_p.h index 42e1010d5..7d1e6ed4c 100644 --- a/src/input/backend/axissetting_p.h +++ b/src/input/backend/axissetting_p.h @@ -51,14 +51,14 @@ // We mean it. // -#include <Qt3DCore/qbackendnode.h> +#include <Qt3DInput/private/backendnode_p.h> QT_BEGIN_NAMESPACE namespace Qt3DInput { namespace Input { -class Q_AUTOTEST_EXPORT AxisSetting : public Qt3DCore::QBackendNode +class Q_AUTOTEST_EXPORT AxisSetting : public BackendNode { public: AxisSetting(); @@ -68,11 +68,9 @@ public: inline QVector<int> axes() const { return m_axes; } inline bool isSmoothEnabled() const { return m_smooth; } -protected: - void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override; + void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override; private: - void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final; float m_deadZoneRadius; QVector<int> m_axes; |