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/qmlaccelerometer.cpp | |
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/qmlaccelerometer.cpp')
-rw-r--r-- | src/sensorsquick/qmlaccelerometer.cpp | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/sensorsquick/qmlaccelerometer.cpp b/src/sensorsquick/qmlaccelerometer.cpp index fc013837..2063ec69 100644 --- a/src/sensorsquick/qmlaccelerometer.cpp +++ b/src/sensorsquick/qmlaccelerometer.cpp @@ -139,6 +139,11 @@ qreal QmlAccelerometerReading::x() const return m_x; } +QBindable<qreal> QmlAccelerometerReading::bindableX() const +{ + return &m_x; +} + /*! \qmlproperty qreal AccelerometerReading::y This property holds the acceleration on the Y axis. @@ -151,6 +156,11 @@ qreal QmlAccelerometerReading::y() const return m_y; } +QBindable<qreal> QmlAccelerometerReading::bindableY() const +{ + return &m_y; +} + /*! \qmlproperty qreal AccelerometerReading::z This property holds the acceleration on the Z axis. @@ -163,6 +173,11 @@ qreal QmlAccelerometerReading::z() const return m_z; } +QBindable<qreal> QmlAccelerometerReading::bindableZ() const +{ + return &m_z; +} + QSensorReading *QmlAccelerometerReading::reading() const { return m_sensor->reading(); @@ -170,19 +185,7 @@ QSensorReading *QmlAccelerometerReading::reading() const void QmlAccelerometerReading::readingUpdate() { - qreal aX = m_sensor->reading()->x(); - if (m_x != aX) { - m_x = aX; - Q_EMIT xChanged(); - } - qreal aY = m_sensor->reading()->y(); - if (m_y != aY) { - m_y = aY; - Q_EMIT yChanged(); - } - qreal aZ = m_sensor->reading()->z(); - if (m_z != aZ) { - m_z = aZ; - Q_EMIT zChanged(); - } + m_x = m_sensor->reading()->x(); + m_y = m_sensor->reading()->y(); + m_z = m_sensor->reading()->z(); } |