summaryrefslogtreecommitdiffstats
path: root/src/imports/sensors/qmlsensor.cpp
diff options
context:
space:
mode:
authorThomas McGuire <thomas.mcguire.qnx@kdab.com>2013-01-10 13:38:43 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-23 18:33:17 +0100
commit78ad1fabee403ac910d29bb212cf0e3b9a670708 (patch)
tree9dbfdfdab19de9666eaf2923e79d2b9141cc4eaa /src/imports/sensors/qmlsensor.cpp
parent5700ab09b06617d73b0495d2db0696512913ba51 (diff)
Add a axes remapping feature
This allows orientable sensors like accelerometer or compass to change to adapt the reading values based on the current screen orientation. Add support for the BlackBerry backend. Change-Id: If7cfde8f20da4f677fdd13c38f7e11f2ed96bedd Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com>
Diffstat (limited to 'src/imports/sensors/qmlsensor.cpp')
-rw-r--r--src/imports/sensors/qmlsensor.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/imports/sensors/qmlsensor.cpp b/src/imports/sensors/qmlsensor.cpp
index 40a0ebfe..727526ae 100644
--- a/src/imports/sensors/qmlsensor.cpp
+++ b/src/imports/sensors/qmlsensor.cpp
@@ -307,6 +307,55 @@ QmlSensorReading *QmlSensor::reading() const
}
/*!
+ \qmlproperty Sensor::AxesOrientationMode Sensor::axesOrientationMode
+ \since QtSensors 5.1
+ This property holds the mode that affects how the screen orientation changes reading values.
+
+ Please see QSensor::axesOrientationMode for information about this property.
+*/
+
+QmlSensor::AxesOrientationMode QmlSensor::axesOrientationMode() const
+{
+ return static_cast<QmlSensor::AxesOrientationMode>(sensor()->axesOrientationMode());
+}
+
+void QmlSensor::setAxesOrientationMode(QmlSensor::AxesOrientationMode axesOrientationMode)
+{
+ sensor()->setAxesOrientationMode(static_cast<QSensor::AxesOrientationMode>(axesOrientationMode));
+}
+
+/*!
+ \qmlproperty int Sensor::currentOrientation
+ \since QtSensors 5.1
+ This property holds the current orientation that is used for rotating the reading values.
+
+ Please see QSensor::currentOrientation for information about this property.
+*/
+
+int QmlSensor::currentOrientation() const
+{
+ return sensor()->currentOrientation();
+}
+
+/*!
+ \qmlproperty int Sensor::userOrientation
+ \since QtSensors 5.1
+ This property holds the angle used for rotating the reading values in the UserOrientation mode.
+
+ Please see QSensor::userOrientation for information about this property.
+*/
+
+int QmlSensor::userOrientation() const
+{
+ return sensor()->userOrientation();
+}
+
+void QmlSensor::setUserOrientation(int userOrientation)
+{
+ sensor()->setUserOrientation(userOrientation);
+}
+
+/*!
\qmlmethod bool Sensor::start()
Start retrieving values from the sensor. Returns true if the sensor was started, false otherwise.
@@ -343,6 +392,10 @@ void QmlSensor::componentComplete()
connect(sensor(), SIGNAL(activeChanged()), this, SIGNAL(activeChanged()));
connect(sensor(), SIGNAL(alwaysOnChanged()), this, SIGNAL(alwaysOnChanged()));
connect(sensor(), SIGNAL(skipDuplicatesChanged(bool)), this, SIGNAL(skipDuplicatesChanged(bool)));
+ connect(sensor(), SIGNAL(axesOrientationModeChanged(AxesOrientationMode)),
+ this, SIGNAL(axesOrientationModeChanged(AxesOrientationMode)));
+ connect(sensor(), SIGNAL(userOrientationChanged(int)), this, SIGNAL(userOrientationChanged(int)));
+ connect(sensor(), SIGNAL(currentOrientationChanged(int)), this, SIGNAL(currentOrientationChanged(int)));
// We need to set this on the sensor object now
sensor()->setIdentifier(m_identifier.toLocal8Bit());