diff options
author | Juha Vuolle <juha.vuolle@insta.fi> | 2021-06-13 11:45:35 +0300 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-06-21 07:31:07 +0000 |
commit | 39b3ff04e6c6d01c4f294a870caaf19ced3216b2 (patch) | |
tree | 38df448da04bf34c5865171ba9b5c77c57031d94 /src/sensorsquick/qmltiltsensor_p.h | |
parent | 480c3543b1f686d15e4d5decafb8ae5c5198d49a (diff) |
Add binding support for sensor readings
Many of the sensors' QML "reading" value properties change with high
frequency. This makes them candidates to benefit from the more
performant bindable support.
This commit adds the bindable support for QML sensor 'reading' classes:
pressure, gyroscope, tap, compass, proximity, orientation, distance,
magnetometer, lid reading, tilt, rotation, humidity, holster, ambient
temperature, light sensor, altimeter, IR proximity, accelerometer,
ambient light, and sensor reading baseclass (timestamp common to all)
In addition to the 'reading' classes, the commit adds bindable support
for QmlSensor::reading, as it's change signal is emitted with high
frequency, on every sensor reading change.
Task-number: QTBUG-92513
Task-number: QTBUG-92503
Task-number: QTBUG-92505
Change-Id: I413ddd8a758142b9b93596e55b3bc8c3c2c98252
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit c255fe62f86598f48bd7e69e449aa95aa016f4fb)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/sensorsquick/qmltiltsensor_p.h')
-rw-r--r-- | src/sensorsquick/qmltiltsensor_p.h | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/sensorsquick/qmltiltsensor_p.h b/src/sensorsquick/qmltiltsensor_p.h index f41757b3..f7fbe6d5 100644 --- a/src/sensorsquick/qmltiltsensor_p.h +++ b/src/sensorsquick/qmltiltsensor_p.h @@ -69,8 +69,9 @@ public: ~QmlTiltSensor(); Q_INVOKABLE void calibrate(); -private: QSensor *sensor() const override; + +private: QTiltSensor *m_sensor; QmlSensorReading *createReading() const override; }; @@ -78,8 +79,8 @@ private: class Q_SENSORSQUICK_PRIVATE_EXPORT QmlTiltSensorReading : public QmlSensorReading { Q_OBJECT - Q_PROPERTY(qreal yRotation READ yRotation NOTIFY yRotationChanged) - Q_PROPERTY(qreal xRotation READ xRotation NOTIFY xRotationChanged) + Q_PROPERTY(qreal yRotation READ yRotation NOTIFY yRotationChanged BINDABLE bindableYRotation) + Q_PROPERTY(qreal xRotation READ xRotation NOTIFY xRotationChanged BINDABLE bindableXRotation) QML_NAMED_ELEMENT(TiltReading) QML_UNCREATABLE("Cannot create TiltReading") QML_ADDED_IN_VERSION(5,0) @@ -88,7 +89,9 @@ public: ~QmlTiltSensorReading(); qreal yRotation() const; + QBindable<qreal> bindableYRotation() const; qreal xRotation() const; + QBindable<qreal> bindableXRotation() const; Q_SIGNALS: void yRotationChanged(); @@ -98,8 +101,10 @@ private: QSensorReading *reading() const override; void readingUpdate() override; QTiltSensor *m_sensor; - qreal m_yRotation; - qreal m_xRotation; + Q_OBJECT_BINDABLE_PROPERTY(QmlTiltSensorReading, qreal, + m_yRotation, &QmlTiltSensorReading::yRotationChanged) + Q_OBJECT_BINDABLE_PROPERTY(QmlTiltSensorReading, qreal, + m_xRotation, &QmlTiltSensorReading::xRotationChanged) }; QT_END_NAMESPACE |