summaryrefslogtreecommitdiffstats
path: root/src/sensorsquick/qmlaccelerometer.cpp
diff options
context:
space:
mode:
authorJuha Vuolle <juha.vuolle@insta.fi>2021-06-13 11:45:35 +0300
committerJuha Vuolle <juha.vuolle@insta.fi>2021-06-21 10:02:07 +0300
commitc255fe62f86598f48bd7e69e449aa95aa016f4fb (patch)
treee16d2acd0921daee507a68316f155a08f52a6eab /src/sensorsquick/qmlaccelerometer.cpp
parent7cad8ab7ece1647afc67870d4cb65c9726192753 (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. Pick-to: 6.2 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>
Diffstat (limited to 'src/sensorsquick/qmlaccelerometer.cpp')
-rw-r--r--src/sensorsquick/qmlaccelerometer.cpp33
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();
}