summaryrefslogtreecommitdiffstats
path: root/src/sensorsquick/qmlrotationsensor_p.h
diff options
context:
space:
mode:
authorJuha Vuolle <juha.vuolle@insta.fi>2021-06-13 11:45:35 +0300
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-06-21 07:31:07 +0000
commit39b3ff04e6c6d01c4f294a870caaf19ced3216b2 (patch)
tree38df448da04bf34c5865171ba9b5c77c57031d94 /src/sensorsquick/qmlrotationsensor_p.h
parent480c3543b1f686d15e4d5decafb8ae5c5198d49a (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/qmlrotationsensor_p.h')
-rw-r--r--src/sensorsquick/qmlrotationsensor_p.h20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/sensorsquick/qmlrotationsensor_p.h b/src/sensorsquick/qmlrotationsensor_p.h
index f14ad791..a3799968 100644
--- a/src/sensorsquick/qmlrotationsensor_p.h
+++ b/src/sensorsquick/qmlrotationsensor_p.h
@@ -68,12 +68,12 @@ public:
~QmlRotationSensor();
bool hasZ() const;
+ QSensor *sensor() const override;
Q_SIGNALS:
void hasZChanged(bool hasZ);
private:
- QSensor *sensor() const override;
void _update() override;
QRotationSensor *m_sensor;
QmlSensorReading *createReading() const override;
@@ -82,9 +82,9 @@ private:
class Q_SENSORSQUICK_PRIVATE_EXPORT QmlRotationSensorReading : public QmlSensorReading
{
Q_OBJECT
- Q_PROPERTY(qreal x READ x NOTIFY xChanged)
- Q_PROPERTY(qreal y READ y NOTIFY yChanged)
- Q_PROPERTY(qreal z READ z NOTIFY zChanged)
+ Q_PROPERTY(qreal x READ x NOTIFY xChanged BINDABLE bindableX)
+ Q_PROPERTY(qreal y READ y NOTIFY yChanged BINDABLE bindableY)
+ Q_PROPERTY(qreal z READ z NOTIFY zChanged BINDABLE bindableZ)
QML_NAMED_ELEMENT(RotationReading)
QML_UNCREATABLE("Cannot create RotationReading")
QML_ADDED_IN_VERSION(5,0)
@@ -93,8 +93,11 @@ public:
~QmlRotationSensorReading();
qreal x() const;
+ QBindable<qreal> bindableX() const;
qreal y() const;
+ QBindable<qreal> bindableY() const;
qreal z() const;
+ QBindable<qreal> bindableZ() const;
Q_SIGNALS:
void xChanged();
@@ -105,9 +108,12 @@ private:
QSensorReading *reading() const override;
void readingUpdate() override;
QRotationSensor *m_sensor;
- qreal m_x;
- qreal m_y;
- qreal m_z;
+ Q_OBJECT_BINDABLE_PROPERTY(QmlRotationSensorReading, qreal,
+ m_x, &QmlRotationSensorReading::xChanged)
+ Q_OBJECT_BINDABLE_PROPERTY(QmlRotationSensorReading, qreal,
+ m_y, &QmlRotationSensorReading::yChanged)
+ Q_OBJECT_BINDABLE_PROPERTY(QmlRotationSensorReading, qreal,
+ m_z, &QmlRotationSensorReading::zChanged)
};
QT_END_NAMESPACE