summaryrefslogtreecommitdiffstats
path: root/src/imports
diff options
context:
space:
mode:
authorWolfgang Beck <wolfgang.beck@nokia.com>2011-09-02 13:29:38 +1000
committerLincoln Ramsay <lincoln.ramsay@nokia.com>2011-10-10 09:25:25 +1000
commit6b2c7688b3f344f350125f8b9713a6a77b82c3dd (patch)
tree2eb622b436f6462b344f1b4d7fbbd39859aefa3a /src/imports
parent3496318f01b63b4127c72999d634530313d60b57 (diff)
MTMW-98 QML API Version 2
Change-Id: I10c610ae22974d291fad663088c5a11449a86b05 Reviewed-on: http://codereview.qt-project.org/4107 Reviewed-by: Wolfgang Beck <wolfgang.beck@nokia.com>
Diffstat (limited to 'src/imports')
-rw-r--r--src/imports/imports.pro1
-rw-r--r--src/imports/sensors/sensors.cpp120
-rw-r--r--src/imports/sensors2/qmldir1
-rw-r--r--src/imports/sensors2/qsensor2ambientlight.cpp149
-rw-r--r--src/imports/sensors2/qsensor2ambientlight.h90
-rw-r--r--src/imports/sensors2/qsensor2proximity.cpp121
-rw-r--r--src/imports/sensors2/qsensor2proximity.h81
-rw-r--r--src/imports/sensors2/qsensor2tilt.cpp365
-rw-r--r--src/imports/sensors2/qsensor2tilt.h108
-rw-r--r--src/imports/sensors2/qsensors2import.pri38
-rw-r--r--src/imports/sensors2/sensors2.cpp72
-rw-r--r--src/imports/sensors2/sensors2.pro39
12 files changed, 1136 insertions, 49 deletions
diff --git a/src/imports/imports.pro b/src/imports/imports.pro
index a68f6a5e..6115652e 100644
--- a/src/imports/imports.pro
+++ b/src/imports/imports.pro
@@ -1,4 +1,5 @@
TEMPLATE = subdirs
SUBDIRS += sensors
+SUBDIRS += sensors2
diff --git a/src/imports/sensors/sensors.cpp b/src/imports/sensors/sensors.cpp
index ea0f076a..0d4394c7 100644
--- a/src/imports/sensors/sensors.cpp
+++ b/src/imports/sensors/sensors.cpp
@@ -63,14 +63,14 @@ class QSensorsDeclarativeModule : public QDeclarativeExtensionPlugin
public:
virtual void registerTypes(const char *uri)
{
- char const * const package = "Qt.sensors";
+ char const * const package = "QtMobility.sensors";
if (QLatin1String(uri) != QLatin1String(package)) return;
int major;
int minor;
- // Register the 1.0 interfaces
+ // Register the 1.2 interfaces
major = 1;
- minor = 0;
+ minor = 2;
qmlRegisterUncreatableType<QSensor >(package, major, minor, "Sensor", QLatin1String("Cannot create Sensor"));
qmlRegisterUncreatableType<QSensorReading >(package, major, minor, "SensorReading", QLatin1String("Cannot create SensorReading"));
qmlRegisterType <QAccelerometer >(package, major, minor, "Accelerometer");
@@ -109,6 +109,7 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
/*!
\qmlclass Sensor QSensor
\ingroup qml-sensors_type
+ \inqmlmodule QtMobility.sensors 1
\brief The Sensor element serves as a base type for sensors.
The Sensor element serves as a base type for sensors.
@@ -122,25 +123,25 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
*/
/*!
- \qmlproperty int Sensor::dataRate
+ \qmlproperty int QtMobility.sensors1::Sensor::dataRate
Sets the rate at which data is returned by the sensor.
Please see QSensor::dataRate for information about this property.
*/
/*!
- \qmlproperty bool Sensor::active
+ \qmlproperty bool QtMobility.sensors1::Sensor::active
Starts or stops the sensor.
Please see QSensor::active for information about this property.
*/
/*!
- \qmlproperty SensorReading Sensor::reading
+ \qmlproperty SensorReading QtMobility.sensors1::Sensor::reading
Holds the most recent sensor reading.
Please see QSensor::reading for information about this property.
*/
/*!
- \qmlsignal Sensor::onReadingChanged()
+ \qmlsignal QtMobility.sensors1::Sensor::onReadingChanged()
Called when the reading object changes.
Please see QSensor::readingChanged() for information about this signal.
*/
@@ -148,6 +149,7 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
/*!
\qmlclass SensorReading QSensorReading
\ingroup qml-sensors_reading
+ \inqmlmodule QtMobility.sensors 1
\brief The SensorReading element serves as a base type for sensor readings.
The SensorReading element serves as a base type for sensor readings.
@@ -159,7 +161,7 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
*/
/*!
- \qmlproperty quint64 SensorReading::timestamp
+ \qmlproperty quint64 QtMobility.sensors1::SensorReading::timestamp
A timestamp for the reading.
Please see QSensorReading::timestamp for information about this property.
*/
@@ -167,6 +169,7 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
/*!
\qmlclass Accelerometer QAccelerometer
\ingroup qml-sensors_type
+ \inqmlmodule QtMobility.sensors 1
\inherits Sensor
\brief The Accelerometer element reports on linear acceleration
along the X, Y and Z axes.
@@ -181,13 +184,13 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
*/
/*!
- \qmlproperty AccelerometerReading Accelerometer::reading
+ \qmlproperty AccelerometerReading QtMobility.sensors1::Accelerometer::reading
Holds the most recent accelerometer reading.
Please see QSensor::reading for information about this property.
*/
/*!
- \qmlsignal Accelerometer::onReadingChanged()
+ \qmlsignal QtMobility.sensors1::Accelerometer::onReadingChanged()
Called when the reading object changes.
Please see QSensor::readingChanged() for information about this signal.
*/
@@ -195,6 +198,7 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
/*!
\qmlclass AccelerometerReading QAccelerometerReading
\ingroup qml-sensors_reading
+ \inqmlmodule QtMobility.sensors 1
\inherits SensorReading
\brief The AccelerometerReading element holds the most recent Accelerometer reading.
@@ -207,23 +211,24 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
*/
/*!
- \qmlproperty qreal AccelerometerReading::x
+ \qmlproperty qreal QtMobility.sensors1::AccelerometerReading::x
Please see QAccelerometerReading::x for information about this property.
*/
/*!
- \qmlproperty qreal AccelerometerReading::y
+ \qmlproperty qreal QtMobility.sensors1::AccelerometerReading::y
Please see QAccelerometerReading::y for information about this property.
*/
/*!
- \qmlproperty qreal AccelerometerReading::z
+ \qmlproperty qreal QtMobility.sensors1::AccelerometerReading::z
Please see QAccelerometerReading::z for information about this property.
*/
/*!
\qmlclass AmbientLightSensor QAmbientLightSensor
\ingroup qml-sensors_type
+ \inqmlmodule QtMobility.sensors 1
\inherits Sensor
\brief The AmbientLightSensor element repors on ambient lighting conditions.
@@ -236,13 +241,13 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
*/
/*!
- \qmlproperty AmbientLightReading AmbientLightSensor::reading
+ \qmlproperty AmbientLightReading QtMobility.sensors1::AmbientLightSensor::reading
Holds the most recent ambient light reading.
Please see QSensor::reading for information about this property.
*/
/*!
- \qmlsignal AmbientLightSensor::onReadingChanged()
+ \qmlsignal QtMobility.sensors1::AmbientLightSensor::onReadingChanged()
Called when the reading object changes.
Please see QSensor::readingChanged() for information about this signal.
*/
@@ -250,6 +255,7 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
/*!
\qmlclass AmbientLightReading QAmbientLightReading
\ingroup qml-sensors_reading
+ \inqmlmodule QtMobility.sensors 1
\inherits SensorReading
\brief The AmbientLightReading element holds the most AmbientLightSensor reading.
@@ -262,7 +268,7 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
*/
/*!
- \qmlproperty QAmbientLightReading::LightLevel AmbientLightReading::lightLevel
+ \qmlproperty QAmbientLightReading::LightLevel QtMobility.sensors1::AmbientLightReading::lightLevel
Please see QAmbientLightReading::lightLevel for information about this property.
LightLevel constants are exposed through the AmbientLightReading class.
@@ -279,6 +285,7 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
/*!
\qmlclass Compass QCompass
\ingroup qml-sensors_type
+ \inqmlmodule QtMobility.sensors 1
\inherits Sensor
\brief The Compass element reports on heading using magnetic north as a reference.
@@ -291,13 +298,13 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
*/
/*!
- \qmlproperty CompassReading Compass::reading
+ \qmlproperty CompassReading QtMobility.sensors1::Compass::reading
Holds the most recent compass reading.
Please see QSensor::reading for information about this property.
*/
/*!
- \qmlsignal Compass::onReadingChanged()
+ \qmlsignal QtMobility.sensors1::Compass::onReadingChanged()
Called when the reading object changes.
Please see QSensor::readingChanged() for information about this signal.
*/
@@ -305,6 +312,7 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
/*!
\qmlclass CompassReading QCompassReading
\ingroup qml-sensors_reading
+ \inqmlmodule QtMobility.sensors 1
\inherits SensorReading
\brief The CompassReading element holds the most recent Compass reading.
@@ -317,18 +325,19 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
*/
/*!
- \qmlproperty qreal CompassReading::azimuth
+ \qmlproperty qreal QtMobility.sensors1::CompassReading::azimuth
Please see QCompassReading::azimuth for information about this property.
*/
/*!
- \qmlproperty qreal CompassReading::calibrationLevel
+ \qmlproperty qreal QtMobility.sensors1::CompassReading::calibrationLevel
Please see QCompassReading::calibrationLevel for information about this property.
*/
/*!
\qmlclass Magnetometer QMagnetometer
\ingroup qml-sensors_type
+ \inqmlmodule QtMobility.sensors 1
\inherits Sensor
\brief The Magnetometer element reports on magnetic field strength
along the Z, Y and Z axes.
@@ -343,13 +352,13 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
*/
/*!
- \qmlproperty MagnetometerReading Magnetometer::reading
+ \qmlproperty MagnetometerReading QtMobility.sensors1::Magnetometer::reading
Holds the most recent magnetometer reading.
Please see QSensor::reading for information about this property.
*/
/*!
- \qmlsignal Magnetometer::onReadingChanged()
+ \qmlsignal QtMobility.sensors1::Magnetometer::onReadingChanged()
Called when the reading object changes.
Please see QSensor::readingChanged() for information about this signal.
*/
@@ -357,6 +366,7 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
/*!
\qmlclass MagnetometerReading QMagnetometerReading
\ingroup qml-sensors_reading
+ \inqmlmodule QtMobility.sensors 1
\inherits SensorReading
\brief The MagnetometerReading element holds the most recent Magnetometer reading.
@@ -369,28 +379,29 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
*/
/*!
- \qmlproperty qreal MagnetometerReading::x
+ \qmlproperty qreal QtMobility.sensors1::MagnetometerReading::x
Please see QMagnetometerReading::x for information about this property.
*/
/*!
- \qmlproperty qreal MagnetometerReading::y
+ \qmlproperty qreal QtMobility.sensors1::MagnetometerReading::y
Please see QMagnetometerReading::y for information about this property.
*/
/*!
- \qmlproperty qreal MagnetometerReading::z
+ \qmlproperty qreal QtMobility.sensors1::MagnetometerReading::z
Please see QMagnetometerReading::z for information about this property.
*/
/*!
- \qmlproperty qreal MagnetometerReading::calibrationLevel
+ \qmlproperty qreal QtMobility.sensors1::MagnetometerReading::calibrationLevel
Please see QMagnetometerReading::calibrationLevel for information about this property.
*/
/*!
\qmlclass OrientationSensor QOrientationSensor
\ingroup qml-sensors_type
+ \inqmlmodule QtMobility.sensors 1
\inherits Sensor
\brief The OrientationSensor element reports device orientation.
@@ -403,13 +414,13 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
*/
/*!
- \qmlproperty OrientationReading OrientationSensor::reading
+ \qmlproperty OrientationReading QtMobility.sensors1::OrientationSensor::reading
Holds the most recent orientation reading.
Please see QSensor::reading for information about this property.
*/
/*!
- \qmlsignal OrientationSensor::onReadingChanged()
+ \qmlsignal QtMobility.sensors1::OrientationSensor::onReadingChanged()
Called when the reading object changes.
Please see QSensor::readingChanged() for information about this signal.
*/
@@ -417,6 +428,7 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
/*!
\qmlclass OrientationReading QOrientationReading
\ingroup qml-sensors_reading
+ \inqmlmodule QtMobility.sensors 1
\inherits SensorReading
\brief The OrientationReading element holds the most recent OrientationSensor reading.
@@ -429,7 +441,7 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
*/
/*!
- \qmlproperty QOrientationReading::Orientation OrientationReading::orientation
+ \qmlproperty QOrientationReading::Orientation QtMobility.sensors1::OrientationReading::orientation
Please see QOrientationReading::orientation for information about this property.
Orientation constants are exposed through the OrientationReading class.
@@ -446,6 +458,7 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
/*!
\qmlclass ProximitySensor QProximitySensor
\ingroup qml-sensors_type
+ \inqmlmodule QtMobility.sensors 1
\inherits Sensor
\brief The ProximitySensor element reports on object proximity.
@@ -458,13 +471,13 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
*/
/*!
- \qmlproperty ProximityReading ProximitySensor::reading
+ \qmlproperty ProximityReading QtMobility.sensors1::ProximitySensor::reading
Holds the most recent proximity reading.
Please see QSensor::reading for information about this property.
*/
/*!
- \qmlsignal ProximitySensor::onReadingChanged()
+ \qmlsignal QtMobility.sensors1::ProximitySensor::onReadingChanged()
Called when the reading object changes.
Please see QSensor::readingChanged() for information about this signal.
*/
@@ -472,6 +485,7 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
/*!
\qmlclass ProximityReading QProximityReading
\ingroup qml-sensors_reading
+ \inqmlmodule QtMobility.sensors 1
\inherits SensorReading
\brief The ProximityReading element holds the most recent ProximitySensor reading.
@@ -484,13 +498,14 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
*/
/*!
- \qmlproperty bool ProximityReading::close
+ \qmlproperty bool QtMobility.sensors1::ProximityReading::close
Please see QProximityReading::close for information about this property.
*/
/*!
\qmlclass RotationSensor QRotationSensor
\ingroup qml-sensors_type
+ \inqmlmodule QtMobility.sensors 1
\inherits Sensor
\brief The RotationSensor element reports on device rotation
around the X, Y and Z axes.
@@ -505,13 +520,13 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
*/
/*!
- \qmlproperty RotationReading RotationSensor::reading
+ \qmlproperty RotationReading QtMobility.sensors1::RotationSensor::reading
Holds the most recent rotation reading.
Please see QSensor::reading for information about this property.
*/
/*!
- \qmlsignal RotationSensor::onReadingChanged()
+ \qmlsignal QtMobility.sensors1::RotationSensor::onReadingChanged()
Called when the reading object changes.
Please see QSensor::readingChanged() for information about this signal.
*/
@@ -519,6 +534,7 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
/*!
\qmlclass RotationReading QRotationReading
\ingroup qml-sensors_reading
+ \inqmlmodule QtMobility.sensors 1
\inherits SensorReading
\brief The RotationReading element holds the most recent RotationSensor reading.
@@ -531,23 +547,24 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
*/
/*!
- \qmlproperty qreal RotationReading::x
+ \qmlproperty qreal QtMobility.sensors1::RotationReading::x
Please see QRotationReading::x for information about this property.
*/
/*!
- \qmlproperty qreal RotationReading::y
+ \qmlproperty qreal QtMobility.sensors1::RotationReading::y
Please see QRotationReading::y for information about this property.
*/
/*!
- \qmlproperty qreal RotationReading::z
+ \qmlproperty qreal QtMobility.sensors1::RotationReading::z
Please see QRotationReading::z for information about this property.
*/
/*!
\qmlclass TapSensor QTapSensor
\ingroup qml-sensors_type
+ \inqmlmodule QtMobility.sensors 1
\inherits Sensor
\brief The TapSensor element reports tap and double tap events
along the X, Y and Z axes.
@@ -562,13 +579,13 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
*/
/*!
- \qmlproperty TapReading TapSensor::reading
+ \qmlproperty TapReading QtMobility.sensors1::TapSensor::reading
Holds the most recent tap sensor reading.
Please see QSensor::reading for information about this property.
*/
/*!
- \qmlsignal TapSensor::onReadingChanged()
+ \qmlsignal QtMobility.sensors1::TapSensor::onReadingChanged()
Called when the reading object changes.
Please see QSensor::readingChanged() for information about this signal.
*/
@@ -576,6 +593,7 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
/*!
\qmlclass TapReading QTapReading
\ingroup qml-sensors_reading
+ \inqmlmodule QtMobility.sensors 1
\inherits SensorReading
\brief The TapReading element holds the most recent TapSensor reading.
@@ -588,12 +606,12 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
*/
/*!
- \qmlproperty bool TapReading::doubleTap
+ \qmlproperty bool QtMobility.sensors1::TapReading::doubleTap
Please see QTapReading::doubleTap for information about this property.
*/
/*!
- \qmlproperty QTapReading::TapDirection TapReading::tapDirection
+ \qmlproperty QTapReading::TapDirection QtMobility.sensors1::TapReading::tapDirection
Please see QTapReading::tapDirection for information about this property.
TapDirection constants are exposed through the TapReading class.
@@ -610,6 +628,7 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
/*!
\qmlclass LightSensor QLightSensor
\ingroup qml-sensors_type
+ \inqmlmodule QtMobility.sensors 1
\inherits Sensor
\brief The LightSensor element reports on light levels using LUX.
@@ -622,13 +641,13 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
*/
/*!
- \qmlproperty LightReading LightSensor::reading
+ \qmlproperty LightReading QtMobility.sensors1::LightSensor::reading
Holds the most recent light sensor reading.
Please see QSensor::reading for information about this property.
*/
/*!
- \qmlsignal LightSensor::onReadingChanged()
+ \qmlsignal QtMobility.sensors1::LightSensor::onReadingChanged()
Called when the reading object changes.
Please see QSensor::readingChanged() for information about this signal.
*/
@@ -636,6 +655,7 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
/*!
\qmlclass LightReading QLightReading
\ingroup qml-sensors_reading
+ \inqmlmodule QtMobility.sensors 1
\inherits SensorReading
\brief The LightReading element holds the most recent LightSensor reading.
@@ -648,13 +668,14 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
*/
/*!
- \qmlproperty qreal LightReading::lux
+ \qmlproperty qreal QtMobility.sensors1::LightReading::lux
Please see QLightReading::lux for information about this property.
*/
/*!
\qmlclass Gyroscope QGyroscope
\ingroup qml-sensors_type
+ \inqmlmodule QtMobility.sensors 1
\inherits Sensor
\brief The Gyroscope element reports on rotational acceleration
around the X, Y and Z axes.
@@ -666,13 +687,13 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
*/
/*!
- \qmlproperty GyroscopeReading Gyroscope::reading
+ \qmlproperty GyroscopeReading QtMobility.sensors1::Gyroscope::reading
Holds the most recent gyroscope reading.
Please see QSensor::reading for information about this property.
*/
/*!
- \qmlsignal Gyroscope::onReadingChanged()
+ \qmlsignal QtMobility.sensors1::Gyroscope::onReadingChanged()
Called when the reading object changes.
Please see QSensor::readingChanged() for information about this signal.
*/
@@ -680,6 +701,7 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
/*!
\qmlclass GyroscopeReading QGyroscopeReading
\ingroup qml-sensors_reading
+ \inqmlmodule QtMobility.sensors 1
\inherits SensorReading
\brief The GyroscopeReading element holds the most recent Gyroscope reading.
@@ -692,17 +714,17 @@ Q_EXPORT_PLUGIN2(qsensorsdeclarativemodule, QT_PREPEND_NAMESPACE(QSensorsDeclara
*/
/*!
- \qmlproperty qreal GyroscopeReading::x
+ \qmlproperty qreal QtMobility.sensors1::GyroscopeReading::x
Please see QGyroscopeReading::x for information about this property.
*/
/*!
- \qmlproperty qreal GyroscopeReading::y
+ \qmlproperty qreal QtMobility.sensors1::GyroscopeReading::y
Please see QGyroscopeReading::y for information about this property.
*/
/*!
- \qmlproperty qreal GyroscopeReading::z
+ \qmlproperty qreal QtMobility.sensors1::GyroscopeReading::z
Please see QGyroscopeReading::z for information about this property.
*/
diff --git a/src/imports/sensors2/qmldir b/src/imports/sensors2/qmldir
new file mode 100644
index 00000000..14c82f3b
--- /dev/null
+++ b/src/imports/sensors2/qmldir
@@ -0,0 +1 @@
+plugin declarative_qtsensors5
diff --git a/src/imports/sensors2/qsensor2ambientlight.cpp b/src/imports/sensors2/qsensor2ambientlight.cpp
new file mode 100644
index 00000000..e2a99510
--- /dev/null
+++ b/src/imports/sensors2/qsensor2ambientlight.cpp
@@ -0,0 +1,149 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsensor2ambientlight.h"
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass AmbientLightSensor QSensor2AmbientLight
+ \inqmlmodule QtSensors 5
+ \ingroup qml-QtSensors5
+ \since QtSensors 5.0
+ \brief The AmbientLightSensor element provide an easy access to determine the ambient light by using the ambient light sensor.
+
+ This element is part of the \bold{QtSensors 5} module.
+
+ \target lightLevelenum
+ \section1 Enums
+ \section2 AmbientLightSensor::LighLevel
+
+ This enum describes the ambient light levels.
+
+ \table
+ \row
+ \o AmbientLightSensor::Undefined
+ \o Ambient light not defined.
+ \row
+ \o AmbientLightSensor::Dark
+ \o Ambient light is dark.
+ \row
+ \o AmbientLightSensor::Twilight
+ \o Ambient light is twilight.
+ \row
+ \o AmbientLightSensor::Light
+ \o Ambient light is light.
+ \row
+ \o AmbientLightSensor::Bright
+ \o Ambient light is bright.
+ \row
+ \o AmbientLightSensor::Sunny
+ \o Ambient light is sunny.
+ \endtable
+*/
+QSensor2AmbientLight::QSensor2AmbientLight(QObject* parent)
+ : QObject(parent)
+ , _lightLevel(QSensor2AmbientLight::Undefined)
+{
+ _ambientLight = new QAmbientLightSensor(this);
+ _ambientLight->addFilter(this);
+}
+
+
+QSensor2AmbientLight::~QSensor2AmbientLight()
+{
+}
+
+/*!
+ \qmlproperty bool QtSensors5::AmbientLightSensor::running
+ Holds the identication if the sensor runs or not.
+*/
+/*!
+ \qmlsignal QtSensors5::AmbientLightSensor::onRunningChanged()
+ This signal is emitted whenever the value of the property running has been changed.
+*/
+bool QSensor2AmbientLight::running()
+{
+ return _ambientLight->isActive();
+}
+
+void QSensor2AmbientLight::setRunning(bool val)
+{
+ bool active = running();
+ if (active != val){
+ if (val){
+ bool ret = _ambientLight->start();
+ if (!ret)
+ qWarning() << "couldn't start the sensor.";
+ }
+ else
+ _ambientLight->stop();
+ emit runningChanged();
+ }
+}
+
+/*!
+ \qmlproperty AmbientLightSensor::LightLevel QtSensors5::AmbientLightSensor::lightLevel
+ Holds the ambient light level.
+ \sa {lightLevelenum} {AmbientLightSensor::LighLevel}
+*/
+/*!
+ \qmlsignal QtSensors5::AmbientLightSensor::onLightLevelChanged()
+ This signal is emitted whenever the value of the property lightLevel has been changed.
+*/
+
+QSensor2AmbientLight::LightLevel QSensor2AmbientLight::lightLevel()
+{
+ return _lightLevel;
+}
+
+bool QSensor2AmbientLight::filter(QAmbientLightReading *reading)
+{
+ QSensor2AmbientLight::LightLevel lv = (QSensor2AmbientLight::LightLevel)reading->lightLevel();
+ if (lv != _lightLevel){
+ _lightLevel = lv;
+ emit lightLevelChanged();
+ }
+ return false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/sensors2/qsensor2ambientlight.h b/src/imports/sensors2/qsensor2ambientlight.h
new file mode 100644
index 00000000..5b9a516a
--- /dev/null
+++ b/src/imports/sensors2/qsensor2ambientlight.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QSENSOR2AMBIENTLIGHT_H
+#define QSENSOR2AMBIENTLIGHT_H
+
+#include <QtDeclarative/qdeclarativeextensionplugin.h>
+#include <QtDeclarative/qdeclarative.h>
+#include <qambientlightsensor.h>
+
+QT_BEGIN_NAMESPACE
+
+class QSensor2AmbientLight : public QObject, public QAmbientLightFilter
+{
+ Q_OBJECT
+ Q_ENUMS(LightLevel)
+ Q_PROPERTY(LightLevel lightLevel READ lightLevel NOTIFY lightLevelChanged)
+ Q_PROPERTY(bool running READ running WRITE setRunning NOTIFY runningChanged)
+
+public:
+ QSensor2AmbientLight(QObject* parent = 0);
+ virtual ~QSensor2AmbientLight();
+
+ enum LightLevel {
+ Undefined = 0,
+ Dark,
+ Twilight,
+ Light,
+ Bright,
+ Sunny
+ };
+
+Q_SIGNALS:
+ void lightLevelChanged();
+ void runningChanged();
+
+private:
+ // Override of QAmbientLightFilter::filter(QAmbientLightReading*)
+ bool filter(QAmbientLightReading *reading);
+ LightLevel lightLevel();
+ bool running();
+ void setRunning(bool val);
+
+ QAmbientLightSensor* _ambientLight;
+ LightLevel _lightLevel;
+};
+
+QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QSensor2AmbientLight))
+
+QT_END_NAMESPACE
+
+
+#endif // QSENSOR2AMBIENTLIGHT_H
diff --git a/src/imports/sensors2/qsensor2proximity.cpp b/src/imports/sensors2/qsensor2proximity.cpp
new file mode 100644
index 00000000..3d49124c
--- /dev/null
+++ b/src/imports/sensors2/qsensor2proximity.cpp
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsensor2proximity.h"
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass ProximitySensor QSensor2Proximity
+ \inqmlmodule QtSensors 5
+ \ingroup qml-QtSensors5
+ \since QtSensors 5.0
+ \brief The ProximitySensor element provide an easy access to determine if the proximity of the mobile user by using the proximity sensor.
+
+ This element is part of the \bold{QtSensors 5} module.
+*/
+
+QSensor2Proximity::QSensor2Proximity(QObject* parent)
+ : QObject(parent)
+ , _close(false)
+{
+ _proximity = new QProximitySensor(this);
+ _proximity->addFilter(this);
+}
+
+QSensor2Proximity::~QSensor2Proximity()
+{
+}
+
+/*!
+ \qmlproperty bool QtSensors5::ProximitySensor::running
+ Holds the identication if the sensor runs or not.
+*/
+/*!
+ \qmlsignal QtSensors5::ProximitySensor::onRunningChanged()
+ This signal is emitted whenever the value of the property running has been changed.
+*/
+bool QSensor2Proximity::running()
+{
+ return _proximity->isActive();
+}
+
+void QSensor2Proximity::setRunning(bool val)
+{
+ bool active = running();
+ if (active != val){
+ if (val){
+ bool ret = _proximity->start();
+ if (!ret)
+ qWarning() << "couldn't start the sensor.";
+ }
+ else
+ _proximity->stop();
+ emit runningChanged();
+ }
+}
+
+/*!
+ \qmlproperty bool QtSensors5::ProximitySensor::close
+ Holds the proximity from the user to the device.
+*/
+/*!
+ \qmlsignal QtSensors5::ProximitySensor::onCloseChanged()
+ This signal is emitted whenever the value of the close property has been changed.
+*/
+bool QSensor2Proximity::close()
+{
+ return _close;
+}
+
+bool QSensor2Proximity::filter(QProximityReading *reading)
+{
+ bool cl = reading->close();
+ if (_close != cl){
+ _close = cl;
+ emit closeChanged();
+ }
+
+ return false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/sensors2/qsensor2proximity.h b/src/imports/sensors2/qsensor2proximity.h
new file mode 100644
index 00000000..d0de3fa2
--- /dev/null
+++ b/src/imports/sensors2/qsensor2proximity.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QSENSOR2PROXIMITY_H
+#define QSENSOR2PROXIMITY_H
+
+#include <QtDeclarative/qdeclarativeextensionplugin.h>
+#include <QtDeclarative/qdeclarative.h>
+#include <qproximitysensor.h>
+
+QT_BEGIN_NAMESPACE
+
+class QSensor2Proximity : public QObject, public QProximityFilter
+{
+ Q_OBJECT
+ Q_PROPERTY(bool close READ close NOTIFY closeChanged)
+ Q_PROPERTY(bool running READ running WRITE setRunning NOTIFY runningChanged)
+
+public:
+ QSensor2Proximity(QObject* parent = 0);
+ virtual ~QSensor2Proximity();
+
+Q_SIGNALS:
+ void closeChanged();
+ void runningChanged();
+
+private:
+ // Override of QProximityFilter::filter(QProximityReading*)
+ bool filter(QProximityReading *reading);
+ bool close();
+ bool running();
+ void setRunning(bool val);
+
+private:
+ QProximitySensor* _proximity;
+ bool _close;
+};
+
+QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QSensor2Proximity))
+
+QT_END_NAMESPACE
+
+
+#endif // QSENSOR2PROXIMITY_H
diff --git a/src/imports/sensors2/qsensor2tilt.cpp b/src/imports/sensors2/qsensor2tilt.cpp
new file mode 100644
index 00000000..03251909
--- /dev/null
+++ b/src/imports/sensors2/qsensor2tilt.cpp
@@ -0,0 +1,365 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsensor2tilt.h"
+#include <math.h>
+#include <errno.h>
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass TiltSensor QSensor2Tilt
+ \inqmlmodule QtSensors 5
+ \ingroup qml-QtSensors5
+ \since QtSensors 5.0
+ \brief The TiltSensor element provides tilt datas from x and y rotation of the device using the accelerometer sensor.
+
+ This element is part of the \bold{QtSensors 5} module.
+
+ \target tiltreferenceenum
+ \section1 Enums
+ \section2 TiltSensor::TiltReference
+
+ This enum describes the orientation of the device.
+
+ \table
+ \row
+ \o TiltSensor::TopUp
+ \o The top of the device points up
+ \o
+ \image TopUp.gif
+ \row
+ \o TiltSensor::TopDown
+ \o The top of the device points down
+ \o
+ \image TopDown.gif
+ \row
+ \o TiltSensor::LeftUp
+ \o The left site of the device points up
+ \o
+ \image LeftUp.gif
+ \row
+ \o TiltSensor::RightUp
+ \o The right site of the device points up
+ \o
+ \image RightUp.gif
+ \row
+ \o TiltSensor::FaceUp
+ \o The screen of the device points up
+ \o
+ \image FaceUp.gif
+ \row
+ \o TiltSensor::FaceDown
+ \o The screen of the device points down
+ \o
+ \image FaceDown.gif
+ \endtable
+
+*/
+QSensor2Tilt::QSensor2Tilt(QObject* parent)
+ : QObject(parent)
+ , _measureFrom(QSensor2Tilt::FaceUp)
+ , _yRotation(0)
+ , _xRotation(0)
+ , _useRadian(true)
+{
+ _accel = new QAccelerometer(this);
+ _accel->addFilter(this);
+}
+
+QSensor2Tilt::~QSensor2Tilt()
+{
+}
+
+/*!
+ \qmlproperty bool QtSensors5::TiltSensor::dataRate
+ Holds the data rate that the sensor should be run at.
+*/
+/*!
+ \qmlsignal QtSensors5::TiltSensor::onDataRateChanged()
+ This signal is emitted whenever the value of the property dataRate has been changed.
+*/
+int QSensor2Tilt::dataRate()
+{
+ return _accel->dataRate();
+}
+
+void QSensor2Tilt::setDataRate(int val)
+{
+ if (val != dataRate()){
+ _accel->setDataRate(val);
+ emit dataRateChanged();
+ }
+}
+
+/*!
+ \qmlproperty bool QtSensors5::TiltSensor::running
+ Holds the identication if the sensor runs or not.
+*/
+/*!
+ \qmlsignal QtSensors5::TiltSensor::onRunningChanged()
+ This signal is emitted whenever the value of the property running has been changed.
+*/
+bool QSensor2Tilt::running()
+{
+ return _accel->isActive();
+}
+
+void QSensor2Tilt::setRunning(bool val)
+{
+ bool active = running();
+ if (active != val){
+ if (val){
+ bool ret = _accel->start();
+ if (!ret)
+ qWarning() << "couldn't start the sensor.";
+ }
+ else
+ _accel->stop();
+ emit runningChanged();
+ }
+}
+
+/*!
+ \qmlproperty QSensor2Tilt::TiltReference QtSensors5::TiltSensor::measureFrom
+ Holds the orientation in which the rotation should be calculated.
+ \sa {tiltreferenceenum} {TiltReference::TiltReference}
+*/
+/*!
+ \qmlsignal QtSensors5::TiltSensor::onMeasureFromChanged()
+ This signal is emitted whenever the value of the property measureFrom has been changed.
+*/
+QSensor2Tilt::TiltReference QSensor2Tilt::measureFrom()
+{
+ return _measureFrom;
+}
+
+void QSensor2Tilt::setMeasureFrom(QSensor2Tilt::TiltReference val)
+{
+ if (val != _measureFrom){
+ _measureFrom = val;
+ emit measureFromChanged();
+ }
+}
+
+/*!
+ \qmlproperty bool QtSensors5::TiltSensor::radian
+ Holds the unit of the rotation. True is rad otherwise deg. true = report values in radians. false = report values in degrees.
+*/
+bool QSensor2Tilt::radian()
+{
+ return _useRadian;
+}
+
+void QSensor2Tilt::setRadian(bool val)
+{
+ _useRadian = val;
+}
+
+
+/*!
+ \qmlproperty float QtSensors5::TiltSensor::yRotation
+ Holds the rotation arround the y axis.
+
+ \table
+ \row
+ \o
+ \image YAngle.gif
+ \o
+ \image YAngleNegative.gif
+ \endtable
+*/
+/*!
+ \qmlsignal QtSensors5::TiltSensor::onYRotationChanged()
+ This signal is emitted whenever the value of the property yRotation has been changed.
+*/
+float QSensor2Tilt::yRotation()
+{
+ return _yRotation;
+}
+
+/*!
+ \qmlproperty float QtSensors5::TiltSensor::xRotation
+ Holds the rotation arround the x axis.
+ \table
+ \row
+ \o
+ \image XAngle.gif
+ \o
+ \image XAngleNegative.gif
+ \endtable
+*/
+/*!
+ \qmlsignal QtSensors5::TiltSensor::onXRotationChanged()
+ This signal is emitted whenever the value of the property XRotation has been changed.
+*/
+float QSensor2Tilt::xRotation()
+{
+ return _xRotation;
+}
+
+/*
+ Angle between Ground and X
+ | Ax |
+ pitch = arctan| ----------------------- |
+ | sqrt(Ay * Ay + Az * Az)|
+*/
+inline float calcPitch(double Ax, double Ay, double Az)
+{
+ errno = 0;
+ float ret = (float)-atan(Ax / (sqrt(Ay * Ay + Az * Az)));
+ if (errno == EDOM){
+ ret = 0.0;
+ errno = 0;
+ }
+ return ret;
+}
+
+/*
+ Angle between Ground and Y
+ | Ay |
+ pitch = arctan| ----------------------- |
+ | sqrt(Ax * Ax + Az * Az)|
+*/
+inline float calcRoll(double Ax, double Ay, double Az)
+{
+ errno = 0;
+ float ret = (float)atan(Ay / (sqrt(Ax * Ax + Az * Az)));
+ if (errno == EDOM){
+ ret = 0.0;
+ errno = 0;
+ }
+ return ret;
+}
+
+bool QSensor2Tilt::filter(QAccelerometerReading* reading)
+{
+ /*
+ z y
+ | /
+ |/___ x
+ */
+
+ int x = reading->x();
+ int y = reading->y();
+ int z = reading->z();
+ float xrot = 0;
+ float yrot = 0;
+
+ switch (_measureFrom)
+ {
+ case QSensor2Tilt::FaceUp:
+ /*
+ y
+ | => Ax = x, Ay = y, Az = z
+ |___ x
+ */
+ yrot = calcPitch(x, y, z);
+ xrot = calcRoll(x, y, z);
+ break;
+ case QSensor2Tilt::LeftUp:
+ /*
+ z
+ | => Ax = y, Ay = z, Az = x
+ |___ y
+ */
+ yrot = calcPitch(y, z, x);
+ xrot = -calcRoll(y, z, x);
+ break;
+ case QSensor2Tilt::TopDown:
+ /*
+ z
+ | => Ax = -x, Ay = z, Az = y
+ |___ -x
+ */
+ yrot = -calcPitch(x, z, y);
+ xrot = -calcRoll(x, z, y);
+ break;
+ case QSensor2Tilt::FaceDown:
+ /*
+ -y
+ | => Ax = x, Ay = -y, Az = -z
+ |___ x
+ */
+ yrot = calcPitch(-x, -y, z);
+ xrot = -calcRoll(-x, -y, z);
+ break;
+ case QSensor2Tilt::RightUp:
+ /*
+ z
+ | => Ax = -y, Ay = z, Az = -x
+ |___ -y
+ */
+ yrot = calcPitch(-y, z, -x);
+ xrot = -calcRoll(-y, z, -x);
+ break;
+ case QSensor2Tilt::TopUp:
+ /*
+ z
+ | => Ax = x, Ay = z, Az = -y
+ |___ x
+ */
+ yrot = calcPitch(x, z, -y);
+ xrot = -calcRoll(x, z, -y);
+ break;
+ }
+
+
+
+ if (!_useRadian){
+ yrot = 180 * yrot / M_PI;
+ xrot = 180 * xrot / M_PI;
+ }
+
+ if (xrot != _xRotation){
+ _xRotation = xrot;
+ emit xRotationChanged();
+ }
+ if (yrot != _yRotation){
+ _yRotation = yrot;
+ emit yRotationChanged();
+ }
+
+ return false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/sensors2/qsensor2tilt.h b/src/imports/sensors2/qsensor2tilt.h
new file mode 100644
index 00000000..23f27271
--- /dev/null
+++ b/src/imports/sensors2/qsensor2tilt.h
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QSEONSOR2TILT_H
+#define QSEONSOR2TILT_H
+
+#include <QtDeclarative/qdeclarativeextensionplugin.h>
+#include <QtDeclarative/qdeclarative.h>
+#include <qaccelerometer.h>
+
+QT_BEGIN_NAMESPACE
+
+class QSensor2Tilt : public QObject, public QAccelerometerFilter
+{
+ Q_OBJECT
+ Q_ENUMS(TiltReference)
+ Q_PROPERTY(TiltReference measureFrom READ measureFrom WRITE setMeasureFrom NOTIFY measureFromChanged)
+ Q_PROPERTY(float yRotation READ yRotation NOTIFY yRotationChanged)
+ Q_PROPERTY(float xRotation READ xRotation NOTIFY xRotationChanged)
+ Q_PROPERTY(bool radian READ radian WRITE setRadian)
+ Q_PROPERTY(int dataRate READ dataRate WRITE setDataRate NOTIFY dataRateChanged)
+ Q_PROPERTY(bool running READ running WRITE setRunning NOTIFY runningChanged)
+
+public:
+ QSensor2Tilt(QObject* parent = 0);
+ virtual ~QSensor2Tilt();
+
+ enum TiltReference{
+ TopUp = 0,
+ TopDown,
+ LeftUp,
+ RightUp,
+ FaceUp,
+ FaceDown
+ };
+
+Q_SIGNALS:
+ void measureFromChanged();
+ void yRotationChanged();
+ void xRotationChanged();
+ void dataRateChanged();
+ void runningChanged();
+
+private:
+ // Override of QAcclerometerFilter::filter(QAccelerometerReading*)
+ bool filter(QAccelerometerReading* reading);
+
+ TiltReference measureFrom();
+ void setMeasureFrom(TiltReference val);
+ float yRotation();
+ float xRotation();
+ bool radian();
+ void setRadian(bool val);
+ int dataRate();
+ void setDataRate(int val);
+ bool running();
+ void setRunning(bool val);
+
+ QAccelerometer* _accel;
+ TiltReference _measureFrom;
+ float _yRotation;
+ float _xRotation;
+ bool _useRadian;
+ bool _init;
+};
+
+QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QSensor2Tilt))
+
+QT_END_NAMESPACE
+
+#endif // QSEONSOR2TILT_H
diff --git a/src/imports/sensors2/qsensors2import.pri b/src/imports/sensors2/qsensors2import.pri
new file mode 100644
index 00000000..d5cfeffc
--- /dev/null
+++ b/src/imports/sensors2/qsensors2import.pri
@@ -0,0 +1,38 @@
+load(qt_module)
+
+symbian:load(qt_plugin)
+TEMPLATE = lib
+CONFIG += qt plugin
+
+win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release
+
+isEmpty(TARGETPATH) {
+ error("qimportbase.pri: You must provide a TARGETPATH!")
+}
+isEmpty(TARGET) {
+ error("qimportbase.pri: You must provide a TARGET!")
+}
+
+QMLDIRFILE = $${_PRO_FILE_PWD_}/qmldir
+copy2build.input = QMLDIRFILE
+copy2build.output = $$QT.sensors.imports/$$TARGETPATH/qmldir
+!contains(TEMPLATE_PREFIX, vc):copy2build.variable_out = PRE_TARGETDEPS
+copy2build.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
+copy2build.name = COPY ${QMAKE_FILE_IN}
+copy2build.CONFIG += no_link
+# `clean' should leave the build in a runnable state, which means it shouldn't delete qmldir
+copy2build.CONFIG += no_clean
+QMAKE_EXTRA_COMPILERS += copy2build
+
+TARGET = $$qtLibraryTarget($$TARGET)
+contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols
+
+load(qt_targets)
+
+wince*:LIBS += $$QMAKE_LIBS_GUI
+
+symbian: {
+ TARGET.EPOCALLOWDLLDATA=1
+ TARGET.CAPABILITY = All -Tcb
+ load(armcc_warnings)
+}
diff --git a/src/imports/sensors2/sensors2.cpp b/src/imports/sensors2/sensors2.cpp
new file mode 100644
index 00000000..9d79863d
--- /dev/null
+++ b/src/imports/sensors2/sensors2.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtDeclarative/qdeclarativeextensionplugin.h>
+#include <QtDeclarative/qdeclarative.h>
+#include "qsensor2ambientlight.h"
+#include "qsensor2proximity.h"
+#include "qsensor2tilt.h"
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+class QSensors2DeclarativeModule : public QDeclarativeExtensionPlugin
+{
+ Q_OBJECT
+public:
+ virtual void registerTypes(const char *uri)
+ {
+ qDebug() << "QSensors2DeclarativeModule::registerTypes(const char *uri)";
+
+ Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.QtSensors"));
+ qmlRegisterType<QSensor2Tilt>(uri, 5, 0, "TiltSensor");
+ qmlRegisterType<QSensor2AmbientLight>(uri, 5, 0, "AmbientLightSensor");
+ qmlRegisterType<QSensor2Proximity>(uri, 5, 0, "ProximitySensor");
+ }
+};
+
+QT_END_NAMESPACE
+
+#include "sensors2.moc"
+
+Q_EXPORT_PLUGIN2(qsensors2declarativemodule, QT_PREPEND_NAMESPACE(QSensors2DeclarativeModule))
+
+
diff --git a/src/imports/sensors2/sensors2.pro b/src/imports/sensors2/sensors2.pro
new file mode 100644
index 00000000..a80446b3
--- /dev/null
+++ b/src/imports/sensors2/sensors2.pro
@@ -0,0 +1,39 @@
+TARGET = declarative_qtsensors5
+TARGETPATH = Qt/QtSensors
+
+include(qsensors2import.pri)
+
+QT += declarative sensors
+
+load(qt_plugin)
+
+SOURCES += sensors2.cpp \
+ qsensor2ambientlight.cpp \
+ qsensor2proximity.cpp \
+ qsensor2tilt.cpp
+
+HEADERS += qsensor2ambientlight.h \
+ qsensor2proximity.h \
+ qsensor2tilt.h
+
+DESTDIR = $$QT.sensors.imports/$$TARGETPATH
+target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
+
+qmldir.files += $$PWD/qmldir
+qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
+
+INSTALLS += target qmldir
+
+symbian {
+ # In Symbian, a library should enjoy _largest_ possible capability set.
+ TARGET.CAPABILITY = ALL -TCB
+ # Allow writable DLL data
+ TARGET.EPOCALLOWDLLDATA = 1
+ # Target UID, makes every Symbian app unique
+ TARGET.UID3 = 0x20021324
+ # Specifies what files shall be deployed: the plugin itself and the qmldir file.
+ importFiles.sources = $$DESTDIR/declarative_sensors$${QT_LIBINFIX}.dll qmldir
+ importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH
+ DEPLOYMENT = importFiles
+ }
+