summaryrefslogtreecommitdiffstats
path: root/src/imports/sensors
diff options
context:
space:
mode:
Diffstat (limited to 'src/imports/sensors')
-rw-r--r--src/imports/sensors/plugins.qmltypes15
-rw-r--r--src/imports/sensors/qmlsensor.cpp53
-rw-r--r--src/imports/sensors/qmlsensor.h23
3 files changed, 91 insertions, 0 deletions
diff --git a/src/imports/sensors/plugins.qmltypes b/src/imports/sensors/plugins.qmltypes
index fe9c961d..94db26d0 100644
--- a/src/imports/sensors/plugins.qmltypes
+++ b/src/imports/sensors/plugins.qmltypes
@@ -172,10 +172,25 @@ Module {
Property { name: "error"; type: "int"; isReadonly: true }
Property { name: "alwaysOn"; type: "bool" }
Property { name: "skipDuplicates"; revision: 1; type: "bool" }
+ Property { name: "axesOrientationMode"; revision: 1; type: "AxesOrientationMode" }
+ Property { name: "currentOrientation"; revision: 1; type: "int"; isReadonly: true }
+ Property { name: "userOrientation"; revision: 1; type: "int" }
Signal {
name: "skipDuplicatesChanged"
Parameter { name: "skipDuplicates"; type: "bool" }
}
+ Signal {
+ name: "axesOrientationModeChanged"
+ Parameter { name: "axesOrientationMode"; type: "AxesOrientationMode" }
+ }
+ Signal {
+ name: "currentOrientationChanged"
+ Parameter { name: "currentOrientation"; type: "int" }
+ }
+ Signal {
+ name: "userOrientationChanged"
+ Parameter { name: "userOrientation"; type: "int" }
+ }
Method { name: "start"; type: "bool" }
Method { name: "stop" }
}
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());
diff --git a/src/imports/sensors/qmlsensor.h b/src/imports/sensors/qmlsensor.h
index e287f194..9b8f7b75 100644
--- a/src/imports/sensors/qmlsensor.h
+++ b/src/imports/sensors/qmlsensor.h
@@ -57,6 +57,7 @@ class QmlSensorReading;
class QmlSensor : public QObject, public QQmlParserStatus
{
Q_OBJECT
+ Q_ENUMS(AxesOrientationMode)
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(QString identifier READ identifier WRITE setIdentifier NOTIFY identifierChanged)
Q_PROPERTY(QString type READ type NOTIFY typeChanged)
@@ -72,7 +73,18 @@ class QmlSensor : public QObject, public QQmlParserStatus
Q_PROPERTY(int error READ error NOTIFY errorChanged)
Q_PROPERTY(bool alwaysOn READ isAlwaysOn WRITE setAlwaysOn NOTIFY alwaysOnChanged)
Q_PROPERTY(bool skipDuplicates READ skipDuplicates WRITE setSkipDuplicates NOTIFY skipDuplicatesChanged REVISION 1)
+ Q_PROPERTY(AxesOrientationMode axesOrientationMode READ axesOrientationMode WRITE setAxesOrientationMode NOTIFY axesOrientationModeChanged REVISION 1)
+ Q_PROPERTY(int currentOrientation READ currentOrientation NOTIFY currentOrientationChanged REVISION 1)
+ Q_PROPERTY(int userOrientation READ userOrientation WRITE setUserOrientation NOTIFY userOrientationChanged REVISION 1)
+
public:
+ // Keep in sync with QSensor::AxesOrientationMode
+ enum AxesOrientationMode {
+ FixedOrientation,
+ AutomaticOrientation,
+ UserOrientation
+ };
+
explicit QmlSensor(QObject *parent = 0);
~QmlSensor();
@@ -107,6 +119,14 @@ public:
QmlSensorReading *reading() const;
+ AxesOrientationMode axesOrientationMode() const;
+ void setAxesOrientationMode(AxesOrientationMode axesOrientationMode);
+
+ int currentOrientation() const;
+
+ int userOrientation() const;
+ void setUserOrientation(int userOrientation);
+
public Q_SLOTS:
bool start();
void stop();
@@ -125,6 +145,9 @@ Q_SIGNALS:
void errorChanged();
void alwaysOnChanged();
void skipDuplicatesChanged(bool skipDuplicates);
+ void axesOrientationModeChanged(AxesOrientationMode axesOrientationMode);
+ void currentOrientationChanged(int currentOrientation);
+ void userOrientationChanged(int userOrientation);
protected:
virtual QSensor *sensor() const = 0;