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/qmlambienttemperaturesensor.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/qmlambienttemperaturesensor.cpp')
-rw-r--r-- | src/sensorsquick/qmlambienttemperaturesensor.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/sensorsquick/qmlambienttemperaturesensor.cpp b/src/sensorsquick/qmlambienttemperaturesensor.cpp index 3f1a4679..2dccfa38 100644 --- a/src/sensorsquick/qmlambienttemperaturesensor.cpp +++ b/src/sensorsquick/qmlambienttemperaturesensor.cpp @@ -116,6 +116,11 @@ qreal QmlAmbientTemperatureReading::temperature() const return m_temperature; } +QBindable<qreal> QmlAmbientTemperatureReading::bindableTemperature() const +{ + return &m_temperature; +} + QSensorReading *QmlAmbientTemperatureReading::reading() const { return m_sensor->reading(); @@ -123,9 +128,5 @@ QSensorReading *QmlAmbientTemperatureReading::reading() const void QmlAmbientTemperatureReading::readingUpdate() { - const qreal temperature = m_sensor->reading()->temperature(); - if (m_temperature != temperature) { - m_temperature = temperature; - Q_EMIT temperatureChanged(); - } + m_temperature = m_sensor->reading()->temperature(); } |