summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Krus <mike.krus@kdab.com>2019-09-30 12:18:23 +0100
committerMike Krus <mike.krus@kdab.com>2019-10-01 07:03:47 +0100
commitecd455dc00ced212a156f678cd022c10652c8422 (patch)
tree7cde7cb85e4f67a18b85ad298332fb4479e13e26
parentdc53660a03d8fd78a565428a351a23752d763036 (diff)
Update QAxisSetting to use direct sync
Change-Id: Ib8067fe61bb0fc1994a4cdfff912e454a0799d44 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
-rw-r--r--src/input/backend/axissetting.cpp32
-rw-r--r--src/input/backend/axissetting_p.h8
-rw-r--r--src/input/frontend/qinputaspect.cpp2
-rw-r--r--tests/auto/input/qabstractphysicaldevicebackendnode/tst_qabstractphysicaldevicebackendnode.cpp4
4 files changed, 16 insertions, 30 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;
diff --git a/src/input/frontend/qinputaspect.cpp b/src/input/frontend/qinputaspect.cpp
index 63bfdff0a..e79a9d944 100644
--- a/src/input/frontend/qinputaspect.cpp
+++ b/src/input/frontend/qinputaspect.cpp
@@ -153,7 +153,7 @@ QInputAspect::QInputAspect(QInputAspectPrivate &dd, QObject *parent)
registerBackendType<QAxisAccumulator>(QBackendNodeMapperPtr(new Input::InputNodeFunctor<Input::AxisAccumulator, Input::AxisAccumulatorManager>(d_func()->m_inputHandler->axisAccumulatorManager())));
registerBackendType<QAnalogAxisInput>(QBackendNodeMapperPtr(new Input::InputNodeFunctor<Input::AnalogAxisInput, Input::AnalogAxisInputManager>(d_func()->m_inputHandler->analogAxisInputManager())));
registerBackendType<QButtonAxisInput>(QBackendNodeMapperPtr(new Input::InputNodeFunctor<Input::ButtonAxisInput, Input::ButtonAxisInputManager>(d_func()->m_inputHandler->buttonAxisInputManager())));
- registerBackendType<QAxisSetting>(QBackendNodeMapperPtr(new Input::InputNodeFunctor<Input::AxisSetting, Input::AxisSettingManager>(d_func()->m_inputHandler->axisSettingManager())));
+ registerBackendType<QAxisSetting, true>(QBackendNodeMapperPtr(new Input::InputNodeFunctor<Input::AxisSetting, Input::AxisSettingManager>(d_func()->m_inputHandler->axisSettingManager())));
registerBackendType<Qt3DInput::QAction, true>(QBackendNodeMapperPtr(new Input::InputNodeFunctor<Input::Action, Input::ActionManager>(d_func()->m_inputHandler->actionManager())));
registerBackendType<QActionInput>(QBackendNodeMapperPtr(new Input::InputNodeFunctor<Input::ActionInput, Input::ActionInputManager>(d_func()->m_inputHandler->actionInputManager())));
registerBackendType<QInputChord>(QBackendNodeMapperPtr(new Input::InputNodeFunctor<Input::InputChord, Input::InputChordManager>(d_func()->m_inputHandler->inputChordManager())));
diff --git a/tests/auto/input/qabstractphysicaldevicebackendnode/tst_qabstractphysicaldevicebackendnode.cpp b/tests/auto/input/qabstractphysicaldevicebackendnode/tst_qabstractphysicaldevicebackendnode.cpp
index d146a80e7..06d390859 100644
--- a/tests/auto/input/qabstractphysicaldevicebackendnode/tst_qabstractphysicaldevicebackendnode.cpp
+++ b/tests/auto/input/qabstractphysicaldevicebackendnode/tst_qabstractphysicaldevicebackendnode.cpp
@@ -195,8 +195,8 @@ private Q_SLOTS:
Qt3DInput::Input::InputHandler *handler = aspectPrivate->m_inputHandler.data();
Qt3DInput::Input::AxisSetting *backendSetting1 = handler->axisSettingManager()->getOrCreateResource(settings1.id());
Qt3DInput::Input::AxisSetting *backendSetting2 = handler->axisSettingManager()->getOrCreateResource(settings2.id());
- simulateInitialization(&settings1, backendSetting1);
- simulateInitialization(&settings2, backendSetting2);
+ simulateInitializationSync(&settings1, backendSetting1);
+ simulateInitializationSync(&settings2, backendSetting2);
}
// Adding AxisSettings