diff options
38 files changed, 73 insertions, 2896 deletions
diff --git a/doc/src/examples/qmlqtsensors.qdoc b/doc/src/examples/qmlqtsensors.qdoc index 01937e0..4016fc4 100644 --- a/doc/src/examples/qmlqtsensors.qdoc +++ b/doc/src/examples/qmlqtsensors.qdoc @@ -54,16 +54,16 @@ Reading the data can be done for each sensor type like following: - \l {QtSensors5::TiltSensor} {TiltSensor} + \l {QtMobility.sensors1::TiltSensor} {TiltSensor} \snippet ../examples/sensors/qmlqtsensors/qmlqtsensors.qml 3 \snippet ../examples/sensors/qmlqtsensors/qmlqtsensors.qml 4 - \l {QtSensors5::AmbientLightSensor} {AmbientLightSensor} + \l {QtMobility.sensors1::AmbientLightSensor} {AmbientLightSensor} \snippet ../examples/sensors/qmlqtsensors/qmlqtsensors.qml 5 - \l {QtSensors5::ProximitySensor} {ProximitySensor} + \l {QtMobility.sensors1::ProximitySensor} {ProximitySensor} \snippet ../examples/sensors/qmlqtsensors/qmlqtsensors.qml 6 */ diff --git a/doc/src/imports/qtsensors5.qdoc b/doc/src/imports/qtsensors5.qdoc deleted file mode 100644 index 32c4667..0000000 --- a/doc/src/imports/qtsensors5.qdoc +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \qmlmodule QtSensors 5 - \title Qt Sensors QML API - \brief The QML import for Qt Sensors - - \section1 Overview - - - Mobile devices contains sensor hardware that allow detecting changes in various physical - properties of the device itself or its immediate environment. Examples of device properties - include the angle at which the device is held, whereas environmental properties include for - example the current level of ambient light. - - These properties can be either actual values, such as the tilt angle in - degrees, or approximations, like the enumeration describing brightness in - relative terms using values such as AmbientLightSensor.Dark and AmbientLightSensor.Bright. - - The latter type of value is also based on a natural phenomenon (in the case - of the ambient light sensor, the amount of visible light emitted by a source), but the value - itself is descriptive instead of using any effective unit of measurement, such as lumen. - - The identifying string for this component is \e QtSensors. - Use this in the QML import statement, as such: \e import QtSensors 5.0 - - Qt Sensors QML API provides an easy to use interface to the Qt Sensors API. - It enables the receiving of sensor events and reading current values from the - sensors. - - The emulator supports simulating the Ambient Light, Orientation, Compass and Proximity sensors. - - The \l {Qt Sensors - QML example} contains code for using the the \l TiltSensor, \l AmbientLightSensor - and ProximitySensor types. - - \section1 QML Types - -*/ - - diff --git a/doc/src/porting.qdoc b/doc/src/porting.qdoc index 432734d..9a3ff71 100644 --- a/doc/src/porting.qdoc +++ b/doc/src/porting.qdoc @@ -39,21 +39,8 @@ \section1 QML - Compatibility for QML applications is provided by shipping the legacy \c QtMobility.sensors - QML import. QML applications should not require any changes to continue operating. - - Applications using the legacy QML import may not be able to trivially port over - to the new QML import because the new QML import does not provide types for - every sensor like the legacy QML import does. - - \table - \row - \li \l {Qt Sensors QML API}{QML API} - \li Information about the Qt Sensors QML API - \row - \li \l {QtMobility.sensors 1.x}{Legacy QML API} - \li Information about the legacy QtMobility.sensors QML API - \endtable + QtSensors ships with a QML import that is mostly compatible with the QtMobility.sensors import. + See \l {QtMobility.sensors 1.x} for more information. \section1 C++ diff --git a/doc/src/qtsensors.qdoc b/doc/src/qtsensors.qdoc index d5f3ce3..0ab598e 100644 --- a/doc/src/qtsensors.qdoc +++ b/doc/src/qtsensors.qdoc @@ -39,7 +39,7 @@ \table \row - \li \l {Qt Sensors QML API}{QML API} + \li \l {QtMobility.sensors 1.x}{QML API} \li Information about the Qt Sensors QML API \row \li \l {Qt Sensors C++ API}{C++ API} diff --git a/examples/sensors/maze/maze.qml b/examples/sensors/maze/maze.qml index 4626287..8610329 100644 --- a/examples/sensors/maze/maze.qml +++ b/examples/sensors/maze/maze.qml @@ -73,7 +73,7 @@ import QtQuick 2.0 import "components" //! [0] -import QtSensors 5.0 +import QtMobility.sensors 1.3 //! [0] import QtSystemInfo 5.0 @@ -202,10 +202,10 @@ ApplicationWindow { //! [3] var xstep = 0; - xstep = tiltSensor.yRotation * 0.1 //acceleration + xstep = tiltSensor.reading.yRotation * 0.1 //acceleration var ystep = 0; - ystep = tiltSensor.xRotation * 0.1 //acceleration + ystep = tiltSensor.reading.xRotation * 0.1 //acceleration //! [3] //! [4] if (xstep < 1 && xstep > 0) diff --git a/examples/sensors/qmlqtsensors/qmlqtsensors.qml b/examples/sensors/qmlqtsensors/qmlqtsensors.qml index d285cc9..8f6f49b 100644 --- a/examples/sensors/qmlqtsensors/qmlqtsensors.qml +++ b/examples/sensors/qmlqtsensors/qmlqtsensors.qml @@ -88,7 +88,7 @@ import QtQuick 2.0 import "components" //! [0] -import QtSensors 5.0 +import QtMobility.sensors 1.3 //! [0] ApplicationWindow { @@ -147,81 +147,11 @@ ApplicationWindow { //! [1] TiltSensor { id: tilt - enabled: false - speed: TiltSensor.Slow + active: false } //! [1] Rectangle{ - id: speedRect - anchors.top: labelTilt.bottom - anchors.topMargin: 5 - anchors.left: mainWnd.left - anchors.leftMargin: mainWnd.width / 2 - anchors.right: mainWnd.right - anchors.rightMargin: 5 - height: 110 - color: "transparent" - - Text{ - id: textSpeed - anchors.top: speedRect.top - anchors.left: speedRect.left - text: "Speed" - font.bold: true - } - - Text{ - id: textSpeedValue - anchors.top: textSpeed.bottom - anchors.topMargin: 5 - anchors.left: speedLower.left - anchors.right: speedHigher.right - text: mainWnd.speed - verticalAlignment: Text.AlignVCenter - } - - Button{ - id: speedLower - anchors.top: textSpeedValue.bottom - anchors.left: speedRect.left - height: 30 - width: 40 - text: "-" - - onClicked:{ - if (tilt.speed === TiltSensor.Fast) { - mainWnd.speed = "Medium"; - tilt.speed = TiltSensor.Medium; - } - else if (tilt.speed === TiltSensor.Medium) { - mainWnd.speed = "Slow"; - tilt.speed = TiltSensor.Slow; - } - } - } - - Button{ - id: speedHigher - anchors.top: textSpeedValue.bottom - anchors.left: speedLower.right - height: 30 - width: 40 - text: "+" - - onClicked:{ - if (tilt.speed === TiltSensor.Slow) { - mainWnd.speed = "Medium"; - tilt.speed = TiltSensor.Medium; - } - else if (tilt.speed === TiltSensor.Medium) { - mainWnd.speed = "Fast"; - tilt.speed = TiltSensor.Fast; - } - } - } - } - Button{ id: calibrate anchors.left: mainWnd.left @@ -243,11 +173,11 @@ ApplicationWindow { anchors.leftMargin: 5 height: 30 width: 80 - text: tilt.enabled ? "Stop" : "Start" + text: tilt.active ? "Stop" : "Start" onClicked:{ //! [2] - tilt.enabled = (tiltStart.text === "Start" ? true: false); + tilt.active = (tiltStart.text === "Start"); //! [2] } } @@ -309,20 +239,20 @@ ApplicationWindow { AmbientLightSensor { id: ambientlight - enabled: false + active: false //! [5] - onLightLevelChanged:{ - if (ambientlight.lightLevel == AmbientLightSensor.Unknown) + onReadingChanged:{ + if (reading.lightLevel == AmbientLightSensor.Unknown) ambientlighttext.text = "Ambient light: Unknown"; - else if (ambientlight.lightLevel == AmbientLightSensor.Dark) + else if (reading.lightLevel == AmbientLightSensor.Dark) ambientlighttext.text = "Ambient light: Dark"; - else if (ambientlight.lightLevel == AmbientLightSensor.Twilight) + else if (reading.lightLevel == AmbientLightSensor.Twilight) ambientlighttext.text = "Ambient light: Twilight"; - else if (ambientlight.lightLevel == AmbientLightSensor.Light) + else if (reading.lightLevel == AmbientLightSensor.Light) ambientlighttext.text = "Ambient light: Light"; - else if (ambientlight.lightLevel == AmbientLightSensor.Bright) + else if (reading.lightLevel == AmbientLightSensor.Bright) ambientlighttext.text = "Ambient light: Bright"; - else if (ambientlight.lightLevel == AmbientLightSensor.Sunny) + else if (reading.lightLevel == AmbientLightSensor.Sunny) ambientlighttext.text = "Ambient light: Sunny"; } //! [5] @@ -336,10 +266,10 @@ ApplicationWindow { anchors.leftMargin: 5 height: 30 width: 80 - text: ambientlight.enabled ? "Stop" : "Start" + text: ambientlight.active ? "Stop" : "Start" onClicked:{ - ambientlight.enabled = (ambientlightStart.text === "Start" ? true: false); + ambientlight.active = (ambientlightStart.text === "Start" ? true: false); } } @@ -381,7 +311,7 @@ ApplicationWindow { ProximitySensor { id: proxi - enabled: false + active: false } Button{ @@ -392,10 +322,10 @@ ApplicationWindow { anchors.leftMargin: 5 height: 30 width: 80 - text: proxi.enabled ? "Stop" : "Start" + text: proxi.active ? "Stop" : "Start" onClicked:{ - proxi.enabled = (proxiStart.text === "Start" ? true: false); + proxi.active = (proxiStart.text === "Start" ? true: false); } } @@ -407,7 +337,7 @@ ApplicationWindow { anchors.bottom: proxiStart.bottom verticalAlignment: Text.AlignVCenter //! [6] - text: "Proximity: " + (proxi.near ? "near" : "far") + text: "Proximity: " + (proxi.reading.near ? "near" : "far") //! [6] } } diff --git a/examples/sensors/qmlsensorgestures/GestureList.qml b/examples/sensors/qmlsensorgestures/GestureList.qml index ea79af3..993fb43 100644 --- a/examples/sensors/qmlsensorgestures/GestureList.qml +++ b/examples/sensors/qmlsensorgestures/GestureList.qml @@ -40,7 +40,7 @@ //Import the declarative plugins import QtQuick 2.0 -import QtSensors 5.0 +import QtMobility.sensors 1.3 /* Layout gesturerect diff --git a/examples/sensors/qmlsensorgestures/GestureView.qml b/examples/sensors/qmlsensorgestures/GestureView.qml index c12c6f2..f1b0cb6 100644 --- a/examples/sensors/qmlsensorgestures/GestureView.qml +++ b/examples/sensors/qmlsensorgestures/GestureView.qml @@ -42,7 +42,7 @@ import QtQuick 2.0 //! [0] -import QtSensors 5.0 +import QtMobility.sensors 1.3 //! [0] /* Layout diff --git a/examples/sensors/qmlsensorgestures/GesturesView.qml b/examples/sensors/qmlsensorgestures/GesturesView.qml index ceab8d1..df91df6 100644 --- a/examples/sensors/qmlsensorgestures/GesturesView.qml +++ b/examples/sensors/qmlsensorgestures/GesturesView.qml @@ -40,7 +40,7 @@ //Import the declarative plugins import QtQuick 2.0 -import QtSensors 5.0 +import QtMobility.sensors 1.3 /* Layout gesturerect diff --git a/examples/sensors/qmlsensorgestures/qmlsensorgestures.qml b/examples/sensors/qmlsensorgestures/qmlsensorgestures.qml index af1f04a..2f76580 100644 --- a/examples/sensors/qmlsensorgestures/qmlsensorgestures.qml +++ b/examples/sensors/qmlsensorgestures/qmlsensorgestures.qml @@ -40,7 +40,7 @@ //Import the declarative plugins import QtQuick 2.0 -import QtSensors 5.0 +import QtMobility.sensors 1.3 /* Layout -------------------------------------------------- diff --git a/examples/sensors/shakeit/shakeit.qml b/examples/sensors/shakeit/shakeit.qml index 00eeb26..d1a142b 100644 --- a/examples/sensors/shakeit/shakeit.qml +++ b/examples/sensors/shakeit/shakeit.qml @@ -41,7 +41,7 @@ import QtQuick 2.0 //! [0] -import QtSensors 5.0 +import QtMobility.sensors 1.3 //! [0] import QtMultimedia 5.0 diff --git a/qtsensors.pro b/qtsensors.pro index ab1457e..e76adec 100644 --- a/qtsensors.pro +++ b/qtsensors.pro @@ -13,8 +13,7 @@ module_qtsensors_snippets.depends = sub_src # Commands to rebuild the plugin.qmltypes files for our imports # Run "make rebuild_qmltypes" after completing a build -sensors_qmltypes.commands = qmlplugindump QtMobility.sensors 1.3 $$QT.sensors.imports > $$PWD/src/imports/sensors/plugins.qmltypes -sensors2_qmltypes.commands = qmlplugindump QtSensors 5.0 $$QT.sensors.imports > $$PWD/src/imports/sensors2/plugins.qmltypes -TYPES = sensors_qmltypes sensors2_qmltypes +sensors_qmltypes.commands = qmlplugindump QtSensors 5.0 $$QT.sensors.imports > $$PWD/src/imports/sensors/plugins.qmltypes +TYPES = sensors_qmltypes rebuild_qmltypes.depends = $$TYPES QMAKE_EXTRA_TARGETS += rebuild_qmltypes $$TYPES diff --git a/src/imports/imports.pro b/src/imports/imports.pro index 6115652..a68f6a5 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -1,5 +1,4 @@ TEMPLATE = subdirs SUBDIRS += sensors -SUBDIRS += sensors2 diff --git a/src/imports/sensors/plugins.qmltypes b/src/imports/sensors/plugins.qmltypes index d1b0bba..88627c1 100644 --- a/src/imports/sensors/plugins.qmltypes +++ b/src/imports/sensors/plugins.qmltypes @@ -3,232 +3,18 @@ import QtQuick.tooling 1.1 // This file describes the plugin-supplied types contained in the library. // It is used for QML tooling purposes only. // -// This file was auto-generated with the command 'qmlplugindump QtMobility.sensors 1.3 /home/lramsay/build/qt50/qtbase/imports'. +// This file was auto-generated with the command 'qmlplugindump QtSensors 5.0 /home/lramsay/build/qt50/qtbase/imports'. Module { Component { - name: "QAccelerometer" - prototype: "QSensor" - exports: ["Accelerometer 1.1", "Accelerometer 1.2"] - } - Component { - name: "QAccelerometerReading" - prototype: "QSensorReading" - exports: ["AccelerometerReading 1.1", "AccelerometerReading 1.2"] - Property { name: "x"; type: "double"; isReadonly: true } - Property { name: "y"; type: "double"; isReadonly: true } - Property { name: "z"; type: "double"; isReadonly: true } - } - Component { - name: "QAmbientLightReading" - prototype: "QSensorReading" - exports: ["AmbientLightReading 1.1", "AmbientLightReading 1.2"] - Enum { - name: "LightLevel" - values: { - "Undefined": 0, - "Dark": 1, - "Twilight": 2, - "Light": 3, - "Bright": 4, - "Sunny": 5 - } - } - Property { name: "lightLevel"; type: "LightLevel"; isReadonly: true } - } - Component { - name: "QAmbientLightSensor" - prototype: "QSensor" - exports: ["AmbientLightSensor 1.1", "AmbientLightSensor 1.2"] - } - Component { - name: "QCompass" - prototype: "QSensor" - exports: ["Compass 1.1", "Compass 1.2"] - } - Component { - name: "QCompassReading" - prototype: "QSensorReading" - exports: ["CompassReading 1.1", "CompassReading 1.2"] - Property { name: "azimuth"; type: "double"; isReadonly: true } - Property { name: "calibrationLevel"; type: "double"; isReadonly: true } - } - Component { - name: "QGyroscope" - prototype: "QSensor" - exports: ["Gyroscope 1.2"] - } - Component { - name: "QGyroscopeReading" - prototype: "QSensorReading" - exports: ["GyroscopeReading 1.2"] - Property { name: "x"; type: "double"; isReadonly: true } - Property { name: "y"; type: "double"; isReadonly: true } - Property { name: "z"; type: "double"; isReadonly: true } - } - Component { - name: "QLightReading" - prototype: "QSensorReading" - exports: ["LightReading 1.2"] - Property { name: "lux"; type: "double"; isReadonly: true } - } - Component { - name: "QLightSensor" - prototype: "QSensor" - exports: ["LightSensor 1.2"] - } - Component { - name: "QMagnetometer" - prototype: "QSensor" - exports: ["Magnetometer 1.1", "Magnetometer 1.2"] - } - Component { - name: "QMagnetometerReading" - prototype: "QSensorReading" - exports: ["MagnetometerReading 1.1", "MagnetometerReading 1.2"] - Property { name: "x"; type: "double"; isReadonly: true } - Property { name: "y"; type: "double"; isReadonly: true } - Property { name: "z"; type: "double"; isReadonly: true } - Property { name: "calibrationLevel"; type: "double"; isReadonly: true } - } - Component { - name: "QOrientationReading" - prototype: "QSensorReading" - exports: ["OrientationReading 1.1", "OrientationReading 1.2"] - Enum { - name: "Orientation" - values: { - "Undefined": 0, - "TopUp": 1, - "TopDown": 2, - "LeftUp": 3, - "RightUp": 4, - "FaceUp": 5, - "FaceDown": 6 - } - } - Property { name: "orientation"; type: "Orientation"; isReadonly: true } - } - Component { - name: "QOrientationSensor" - prototype: "QSensor" - exports: ["OrientationSensor 1.1", "OrientationSensor 1.2"] - } - Component { - name: "QProximityReading" - prototype: "QSensorReading" - exports: ["ProximityReading 1.1", "ProximityReading 1.2"] - Property { name: "close"; type: "bool"; isReadonly: true } - } - Component { - name: "QProximitySensor" - prototype: "QSensor" - exports: ["ProximitySensor 1.1", "ProximitySensor 1.2"] - } - Component { - name: "QRotationReading" - prototype: "QSensorReading" - exports: ["RotationReading 1.1", "RotationReading 1.2"] - Property { name: "x"; type: "double"; isReadonly: true } - Property { name: "y"; type: "double"; isReadonly: true } - Property { name: "z"; type: "double"; isReadonly: true } - } - Component { - name: "QRotationSensor" - prototype: "QSensor" - exports: ["RotationSensor 1.1", "RotationSensor 1.2"] - } - Component { - name: "QSensor" - prototype: "QObject" - exports: ["Sensor 1.2"] - Enum { - name: "Feature" - values: { - "Buffering": 0, - "AlwaysOn": 1, - "GeoValues": 2, - "FieldOfView": 3, - "Reserved": 257 - } - } - Property { name: "identifier"; type: "QByteArray" } - Property { name: "type"; type: "QByteArray"; isReadonly: true } - Property { name: "connectedToBackend"; type: "bool"; isReadonly: true } - Property { name: "availableDataRates"; type: "qrangelist"; isReadonly: true } - Property { name: "dataRate"; type: "int" } - Property { name: "reading"; type: "QSensorReading"; isReadonly: true; isPointer: true } - Property { name: "busy"; type: "bool"; isReadonly: true } - Property { name: "active"; type: "bool" } - Property { name: "outputRanges"; type: "qoutputrangelist"; isReadonly: true } - Property { name: "outputRange"; type: "int" } - Property { name: "description"; type: "string"; isReadonly: true } - Property { name: "error"; type: "int"; isReadonly: true } - Property { name: "alwaysOn"; revision: 1; type: "bool" } - Signal { name: "busyChanged"; type: "void" } - Signal { name: "activeChanged"; type: "void" } - Signal { name: "readingChanged"; type: "void" } - Signal { - name: "sensorError" - type: "void" - Parameter { name: "error"; type: "int" } - } - Signal { name: "availableSensorsChanged"; type: "void" } - Signal { name: "alwaysOnChanged"; type: "void" } - Method { name: "start"; type: "bool" } - Method { name: "stop"; type: "void" } - Method { name: "connectToBackend"; type: "bool" } - Method { - name: "isFeatureSupported" - type: "bool" - Parameter { name: "feature"; type: "Feature" } - } - } - Component { - name: "QSensorReading" - prototype: "QObject" - exports: ["SensorReading 1.1", "SensorReading 1.2"] - Property { name: "timestamp"; type: "qulonglong"; isReadonly: true } - } - Component { - name: "QTapReading" - prototype: "QSensorReading" - exports: ["TapReading 1.1", "TapReading 1.2"] - Enum { - name: "TapDirection" - values: { - "Undefined": 0, - "X": 1, - "Y": 2, - "Z": 4, - "X_Pos": 17, - "Y_Pos": 34, - "Z_Pos": 68, - "X_Neg": 257, - "Y_Neg": 514, - "Z_Neg": 1028, - "X_Both": 273, - "Y_Both": 546, - "Z_Both": 1092 - } - } - Property { name: "tapDirection"; type: "TapDirection"; isReadonly: true } - Property { name: "doubleTap"; type: "bool"; isReadonly: true } - } - Component { - name: "QTapSensor" - prototype: "QSensor" - exports: ["TapSensor 1.1", "TapSensor 1.2"] - } - Component { name: "QmlAccelerometer" prototype: "QmlSensor" - exports: ["Accelerometer 1.3"] + exports: ["Accelerometer 5.0"] } Component { name: "QmlAccelerometerReading" prototype: "QmlSensorReading" - exports: ["AccelerometerReading 1.3"] + exports: ["AccelerometerReading 5.0"] Property { name: "x"; type: "double"; isReadonly: true } Property { name: "y"; type: "double"; isReadonly: true } Property { name: "z"; type: "double"; isReadonly: true } @@ -239,12 +25,12 @@ Module { Component { name: "QmlAmbientLightSensor" prototype: "QmlSensor" - exports: ["AmbientLightSensor 1.3"] + exports: ["AmbientLightSensor 5.0"] } Component { name: "QmlAmbientLightSensorReading" prototype: "QmlSensorReading" - exports: ["AmbientLightReading 1.3"] + exports: ["AmbientLightReading 5.0"] Enum { name: "LightLevel" values: { @@ -262,12 +48,12 @@ Module { Component { name: "QmlCompass" prototype: "QmlSensor" - exports: ["Compass 1.3"] + exports: ["Compass 5.0"] } Component { name: "QmlCompassReading" prototype: "QmlSensorReading" - exports: ["CompassReading 1.3"] + exports: ["CompassReading 5.0"] Property { name: "azimuth"; type: "double"; isReadonly: true } Property { name: "calibrationLevel"; type: "double"; isReadonly: true } Signal { name: "azimuthChanged"; type: "void" } @@ -276,12 +62,12 @@ Module { Component { name: "QmlGyroscope" prototype: "QmlSensor" - exports: ["Gyroscope 1.3"] + exports: ["Gyroscope 5.0"] } Component { name: "QmlGyroscopeReading" prototype: "QmlSensorReading" - exports: ["GyroscopeReading 1.3"] + exports: ["GyroscopeReading 5.0"] Property { name: "x"; type: "double"; isReadonly: true } Property { name: "y"; type: "double"; isReadonly: true } Property { name: "z"; type: "double"; isReadonly: true } @@ -292,40 +78,40 @@ Module { Component { name: "QmlIRProximitySensor" prototype: "QmlSensor" - exports: ["IRProximitySensor 1.3"] + exports: ["IRProximitySensor 5.0"] } Component { name: "QmlIRProximitySensorReading" prototype: "QmlSensorReading" - exports: ["IRProximityReading 1.3"] + exports: ["IRProximityReading 5.0"] Property { name: "reflectance"; type: "double"; isReadonly: true } Signal { name: "reflectanceChanged"; type: "void" } } Component { name: "QmlLightSensor" prototype: "QmlSensor" - exports: ["LightSensor 1.3"] + exports: ["LightSensor 5.0"] Property { name: "fieldOfView"; type: "double"; isReadonly: true } Signal { name: "fieldOfViewChanged"; type: "void" } } Component { name: "QmlLightSensorReading" prototype: "QmlSensorReading" - exports: ["LightReading 1.3"] + exports: ["LightReading 5.0"] Property { name: "lux"; type: "double"; isReadonly: true } Signal { name: "luxChanged"; type: "void" } } Component { name: "QmlMagnetometer" prototype: "QmlSensor" - exports: ["Magnetometer 1.3"] + exports: ["Magnetometer 5.0"] Property { name: "returnGeoValues"; type: "bool" } Signal { name: "returnGeoValuesChanged"; type: "void" } } Component { name: "QmlMagnetometerReading" prototype: "QmlSensorReading" - exports: ["MagnetometerReading 1.3"] + exports: ["MagnetometerReading 5.0"] Property { name: "x"; type: "double"; isReadonly: true } Property { name: "y"; type: "double"; isReadonly: true } Property { name: "z"; type: "double"; isReadonly: true } @@ -338,12 +124,12 @@ Module { Component { name: "QmlOrientationSensor" prototype: "QmlSensor" - exports: ["OrientationSensor 1.3"] + exports: ["OrientationSensor 5.0"] } Component { name: "QmlOrientationSensorReading" prototype: "QmlSensorReading" - exports: ["OrientationReading 1.3"] + exports: ["OrientationReading 5.0"] Enum { name: "Orientation" values: { @@ -362,26 +148,26 @@ Module { Component { name: "QmlProximitySensor" prototype: "QmlSensor" - exports: ["ProximitySensor 1.3"] + exports: ["ProximitySensor 5.0"] } Component { name: "QmlProximitySensorReading" prototype: "QmlSensorReading" - exports: ["ProximityReading 1.3"] + exports: ["ProximityReading 5.0"] Property { name: "close"; type: "bool"; isReadonly: true } Signal { name: "closeChanged"; type: "void" } } Component { name: "QmlRotationSensor" prototype: "QmlSensor" - exports: ["RotationSensor 1.3"] + exports: ["RotationSensor 5.0"] Property { name: "hasZ"; type: "bool"; isReadonly: true } Signal { name: "hasZChanged"; type: "void" } } Component { name: "QmlRotationSensorReading" prototype: "QmlSensorReading" - exports: ["RotationReading 1.3"] + exports: ["RotationReading 5.0"] Property { name: "x"; type: "double"; isReadonly: true } Property { name: "y"; type: "double"; isReadonly: true } Property { name: "z"; type: "double"; isReadonly: true } @@ -392,7 +178,7 @@ Module { Component { name: "QmlSensor" prototype: "QObject" - exports: ["Sensor 1.3"] + exports: ["Sensor 5.0"] exportMetaObjectRevisions: [1] Property { name: "identifier"; type: "string" } Property { name: "type"; type: "string"; isReadonly: true } @@ -426,7 +212,7 @@ Module { Component { name: "QmlSensorGesture" prototype: "QObject" - exports: ["SensorGesture 1.3"] + exports: ["SensorGesture 5.0"] Property { name: "availableGestures"; type: "QStringList"; isReadonly: true } Property { name: "gestures"; type: "QStringList" } Property { name: "validGestures"; type: "QStringList"; isReadonly: true } @@ -462,7 +248,7 @@ Module { Component { name: "QmlSensorOutputRange" prototype: "QObject" - exports: ["OutputRange 1.3"] + exports: ["OutputRange 5.0"] Property { name: "minimum"; type: "double"; isReadonly: true } Property { name: "maximum"; type: "double"; isReadonly: true } Property { name: "accuracy"; type: "double"; isReadonly: true } @@ -470,28 +256,28 @@ Module { Component { name: "QmlSensorRange" prototype: "QObject" - exports: ["Range 1.3"] + exports: ["Range 5.0"] Property { name: "minimum"; type: "int"; isReadonly: true } Property { name: "maximum"; type: "int"; isReadonly: true } } Component { name: "QmlSensorReading" prototype: "QObject" - exports: ["SensorReading 1.3"] + exports: ["SensorReading 5.0"] Property { name: "timestamp"; type: "qulonglong"; isReadonly: true } Signal { name: "timestampChanged"; type: "void" } } Component { name: "QmlTapSensor" prototype: "QmlSensor" - exports: ["TapSensor 1.3"] + exports: ["TapSensor 5.0"] Property { name: "returnDoubleTapEvents"; type: "bool" } Signal { name: "returnDoubleTapEventsChanged"; type: "void" } } Component { name: "QmlTapSensorReading" prototype: "QmlSensorReading" - exports: ["TapReading 1.3"] + exports: ["TapReading 5.0"] Enum { name: "TapDirection" values: { @@ -518,18 +304,18 @@ Module { Component { name: "QmlTiltSensor" prototype: "QmlSensor" - exports: ["TiltSensor 1.3"] + exports: ["TiltSensor 5.0"] } Method { name: "calibrate"; type: "void" } } Component { name: "QmlTiltSensorReading" prototype: "QmlSensorReading" - exports: ["TiltReading 1.3"] + exports: ["TiltReading 5.0"] Property { name: "yRotation"; type: "double"; isReadonly: true } Property { name: "xRotation"; type: "double"; isReadonly: true } Signal { name: "yRotationChanged"; type: "void" } Signal { name: "xRotationChanged"; type: "void" } } - ModuleApi { version: 1.3; name: "QmlSensorGlobal" } + ModuleApi { version: 5.0; name: "QmlSensorGlobal" } } diff --git a/src/imports/sensors/qmltiltsensor.cpp b/src/imports/sensors/qmltiltsensor.cpp index 26f6611..3987104 100644 --- a/src/imports/sensors/qmltiltsensor.cpp +++ b/src/imports/sensors/qmltiltsensor.cpp @@ -115,7 +115,6 @@ QmlTiltSensorReading::QmlTiltSensorReading(QTiltSensor *sensor) : QmlSensorReading(sensor) , m_sensor(sensor) { - update(); } QmlTiltSensorReading::~QmlTiltSensorReading() diff --git a/src/imports/sensors2/plugin.json b/src/imports/sensors2/plugin.json deleted file mode 100644 index 0967ef4..0000000 --- a/src/imports/sensors2/plugin.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/src/imports/sensors2/plugins.qmltypes b/src/imports/sensors2/plugins.qmltypes deleted file mode 100644 index ea8b526..0000000 --- a/src/imports/sensors2/plugins.qmltypes +++ /dev/null @@ -1,91 +0,0 @@ -import QtQuick.tooling 1.1 - -// This file describes the plugin-supplied types contained in the library. -// It is used for QML tooling purposes only. -// -// This file was auto-generated with the command 'qmlplugindump QtSensors 5.0 /home/lramsay/build/qt50/qtbase/imports'. - -Module { - Component { - name: "QSensor2AmbientLight" - prototype: "qsensor2common" - exports: ["AmbientLightSensor 5.0"] - Enum { - name: "LightLevel" - values: { - "Unknown": 0, - "Dark": 1, - "Twilight": 2, - "Light": 3, - "Bright": 4, - "Sunny": 5 - } - } - Property { name: "lightLevel"; type: "LightLevel"; isReadonly: true } - Signal { name: "lightLevelChanged"; type: "void" } - } - Component { - name: "QSensor2Gesture" - prototype: "QObject" - exports: ["SensorGesture 5.0"] - Property { name: "availableGestures"; type: "QStringList"; isReadonly: true } - Property { name: "gestures"; type: "QStringList" } - Property { name: "validGestures"; type: "QStringList"; isReadonly: true } - Property { name: "invalidGestures"; type: "QStringList"; isReadonly: true } - Property { name: "enabled"; type: "bool" } - Signal { - name: "detected" - type: "void" - Parameter { name: "gesture"; type: "string" } - } - Signal { name: "availableGesturesChanged"; type: "void" } - Signal { name: "gesturesChanged"; type: "void" } - Signal { name: "validGesturesChanged"; type: "void" } - Signal { name: "invalidGesturesChanged"; type: "void" } - Signal { name: "enabledChanged"; type: "void" } - } - Component { - name: "QSensor2Proximity" - prototype: "qsensor2common" - exports: ["ProximitySensor 5.0"] - Property { name: "near"; type: "bool"; isReadonly: true } - Signal { name: "nearChanged"; type: "void" } - } - Component { - name: "QSensor2Tilt" - prototype: "qsensor2common" - exports: ["TiltSensor 5.0"] - Enum { - name: "Speed" - values: { - "Slow": 0, - "Medium": 1, - "Fast": 2 - } - } - Property { name: "yRotation"; type: "double"; isReadonly: true } - Property { name: "xRotation"; type: "double"; isReadonly: true } - Property { name: "speed"; type: "Speed" } - Property { name: "settings"; type: "QByteArray" } - Signal { name: "yRotationChanged"; type: "void" } - Signal { name: "xRotationChanged"; type: "void" } - Signal { name: "speedChanged"; type: "void" } - Signal { - name: "tiltChanged" - type: "void" - Parameter { name: "deltaX"; type: "double" } - Parameter { name: "deltaY"; type: "double" } - } - Signal { name: "accuracyChanged"; type: "void" } - Method { name: "calibrate"; type: "void" } - } - Component { - name: "qsensor2common" - prototype: "QObject" - exports: ["Sensor 5.0"] - Property { name: "enabled"; type: "bool" } - Property { name: "alwaysOn"; type: "bool" } - Signal { name: "enabledChanged"; type: "void" } - Signal { name: "alwaysOnChanged"; type: "void" } - } -} diff --git a/src/imports/sensors2/qmldir b/src/imports/sensors2/qmldir deleted file mode 100644 index cfef92b..0000000 --- a/src/imports/sensors2/qmldir +++ /dev/null @@ -1,3 +0,0 @@ -module QtSensors -plugin declarative_qtsensors5 -typeinfo plugins.qmltypes diff --git a/src/imports/sensors2/qsensor2ambientlight.cpp b/src/imports/sensors2/qsensor2ambientlight.cpp deleted file mode 100644 index a670a5f..0000000 --- a/src/imports/sensors2/qsensor2ambientlight.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qsensor2ambientlight.h" -#include <QtCore/QDebug> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype AmbientLightSensor - \instantiates QSensor2AmbientLight - \inherits QtSensors5::Sensor - \inqmlmodule QtSensors 5.0 - \ingroup qml-QtSensors5 - \since QtSensors 5.0 - \brief Provides access to the current ambient light level. - - This type provides easy access to determine the ambient light by using the ambient light sensor. - For example brightening the screen according to whether the device is in full sunlight or not. - - This type is part of the \b{QtSensors 5} module. - - The \l {Qt Sensors - QML example} is an example how to use this QML type. -*/ -QSensor2AmbientLight::QSensor2AmbientLight(QObject* parent) - : qsensor2common(parent) - , _lightLevel(QSensor2AmbientLight::Unknown) -{ - _ambientLight = new QAmbientLightSensor(this); - _ambientLight->addFilter(this); -} - - -QSensor2AmbientLight::~QSensor2AmbientLight() -{ -} - -/*! - \qmlproperty enumeration QtSensors5::AmbientLightSensor::lightLevel - Holds the ambient light level in the form of the LightLevel enum: - - \table - \row - \li AmbientLightSensor.Unknown - \li Ambient light value is not set yet. - \row - \li AmbientLightSensor.Dark - \li It is dark. - \row - \li AmbientLightSensor.Twilight - \li It is moderately dark. - \row - \li AmbientLightSensor.Light - \li It is light (internal lights). - \row - \li AmbientLightSensor.Bright - \li It is bright (outside but in the shade). - \row - \li AmbientLightSensor.Sunny - \li It is very bright (direct sunlight). - \endtable -*/ -QSensor2AmbientLight::LightLevel QSensor2AmbientLight::lightLevel() -{ - return _lightLevel; -} - -bool QSensor2AmbientLight::filter(QAmbientLightReading *reading) -{ - QSensor2AmbientLight::LightLevel lv = (QSensor2AmbientLight::LightLevel)reading->lightLevel(); - if (lv != _lightLevel){ - _lightLevel = lv; - Q_EMIT lightLevelChanged(); - } - return false; -} - -QT_END_NAMESPACE diff --git a/src/imports/sensors2/qsensor2ambientlight.h b/src/imports/sensors2/qsensor2ambientlight.h deleted file mode 100644 index 96bb5cd..0000000 --- a/src/imports/sensors2/qsensor2ambientlight.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSENSOR2AMBIENTLIGHT_H -#define QSENSOR2AMBIENTLIGHT_H - -#include <QtQml/qqmlextensionplugin.h> -#include <QtQml/qqml.h> -#include <qambientlightsensor.h> -#include "qsensor2common.h" - -QT_BEGIN_NAMESPACE - -class QSensor2AmbientLight : public qsensor2common, public QAmbientLightFilter -{ - Q_OBJECT - Q_ENUMS(LightLevel) - Q_PROPERTY(LightLevel lightLevel READ lightLevel NOTIFY lightLevelChanged) -public: - QSensor2AmbientLight(QObject* parent = 0); - virtual ~QSensor2AmbientLight(); - - enum LightLevel { - Unknown = 0, - Dark, - Twilight, - Light, - Bright, - Sunny - }; - -Q_SIGNALS: - void lightLevelChanged(); - -private: - // Override of QAmbientLightFilter::filter(QAmbientLightReading*) - bool filter(QAmbientLightReading *reading); - LightLevel lightLevel(); - - QSensor *sensor() { return _ambientLight; } - QAmbientLightSensor* _ambientLight; - LightLevel _lightLevel; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QSensor2AmbientLight) - -#endif // QSENSOR2AMBIENTLIGHT_H diff --git a/src/imports/sensors2/qsensor2common.cpp b/src/imports/sensors2/qsensor2common.cpp deleted file mode 100644 index a151b86..0000000 --- a/src/imports/sensors2/qsensor2common.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qsensor2common.h" -#include <QSensor> -#include <QDebug> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype Sensor - \instantiates qsensor2common - \inqmlmodule QtSensors 5.0 - \brief The Sensor type serves as a base type for sensors. - - The Sensor type serves as a base type for sensors. - - This type cannot be directly created. Please use one of the sub-classes instead. -*/ - -qsensor2common::qsensor2common(QObject *parent) - : QObject(parent) -{ -} - -qsensor2common::~qsensor2common() -{ -} - -/*! - \qmlproperty bool QtSensors5::Sensor::enabled - Starts or stops the sensor. Default value is false. -*/ - -bool qsensor2common::enabled() -{ - return sensor()->isActive(); -} - -void qsensor2common::setEnabled(bool val) -{ - bool active = enabled(); - if (active != val){ - if (val){ - bool ret = sensor()->start(); - if (!ret) - qWarning() << "couldn't start the sensor."; - } - else - sensor()->stop(); - Q_EMIT enabledChanged(); - } -} - -/*! - \qmlproperty bool QtSensors5::Sensor::alwaysOn - Keeps the sensor running when the screen turns off. Default value is false. -*/ - -bool qsensor2common::alwaysOn() -{ - return sensor()->isAlwaysOn(); -} - -void qsensor2common::setAlwaysOn(bool alwaysOn) -{ - if (sensor()->isAlwaysOn() == alwaysOn) return; - sensor()->setAlwaysOn(alwaysOn); - Q_EMIT alwaysOnChanged(); -} - -QT_END_NAMESPACE - diff --git a/src/imports/sensors2/qsensor2common.h b/src/imports/sensors2/qsensor2common.h deleted file mode 100644 index 84aac1e..0000000 --- a/src/imports/sensors2/qsensor2common.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSENSOR2COMMON_H -#define QSENSOR2COMMON_H - -#include <QObject> - -QT_BEGIN_NAMESPACE - -class QSensor; - -class qsensor2common : public QObject -{ - Q_OBJECT - Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) - Q_PROPERTY(bool alwaysOn READ alwaysOn WRITE setAlwaysOn NOTIFY alwaysOnChanged) -public: - explicit qsensor2common(QObject *parent = 0); - virtual ~qsensor2common(); - - bool enabled(); - virtual void setEnabled(bool val); - - bool alwaysOn(); - void setAlwaysOn(bool alwaysOn); - -signals: - void enabledChanged(); - void alwaysOnChanged(); - -protected: - virtual QSensor *sensor() = 0; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/imports/sensors2/qsensor2gesture.cpp b/src/imports/sensors2/qsensor2gesture.cpp deleted file mode 100644 index 8341c52..0000000 --- a/src/imports/sensors2/qsensor2gesture.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qsensor2gesture.h" -#include <qsensorgesture.h> -#include <qsensorgesturemanager.h> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype SensorGesture - \instantiates QSensor2Gesture - \inqmlmodule QtSensors 5.0 - \since QtSensors 5.0 - \brief Provides notifications when sensor-based gestures are detected. - - This type provides notification when sensor gestures are triggered. - - This type is part of the \b{QtSensors 5} module. - - The following QML code creates a "shake" and "SecondCounter" SensorGesture QML type, and - displays the detected gesture in a text type. - - QtSensors.shake gesture is available with the Qt Sensors API, but the QtSensors.SecondCounter - sensor gesture is provided as example code for the \l {Qt Sensors - SensorGesture QML Type example} - - \qml - Item { - SensorGesture { - id: sensorGesture - enabled: false - gestures : ["QtSensors.shake", "QtSensors.SecondCounter"] - onDetected:{ - detectedText.text = gesture - } - } - Text { - id: detectedText - x:5 - y:160 - text: "" - } - } - \endqml - - \l {Qt Sensor Gestures} contains a list of currently supported sensor gestures and their - descriptions. - - -*/ -QSensor2Gesture::QSensor2Gesture(QObject* parent) - : QObject(parent) - , isEnabled(false) - , initDone(false) - , sensorGesture(0) - , sensorGestureManager(new QSensorGestureManager(this)) -{ - connect(sensorGestureManager, SIGNAL(newSensorGestureAvailable()), SIGNAL(availableGesturesChanged())); -} - -QSensor2Gesture::~QSensor2Gesture() -{ -} - -/* - QQmlParserStatus interface implementation -*/ -void QSensor2Gesture::classBegin() -{ -} - -void QSensor2Gesture::componentComplete() -{ - /* - this is needed in the case the customer defines the type(s) and set it enabled = true - */ - initDone = true; - setEnabled(isEnabled); -} -/* - End of QQmlParserStatus interface implementation -*/ - -/*! - \qmlproperty stringlist QtSensors5::SensorGesture::availableGestures - This property can be used to determine all available gestures on the system. -*/ -QStringList QSensor2Gesture::availableGestures() -{ - return sensorGestureManager->gestureIds(); -} - -/*! - \qmlproperty stringlist QtSensors5::SensorGesture::gestures - Set this property to a list of the gestures that the application is interested in detecting. - This property cannot be changed while the type is enabled. - - The properties validGestures and invalidGestures will be set as appropriate immediately. - To determine all available getures on the system please use the - \l {QtSensors5::SensorGesture::availableGestures} {availableGestures} property. - - \sa {QtSensorGestures Plugins} -*/ -QStringList QSensor2Gesture::gestures() const -{ - return gestureList; -} - -void QSensor2Gesture::setGestures(const QStringList& value) -{ - if (gestureList == value) - return; - - if (initDone && enabled()) { - qWarning() << "Cannot change gestures while running."; - return; - } - gestureList.clear(); - gestureList = value; - createGesture(); - Q_EMIT gesturesChanged(); -} - - -/*! - \qmlproperty stringlist QtSensors5::SensorGesture::validGestures - This property holds the requested gestures that were found on the system. -*/ -QStringList QSensor2Gesture::validGestures() const -{ - if (sensorGesture) - return sensorGesture->validIds(); - return QStringList(); -} - -/*! - \qmlproperty stringlist QtSensors5::SensorGesture::invalidGestures - This property holds the requested gestures that were not found on the system. -*/ -QStringList QSensor2Gesture::invalidGestures() const -{ - if (sensorGesture) - return sensorGesture->invalidIds(); - return QStringList(); -} - -/*! - \qmlproperty bool QtSensors5::SensorGesture::enabled - This property can be used to activate or deactivate the sensor gesture. - Default value is false; - \sa {QtSensors5::SensorGesture::detected}, {detected} -*/ -bool QSensor2Gesture::enabled() const -{ - return isEnabled; -} - -void QSensor2Gesture::setEnabled(bool value) -{ - bool hasChanged = false; - if (isEnabled != value) { - isEnabled = value; - hasChanged = true; - } - if (!initDone) - return; - - if (sensorGesture) { - if (value) { - sensorGesture->startDetection(); - } else { - sensorGesture->stopDetection(); - } - } - if (hasChanged) - Q_EMIT enabledChanged(); -} - -/*! - \qmlsignal QtSensors5::SensorGesture::detected(string gesture) - This signal is emitted whenever a gesture is detected. - The gesture parameter contains the gesture that was detected. -*/ - -/* - private funtion implementation -*/ -void QSensor2Gesture::deleteGesture() -{ - if (sensorGesture) { - bool emitInvalidChange = !invalidGestures().isEmpty(); - bool emitValidChange = !validGestures().isEmpty(); - - if (sensorGesture->isActive()) { - sensorGesture->stopDetection(); - } - delete sensorGesture; - sensorGesture = 0; - - if (emitInvalidChange) { - Q_EMIT invalidGesturesChanged(); - } - if (emitValidChange) { - Q_EMIT validGesturesChanged(); - } - } -} - -void QSensor2Gesture::createGesture() -{ - deleteGesture(); - sensorGesture = new QSensorGesture(gestureList, this); - if (!validGestures().isEmpty()) { - QObject::connect(sensorGesture - , SIGNAL(detected(QString)) - , this - , SIGNAL(detected(QString))); - Q_EMIT validGesturesChanged(); - } - if (!invalidGestures().isEmpty()) - Q_EMIT invalidGesturesChanged(); -} - -/* - End of private funtion implementation -*/ - -QT_END_NAMESPACE diff --git a/src/imports/sensors2/qsensor2gesture.h b/src/imports/sensors2/qsensor2gesture.h deleted file mode 100644 index 2a27b05..0000000 --- a/src/imports/sensors2/qsensor2gesture.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSENSOR2GESTURE_H -#define QSENSOR2GESTURE_H - -#include <QtQml/QQmlParserStatus> -#include <QtQml/qqml.h> -#include <QtCore/QStringList> -#include <QtCore/QMap> - -QT_BEGIN_NAMESPACE - -class QSensorGesture; -class QSensorGestureManager; -class QSensor2Gesture : public QObject, public QQmlParserStatus -{ - Q_OBJECT - Q_PROPERTY(QStringList availableGestures READ availableGestures NOTIFY availableGesturesChanged) - Q_PROPERTY(QStringList gestures READ gestures WRITE setGestures NOTIFY gesturesChanged) - Q_PROPERTY(QStringList validGestures READ validGestures NOTIFY validGesturesChanged) - Q_PROPERTY(QStringList invalidGestures READ invalidGestures NOTIFY invalidGesturesChanged) - Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) - Q_INTERFACES(QQmlParserStatus) - -public: - explicit QSensor2Gesture(QObject* parent = 0); - ~QSensor2Gesture(); - void classBegin() Q_DECL_OVERRIDE; - void componentComplete() Q_DECL_OVERRIDE; - -Q_SIGNALS: - void detected(const QString &gesture); - void availableGesturesChanged(); - void gesturesChanged(); - void validGesturesChanged(); - void invalidGesturesChanged(); - void enabledChanged(); - -public: - QStringList availableGestures(); - QStringList gestures() const; - void setGestures(const QStringList& value); - bool enabled() const; - void setEnabled(bool value); - QStringList validGestures() const; - QStringList invalidGestures() const; - -private: - void deleteGesture(); - void createGesture(); - -private: - QStringList gestureIds; - bool isEnabled; - bool initDone; - QStringList gestureList; - - QSensorGesture* sensorGesture; - QSensorGestureManager* sensorGestureManager; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QSensor2Gesture) - -#endif // QSENSOR2GESTURE_H diff --git a/src/imports/sensors2/qsensor2proximity.cpp b/src/imports/sensors2/qsensor2proximity.cpp deleted file mode 100644 index b5e3dd7..0000000 --- a/src/imports/sensors2/qsensor2proximity.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qsensor2proximity.h" -#include <QtCore/QDebug> - -QT_BEGIN_NAMESPACE - -/*! - \qmltype ProximitySensor - \instantiates QSensor2Proximity - \inherits QtSensors5::Sensor - \inqmlmodule QtSensors 5.0 - \since QtSensors 5.0 - \brief Provides access to the proximity sensor. - - This type allows determining if something is held in close proximity to the device, such - as determining if the user is holding the device to their ear. - - This type is part of the \b{QtSensors 5} module. - - The \l {Qt Sensors - QML example} is an example how to use this QML type. - -*/ - -QSensor2Proximity::QSensor2Proximity(QObject* parent) - : qsensor2common(parent) - , _near(false) -{ - _proximity = new QProximitySensor(this); - _proximity->addFilter(this); -} - -QSensor2Proximity::~QSensor2Proximity() -{ -} - -/*! - \qmlproperty bool QtSensors5::ProximitySensor::near - This property holds whether the sensor has detected something in close proximity. - The definition of close proximity is device dependent, but it - typically stands for a distance of 1-2 cm. -*/ -bool QSensor2Proximity::near() -{ - return _near; -} - -bool QSensor2Proximity::filter(QProximityReading *reading) -{ - bool cl = reading->close(); - if (_near != cl){ - _near = cl; - Q_EMIT nearChanged(); - } - - return false; -} - -QT_END_NAMESPACE diff --git a/src/imports/sensors2/qsensor2proximity.h b/src/imports/sensors2/qsensor2proximity.h deleted file mode 100644 index 3c64cf9..0000000 --- a/src/imports/sensors2/qsensor2proximity.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSENSOR2PROXIMITY_H -#define QSENSOR2PROXIMITY_H - -#include <QtQml/qqmlextensionplugin.h> -#include <QtQml/qqml.h> -#include <qproximitysensor.h> -#include "qsensor2common.h" - -QT_BEGIN_NAMESPACE - -class QSensor2Proximity : public qsensor2common, public QProximityFilter -{ - Q_OBJECT - Q_PROPERTY(bool near READ near NOTIFY nearChanged) - -public: - QSensor2Proximity(QObject* parent = 0); - virtual ~QSensor2Proximity(); - -Q_SIGNALS: - void nearChanged(); - -private: - // Override of QProximityFilter::filter(QProximityReading*) - bool filter(QProximityReading *reading); - bool near(); - -private: - QSensor *sensor() { return _proximity; } - QProximitySensor* _proximity; - bool _near; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QSensor2Proximity) - -#endif // QSENSOR2PROXIMITY_H diff --git a/src/imports/sensors2/qsensor2tilt.cpp b/src/imports/sensors2/qsensor2tilt.cpp deleted file mode 100644 index 85d39ce..0000000 --- a/src/imports/sensors2/qsensor2tilt.cpp +++ /dev/null @@ -1,409 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qsensor2tilt.h" -#define _USE_MATH_DEFINES -#include <qmath.h> -#include <QtCore/QDebug> -#include <QtCore/QStringList> - -#define MAXRATE 30 - -QT_BEGIN_NAMESPACE - -/*! - \qmltype TiltSensor - \instantiates QSensor2Tilt - \inherits QtSensors5::Sensor - \inqmlmodule QtSensors 5.0 - \since QtSensors 5.0 - \brief Provides access to the current X and Y axis rotation angles of the device. - - This type provides tilt data from the rotation around the x and y axis of the device using - the accelerometer sensor. Like for a marble and maze game, where the marble is rolled - around the screen according to the user tilting the device. - - This type is part of the \b{QtSensors 5} module. - - The \l {Qt Sensors - QML example} is an example how to use this QML type. - -*/ -QSensor2Tilt::QSensor2Tilt(QObject* parent) - : qsensor2common(parent) - , _yRotation(0) - , _xRotation(0) - , _radAccuracy(M_PI / 180) - , _pitch(0) - , _roll(0) - , _calibratedPitch(0) - , _calibratedRoll(0) - , _speed(QSensor2Tilt::Slow) -{ - _accel = new QAccelerometer(this); - _accel->addFilter(this); -} - -QSensor2Tilt::~QSensor2Tilt() -{ -} - -int searchDataRate(const QList<int>& datarates, int value) -{ - int l = 0; - int r = datarates.count() - 1; - int m = (l + r) / 2; - - while (l <= r) { - m = (l + r) / 2; - if (datarates[m] == value) - break; - else if (datarates[m] < value) - r = m - 1; - else - l = m + 1; - } - if (m > 0){ - int ddr = datarates[m - 1]; - ddr -= value; - int ddr1 = datarates[m] - value; - if (ddr1 < 0) ddr1 = -ddr1; - if (ddr < ddr1) - return datarates[m - 1]; - } - - return datarates[m]; -} - -QMap<QSensor2Tilt::Speed, int> QSensor2Tilt::dataRate() -{ - return _dataRate; -} - -void QSensor2Tilt::createRunModeDataRateMap() -{ - _dataRate.clear(); - qrangelist rl = _accel->availableDataRates(); - - //1. make a list of all available datarates - QList<int> dr; - foreach (const qrange &r, rl) { - for (int i = r.first; i <= r.second; i++){ - if (i <= MAXRATE){ - if (!dr.contains(i)) - dr.append(i); - } - } - } - - //2. Sort the list - if (dr.count() > 0){ - qSort(dr.begin(), dr.end(), qGreater<int>()); - _dataRate.insert(QSensor2Tilt::Slow, searchDataRate(dr, 2)); - _dataRate.insert(QSensor2Tilt::Medium, searchDataRate(dr, 10)); - _dataRate.insert(QSensor2Tilt::Fast, searchDataRate(dr, 20)); - } -} - -/*! - \qmlproperty enumeration QtSensors5::TiltSensor::speed - Holds the speed that the sensor should be run at. - Default is Slow. - - \table - \row - \li TiltSensor.Slow - \li The sensor runs in slow mode. - \li Closest available datarate at 2Hz. - \row - \li TiltSensor.Medium - \li The sensor runs in medium mode. - \li Closest available datarate at 10Hz. - \row - \li TiltSensor.Fast - \li The sensor runs in fast mode. - \li Closest available datarate at 20Hz. - \endtable -*/ -QSensor2Tilt::Speed QSensor2Tilt::speed() -{ - return _speed; -} - -void QSensor2Tilt::setSpeed(const QSensor2Tilt::Speed val) -{ - if (_dataRate.keys().contains(val)){ - if (_dataRate.value(val) != _accel->dataRate()){ - _accel->setDataRate(_dataRate.value(val)); - Q_EMIT speedChanged(); - } - } - _speed = val; -} - -void QSensor2Tilt::setEnabled(const bool val) -{ - bool active = enabled(); - if (active != val){ - if (val){ - bool readDatarateMap = !_accel->isConnectedToBackend(); - bool ret = _accel->start(); - if (!ret) - qWarning() << "couldn't start the sensor."; - else if (readDatarateMap){ - createRunModeDataRateMap(); - setSpeed(_speed); - } - } - else - _accel->stop(); - Q_EMIT enabledChanged(); - } -} - - -/*! - \qmlproperty real QtSensors5::TiltSensor::yRotation - Holds the rotation arround the y axis. - - \table - \row - \li - \image YAngle.gif - \li - \image YAngleNegative.gif - \endtable -*/ -qreal QSensor2Tilt::yRotation() -{ - return _yRotation * 180 / M_PI; -} - -/*! - \qmlproperty real QtSensors5::TiltSensor::xRotation - Holds the rotation arround the x axis. - \table - \row - \li - \image XAngle.gif - \li - \image XAngleNegative.gif - \endtable -*/ -qreal QSensor2Tilt::xRotation() -{ - return _xRotation * 180 / M_PI; -} - -/* - Angle between Ground and X - | Ax | - pitch = arctan| ----------------------- | - | sqrt(Ay * Ay + Az * Az)| -*/ -inline qreal calcPitch(double Ax, double Ay, double Az) -{ - return -qAtan2(Ax, sqrt(Ay * Ay + Az * Az)); -} - -/* - Angle between Ground and Y - | Ay | - roll = arctan| ----------------------- | - | sqrt(Ax * Ax + Az * Az)| -*/ -inline qreal calcRoll(double Ax, double Ay, double Az) -{ - return qAtan2(Ay, (sqrt(Ax * Ax + Az * Az))); -} - -/*! - \qmlproperty real QtSensors5::TiltSensor::accuracy - This property contains the accuracy (in degrees) in which the rotation should be measured. - This can be used to minimize signal emiting and therefore saving of performance. - Default value is 1 degree. - The accuracy value is unsigned and works clockwise and counterclockwise in X and Y axis rotation - directions. Accuracy range can be 0 to 90 degrees. - - - For example: - Accuracy 5.5 will notify the client application about an rotation change only if the rotation angle over the X and / or Y axis was changed by 5.5 or more degrees clockwise or anti-clockwise. - - \table - \header \li Rotation \li notify application \li reason - \row \li 0.2424 \li no \li - \row \li 4.34234 \li no \li - \row \li 5.23423 \li no \li - \row \li 6.34324 \li yes \li because 6.34324 >= 5.5 - \row \li 7.43264 \li no \li - \row \li 8.24504 \li no \li - \row \li 9.34653 \li no \li - \row \li 10.23476 \li no \li - \row \li 11.43565 \li no \li - \row \li 12.45645 \li yes \li because 12.45645 - 6.34324 = 6.11321 >= 5.5 - \endtable -*/ -/*! - \qmlsignal QtSensors5::TiltSensor::tiltChanged(real deltaX, real deltaY) - This signal is emitted whenever the change from at leat one of the rotation values was higher than the accuracy. - The angle value is based on degrees. - -*/ - -//void QSensor2Tilt::setAccuracy(qreal val) -//{ -// //save in rad to save convertion calc in filter function -// if (val <= 90 && val >= 0) -// _radAccuracy = M_PI * val / 180; -//} - -/*! - \qmlmethod void QtSensors5::TiltSensor::calibrate() - The call of this function calibrates the tilt from x and y to the current position. -*/ -void QSensor2Tilt::calibrate() -{ - _calibratedPitch = _pitch; - _calibratedRoll = _roll; -#ifdef LOGCALIBRATION - qDebug() << "--------- calibrate --------"; - qDebug() << "_calibratedPitch: " << _calibratedPitch; - qDebug() << "_calibratedRoll: " << _calibratedRoll; - qDebug() << "----------------------------"; -#endif -} - -/*! - \qmlproperty real QtSensors5::TiltSensor::settings - This property contains the setting of the current state. - It can be used for saving and reloading previously saved calibrations. -*/ -QByteArray QSensor2Tilt::settings() const -{ - QByteArray arr; - arr.append(QString::number((double)_calibratedPitch)); - arr.append(";"); - arr.append(QString::number((double)_calibratedRoll)); - return arr; -} - -void QSensor2Tilt::setSettings(const QByteArray val) -{ - QString str(val); - if (str.indexOf(";") > 0){ - QStringList strlist = str.split(";"); - if (strlist.length() == 2){ - _calibratedPitch = strlist.at(0).toDouble(); - _calibratedRoll = strlist.at(1).toDouble(); - } - } -} - -bool QSensor2Tilt::filter(QAccelerometerReading* reading) -{ - /* - z y - | / - |/___ x - */ - - qreal ax = reading->x(); - qreal ay = reading->y(); - qreal az = reading->z(); -#ifdef LOGCALIBRATION - qDebug() << "------------ new value -----------"; - qDebug() << "old _pitch: " << _pitch; - qDebug() << "old _roll: " << _roll; - qDebug() << "_calibratedPitch: " << _calibratedPitch; - qDebug() << "_calibratedRoll: " << _calibratedRoll; -#endif - _pitch = calcPitch(ax, ay, az); - _roll = calcRoll (ax, ay, az); -#ifdef LOGCALIBRATION - qDebug() << "_pitch: " << _pitch; - qDebug() << "_roll: " << _roll; -#endif - qreal xrot = _roll - _calibratedRoll; - qreal yrot = _pitch - _calibratedPitch; - //get angle beteen 0 and 180 or 0 -180 - qreal aG = 1 * sin(xrot); - qreal aK = 1 * cos(xrot); - xrot = qAtan2(aG, aK); - if (xrot > M_PI_2) - xrot = M_PI - xrot; - else if (xrot < -M_PI_2) - xrot = -(M_PI + xrot); - aG = 1 * sin(yrot); - aK = 1 * cos(yrot); - yrot = qAtan2(aG, aK); - if (yrot > M_PI_2) - yrot = M_PI - yrot; - else if (yrot < -M_PI_2) - yrot = -(M_PI + yrot); - - -#ifdef LOGCALIBRATION - qDebug() << "new xrot: " << xrot; - qDebug() << "new yrot: " << yrot; - qDebug() << "----------------------------------"; -#endif - qreal dxrot = xrot - _xRotation; - qreal dyrot = yrot - _yRotation; - if (dxrot < 0) dxrot = -dxrot; - if (dyrot < 0) dyrot = -dyrot; - - bool change = false; - if (dxrot >= _radAccuracy){ - _xRotation = xrot; - Q_EMIT xRotationChanged(); - change = true; - } - if (dyrot >= _radAccuracy){ - _yRotation = yrot; - Q_EMIT yRotationChanged(); - change = true; - } - if (change){ - Q_EMIT tiltChanged(dxrot * 180 / M_PI, dyrot * 180 / M_PI); - } - return false; -} - -QT_END_NAMESPACE diff --git a/src/imports/sensors2/qsensor2tilt.h b/src/imports/sensors2/qsensor2tilt.h deleted file mode 100644 index 359db0d..0000000 --- a/src/imports/sensors2/qsensor2tilt.h +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSEONSOR2TILT_H -#define QSEONSOR2TILT_H - -#include <QtQml/qqmlextensionplugin.h> -#include <QtQml/qqml.h> -#include <qaccelerometer.h> -#include "qsensor2common.h" - -QT_BEGIN_NAMESPACE - -class QSensor2Tilt : public qsensor2common, public QAccelerometerFilter -{ - Q_OBJECT - Q_ENUMS(Unit Speed) - Q_PROPERTY(qreal yRotation READ yRotation NOTIFY yRotationChanged) - Q_PROPERTY(qreal xRotation READ xRotation NOTIFY xRotationChanged) - Q_PROPERTY(Speed speed READ speed WRITE setSpeed NOTIFY speedChanged) - Q_PROPERTY(QByteArray settings READ settings WRITE setSettings) - -public: - QSensor2Tilt(QObject* parent = 0); - virtual ~QSensor2Tilt(); - Q_INVOKABLE void calibrate(); - - enum Speed{ - Slow = 0 - , Medium - , Fast - }; - - -Q_SIGNALS: - void yRotationChanged(); - void xRotationChanged(); - void speedChanged(); - void tiltChanged(qreal deltaX, qreal deltaY); - -public: - // Override of QAcclerometerFilter::filter(QAccelerometerReading*) - qreal yRotation(); - qreal xRotation(); - Speed speed(); - void setSpeed(const Speed val); - void setEnabled(bool val); - QByteArray settings() const; - void setSettings(const QByteArray val); - void createRunModeDataRateMap(); - QMap<Speed, int> dataRate(); - -private: - bool filter(QAccelerometerReading* reading); - - QSensor *sensor() { return _accel; } - QAccelerometer* _accel; - qreal _yRotation; - qreal _xRotation; - qreal _radAccuracy; - qreal _pitch; - qreal _roll; - qreal _calibratedPitch; - qreal _calibratedRoll; - QMap<Speed, int> _dataRate; - Speed _speed; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QSensor2Tilt) - -#endif // QSEONSOR2TILT_H diff --git a/src/imports/sensors2/sensors2.cpp b/src/imports/sensors2/sensors2.cpp deleted file mode 100644 index 061549d..0000000 --- a/src/imports/sensors2/sensors2.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtQml/qqmlextensionplugin.h> -#include <QtQml/qqml.h> -#include "qsensor2ambientlight.h" -#include "qsensor2proximity.h" -#include "qsensor2tilt.h" -#include "qsensor2gesture.h" -#include <QtCore/QDebug> - -QT_BEGIN_NAMESPACE - -class QSensors2DeclarativeModule : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "plugin.json") -public: - virtual void registerTypes(const char *uri) - { - qDebug() << "QSensors2DeclarativeModule::registerTypes(const char *uri)"; - Q_ASSERT(QLatin1String(uri) == QLatin1String("QtSensors")); - - qmlRegisterUncreatableType<qsensor2common >(uri, 5, 0, "Sensor", QLatin1String("Cannot create Sensor")); - qmlRegisterType <QSensor2Tilt >(uri, 5, 0, "TiltSensor"); - qmlRegisterType <QSensor2AmbientLight>(uri, 5, 0, "AmbientLightSensor"); - qmlRegisterType <QSensor2Proximity >(uri, 5, 0, "ProximitySensor"); - qmlRegisterType <QSensor2Gesture >(uri, 5, 0, "SensorGesture"); - } -}; - -QT_END_NAMESPACE - -#include "sensors2.moc" diff --git a/src/imports/sensors2/sensors2.pro b/src/imports/sensors2/sensors2.pro deleted file mode 100644 index 24f3fb9..0000000 --- a/src/imports/sensors2/sensors2.pro +++ /dev/null @@ -1,22 +0,0 @@ -CXX_MODULE = sensors -TARGET = declarative_qtsensors5 - -QT += qml sensors - -SOURCES += sensors2.cpp \ - qsensor2ambientlight.cpp \ - qsensor2proximity.cpp \ - qsensor2tilt.cpp \ - qsensor2gesture.cpp \ - qsensor2common.cpp - -HEADERS += qsensor2ambientlight.h \ - qsensor2proximity.h \ - qsensor2tilt.h \ - qsensor2gesture.h \ - qsensor2common.h - -load(qml_plugin) - -OTHER_FILES += \ - plugin.json qmldir plugins.qmltypes diff --git a/src/sensors/gestures/qsensorgestureplugininterface.cpp b/src/sensors/gestures/qsensorgestureplugininterface.cpp index add34c0..b69c81c 100644 --- a/src/sensors/gestures/qsensorgestureplugininterface.cpp +++ b/src/sensors/gestures/qsensorgestureplugininterface.cpp @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE \brief The QSensorGesturePluginInterface class is the pure virtual interface to sensor gesture plugins. - \since QtSensors 5.0 + \since QtMobility.sensors 1.3 The QSensorGesturePluginInterface class is implemented in sensor gesture plugins to register sensor gesture recognizers with QSensorGestureManager. diff --git a/tests/auto/qtsensors5/tst_qtsensors5.cpp b/tests/auto/qtsensors5/tst_qtsensors5.cpp index 92b89c9..719876f 100644 --- a/tests/auto/qtsensors5/tst_qtsensors5.cpp +++ b/tests/auto/qtsensors5/tst_qtsensors5.cpp @@ -60,98 +60,6 @@ private slots: void cleanupTestCase() { } - - void versions_data() - { - QTest::addColumn<QString>("version"); - QTest::addColumn<bool>("exists"); - - QTest::newRow("5.0") << "5.0" << true; - } - - void versions() - { - QFETCH(QString, version); - QFETCH(bool, exists); - - QQmlEngine engine; - QString qml = QString("import QtQuick 2.0\nimport QtSensors %1\nItem {}").arg(version); - QQmlComponent c(&engine); - c.setData(qml.toLocal8Bit(), QUrl::fromLocalFile(QDir::currentPath())); - if (!exists) - QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); - QObject *obj = c.create(); - QCOMPARE(exists, (obj != 0)); - delete obj; - QList<QQmlError> errors = c.errors(); - if (exists) { - QCOMPARE(errors.count(), 0); - } else { - QCOMPARE(errors.count(), 1); - QString expected = QString("module \"QtSensors\" version %1 is not installed").arg(version); - QString actual = errors.first().description(); - QCOMPARE(expected, actual); - } - } - - void elements_data() - { - QTest::addColumn<QString>("version"); - QTest::addColumn<QString>("element"); - QTest::addColumn<bool>("exists"); - - QTest::newRow("5.0 AmbientLightSensor") << "5.0" << "AmbientLightSensor" << true; - QTest::newRow("5.0 ProximitySensor") << "5.0" << "ProximitySensor" << true; - QTest::newRow("5.0 TiltSensor") << "5.0" << "TiltSensor" << true; - QTest::newRow("5.0 SensorGesture") << "5.0" << "SensorGesture" << true; - } - - void elements() - { - QFETCH(QString, version); - QFETCH(QString, element); - QFETCH(bool, exists); - - QQmlEngine engine; - QString qml = QString("import QtQuick 2.0\nimport QtSensors %1\n%2 {}").arg(version).arg(element); - QQmlComponent c(&engine); - c.setData(qml.toLocal8Bit(), QUrl::fromLocalFile(QDir::currentPath())); - if (!exists) - QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); - QObject *obj = c.create(); - QCOMPARE(exists, (obj != 0)); - delete obj; - QList<QQmlError> errors = c.errors(); - QCOMPARE(errors.count(), 0); - } - - void uncreatable_elements_data() - { - QTest::addColumn<QString>("version"); - QTest::addColumn<QString>("element"); - - QTest::newRow("5.0 Sensor") << "5.0" << "Sensor"; - } - - void uncreatable_elements() - { - QFETCH(QString, version); - QFETCH(QString, element); - - QQmlEngine engine; - QString qml = QString("import QtQuick 2.0\nimport QtSensors %1\n%2 {}").arg(version).arg(element); - QQmlComponent c(&engine); - c.setData(qml.toLocal8Bit(), QUrl::fromLocalFile(QDir::currentPath())); - //QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); - QObject *obj = c.create(); - QCOMPARE(obj, static_cast<QObject*>(0)); - delete obj; - QList<QQmlError> errors = c.errors(); - QCOMPARE(errors.count(), 1); - QString expected = QString("Cannot create %1").arg(element); - QString actual = errors.first().description(); - QCOMPARE(expected, actual); - } }; QTEST_MAIN(tst_qtsensors5) diff --git a/tests/auto/sensors2qmlapi/qbackends.h b/tests/auto/sensors2qmlapi/qbackends.h deleted file mode 100644 index 020a1c0..0000000 --- a/tests/auto/sensors2qmlapi/qbackends.h +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef BACKENDS_H -#define BACKENDS_H - -#include "qdeclaccelerometer.h" -#include "qdeclambientlightsensor.h" -#include "qdeclproximitysensor.h" -#include <qsensorplugin.h> -#include <QtCore/QDebug> - - -class TestSensorPlugin : public QObject, - public QSensorPluginInterface, - public QSensorChangesInterface, - public QSensorBackendFactory -{ - Q_OBJECT - //Q_PLUGIN_METADATA(IID "com.nokia.Qt.QSensorPluginInterface/1.0" FILE "plugin.json") - Q_INTERFACES(QSensorPluginInterface QSensorChangesInterface) -public: - void registerSensors() - { - QSensorManager::registerBackend("QAccelerometer", "QAccelerometer", this); - QSensorManager::registerBackend("QAmbientLightSensor", "QAmbientLightSensor", this); - QSensorManager::registerBackend("QProximitySensor", "QProximitySensor", this); - } - - void sensorsChanged() - { - } - - QSensorBackend *createBackend(QSensor *sensor) - { - if (sensor->identifier() == "QAccelerometer") { - if (TestSensorPlugin::stAccel != 0) - return TestSensorPlugin::stAccel; - else - TestSensorPlugin::stAccel = new QDeclAccelerometer(sensor); - return createBackend(sensor); - } - else if (sensor->identifier() == "QAmbientLightSensor") { - if (TestSensorPlugin::stAbl != 0) - return TestSensorPlugin::stAbl; - else - TestSensorPlugin::stAbl = new QDeclAmbientLightSensor(sensor); - return createBackend(sensor); - } - else if (sensor->identifier() == "QProximitySensor") { - if (TestSensorPlugin::stProxi != 0) - return TestSensorPlugin::stProxi; - else - TestSensorPlugin::stProxi = new QDeclProximitySensor(sensor); - return createBackend(sensor); - } - - qWarning() << "Can't create backend" << sensor->identifier(); - return 0; - } -public: - static QDeclAccelerometer* stAccel; - static QDeclAmbientLightSensor* stAbl; - static QDeclProximitySensor* stProxi; -}; - -#endif - diff --git a/tests/auto/sensors2qmlapi/qdeclaccelerometer.h b/tests/auto/sensors2qmlapi/qdeclaccelerometer.h deleted file mode 100644 index 56040ec..0000000 --- a/tests/auto/sensors2qmlapi/qdeclaccelerometer.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLACCELEROMETER_H -#define QDECLACCELEROMETER_H - -#include <qsensorbackend.h> -#include "qaccelerometer.h" - -class QDeclAccelerometer : public QSensorBackend -{ - Q_OBJECT -public: - explicit QDeclAccelerometer(QSensor *sensor) - : QSensorBackend(sensor) - , _active(false) - , _sensor(sensor) - { - } - virtual ~QDeclAccelerometer() {} - - void start() { _active = true; } - void stop() - { - _sensor->stop(); - _active = false; - } - bool isActive() { return _active; } - - void test(qreal x, qreal y, qreal z) - { - if (sensor()->filters().count() > 0){ - QAccelerometerFilter* af = (QAccelerometerFilter*)sensor()->filters().at(0); - reader.setX(x); - reader.setY(y); - reader.setZ(z); - af->filter(&reader); - } - } -private: - bool _active; - QSensor* _sensor; - QAccelerometerReading reader; -}; -#endif - diff --git a/tests/auto/sensors2qmlapi/qdeclambientlightsensor.h b/tests/auto/sensors2qmlapi/qdeclambientlightsensor.h deleted file mode 100644 index 6c0b56c..0000000 --- a/tests/auto/sensors2qmlapi/qdeclambientlightsensor.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLAMBIENTLIGHTSENSOR_H -#define QDECLAMBIENTLIGHTSENSOR_H - -#include <qsensorbackend.h> -#include "./../../../src/imports/sensors2/qsensor2ambientlight.h" - -class QDeclAmbientLightSensor : public QSensorBackend -{ - Q_OBJECT -public: - explicit QDeclAmbientLightSensor(QSensor *sensor) - : QSensorBackend(sensor) - , _active(false) - , _sensor(sensor) - { - } - virtual ~QDeclAmbientLightSensor() {} - - void start() { _active = true; } - void stop() { _active = false; } - bool isActive() { return _active; } - - void test(QSensor2AmbientLight::LightLevel lv) - { - if (sensor()->filters().count() > 0){ - QAmbientLightFilter* af = (QAmbientLightFilter*)sensor()->filters().at(0); - reader.setLightLevel((QAmbientLightReading::LightLevel)lv); - af->filter(&reader); - } - } -private: - bool _active; - QSensor* _sensor; - QAmbientLightReading reader; -}; - -#endif - diff --git a/tests/auto/sensors2qmlapi/qdeclproximitysensor.h b/tests/auto/sensors2qmlapi/qdeclproximitysensor.h deleted file mode 100644 index 6ccdb30..0000000 --- a/tests/auto/sensors2qmlapi/qdeclproximitysensor.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, 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, Digia gives you certain additional -** rights. These rights are described in the Digia 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLPROXIMITYSENSOR_H -#define QDECLPROXIMITYSENSOR_H - -#include <qsensorbackend.h> -#include "qproximitysensor.h" - -class QDeclProximitySensor : public QSensorBackend -{ - Q_OBJECT -public: - explicit QDeclProximitySensor(QSensor *sensor) - : QSensorBackend(sensor) - , _active(false) - , _sensor(sensor) - { - } - virtual ~QDeclProximitySensor() {} - - void start() { _active = true; } - void stop() { _active = false; } - bool isActive() { return _active; } - - void test(bool val) - { - if (sensor()->filters().count() > 0){ - QProximityFilter* af = (QProximityFilter*)sensor()->filters().at(0); - reader.setClose(val); - af->filter(&reader); - } - } -private: - bool _active; - QSensor* _sensor; - QProximityReading reader; -}; -#endif - diff --git a/tests/auto/sensors2qmlapi/sensors2qmlapi.pro b/tests/auto/sensors2qmlapi/sensors2qmlapi.pro index 8344710..faa0c33 100644 --- a/tests/auto/sensors2qmlapi/sensors2qmlapi.pro +++ b/tests/auto/sensors2qmlapi/sensors2qmlapi.pro @@ -5,23 +5,12 @@ CONFIG += testcase QT = core testlib sensors-private qml SOURCES += tst_sensors2qmlapi.cpp \ - ./../../../src/imports/sensors2/qsensor2ambientlight.cpp \ - ./../../../src/imports/sensors2/qsensor2proximity.cpp \ - ./../../../src/imports/sensors2/qsensor2tilt.cpp \ - ./../../../src/imports/sensors2/qsensor2gesture.cpp \ - ./../../../src/imports/sensors2/qsensor2common.cpp \ + ./../../../src/imports/sensors/qmlsensorgesture.cpp \ qtemplategestureplugin.cpp \ qtemplaterecognizer.cpp -HEADERS += qdeclaccelerometer.h \ - qdeclambientlightsensor.h \ - qdeclproximitysensor.h \ - qbackends.h \ - ./../../../src/imports/sensors2/qsensor2ambientlight.h \ - ./../../../src/imports/sensors2/qsensor2proximity.h \ - ./../../../src/imports/sensors2/qsensor2tilt.h \ - ./../../../src/imports/sensors2/qsensor2gesture.h \ - ./../../../src/imports/sensors2/qsensor2common.h \ +HEADERS += \ + ./../../../src/imports/sensors/qmlsensorgesture.h \ qtemplategestureplugin.h \ qtemplaterecognizer.h diff --git a/tests/auto/sensors2qmlapi/tst_sensors2qmlapi.cpp b/tests/auto/sensors2qmlapi/tst_sensors2qmlapi.cpp index 42ef629..5573dd4 100644 --- a/tests/auto/sensors2qmlapi/tst_sensors2qmlapi.cpp +++ b/tests/auto/sensors2qmlapi/tst_sensors2qmlapi.cpp @@ -42,20 +42,13 @@ #include <QtTest/QtTest> #include <QtTest/QSignalSpy> #include <QtCore/QDebug> -#include "../../../src/imports/sensors2/qsensor2ambientlight.h" -#include "../../../src/imports/sensors2/qsensor2proximity.h" -#include "../../../src/imports/sensors2/qsensor2tilt.h" -#include "../../../src/imports/sensors2/qsensor2gesture.h" +#include "../../../src/imports/sensors/qmlsensorgesture.h" #include "qtemplategestureplugin.h" #include "qtemplaterecognizer.h" #include <qsensorgesturemanager.h> -#include "qbackends.h" #include "qsensormanager.h" QT_USE_NAMESPACE -QDeclAccelerometer* TestSensorPlugin::stAccel = 0; -QDeclAmbientLightSensor* TestSensorPlugin::stAbl = 0; -QDeclProximitySensor* TestSensorPlugin::stProxi = 0; QT_BEGIN_NAMESPACE @@ -65,366 +58,12 @@ class tst_Sensors2QMLAPI : public QObject private slots: void initTestCase(); - void testTilt_data(); - void testTilt(); - void testTilt_receivedSignalsCount(); - void testTiltSettings(); - void testTiltCalibration(); - void testTiltRunningMode(); - void testProximity(); - void testAmbientLight(); void testGesture(); - -protected: - TestSensorPlugin _plugin; - QSensor2Tilt* _tilt; }; void tst_Sensors2QMLAPI::initTestCase() { qputenv("QT_SENSORS_LOAD_PLUGINS", "0"); // Do not load plugins - _plugin.registerSensors(); - _tilt = 0; -} - -void tst_Sensors2QMLAPI::testProximity() -{ - QSensor2Proximity prox; - QSignalSpy spy(&prox, SIGNAL(enabledChanged())); - prox.setProperty("enabled", true); - QCOMPARE(spy.count() , 1); - - spy.clear(); - prox.setProperty("enabled", true); - QCOMPARE(spy.count() , 0); - - TestSensorPlugin plugin; - QDeclProximitySensor* proxi = plugin.stProxi; - - proxi->test(true); - bool expected = true; - bool actual = prox.property("near").toBool(); - QCOMPARE(expected, actual); - - QSignalSpy spy1(&prox, SIGNAL(nearChanged())); - proxi->test(false); - QCOMPARE(spy1.count() , 1); - expected = false; - actual = prox.property("near").toBool(); - QCOMPARE(expected, actual); - - spy1.clear(); - proxi->test(false); - QCOMPARE(spy1.count() , 0); - prox.setProperty("enabled", false); -} - -void tst_Sensors2QMLAPI::testAmbientLight() -{ - QSensor2AmbientLight als; - QSignalSpy spy(&als, SIGNAL(enabledChanged())); - als.setProperty("enabled", true); - QCOMPARE(spy.count() , 1); - - spy.clear(); - als.setProperty("enabled", true); - QCOMPARE(spy.count() , 0); - - TestSensorPlugin plugin; - QDeclAmbientLightSensor* abl = plugin.stAbl; - - for (int en = 5; en >= 0; en--){ - QSignalSpy spy1(&als, SIGNAL(lightLevelChanged())); - abl->test(static_cast<QSensor2AmbientLight::LightLevel>(en)); - QCOMPARE(spy1.count() , 1); - int expected = en; - int actual = als.property("lightLevel").toInt(); - if (expected != actual) - QCOMPARE(expected, actual); - - spy1.clear(); - abl->test(static_cast<QSensor2AmbientLight::LightLevel>(en)); - QCOMPARE(spy1.count() , 0); - } - als.setProperty("enabled", false); -} - -void tst_Sensors2QMLAPI::testTilt_data() -{ - QTest::addColumn<float>("pitch"); - QTest::addColumn<float>("roll"); - QTest::addColumn<int>("x"); - QTest::addColumn<int>("y"); - QTest::addColumn<int>("z"); - QTest::addColumn<int>("xRotation"); - QTest::addColumn<int>("yRotation"); - - //Face up - // Pitch Roll x y z xRot yRot - QTest::newRow("FaceUp1") << 0.0f << 0.0f << 0 << 0 << 1 << 0 << 0; - QTest::newRow("FaceUp2") << 0.0f << 0.0f << 0 << 1 << 0 << 90 << 0; - QTest::newRow("FaceUp3") << 0.0f << 0.0f << 1 << 0 << 0 << 0 << -90; - QTest::newRow("FaceUp4") << 0.0f << 0.0f << 1 << 0 << 1 << 0 << -45; - QTest::newRow("FaceUp5") << 0.0f << 0.0f << 1 << 1 << 0 << 45 << -45; - QTest::newRow("FaceUp6") << 0.0f << 0.0f << 0 << 1 << 1 << 45 << 0; - - //top up roll = 90 - // Pitch Roll x y z xRot yRot - QTest::newRow("TopUp1") << 0.0f << 90.0f << 0 << 0 << 1 << -90 << 0; - QTest::newRow("TopUp2") << 0.0f << 90.0f << 0 << 1 << 0 << 0 << 0; - QTest::newRow("TopUp3") << 0.0f << 90.0f << 1 << 0 << 0 << -90 << -90; - QTest::newRow("TopUp4") << 0.0f << 90.0f << 1 << 0 << 1 << -90 << -45; - QTest::newRow("TopUp5") << 0.0f << 90.0f << 1 << 1 << 0 << -45 << -45; - QTest::newRow("TopUp6") << 0.0f << 90.0f << 0 << 1 << 1 << -45 << 0; - - //top down roll = -90 - // Pitch Roll x y z xRot yRot - QTest::newRow("TopDown1") << 0.0f <<-90.0f << 0 << 0 << 1 << 90 << 0; - QTest::newRow("TopDown2") << 0.0f <<-90.0f << 0 << 1 << 0 << 0 << 0; - QTest::newRow("TopDown3") << 0.0f <<-90.0f << 1 << 0 << 0 << 90 << -90; - QTest::newRow("TopDown4") << 0.0f <<-90.0f << 1 << 0 << 1 << 90 << -45; - QTest::newRow("TopDown5") << 0.0f <<-90.0f << 1 << 1 << 0 << 45 << -45; - QTest::newRow("TopDown6") << 0.0f <<-90.0f << 0 << 1 << 1 << 45 << 0; - - //Left up Pitch = -90 Roll = 90 - // Pitch Roll x y z xRot yRot - QTest::newRow("LeftUp1") <<-90.0f << 90.0f << 0 << 0 << 1 << -90 << 90; - QTest::newRow("LeftUp2") <<-90.0f << 90.0f << 0 << 1 << 0 << 0 << 90; - QTest::newRow("LeftUp3") <<-90.0f << 90.0f << 1 << 0 << 0 << -90 << 0; - QTest::newRow("LeftUp4") <<-90.0f << 90.0f << 1 << 0 << 1 << -90 << 45; - QTest::newRow("LeftUp5") <<-90.0f << 90.0f << 1 << 1 << 0 << -45 << 45; - QTest::newRow("LeftUp6") <<-90.0f << 90.0f << 0 << 1 << 1 << -45 << 90; - - //Right up Pitch = -90 Roll = 90 - // Pitch Roll x y z xRot yRot - QTest::newRow("RightUp1") << 90.0f << 90.0f << 0 << 0 << 1 << -90 << -90; - QTest::newRow("RightUp2") << 90.0f << 90.0f << 0 << 1 << 0 << 0 << -90; - QTest::newRow("RightUp3") << 90.0f << 90.0f << 1 << 0 << 0 << -90 << 0; - QTest::newRow("RightUp4") << 90.0f << 90.0f << 1 << 0 << 1 << -90 << -45; - QTest::newRow("RightUp5") << 90.0f << 90.0f << 1 << 1 << 0 << -45 << -45; - QTest::newRow("RightUp6") << 90.0f << 90.0f << 0 << 1 << 1 << -45 << -90; - - //Face Down Pitch = -180 Roll = -180 - // Pitch Roll x y z xRot yRot - QTest::newRow("FaceDown1") <<-180.0f<<-180.0f<< 0 << 0 << 1 << 0 << 0; - QTest::newRow("FaceDown2") <<-180.0f<<-180.0f<< 0 << 1 << 0 << -90 << 0; - QTest::newRow("FaceDown3") <<-180.0f<<-180.0f<< 1 << 0 << 0 << 0 << 90; - QTest::newRow("FaceDown4") <<-180.0f<<-180.0f<< 1 << 0 << 1 << 0 << 45; - QTest::newRow("FaceDown5") <<-180.0f<<-180.0f<< 1 << 1 << 0 << -45 << 45; - QTest::newRow("FaceDown6") <<-180.0f<<-180.0f<< 0 << 1 << 1 << -45 << 0; -} - -int xrotch = 0; -int yrotch = 0; -void tst_Sensors2QMLAPI::testTilt() -{ - QFETCH(float, pitch); - QFETCH(float, roll); - QFETCH(int, x); - QFETCH(int, y); - QFETCH(int, z); - QFETCH(int, xRotation); - QFETCH(int, yRotation); - - if (!_tilt) - _tilt = new QSensor2Tilt(this); - - QSignalSpy spy(_tilt, SIGNAL(enabledChanged())); - _tilt->setProperty("enabled", true); - QCOMPARE(spy.count() , 1); - - spy.clear(); - _tilt->setProperty("enabled", true); - QCOMPARE(spy.count() , 0); - - QByteArray settings; - settings.append(QString::number(-5.0)); - settings.append(";"); - settings.append(QString::number(-5.0)); - _tilt->setProperty("settings", settings); - - QByteArray settings1; - settings1.append(QString::number(pitch * M_PI / 180.0, 'g', 20)); - settings1.append(";"); - settings1.append(QString::number(roll * M_PI / 180.0, 'g', 20)); - _tilt->setProperty("settings", settings1); - - QDeclAccelerometer* accel = _plugin.stAccel; - - QSignalSpy spyxrot(_tilt, SIGNAL(xRotationChanged())); - QSignalSpy spyyrot(_tilt, SIGNAL(yRotationChanged())); - accel->test(x,y,z); - xrotch += spyxrot.count(); - yrotch += spyyrot.count(); - - QCOMPARE(xRotation, _tilt->property("xRotation").toInt()); - QCOMPARE(yRotation, _tilt->property("yRotation").toInt()); - - spy.clear(); - _tilt->setProperty("enabled", false); - QCOMPARE(spy.count() , 1); - - spy.clear(); - _tilt->setProperty("enabled", false); - QCOMPARE(spy.count() , 0); -} - -void tst_Sensors2QMLAPI::testTiltSettings() -{ - if (!_tilt) - _tilt = new QSensor2Tilt(this); - - QByteArray settings; - settings.append(QString::number(-5.0)); - settings.append(";"); - settings.append(QString::number(-5.0)); - _tilt->setProperty("settings", settings); - QByteArray val = _tilt->property("settings").toByteArray(); - QCOMPARE(settings, val); - - QByteArray settings1; - settings1.append(QString::number(-6.0)); - settings1.append(":"); - settings1.append(QString::number(3.0)); - _tilt->setProperty("settings", settings1); - val = _tilt->property("settings").toByteArray(); - QCOMPARE(settings, val); - - settings1.clear(); - settings1.append(":"); - _tilt->setProperty("settings", settings1); - val = _tilt->property("settings").toByteArray(); - QCOMPARE(settings, val); - - settings1.clear(); - settings1.append("1;2;3"); - _tilt->setProperty("settings", settings1); - val = _tilt->property("settings").toByteArray(); - QCOMPARE(settings, val); -} - -void tst_Sensors2QMLAPI::testTilt_receivedSignalsCount() -{ - QCOMPARE(xrotch , 23); - QCOMPARE(yrotch , 21); -} - -void tst_Sensors2QMLAPI::testTiltCalibration() -{ - if (!_tilt) - _tilt = new QSensor2Tilt(this); - - QByteArray settings; - settings.append(QString::number(0.0)); - settings.append(";"); - settings.append(QString::number(0.0)); - _tilt->setProperty("settings", settings); - _tilt->setProperty("enabled", true); - - QDeclAccelerometer* accel = _plugin.stAccel; - - //be sure we set rotation to 0 - accel->test(-3.59904, 5.52114, 7.07059); - _tilt->calibrate(); - accel->test(-3.59904, 5.52114, 7.07059); - float xRotation = _tilt->property("xRotation").toFloat(); - float yRotation = _tilt->property("yRotation").toFloat(); - if (xRotation < 0.0) xRotation = -xRotation; - if (yRotation < 0.0) yRotation = -yRotation; - QVERIFY(xRotation < 0.001); - QVERIFY(yRotation < 0.001); - - accel->test(0.519752, 6.82543, 7.06079); - _tilt->calibrate(); - accel->test(0.539366, 6.79601, 7.0804); - xRotation = _tilt->property("xRotation").toFloat(); - yRotation = _tilt->property("yRotation").toFloat(); - if (xRotation < 0.0) xRotation = -xRotation; - if (yRotation < 0.0) yRotation = -yRotation; - QVERIFY(xRotation < 0.25); - QVERIFY(yRotation < 0.12); - _tilt->setProperty("enabled", false); -} - -void tst_Sensors2QMLAPI::testTiltRunningMode() -{ - if (!_tilt) - _tilt = new QSensor2Tilt(this); - QDeclAccelerometer* accel = _plugin.stAccel; - QCOMPARE(_tilt->dataRate().count(), 0); - accel->addDataRate(13, 15); - _tilt->createRunModeDataRateMap(); - QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Slow), 13); - QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Medium), 13); - QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Fast), 15); - - accel->addDataRate(1, 8); - _tilt->createRunModeDataRateMap(); - QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Slow), 2); - QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Medium), 8); - QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Fast), 15); - - accel->addDataRate(11, 12); - _tilt->createRunModeDataRateMap(); - QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Slow), 2); - QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Medium), 11); - QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Fast), 15); - - accel->addDataRate(13, 18); - _tilt->createRunModeDataRateMap(); - QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Slow), 2); - QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Medium), 11); - QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Fast), 18); - - accel->addDataRate(21, 31); - _tilt->createRunModeDataRateMap(); - QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Slow), 2); - QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Medium), 11); - QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Fast), 21); - - accel->addDataRate(19, 20); - _tilt->createRunModeDataRateMap(); - QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Slow), 2); - QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Medium), 11); - QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Fast), 20); - - accel->addDataRate(9, 10); - _tilt->createRunModeDataRateMap(); - QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Slow), 2); - QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Medium), 10); - QCOMPARE(_tilt->dataRate().value(QSensor2Tilt::Fast), 20); - - QSensor2Tilt::Speed speed = static_cast<QSensor2Tilt::Speed>(_tilt->property("speed").toInt()); - QCOMPARE(speed, QSensor2Tilt::Slow); - _tilt->setProperty("speed", QSensor2Tilt::Slow); - - QSignalSpy spymode(_tilt, SIGNAL(speedChanged())); - _tilt->setProperty("speed", QSensor2Tilt::Slow); - QCOMPARE(spymode.count() , 0); - speed = static_cast<QSensor2Tilt::Speed>(_tilt->property("speed").toInt()); - QCOMPARE(speed, QSensor2Tilt::Slow); - - _tilt->setProperty("speed", QSensor2Tilt::Medium); - QCOMPARE(spymode.count() , 1); - spymode.clear(); - speed = static_cast<QSensor2Tilt::Speed>(_tilt->property("speed").toInt()); - QCOMPARE(speed, QSensor2Tilt::Medium); - - _tilt->setProperty("speed", QSensor2Tilt::Medium); - QCOMPARE(spymode.count() , 0); - speed = static_cast<QSensor2Tilt::Speed>(_tilt->property("speed").toInt()); - QCOMPARE(speed, QSensor2Tilt::Medium); - - _tilt->setProperty("speed", QSensor2Tilt::Fast); - QCOMPARE(spymode.count() , 1); - spymode.clear(); - speed = static_cast<QSensor2Tilt::Speed>(_tilt->property("speed").toInt()); - QCOMPARE(speed, QSensor2Tilt::Fast); - - _tilt->setProperty("speed", QSensor2Tilt::Fast); - QCOMPARE(spymode.count() , 0); - speed = static_cast<QSensor2Tilt::Speed>(_tilt->property("speed").toInt()); - QCOMPARE(speed, QSensor2Tilt::Fast); } void tst_Sensors2QMLAPI::testGesture() @@ -433,7 +72,7 @@ void tst_Sensors2QMLAPI::testGesture() QList <QSensorGestureRecognizer *> recognizers = plugin->createRecognizers(); QSensorGestureManager manager; - QSensor2Gesture* gs = new QSensor2Gesture(this); + QmlSensorGesture* gs = new QmlSensorGesture(this); gs->componentComplete(); QSignalSpy spy_availableGesturesChanged(gs, SIGNAL(availableGesturesChanged())); QSignalSpy spy_detected(gs, SIGNAL(detected(QString))); @@ -482,7 +121,7 @@ void tst_Sensors2QMLAPI::testGesture() gs->setEnabled(false); - QSensor2Gesture* gs1 = new QSensor2Gesture(this); + QmlSensorGesture* gs1 = new QmlSensorGesture(this); QSignalSpy spy1_detected(gs1, SIGNAL(detected(QString))); QSignalSpy spy1_gesturesChanged(gs1, SIGNAL(gesturesChanged())); QSignalSpy spy1_validGesturesChanged(gs1, SIGNAL(validGesturesChanged())); @@ -534,7 +173,7 @@ void tst_Sensors2QMLAPI::testGesture() gs1->setEnabled(false); //check sensor shouldn't run until the componentComplete gets called - QSensor2Gesture* gs2 = new QSensor2Gesture(this); + QmlSensorGesture* gs2 = new QmlSensorGesture(this); QSignalSpy spy2_detected(gs2, SIGNAL(detected(QString))); gs2->setGestures(QStringList() << "QtSensors.template"); gs2->setEnabled(true); |