From 0193d164e79845f7a2b5a388ed2818854c77399f Mon Sep 17 00:00:00 2001 From: Juha Vuolle Date: Fri, 21 May 2021 10:01:56 +0300 Subject: Split the Sensors QML plugin into a library and a plugin The main changes: - Introduction of new SensorsQuick library with private exports - The original QML plugin loads this new library and does little else - Renamed original 'sensors' plugin as 'declarative_sensors' to provide an idea what it relates to - Renamed library headers as private "_p.h" and added "We mean it" - Changed qmlRegister* calls to QML_ELEMENT macros - Removed files that are generated in Qt6 (qmldir, plugins.qmltypes) Task-number: QTBUG-92530 Change-Id: I18f849adabcc79ac47e67305f78aefeee82801bc Reviewed-by: Fabian Kosmale --- src/CMakeLists.txt | 1 + src/imports/sensors/CMakeLists.txt | 36 +- src/imports/sensors/plugin.json | 1 - src/imports/sensors/plugins.qmltypes | 613 --------------------- src/imports/sensors/qmlaccelerometer.cpp | 188 ------- src/imports/sensors/qmlaccelerometer.h | 107 ---- src/imports/sensors/qmlaltimeter.cpp | 131 ----- src/imports/sensors/qmlaltimeter.h | 84 --- src/imports/sensors/qmlambientlightsensor.cpp | 141 ----- src/imports/sensors/qmlambientlightsensor.h | 86 --- .../sensors/qmlambienttemperaturesensor.cpp | 131 ----- src/imports/sensors/qmlambienttemperaturesensor.h | 84 --- src/imports/sensors/qmlcompass.cpp | 148 ----- src/imports/sensors/qmlcompass.h | 88 --- src/imports/sensors/qmldir | 4 - src/imports/sensors/qmldistancesensor.cpp | 131 ----- src/imports/sensors/qmldistancesensor.h | 85 --- src/imports/sensors/qmlgyroscope.cpp | 164 ------ src/imports/sensors/qmlgyroscope.h | 92 ---- src/imports/sensors/qmlholstersensor.cpp | 131 ----- src/imports/sensors/qmlholstersensor.h | 84 --- src/imports/sensors/qmlhumiditysensor.cpp | 150 ----- src/imports/sensors/qmlhumiditysensor.h | 90 --- src/imports/sensors/qmlirproximitysensor.cpp | 129 ----- src/imports/sensors/qmlirproximitysensor.h | 83 --- src/imports/sensors/qmllidsensor.cpp | 149 ----- src/imports/sensors/qmllidsensor.h | 88 --- src/imports/sensors/qmllightsensor.cpp | 145 ----- src/imports/sensors/qmllightsensor.h | 89 --- src/imports/sensors/qmlmagnetometer.cpp | 203 ------- src/imports/sensors/qmlmagnetometer.h | 102 ---- src/imports/sensors/qmlorientationsensor.cpp | 141 ----- src/imports/sensors/qmlorientationsensor.h | 86 --- src/imports/sensors/qmlpressuresensor.cpp | 151 ----- src/imports/sensors/qmlpressuresensor.h | 88 --- src/imports/sensors/qmlproximitysensor.cpp | 131 ----- src/imports/sensors/qmlproximitysensor.h | 86 --- src/imports/sensors/qmlrotationsensor.cpp | 184 ------- src/imports/sensors/qmlrotationsensor.h | 98 ---- src/imports/sensors/qmlsensor.cpp | 577 ------------------- src/imports/sensors/qmlsensor.h | 206 ------- src/imports/sensors/qmlsensorgesture.cpp | 262 --------- src/imports/sensors/qmlsensorgesture.h | 100 ---- src/imports/sensors/qmlsensorglobal.cpp | 121 ---- src/imports/sensors/qmlsensorglobal.h | 70 --- src/imports/sensors/qmlsensorrange.cpp | 88 --- src/imports/sensors/qmlsensorrange.h | 94 ---- src/imports/sensors/qmltapsensor.cpp | 179 ------ src/imports/sensors/qmltapsensor.h | 96 ---- src/imports/sensors/qmltiltsensor.cpp | 163 ------ src/imports/sensors/qmltiltsensor.h | 90 --- src/imports/sensors/sensors.cpp | 202 +------ src/sensorsquick/CMakeLists.txt | 45 ++ src/sensorsquick/qmlaccelerometer.cpp | 188 +++++++ src/sensorsquick/qmlaccelerometer_p.h | 123 +++++ src/sensorsquick/qmlaltimeter.cpp | 131 +++++ src/sensorsquick/qmlaltimeter_p.h | 100 ++++ src/sensorsquick/qmlambientlightsensor.cpp | 141 +++++ src/sensorsquick/qmlambientlightsensor_p.h | 102 ++++ src/sensorsquick/qmlambienttemperaturesensor.cpp | 131 +++++ src/sensorsquick/qmlambienttemperaturesensor_p.h | 100 ++++ src/sensorsquick/qmlcompass.cpp | 148 +++++ src/sensorsquick/qmlcompass_p.h | 104 ++++ src/sensorsquick/qmldistancesensor.cpp | 131 +++++ src/sensorsquick/qmldistancesensor_p.h | 101 ++++ src/sensorsquick/qmlgyroscope.cpp | 164 ++++++ src/sensorsquick/qmlgyroscope_p.h | 108 ++++ src/sensorsquick/qmlholstersensor.cpp | 131 +++++ src/sensorsquick/qmlholstersensor_p.h | 100 ++++ src/sensorsquick/qmlhumiditysensor.cpp | 150 +++++ src/sensorsquick/qmlhumiditysensor_p.h | 106 ++++ src/sensorsquick/qmlirproximitysensor.cpp | 129 +++++ src/sensorsquick/qmlirproximitysensor_p.h | 99 ++++ src/sensorsquick/qmllidsensor.cpp | 149 +++++ src/sensorsquick/qmllidsensor_p.h | 104 ++++ src/sensorsquick/qmllightsensor.cpp | 145 +++++ src/sensorsquick/qmllightsensor_p.h | 105 ++++ src/sensorsquick/qmlmagnetometer.cpp | 203 +++++++ src/sensorsquick/qmlmagnetometer_p.h | 118 ++++ src/sensorsquick/qmlorientationsensor.cpp | 141 +++++ src/sensorsquick/qmlorientationsensor_p.h | 102 ++++ src/sensorsquick/qmlpressuresensor.cpp | 151 +++++ src/sensorsquick/qmlpressuresensor_p.h | 104 ++++ src/sensorsquick/qmlproximitysensor.cpp | 131 +++++ src/sensorsquick/qmlproximitysensor_p.h | 102 ++++ src/sensorsquick/qmlrotationsensor.cpp | 184 +++++++ src/sensorsquick/qmlrotationsensor_p.h | 114 ++++ src/sensorsquick/qmlsensor.cpp | 577 +++++++++++++++++++ src/sensorsquick/qmlsensor_p.h | 226 ++++++++ src/sensorsquick/qmlsensorgesture.cpp | 262 +++++++++ src/sensorsquick/qmlsensorgesture_p.h | 116 ++++ src/sensorsquick/qmlsensorglobal.cpp | 121 ++++ src/sensorsquick/qmlsensorglobal_p.h | 86 +++ src/sensorsquick/qmlsensorrange.cpp | 88 +++ src/sensorsquick/qmlsensorrange_p.h | 113 ++++ src/sensorsquick/qmltapsensor.cpp | 179 ++++++ src/sensorsquick/qmltapsensor_p.h | 112 ++++ src/sensorsquick/qmltiltsensor.cpp | 163 ++++++ src/sensorsquick/qmltiltsensor_p.h | 106 ++++ src/sensorsquick/qsensorsquickglobal_p.h | 74 +++ 100 files changed, 6623 insertions(+), 6956 deletions(-) delete mode 100644 src/imports/sensors/plugin.json delete mode 100644 src/imports/sensors/plugins.qmltypes delete mode 100644 src/imports/sensors/qmlaccelerometer.cpp delete mode 100644 src/imports/sensors/qmlaccelerometer.h delete mode 100644 src/imports/sensors/qmlaltimeter.cpp delete mode 100644 src/imports/sensors/qmlaltimeter.h delete mode 100644 src/imports/sensors/qmlambientlightsensor.cpp delete mode 100644 src/imports/sensors/qmlambientlightsensor.h delete mode 100644 src/imports/sensors/qmlambienttemperaturesensor.cpp delete mode 100644 src/imports/sensors/qmlambienttemperaturesensor.h delete mode 100644 src/imports/sensors/qmlcompass.cpp delete mode 100644 src/imports/sensors/qmlcompass.h delete mode 100644 src/imports/sensors/qmldir delete mode 100644 src/imports/sensors/qmldistancesensor.cpp delete mode 100644 src/imports/sensors/qmldistancesensor.h delete mode 100644 src/imports/sensors/qmlgyroscope.cpp delete mode 100644 src/imports/sensors/qmlgyroscope.h delete mode 100644 src/imports/sensors/qmlholstersensor.cpp delete mode 100644 src/imports/sensors/qmlholstersensor.h delete mode 100644 src/imports/sensors/qmlhumiditysensor.cpp delete mode 100644 src/imports/sensors/qmlhumiditysensor.h delete mode 100644 src/imports/sensors/qmlirproximitysensor.cpp delete mode 100644 src/imports/sensors/qmlirproximitysensor.h delete mode 100644 src/imports/sensors/qmllidsensor.cpp delete mode 100644 src/imports/sensors/qmllidsensor.h delete mode 100644 src/imports/sensors/qmllightsensor.cpp delete mode 100644 src/imports/sensors/qmllightsensor.h delete mode 100644 src/imports/sensors/qmlmagnetometer.cpp delete mode 100644 src/imports/sensors/qmlmagnetometer.h delete mode 100644 src/imports/sensors/qmlorientationsensor.cpp delete mode 100644 src/imports/sensors/qmlorientationsensor.h delete mode 100644 src/imports/sensors/qmlpressuresensor.cpp delete mode 100644 src/imports/sensors/qmlpressuresensor.h delete mode 100644 src/imports/sensors/qmlproximitysensor.cpp delete mode 100644 src/imports/sensors/qmlproximitysensor.h delete mode 100644 src/imports/sensors/qmlrotationsensor.cpp delete mode 100644 src/imports/sensors/qmlrotationsensor.h delete mode 100644 src/imports/sensors/qmlsensor.cpp delete mode 100644 src/imports/sensors/qmlsensor.h delete mode 100644 src/imports/sensors/qmlsensorgesture.cpp delete mode 100644 src/imports/sensors/qmlsensorgesture.h delete mode 100644 src/imports/sensors/qmlsensorglobal.cpp delete mode 100644 src/imports/sensors/qmlsensorglobal.h delete mode 100644 src/imports/sensors/qmlsensorrange.cpp delete mode 100644 src/imports/sensors/qmlsensorrange.h delete mode 100644 src/imports/sensors/qmltapsensor.cpp delete mode 100644 src/imports/sensors/qmltapsensor.h delete mode 100644 src/imports/sensors/qmltiltsensor.cpp delete mode 100644 src/imports/sensors/qmltiltsensor.h create mode 100644 src/sensorsquick/CMakeLists.txt create mode 100644 src/sensorsquick/qmlaccelerometer.cpp create mode 100644 src/sensorsquick/qmlaccelerometer_p.h create mode 100644 src/sensorsquick/qmlaltimeter.cpp create mode 100644 src/sensorsquick/qmlaltimeter_p.h create mode 100644 src/sensorsquick/qmlambientlightsensor.cpp create mode 100644 src/sensorsquick/qmlambientlightsensor_p.h create mode 100644 src/sensorsquick/qmlambienttemperaturesensor.cpp create mode 100644 src/sensorsquick/qmlambienttemperaturesensor_p.h create mode 100644 src/sensorsquick/qmlcompass.cpp create mode 100644 src/sensorsquick/qmlcompass_p.h create mode 100644 src/sensorsquick/qmldistancesensor.cpp create mode 100644 src/sensorsquick/qmldistancesensor_p.h create mode 100644 src/sensorsquick/qmlgyroscope.cpp create mode 100644 src/sensorsquick/qmlgyroscope_p.h create mode 100644 src/sensorsquick/qmlholstersensor.cpp create mode 100644 src/sensorsquick/qmlholstersensor_p.h create mode 100644 src/sensorsquick/qmlhumiditysensor.cpp create mode 100644 src/sensorsquick/qmlhumiditysensor_p.h create mode 100644 src/sensorsquick/qmlirproximitysensor.cpp create mode 100644 src/sensorsquick/qmlirproximitysensor_p.h create mode 100644 src/sensorsquick/qmllidsensor.cpp create mode 100644 src/sensorsquick/qmllidsensor_p.h create mode 100644 src/sensorsquick/qmllightsensor.cpp create mode 100644 src/sensorsquick/qmllightsensor_p.h create mode 100644 src/sensorsquick/qmlmagnetometer.cpp create mode 100644 src/sensorsquick/qmlmagnetometer_p.h create mode 100644 src/sensorsquick/qmlorientationsensor.cpp create mode 100644 src/sensorsquick/qmlorientationsensor_p.h create mode 100644 src/sensorsquick/qmlpressuresensor.cpp create mode 100644 src/sensorsquick/qmlpressuresensor_p.h create mode 100644 src/sensorsquick/qmlproximitysensor.cpp create mode 100644 src/sensorsquick/qmlproximitysensor_p.h create mode 100644 src/sensorsquick/qmlrotationsensor.cpp create mode 100644 src/sensorsquick/qmlrotationsensor_p.h create mode 100644 src/sensorsquick/qmlsensor.cpp create mode 100644 src/sensorsquick/qmlsensor_p.h create mode 100644 src/sensorsquick/qmlsensorgesture.cpp create mode 100644 src/sensorsquick/qmlsensorgesture_p.h create mode 100644 src/sensorsquick/qmlsensorglobal.cpp create mode 100644 src/sensorsquick/qmlsensorglobal_p.h create mode 100644 src/sensorsquick/qmlsensorrange.cpp create mode 100644 src/sensorsquick/qmlsensorrange_p.h create mode 100644 src/sensorsquick/qmltapsensor.cpp create mode 100644 src/sensorsquick/qmltapsensor_p.h create mode 100644 src/sensorsquick/qmltiltsensor.cpp create mode 100644 src/sensorsquick/qmltiltsensor_p.h create mode 100644 src/sensorsquick/qsensorsquickglobal_p.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9a363951..bb87443e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,6 @@ add_subdirectory(sensors) add_subdirectory(plugins) if(TARGET Qt::Quick) + add_subdirectory(sensorsquick) add_subdirectory(imports) endif() diff --git a/src/imports/sensors/CMakeLists.txt b/src/imports/sensors/CMakeLists.txt index 87414bde..d20add31 100644 --- a/src/imports/sensors/CMakeLists.txt +++ b/src/imports/sensors/CMakeLists.txt @@ -1,42 +1,14 @@ - -# TODO Qt 6.2 split into separate QML library + plugin - -qt_internal_add_qml_module(sensors +qt_internal_add_qml_module(declarative_sensors URI "QtSensors" - VERSION "${CMAKE_PROJECT_VERSION}" + VERSION "${PROJECT_VERSION}" CLASSNAME QtSensorsDeclarativeModule SKIP_TYPE_REGISTRATION + PLUGIN_OPTIONAL SOURCES - qmlaccelerometer.cpp qmlaccelerometer.h - qmlaltimeter.cpp qmlaltimeter.h - qmlambientlightsensor.cpp qmlambientlightsensor.h - qmlambienttemperaturesensor.cpp qmlambienttemperaturesensor.h - qmlcompass.cpp qmlcompass.h - qmldistancesensor.cpp qmldistancesensor.h - qmlgyroscope.cpp qmlgyroscope.h - qmlholstersensor.cpp qmlholstersensor.h - qmlhumiditysensor.cpp qmlhumiditysensor.h - qmlirproximitysensor.cpp qmlirproximitysensor.h - qmllidsensor.cpp qmllidsensor.h - qmllightsensor.cpp qmllightsensor.h - qmlmagnetometer.cpp qmlmagnetometer.h - qmlorientationsensor.cpp qmlorientationsensor.h - qmlpressuresensor.cpp qmlpressuresensor.h - qmlproximitysensor.cpp qmlproximitysensor.h - qmlrotationsensor.cpp qmlrotationsensor.h - qmlsensor.cpp qmlsensor.h - qmlsensorgesture.cpp qmlsensorgesture.h - qmlsensorglobal.cpp qmlsensorglobal.h - qmlsensorrange.cpp qmlsensorrange.h - qmltapsensor.cpp qmltapsensor.h - qmltiltsensor.cpp qmltiltsensor.h sensors.cpp PUBLIC_LIBRARIES Qt::Core - Qt::Gui Qt::Qml - Qt::Sensors LIBRARIES - Qt::CorePrivate - Qt::SensorsPrivate + Qt::SensorsQuickPrivate ) diff --git a/src/imports/sensors/plugin.json b/src/imports/sensors/plugin.json deleted file mode 100644 index 0967ef42..00000000 --- a/src/imports/sensors/plugin.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/src/imports/sensors/plugins.qmltypes b/src/imports/sensors/plugins.qmltypes deleted file mode 100644 index c68c37b3..00000000 --- a/src/imports/sensors/plugins.qmltypes +++ /dev/null @@ -1,613 +0,0 @@ -import QtQuick.tooling 1.2 - -// This file describes the plugin-supplied types contained in the library. -// It is used for QML tooling purposes only. -// -// This file was auto-generated by: -// 'qmlplugindump -nonrelocatable QtSensors 5.15' - -Module { - dependencies: ["QtQuick 2.0"] - Component { - name: "QmlAccelerometer" - prototype: "QmlSensor" - exports: [ - "QtSensors/Accelerometer 5.0", - "QtSensors/Accelerometer 5.1", - "QtSensors/Accelerometer 5.2" - ] - exportMetaObjectRevisions: [0, 1, 1] - Enum { - name: "AccelerationMode" - values: { - "Combined": 0, - "Gravity": 1, - "User": 2 - } - } - Property { name: "accelerationMode"; revision: 1; type: "AccelerationMode" } - Signal { - name: "accelerationModeChanged" - revision: 1 - Parameter { name: "accelerationMode"; type: "AccelerationMode" } - } - } - Component { - name: "QmlAccelerometerReading" - prototype: "QmlSensorReading" - exports: [ - "QtSensors/AccelerometerReading 5.0", - "QtSensors/AccelerometerReading 5.1", - "QtSensors/AccelerometerReading 5.2" - ] - isCreatable: false - exportMetaObjectRevisions: [0, 0, 0] - Property { name: "x"; type: "double"; isReadonly: true } - Property { name: "y"; type: "double"; isReadonly: true } - Property { name: "z"; type: "double"; isReadonly: true } - } - Component { - name: "QmlAltimeter" - prototype: "QmlSensor" - exports: ["QtSensors/Altimeter 5.1", "QtSensors/Altimeter 5.2"] - exportMetaObjectRevisions: [0, 0] - } - Component { - name: "QmlAltimeterReading" - prototype: "QmlSensorReading" - exports: [ - "QtSensors/AltimeterReading 5.1", - "QtSensors/AltimeterReading 5.2" - ] - isCreatable: false - exportMetaObjectRevisions: [0, 0] - Property { name: "altitude"; type: "double"; isReadonly: true } - } - Component { - name: "QmlAmbientLightSensor" - prototype: "QmlSensor" - exports: [ - "QtSensors/AmbientLightSensor 5.0", - "QtSensors/AmbientLightSensor 5.1", - "QtSensors/AmbientLightSensor 5.2" - ] - exportMetaObjectRevisions: [0, 0, 0] - } - Component { - name: "QmlAmbientLightSensorReading" - prototype: "QmlSensorReading" - exports: [ - "QtSensors/AmbientLightReading 5.0", - "QtSensors/AmbientLightReading 5.1", - "QtSensors/AmbientLightReading 5.2" - ] - isCreatable: false - exportMetaObjectRevisions: [0, 0, 0] - Property { name: "lightLevel"; type: "QAmbientLightReading::LightLevel"; isReadonly: true } - } - Component { - name: "QmlAmbientTemperatureReading" - prototype: "QmlSensorReading" - exports: [ - "QtSensors/AmbientTemperatureReading 5.1", - "QtSensors/AmbientTemperatureReading 5.2" - ] - isCreatable: false - exportMetaObjectRevisions: [0, 0] - Property { name: "temperature"; type: "double"; isReadonly: true } - } - Component { - name: "QmlAmbientTemperatureSensor" - prototype: "QmlSensor" - exports: [ - "QtSensors/AmbientTemperatureSensor 5.1", - "QtSensors/AmbientTemperatureSensor 5.2" - ] - exportMetaObjectRevisions: [0, 0] - } - Component { - name: "QmlCompass" - prototype: "QmlSensor" - exports: [ - "QtSensors/Compass 5.0", - "QtSensors/Compass 5.1", - "QtSensors/Compass 5.2" - ] - exportMetaObjectRevisions: [0, 0, 0] - } - Component { - name: "QmlCompassReading" - prototype: "QmlSensorReading" - exports: [ - "QtSensors/CompassReading 5.0", - "QtSensors/CompassReading 5.1", - "QtSensors/CompassReading 5.2" - ] - isCreatable: false - exportMetaObjectRevisions: [0, 0, 0] - Property { name: "azimuth"; type: "double"; isReadonly: true } - Property { name: "calibrationLevel"; type: "double"; isReadonly: true } - } - Component { - name: "QmlDistanceReading" - prototype: "QmlSensorReading" - exports: ["QtSensors/DistanceReading 5.4"] - isCreatable: false - exportMetaObjectRevisions: [0] - Property { name: "distance"; type: "double"; isReadonly: true } - } - Component { - name: "QmlDistanceSensor" - prototype: "QmlSensor" - exports: ["QtSensors/DistanceSensor 5.4"] - exportMetaObjectRevisions: [0] - } - Component { - name: "QmlGyroscope" - prototype: "QmlSensor" - exports: [ - "QtSensors/Gyroscope 5.0", - "QtSensors/Gyroscope 5.1", - "QtSensors/Gyroscope 5.2" - ] - exportMetaObjectRevisions: [0, 0, 0] - } - Component { - name: "QmlGyroscopeReading" - prototype: "QmlSensorReading" - exports: [ - "QtSensors/GyroscopeReading 5.0", - "QtSensors/GyroscopeReading 5.1", - "QtSensors/GyroscopeReading 5.2" - ] - isCreatable: false - exportMetaObjectRevisions: [0, 0, 0] - Property { name: "x"; type: "double"; isReadonly: true } - Property { name: "y"; type: "double"; isReadonly: true } - Property { name: "z"; type: "double"; isReadonly: true } - } - Component { - name: "QmlHolsterReading" - prototype: "QmlSensorReading" - exports: [ - "QtSensors/HolsterReading 5.1", - "QtSensors/HolsterReading 5.2" - ] - isCreatable: false - exportMetaObjectRevisions: [0, 0] - Property { name: "holstered"; type: "bool"; isReadonly: true } - } - Component { - name: "QmlHolsterSensor" - prototype: "QmlSensor" - exports: [ - "QtSensors/HolsterSensor 5.1", - "QtSensors/HolsterSensor 5.2" - ] - exportMetaObjectRevisions: [0, 0] - } - Component { - name: "QmlHumidityReading" - prototype: "QmlSensorReading" - exports: ["QtSensors/HumidityReading 5.9"] - isCreatable: false - exportMetaObjectRevisions: [0] - Property { name: "relativeHumidity"; type: "double"; isReadonly: true } - Property { name: "absoluteHumidity"; type: "double"; isReadonly: true } - } - Component { - name: "QmlHumiditySensor" - prototype: "QmlSensor" - exports: ["QtSensors/HumiditySensor 5.9"] - exportMetaObjectRevisions: [0] - } - Component { - name: "QmlIRProximitySensor" - prototype: "QmlSensor" - exports: [ - "QtSensors/IRProximitySensor 5.0", - "QtSensors/IRProximitySensor 5.1", - "QtSensors/IRProximitySensor 5.2" - ] - exportMetaObjectRevisions: [0, 0, 0] - } - Component { - name: "QmlIRProximitySensorReading" - prototype: "QmlSensorReading" - exports: [ - "QtSensors/IRProximityReading 5.0", - "QtSensors/IRProximityReading 5.1", - "QtSensors/IRProximityReading 5.2" - ] - isCreatable: false - exportMetaObjectRevisions: [0, 0, 0] - Property { name: "reflectance"; type: "double"; isReadonly: true } - } - Component { - name: "QmlLidReading" - prototype: "QmlSensorReading" - exports: ["QtSensors/LidReading 5.9"] - isCreatable: false - exportMetaObjectRevisions: [0] - Property { name: "backLidChanged"; type: "bool"; isReadonly: true } - Property { name: "frontLidClosed"; type: "bool"; isReadonly: true } - Signal { - name: "backLidChanged" - Parameter { name: "closed"; type: "bool" } - } - Signal { - name: "frontLidChanged" - type: "bool" - Parameter { name: "closed"; type: "bool" } - } - } - Component { - name: "QmlLidSensor" - prototype: "QmlSensor" - exports: ["QtSensors/LidSensor 5.9"] - exportMetaObjectRevisions: [0] - } - Component { - name: "QmlLightSensor" - prototype: "QmlSensor" - exports: [ - "QtSensors/LightSensor 5.0", - "QtSensors/LightSensor 5.1", - "QtSensors/LightSensor 5.2" - ] - exportMetaObjectRevisions: [0, 0, 0] - Property { name: "fieldOfView"; type: "double"; isReadonly: true } - Signal { - name: "fieldOfViewChanged" - Parameter { name: "fieldOfView"; type: "double" } - } - } - Component { - name: "QmlLightSensorReading" - prototype: "QmlSensorReading" - exports: [ - "QtSensors/LightReading 5.0", - "QtSensors/LightReading 5.1", - "QtSensors/LightReading 5.2" - ] - isCreatable: false - exportMetaObjectRevisions: [0, 0, 0] - Property { name: "illuminance"; type: "double"; isReadonly: true } - } - Component { - name: "QmlMagnetometer" - prototype: "QmlSensor" - exports: [ - "QtSensors/Magnetometer 5.0", - "QtSensors/Magnetometer 5.1", - "QtSensors/Magnetometer 5.2" - ] - exportMetaObjectRevisions: [0, 0, 0] - Property { name: "returnGeoValues"; type: "bool" } - Signal { - name: "returnGeoValuesChanged" - Parameter { name: "returnGeoValues"; type: "bool" } - } - } - Component { - name: "QmlMagnetometerReading" - prototype: "QmlSensorReading" - exports: [ - "QtSensors/MagnetometerReading 5.0", - "QtSensors/MagnetometerReading 5.1", - "QtSensors/MagnetometerReading 5.2" - ] - isCreatable: false - exportMetaObjectRevisions: [0, 0, 0] - 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: "QmlOrientationSensor" - prototype: "QmlSensor" - exports: [ - "QtSensors/OrientationSensor 5.0", - "QtSensors/OrientationSensor 5.1", - "QtSensors/OrientationSensor 5.2" - ] - exportMetaObjectRevisions: [0, 0, 0] - } - Component { - name: "QmlOrientationSensorReading" - prototype: "QmlSensorReading" - exports: [ - "QtSensors/OrientationReading 5.0", - "QtSensors/OrientationReading 5.1", - "QtSensors/OrientationReading 5.2" - ] - isCreatable: false - exportMetaObjectRevisions: [0, 0, 0] - Property { name: "orientation"; type: "QOrientationReading::Orientation"; isReadonly: true } - } - Component { - name: "QmlPressureReading" - prototype: "QmlSensorReading" - exports: [ - "QtSensors/PressureReading 5.1", - "QtSensors/PressureReading 5.2" - ] - isCreatable: false - exportMetaObjectRevisions: [0, 1] - Property { name: "pressure"; type: "double"; isReadonly: true } - Property { name: "temperature"; revision: 1; type: "double"; isReadonly: true } - Signal { name: "temperatureChanged"; revision: 1 } - } - Component { - name: "QmlPressureSensor" - prototype: "QmlSensor" - exports: [ - "QtSensors/PressureSensor 5.1", - "QtSensors/PressureSensor 5.2" - ] - exportMetaObjectRevisions: [0, 0] - } - Component { - name: "QmlProximitySensor" - prototype: "QmlSensor" - exports: [ - "QtSensors/ProximitySensor 5.0", - "QtSensors/ProximitySensor 5.1", - "QtSensors/ProximitySensor 5.2" - ] - exportMetaObjectRevisions: [0, 0, 0] - } - Component { - name: "QmlProximitySensorReading" - prototype: "QmlSensorReading" - exports: [ - "QtSensors/ProximityReading 5.0", - "QtSensors/ProximityReading 5.1", - "QtSensors/ProximityReading 5.2" - ] - isCreatable: false - exportMetaObjectRevisions: [0, 0, 0] - Property { name: "near"; type: "bool"; isReadonly: true } - } - Component { - name: "QmlRotationSensor" - prototype: "QmlSensor" - exports: [ - "QtSensors/RotationSensor 5.0", - "QtSensors/RotationSensor 5.1", - "QtSensors/RotationSensor 5.2" - ] - exportMetaObjectRevisions: [0, 0, 0] - Property { name: "hasZ"; type: "bool"; isReadonly: true } - Signal { - name: "hasZChanged" - Parameter { name: "hasZ"; type: "bool" } - } - } - Component { - name: "QmlRotationSensorReading" - prototype: "QmlSensorReading" - exports: [ - "QtSensors/RotationReading 5.0", - "QtSensors/RotationReading 5.1", - "QtSensors/RotationReading 5.2" - ] - isCreatable: false - exportMetaObjectRevisions: [0, 0, 0] - Property { name: "x"; type: "double"; isReadonly: true } - Property { name: "y"; type: "double"; isReadonly: true } - Property { name: "z"; type: "double"; isReadonly: true } - } - Component { - name: "QmlSensor" - prototype: "QObject" - exports: [ - "QtSensors/Sensor 5.0", - "QtSensors/Sensor 5.1", - "QtSensors/Sensor 5.2" - ] - isCreatable: false - exportMetaObjectRevisions: [0, 1, 1] - Enum { - name: "AxesOrientationMode" - values: { - "FixedOrientation": 0, - "AutomaticOrientation": 1, - "UserOrientation": 2 - } - } - Property { name: "identifier"; type: "string" } - Property { name: "type"; type: "string"; isReadonly: true } - Property { name: "connectedToBackend"; type: "bool"; isReadonly: true } - Property { name: "availableDataRates"; type: "QmlSensorRange"; isList: true; isReadonly: true } - Property { name: "dataRate"; type: "int" } - Property { name: "reading"; type: "QmlSensorReading"; isReadonly: true; isPointer: true } - Property { name: "busy"; type: "bool"; isReadonly: true } - Property { name: "active"; type: "bool" } - Property { name: "outputRanges"; type: "QmlSensorOutputRange"; isList: true; isReadonly: true } - Property { name: "outputRange"; type: "int" } - Property { name: "description"; type: "string"; isReadonly: true } - Property { name: "error"; type: "int"; isReadonly: true } - Property { name: "alwaysOn"; type: "bool" } - Property { name: "skipDuplicates"; revision: 1; type: "bool" } - Property { name: "axesOrientationMode"; revision: 1; type: "AxesOrientationMode" } - Property { name: "currentOrientation"; revision: 1; type: "int"; isReadonly: true } - Property { name: "userOrientation"; revision: 1; type: "int" } - Property { name: "maxBufferSize"; revision: 1; type: "int"; isReadonly: true } - Property { name: "efficientBufferSize"; revision: 1; type: "int"; isReadonly: true } - Property { name: "bufferSize"; revision: 1; type: "int" } - Signal { - name: "skipDuplicatesChanged" - revision: 1 - Parameter { name: "skipDuplicates"; type: "bool" } - } - Signal { - name: "axesOrientationModeChanged" - revision: 1 - Parameter { name: "axesOrientationMode"; type: "AxesOrientationMode" } - } - Signal { - name: "currentOrientationChanged" - revision: 1 - Parameter { name: "currentOrientation"; type: "int" } - } - Signal { - name: "userOrientationChanged" - revision: 1 - Parameter { name: "userOrientation"; type: "int" } - } - Signal { - name: "maxBufferSizeChanged" - revision: 1 - Parameter { name: "maxBufferSize"; type: "int" } - } - Signal { - name: "efficientBufferSizeChanged" - revision: 1 - Parameter { name: "efficientBufferSize"; type: "int" } - } - Signal { - name: "bufferSizeChanged" - revision: 1 - Parameter { name: "bufferSize"; type: "int" } - } - Method { name: "start"; type: "bool" } - Method { name: "stop" } - } - Component { - name: "QmlSensorGesture" - prototype: "QObject" - exports: [ - "QtSensors/SensorGesture 5.0", - "QtSensors/SensorGesture 5.1", - "QtSensors/SensorGesture 5.2" - ] - exportMetaObjectRevisions: [0, 0, 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" - Parameter { name: "gesture"; type: "string" } - } - } - Component { - name: "QmlSensorGlobal" - prototype: "QObject" - exports: [ - "QtSensors/QmlSensors 5.0", - "QtSensors/QmlSensors 5.1", - "QtSensors/QmlSensors 5.2" - ] - isCreatable: false - isSingleton: true - exportMetaObjectRevisions: [0, 0, 0] - Signal { name: "availableSensorsChanged" } - Method { name: "sensorTypes"; type: "QStringList" } - Method { - name: "sensorsForType" - type: "QStringList" - Parameter { name: "type"; type: "string" } - } - Method { - name: "defaultSensorForType" - type: "string" - Parameter { name: "type"; type: "string" } - } - } - Component { - name: "QmlSensorOutputRange" - prototype: "QObject" - exports: [ - "QtSensors/OutputRange 5.0", - "QtSensors/OutputRange 5.1", - "QtSensors/OutputRange 5.2" - ] - isCreatable: false - exportMetaObjectRevisions: [0, 0, 0] - Property { name: "minimum"; type: "double"; isReadonly: true } - Property { name: "maximum"; type: "double"; isReadonly: true } - Property { name: "accuracy"; type: "double"; isReadonly: true } - } - Component { - name: "QmlSensorRange" - prototype: "QObject" - exports: [ - "QtSensors/Range 5.0", - "QtSensors/Range 5.1", - "QtSensors/Range 5.2" - ] - isCreatable: false - exportMetaObjectRevisions: [0, 0, 0] - Property { name: "minimum"; type: "int"; isReadonly: true } - Property { name: "maximum"; type: "int"; isReadonly: true } - } - Component { - name: "QmlSensorReading" - prototype: "QObject" - exports: [ - "QtSensors/SensorReading 5.0", - "QtSensors/SensorReading 5.1", - "QtSensors/SensorReading 5.2" - ] - isCreatable: false - exportMetaObjectRevisions: [0, 0, 0] - Property { name: "timestamp"; type: "qulonglong"; isReadonly: true } - } - Component { - name: "QmlTapSensor" - prototype: "QmlSensor" - exports: [ - "QtSensors/TapSensor 5.0", - "QtSensors/TapSensor 5.1", - "QtSensors/TapSensor 5.2" - ] - exportMetaObjectRevisions: [0, 0, 0] - Property { name: "returnDoubleTapEvents"; type: "bool" } - Signal { - name: "returnDoubleTapEventsChanged" - Parameter { name: "returnDoubleTapEvents"; type: "bool" } - } - } - Component { - name: "QmlTapSensorReading" - prototype: "QmlSensorReading" - exports: [ - "QtSensors/TapReading 5.0", - "QtSensors/TapReading 5.1", - "QtSensors/TapReading 5.2" - ] - isCreatable: false - exportMetaObjectRevisions: [0, 0, 0] - Property { name: "tapDirection"; type: "QTapReading::TapDirection"; isReadonly: true } - Property { name: "doubleTap"; type: "bool"; isReadonly: true } - Signal { name: "isDoubleTapChanged" } - } - Component { - name: "QmlTiltSensor" - prototype: "QmlSensor" - exports: [ - "QtSensors/TiltSensor 5.0", - "QtSensors/TiltSensor 5.1", - "QtSensors/TiltSensor 5.2" - ] - exportMetaObjectRevisions: [0, 0, 0] - Method { name: "calibrate" } - } - Component { - name: "QmlTiltSensorReading" - prototype: "QmlSensorReading" - exports: [ - "QtSensors/TiltReading 5.0", - "QtSensors/TiltReading 5.1", - "QtSensors/TiltReading 5.2" - ] - isCreatable: false - exportMetaObjectRevisions: [0, 0, 0] - Property { name: "yRotation"; type: "double"; isReadonly: true } - Property { name: "xRotation"; type: "double"; isReadonly: true } - } -} diff --git a/src/imports/sensors/qmlaccelerometer.cpp b/src/imports/sensors/qmlaccelerometer.cpp deleted file mode 100644 index 8d78fbfc..00000000 --- a/src/imports/sensors/qmlaccelerometer.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmlaccelerometer.h" -#include - -/*! - \qmltype Accelerometer - \instantiates QmlAccelerometer - \ingroup qml-sensors_type - \inqmlmodule QtSensors - \since QtSensors 5.0 - \inherits Sensor - \brief The Accelerometer element reports on linear acceleration - along the X, Y and Z axes. - - The Accelerometer element reports on linear acceleration - along the X, Y and Z axes. - - This element wraps the QAccelerometer class. Please see the documentation for - QAccelerometer for details. - - \sa AccelerometerReading -*/ - -QmlAccelerometer::QmlAccelerometer(QObject *parent) - : QmlSensor(parent) - , m_sensor(new QAccelerometer(this)) -{ - connect(m_sensor, SIGNAL(accelerationModeChanged(AccelerationMode)), - this, SIGNAL(accelerationModeChanged(AccelerationMode))); -} - -QmlAccelerometer::~QmlAccelerometer() -{ -} - -/*! - \qmlproperty AccelerationMode Accelerometer::accelerationMode - \since QtSensors 5.1 - - This property holds the current acceleration mode. - - Please see QAccelerometer::accelerationMode for information about this property. -*/ - -QmlAccelerometer::AccelerationMode QmlAccelerometer::accelerationMode() const -{ - return static_cast(m_sensor->accelerationMode()); -} - -void QmlAccelerometer::setAccelerationMode(QmlAccelerometer::AccelerationMode accelerationMode) -{ - m_sensor->setAccelerationMode(static_cast(accelerationMode)); -} - -QmlSensorReading *QmlAccelerometer::createReading() const -{ - return new QmlAccelerometerReading(m_sensor); -} - -QSensor *QmlAccelerometer::sensor() const -{ - return m_sensor; -} - -/*! - \qmltype AccelerometerReading - \instantiates QmlAccelerometerReading - \ingroup qml-sensors_reading - \inqmlmodule QtSensors - \since QtSensors 5.0 - \inherits SensorReading - \brief The AccelerometerReading element holds the most recent Accelerometer reading. - - The AccelerometerReading element holds the most recent Accelerometer reading. - - This element wraps the QAccelerometerReading class. Please see the documentation for - QAccelerometerReading for details. - - This element cannot be directly created. -*/ - -QmlAccelerometerReading::QmlAccelerometerReading(QAccelerometer *sensor) - : QmlSensorReading(sensor) - , m_sensor(sensor) -{ -} - -QmlAccelerometerReading::~QmlAccelerometerReading() -{ -} - -/*! - \qmlproperty qreal AccelerometerReading::x - This property holds the acceleration on the X axis. - - Please see QAccelerometerReading::x for information about this property. -*/ - -qreal QmlAccelerometerReading::x() const -{ - return m_x; -} - -/*! - \qmlproperty qreal AccelerometerReading::y - This property holds the acceleration on the Y axis. - - Please see QAccelerometerReading::y for information about this property. -*/ - -qreal QmlAccelerometerReading::y() const -{ - return m_y; -} - -/*! - \qmlproperty qreal AccelerometerReading::z - This property holds the acceleration on the Z axis. - - Please see QAccelerometerReading::z for information about this property. -*/ - -qreal QmlAccelerometerReading::z() const -{ - return m_z; -} - -QSensorReading *QmlAccelerometerReading::reading() const -{ - return m_sensor->reading(); -} - -void QmlAccelerometerReading::readingUpdate() -{ - qreal aX = m_sensor->reading()->x(); - if (m_x != aX) { - m_x = aX; - Q_EMIT xChanged(); - } - qreal aY = m_sensor->reading()->y(); - if (m_y != aY) { - m_y = aY; - Q_EMIT yChanged(); - } - qreal aZ = m_sensor->reading()->z(); - if (m_z != aZ) { - m_z = aZ; - Q_EMIT zChanged(); - } -} diff --git a/src/imports/sensors/qmlaccelerometer.h b/src/imports/sensors/qmlaccelerometer.h deleted file mode 100644 index e04b9712..00000000 --- a/src/imports/sensors/qmlaccelerometer.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLACCELEROMETER_H -#define QMLACCELEROMETER_H - -#include "qmlsensor.h" - -QT_BEGIN_NAMESPACE - -class QAccelerometer; - -class QmlAccelerometer : public QmlSensor -{ - Q_OBJECT - Q_ENUMS(AccelerationMode) - Q_PROPERTY(AccelerationMode accelerationMode READ accelerationMode WRITE setAccelerationMode - NOTIFY accelerationModeChanged REVISION 1) -public: - explicit QmlAccelerometer(QObject *parent = 0); - ~QmlAccelerometer(); - - // Keep this enum in sync with QAccelerometer::AccelerationMode - enum AccelerationMode { - Combined, - Gravity, - User - }; - - AccelerationMode accelerationMode() const; - void setAccelerationMode(AccelerationMode accelerationMode); - -signals: - Q_REVISION(1) void accelerationModeChanged(AccelerationMode accelerationMode); - -private: - QSensor *sensor() const override; - QAccelerometer *m_sensor; - QmlSensorReading *createReading() const override; -}; - -class QmlAccelerometerReading : public QmlSensorReading -{ - Q_OBJECT - Q_PROPERTY(qreal x READ x NOTIFY xChanged) - Q_PROPERTY(qreal y READ y NOTIFY yChanged) - Q_PROPERTY(qreal z READ z NOTIFY zChanged) -public: - explicit QmlAccelerometerReading(QAccelerometer *sensor); - ~QmlAccelerometerReading(); - - qreal x() const; - qreal y() const; - qreal z() const; - -Q_SIGNALS: - void xChanged(); - void yChanged(); - void zChanged(); - -private: - QSensorReading *reading() const override; - void readingUpdate() override; - QAccelerometer *m_sensor; - qreal m_x; - qreal m_y; - qreal m_z; -}; - -QT_END_NAMESPACE -#endif diff --git a/src/imports/sensors/qmlaltimeter.cpp b/src/imports/sensors/qmlaltimeter.cpp deleted file mode 100644 index 63c979d3..00000000 --- a/src/imports/sensors/qmlaltimeter.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Research In Motion -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "qmlaltimeter.h" -#include - -/*! - \qmltype Altimeter - \instantiates QmlAltimeter - \ingroup qml-sensors_type - \inqmlmodule QtSensors - \since QtSensors 5.1 - \inherits Sensor - \brief The Altimeter element reports on altitude. - - The Altimeter element reports on altitude. - - This element wraps the QAltimeter class. Please see the documentation for - QAltimeter for details. - - \sa AltimeterReading -*/ - -QmlAltimeter::QmlAltimeter(QObject *parent) - : QmlSensor(parent) - , m_sensor(new QAltimeter(this)) -{ -} - -QmlAltimeter::~QmlAltimeter() -{ -} - -QmlSensorReading *QmlAltimeter::createReading() const -{ - return new QmlAltimeterReading(m_sensor); -} - -QSensor *QmlAltimeter::sensor() const -{ - return m_sensor; -} - -/*! - \qmltype AltimeterReading - \instantiates QmlAltimeterReading - \ingroup qml-sensors_reading - \inqmlmodule QtSensors - \since QtSensors 5.1 - \inherits SensorReading - \brief The AltimeterReading element holds the most recent Altimeter reading. - - The AltimeterReading element holds the most recent Altimeter reading. - - This element wraps the QAltimeterReading class. Please see the documentation for - QAltimeterReading for details. - - This element cannot be directly created. -*/ - -QmlAltimeterReading::QmlAltimeterReading(QAltimeter *sensor) - : QmlSensorReading(sensor) - , m_sensor(sensor) - , m_altitude(0) -{ -} - -QmlAltimeterReading::~QmlAltimeterReading() -{ -} - -/*! - \qmlproperty qreal AltimeterReading::altitude - This property holds the altitude of the device. - - Please see QAltimeterReading::altitude for information about this property. -*/ - -qreal QmlAltimeterReading::altitude() const -{ - return m_altitude; -} - -QSensorReading *QmlAltimeterReading::reading() const -{ - return m_sensor->reading(); -} - -void QmlAltimeterReading::readingUpdate() -{ - qreal altitude = m_sensor->reading()->altitude(); - if (m_altitude != altitude) { - m_altitude = altitude; - Q_EMIT altitudeChanged(); - } -} diff --git a/src/imports/sensors/qmlaltimeter.h b/src/imports/sensors/qmlaltimeter.h deleted file mode 100644 index 04938b53..00000000 --- a/src/imports/sensors/qmlaltimeter.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Research In Motion -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QMLALTIMETER_H -#define QMLALTIMETER_H - -#include "qmlsensor.h" - -QT_BEGIN_NAMESPACE - -class QAltimeter; - -class QmlAltimeter : public QmlSensor -{ - Q_OBJECT -public: - explicit QmlAltimeter(QObject *parent = 0); - ~QmlAltimeter(); - -private: - QSensor *sensor() const override; - QmlSensorReading *createReading() const override; - - QAltimeter *m_sensor; -}; - -class QmlAltimeterReading : public QmlSensorReading -{ - Q_OBJECT - Q_PROPERTY(qreal altitude READ altitude NOTIFY altitudeChanged) -public: - explicit QmlAltimeterReading(QAltimeter *sensor); - ~QmlAltimeterReading(); - - qreal altitude() const; - -Q_SIGNALS: - void altitudeChanged(); - -private: - QSensorReading *reading() const override; - void readingUpdate() override; - - QAltimeter *m_sensor; - qreal m_altitude; -}; - -QT_END_NAMESPACE -#endif diff --git a/src/imports/sensors/qmlambientlightsensor.cpp b/src/imports/sensors/qmlambientlightsensor.cpp deleted file mode 100644 index 5d9ab3b6..00000000 --- a/src/imports/sensors/qmlambientlightsensor.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmlambientlightsensor.h" -#include - -/*! - \qmltype AmbientLightSensor - \instantiates QmlAmbientLightSensor - \ingroup qml-sensors_type - \inqmlmodule QtSensors - \since QtSensors 5.0 - \inherits Sensor - \brief The AmbientLightSensor element repors on ambient lighting conditions. - - The AmbientLightSensor element repors on ambient lighting conditions. - - This element wraps the QAmbientLightSensor class. Please see the documentation for - QAmbientLightSensor for details. - - \sa AmbientLightReading -*/ - -QmlAmbientLightSensor::QmlAmbientLightSensor(QObject *parent) - : QmlSensor(parent) - , m_sensor(new QAmbientLightSensor(this)) -{ -} - -QmlAmbientLightSensor::~QmlAmbientLightSensor() -{ -} - -QmlSensorReading *QmlAmbientLightSensor::createReading() const -{ - return new QmlAmbientLightSensorReading(m_sensor); -} - -QSensor *QmlAmbientLightSensor::sensor() const -{ - return m_sensor; -} - -/*! - \qmltype AmbientLightReading - \instantiates QmlAmbientLightSensorReading - \ingroup qml-sensors_reading - \inqmlmodule QtSensors - \since QtSensors 5.0 - \inherits SensorReading - \brief The AmbientLightReading element holds the most AmbientLightSensor reading. - - The AmbientLightReading element holds the most AmbientLightSensor reading. - - This element wraps the QAmbientLightReading class. Please see the documentation for - QAmbientLightReading for details. - - This element cannot be directly created. -*/ - -QmlAmbientLightSensorReading::QmlAmbientLightSensorReading(QAmbientLightSensor *sensor) - : QmlSensorReading(sensor) - , m_sensor(sensor) -{ -} - -QmlAmbientLightSensorReading::~QmlAmbientLightSensorReading() -{ -} - -/*! - \qmlproperty LightLevel AmbientLightReading::lightLevel - This property holds the ambient light level. - - Please see QAmbientLightReading::lightLevel for information about this property. - - Note that LightLevel constants are exposed through the AmbientLightReading class. - \code - AmbientLightSensor { - onReadingChanged: { - if (reading.lightLevel == AmbientLightReading.Dark) - // do something - } - } - \endcode -*/ - -QAmbientLightReading::LightLevel QmlAmbientLightSensorReading::lightLevel() const -{ - return m_lightLevel; -} - -QSensorReading *QmlAmbientLightSensorReading::reading() const -{ - return m_sensor->reading(); -} - -void QmlAmbientLightSensorReading::readingUpdate() -{ - QAmbientLightReading::LightLevel ll = m_sensor->reading()->lightLevel(); - if (m_lightLevel != ll) { - m_lightLevel = ll; - Q_EMIT lightLevelChanged(); - } -} diff --git a/src/imports/sensors/qmlambientlightsensor.h b/src/imports/sensors/qmlambientlightsensor.h deleted file mode 100644 index 4de42f31..00000000 --- a/src/imports/sensors/qmlambientlightsensor.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLAMBIENTLIGHTSENSOR_H -#define QMLAMBIENTLIGHTSENSOR_H - -#include "qmlsensor.h" -#include - -QT_BEGIN_NAMESPACE - -class QAmbientLightSensor; - -class QmlAmbientLightSensor : public QmlSensor -{ - Q_OBJECT -public: - explicit QmlAmbientLightSensor(QObject *parent = 0); - ~QmlAmbientLightSensor(); - -private: - QSensor *sensor() const override; - QAmbientLightSensor *m_sensor; - QmlSensorReading *createReading() const override; - -}; - -class QmlAmbientLightSensorReading : public QmlSensorReading -{ - Q_OBJECT - Q_PROPERTY(QAmbientLightReading::LightLevel lightLevel READ lightLevel NOTIFY lightLevelChanged) -public: - - explicit QmlAmbientLightSensorReading(QAmbientLightSensor *sensor); - ~QmlAmbientLightSensorReading(); - - QAmbientLightReading::LightLevel lightLevel() const; - -Q_SIGNALS: - void lightLevelChanged(); - -private: - QSensorReading *reading() const override; - void readingUpdate() override; - QAmbientLightSensor *m_sensor; - QAmbientLightReading::LightLevel m_lightLevel; -}; - -QT_END_NAMESPACE -#endif diff --git a/src/imports/sensors/qmlambienttemperaturesensor.cpp b/src/imports/sensors/qmlambienttemperaturesensor.cpp deleted file mode 100644 index 1958f6d8..00000000 --- a/src/imports/sensors/qmlambienttemperaturesensor.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Research In Motion -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "qmlambienttemperaturesensor.h" -#include - -/*! - \qmltype AmbientTemperatureSensor - \instantiates QmlAmbientTemperatureSensor - \ingroup qml-sensors_type - \inqmlmodule QtSensors - \since QtSensors 5.1 - \inherits Sensor - \brief The AmbientTemperatureSensor element reports on the ambient temperature. - - The AmbientTemperatureSensor element reports on the ambient temperature. - - This element wraps the QAmbientTemperatureSensor class. Please see the documentation for - QAmbientTemperatureSensor for details. - - \sa AmbientTemperatureReading -*/ - -QmlAmbientTemperatureSensor::QmlAmbientTemperatureSensor(QObject *parent) - : QmlSensor(parent) - , m_sensor(new QAmbientTemperatureSensor(this)) -{ -} - -QmlAmbientTemperatureSensor::~QmlAmbientTemperatureSensor() -{ -} - -QmlSensorReading *QmlAmbientTemperatureSensor::createReading() const -{ - return new QmlAmbientTemperatureReading(m_sensor); -} - -QSensor *QmlAmbientTemperatureSensor::sensor() const -{ - return m_sensor; -} - -/*! - \qmltype AmbientTemperatureReading - \instantiates QmlAmbientTemperatureReading - \ingroup qml-sensors_reading - \inqmlmodule QtSensors - \since QtSensors 5.1 - \inherits SensorReading - \brief The AmbientTemperatureReading element holds the most recent temperature reading. - - The AmbientTemperatureReading element holds the most recent temperature reading. - - This element wraps the QAmbientTemperatureReading class. Please see the documentation for - QAmbientTemperatureReading for details. - - This element cannot be directly created. -*/ - -QmlAmbientTemperatureReading::QmlAmbientTemperatureReading(QAmbientTemperatureSensor *sensor) - : QmlSensorReading(sensor) - , m_sensor(sensor) - , m_temperature(0) -{ -} - -QmlAmbientTemperatureReading::~QmlAmbientTemperatureReading() -{ -} - -/*! - \qmlproperty qreal AmbientTemperatureReading::temperature - This property holds the ambient temperature in degree Celsius. - - Please see QAmbientTemperatureReading::temperature for information about this property. -*/ - -qreal QmlAmbientTemperatureReading::temperature() const -{ - return m_temperature; -} - -QSensorReading *QmlAmbientTemperatureReading::reading() const -{ - return m_sensor->reading(); -} - -void QmlAmbientTemperatureReading::readingUpdate() -{ - const qreal temperature = m_sensor->reading()->temperature(); - if (m_temperature != temperature) { - m_temperature = temperature; - Q_EMIT temperatureChanged(); - } -} diff --git a/src/imports/sensors/qmlambienttemperaturesensor.h b/src/imports/sensors/qmlambienttemperaturesensor.h deleted file mode 100644 index 31ec72fa..00000000 --- a/src/imports/sensors/qmlambienttemperaturesensor.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Research In Motion -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QMLAMBIENTTEMPERATURESENSOR_H -#define QMLAMBIENTTEMPERATURESENSOR_H - -#include "qmlsensor.h" - -QT_BEGIN_NAMESPACE - -class QAmbientTemperatureSensor; - -class QmlAmbientTemperatureSensor : public QmlSensor -{ - Q_OBJECT -public: - explicit QmlAmbientTemperatureSensor(QObject *parent = 0); - ~QmlAmbientTemperatureSensor(); - -private: - QSensor *sensor() const override; - QmlSensorReading *createReading() const override; - - QAmbientTemperatureSensor *m_sensor; -}; - -class QmlAmbientTemperatureReading : public QmlSensorReading -{ - Q_OBJECT - Q_PROPERTY(qreal temperature READ temperature NOTIFY temperatureChanged) -public: - explicit QmlAmbientTemperatureReading(QAmbientTemperatureSensor *sensor); - ~QmlAmbientTemperatureReading(); - - qreal temperature() const; - -Q_SIGNALS: - void temperatureChanged(); - -private: - QSensorReading *reading() const override; - void readingUpdate() override; - - QAmbientTemperatureSensor *m_sensor; - qreal m_temperature; -}; - -QT_END_NAMESPACE -#endif diff --git a/src/imports/sensors/qmlcompass.cpp b/src/imports/sensors/qmlcompass.cpp deleted file mode 100644 index 38fc388e..00000000 --- a/src/imports/sensors/qmlcompass.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmlcompass.h" -#include - -/*! - \qmltype Compass - \instantiates QmlCompass - \ingroup qml-sensors_type - \inqmlmodule QtSensors - \since QtSensors 5.0 - \inherits Sensor - \brief The Compass element reports on heading using magnetic north as a reference. - - The Compass element reports on heading using magnetic north as a reference. - - This element wraps the QCompass class. Please see the documentation for - QCompass for details. - - \sa CompassReading -*/ - -QmlCompass::QmlCompass(QObject *parent) - : QmlSensor(parent) - , m_sensor(new QCompass(this)) -{ -} - -QmlCompass::~QmlCompass() -{ -} - -QmlSensorReading *QmlCompass::createReading() const -{ - return new QmlCompassReading(m_sensor); -} - -QSensor *QmlCompass::sensor() const -{ - return m_sensor; -} - -/*! - \qmltype CompassReading - \instantiates QmlCompassReading - \ingroup qml-sensors_reading - \inqmlmodule QtSensors - \since QtSensors 5.0 - \inherits SensorReading - \brief The CompassReading element holds the most recent Compass reading. - - The CompassReading element holds the most recent Compass reading. - - This element wraps the QCompassReading class. Please see the documentation for - QCompassReading for details. - - This element cannot be directly created. -*/ - -QmlCompassReading::QmlCompassReading(QCompass *sensor) - : QmlSensorReading(sensor) - , m_sensor(sensor) -{ -} - -QmlCompassReading::~QmlCompassReading() -{ -} - -/*! - \qmlproperty qreal CompassReading::azimuth - This property holds the azimuth of the device. - - Please see QCompassReading::azimuth for information about this property. -*/ - -qreal QmlCompassReading::azimuth() const -{ - return m_azimuth; -} - -/*! - \qmlproperty qreal CompassReading::calibrationLevel - This property holds the calibration level of the reading. - - Please see QCompassReading::calibrationLevel for information about this property. -*/ - -qreal QmlCompassReading::calibrationLevel() const -{ - return m_calibrationLevel; -} - -QSensorReading *QmlCompassReading::reading() const -{ - return m_sensor->reading(); -} - -void QmlCompassReading::readingUpdate() -{ - qreal azm = m_sensor->reading()->azimuth(); - if (m_azimuth != azm) { - m_azimuth = azm; - Q_EMIT azimuthChanged(); - } - qreal calLevel = m_sensor->reading()->calibrationLevel(); - if (m_calibrationLevel != calLevel) { - m_calibrationLevel = calLevel; - Q_EMIT calibrationLevelChanged(); - } -} diff --git a/src/imports/sensors/qmlcompass.h b/src/imports/sensors/qmlcompass.h deleted file mode 100644 index ef4fd22f..00000000 --- a/src/imports/sensors/qmlcompass.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLCOMPASS_H -#define QMLCOMPASS_H - -#include "qmlsensor.h" - -QT_BEGIN_NAMESPACE - -class QCompass; - -class QmlCompass : public QmlSensor -{ - Q_OBJECT -public: - explicit QmlCompass(QObject *parent = 0); - ~QmlCompass(); - - -private: - QSensor *sensor() const override; - QCompass *m_sensor; - QmlSensorReading *createReading() const override; -}; - -class QmlCompassReading : public QmlSensorReading -{ - Q_OBJECT - Q_PROPERTY(qreal azimuth READ azimuth NOTIFY azimuthChanged) - Q_PROPERTY(qreal calibrationLevel READ calibrationLevel NOTIFY calibrationLevelChanged) -public: - explicit QmlCompassReading(QCompass *sensor); - ~QmlCompassReading(); - - qreal azimuth() const; - qreal calibrationLevel() const; - -Q_SIGNALS: - void azimuthChanged(); - void calibrationLevelChanged(); - -private: - QSensorReading *reading() const override; - void readingUpdate() override; - QCompass *m_sensor; - qreal m_azimuth; - qreal m_calibrationLevel; -}; - -QT_END_NAMESPACE -#endif diff --git a/src/imports/sensors/qmldir b/src/imports/sensors/qmldir deleted file mode 100644 index 8ce4a5aa..00000000 --- a/src/imports/sensors/qmldir +++ /dev/null @@ -1,4 +0,0 @@ -module QtSensors -plugin declarative_sensors -classname QtSensorsDeclarativeModule -typeinfo plugins.qmltypes diff --git a/src/imports/sensors/qmldistancesensor.cpp b/src/imports/sensors/qmldistancesensor.cpp deleted file mode 100644 index f715ae0d..00000000 --- a/src/imports/sensors/qmldistancesensor.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 BlackBerry Limited. All rights reserved. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "qmldistancesensor.h" -#include - -/*! - \qmltype DistanceSensor - \instantiates QmlDistanceSensor - \ingroup qml-sensors_type - \inqmlmodule QtSensors - \since QtSensors 5.4 - \inherits Sensor - \brief The DistanceSensor element reports the distance in cm from an object to the device. - - The DistanceSensor element reports the distance in cm from an object to the device. - - This element wraps the QDistanceSensor class. Please see the documentation for - QDistanceSensor for details. - - \sa DistanceReading -*/ - -QmlDistanceSensor::QmlDistanceSensor(QObject *parent) - : QmlSensor(parent) - , m_sensor(new QDistanceSensor(this)) -{ -} - -QmlDistanceSensor::~QmlDistanceSensor() -{ -} - -QmlSensorReading *QmlDistanceSensor::createReading() const -{ - return new QmlDistanceReading(m_sensor); -} - -QSensor *QmlDistanceSensor::sensor() const -{ - return m_sensor; -} - -/*! - \qmltype DistanceReading - \instantiates QmlDistanceReading - \ingroup qml-sensors_reading - \inqmlmodule QtSensors - \since QtSensors 5.4 - \inherits SensorReading - \brief The DistanceReading element holds the most recent DistanceSensor reading. - - The DistanceReading element holds the most recent DistanceSensor reading. - - This element wraps the QDistanceReading class. Please see the documentation for - QDistanceReading for details. - - This element cannot be directly created. -*/ - -QmlDistanceReading::QmlDistanceReading(QDistanceSensor *sensor) - : QmlSensorReading(sensor) - , m_sensor(sensor) - , m_distance(0.0) -{ -} - -QmlDistanceReading::~QmlDistanceReading() -{ -} - -/*! - \qmlproperty qreal DistanceReading::distance - This property holds the distance measurement - - Please see QDistanceReading::distance for information about this property. -*/ - -qreal QmlDistanceReading::distance() const -{ - return m_distance; -} - -QSensorReading *QmlDistanceReading::reading() const -{ - return m_sensor->reading(); -} - -void QmlDistanceReading::readingUpdate() -{ - qreal distance = m_sensor->reading()->distance(); - if (m_distance != distance) { - m_distance = distance; - Q_EMIT distanceChanged(); - } -} diff --git a/src/imports/sensors/qmldistancesensor.h b/src/imports/sensors/qmldistancesensor.h deleted file mode 100644 index e60e0e7e..00000000 --- a/src/imports/sensors/qmldistancesensor.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 BlackBerry Limited. All rights reserved. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLDISTANCESENSOR_H -#define QMLDISTANCESENSOR_H - -#include "qmlsensor.h" - -QT_BEGIN_NAMESPACE - -class QDistanceSensor; - -class QmlDistanceSensor : public QmlSensor -{ - Q_OBJECT -public: - explicit QmlDistanceSensor(QObject *parent = 0); - ~QmlDistanceSensor(); - -private: - QSensor *sensor() const override; - QmlSensorReading *createReading() const override; - - QDistanceSensor *m_sensor; -}; - -class QmlDistanceReading : public QmlSensorReading -{ - Q_OBJECT - Q_PROPERTY(qreal distance READ distance NOTIFY distanceChanged) -public: - explicit QmlDistanceReading(QDistanceSensor *sensor); - ~QmlDistanceReading(); - - qreal distance() const; - -Q_SIGNALS: - void distanceChanged(); - -private: - QSensorReading *reading() const override; - void readingUpdate() override; - - QDistanceSensor *m_sensor; - qreal m_distance; -}; - -QT_END_NAMESPACE -#endif diff --git a/src/imports/sensors/qmlgyroscope.cpp b/src/imports/sensors/qmlgyroscope.cpp deleted file mode 100644 index 3f61b8d7..00000000 --- a/src/imports/sensors/qmlgyroscope.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmlgyroscope.h" -#include - -/*! - \qmltype Gyroscope - \instantiates QmlGyroscope - \ingroup qml-sensors_type - \inqmlmodule QtSensors - \since QtSensors 5.0 - \inherits Sensor - \brief The Gyroscope element reports on rotational acceleration - around the X, Y and Z axes. - - This element wraps the QGyroscope class. Please see the documentation for - QGyroscope for details. - - \sa GyroscopeReading -*/ - -QmlGyroscope::QmlGyroscope(QObject *parent) - : QmlSensor(parent) - , m_sensor(new QGyroscope(this)) -{ -} - -QmlGyroscope::~QmlGyroscope() -{ -} - -QmlSensorReading *QmlGyroscope::createReading() const -{ - return new QmlGyroscopeReading(m_sensor); -} - -QSensor *QmlGyroscope::sensor() const -{ - return m_sensor; -} - -/*! - \qmltype GyroscopeReading - \instantiates QmlGyroscopeReading - \ingroup qml-sensors_reading - \inqmlmodule QtSensors - \since QtSensors 5.0 - \inherits SensorReading - \brief The GyroscopeReading element holds the most recent Gyroscope reading. - - The GyroscopeReading element holds the most recent Gyroscope reading. - - This element wraps the QGyroscopeReading class. Please see the documentation for - QGyroscopeReading for details. - - This element cannot be directly created. -*/ - -QmlGyroscopeReading::QmlGyroscopeReading(QGyroscope *sensor) - : QmlSensorReading(sensor) - , m_sensor(sensor) -{ -} - -QmlGyroscopeReading::~QmlGyroscopeReading() -{ -} - -/*! - \qmlproperty qreal GyroscopeReading::x - This property holds the angular velocity around the x axis. - - Please see QGyroscopeReading::x for information about this property. -*/ - -qreal QmlGyroscopeReading::x() const -{ - return m_x; -} - -/*! - \qmlproperty qreal GyroscopeReading::y - This property holds the angular velocity around the y axis. - - Please see QGyroscopeReading::y for information about this property. -*/ - -qreal QmlGyroscopeReading::y() const -{ - return m_y; -} - -/*! - \qmlproperty qreal GyroscopeReading::z - This property holds the angular velocity around the z axis. - - Please see QGyroscopeReading::z for information about this property. -*/ - -qreal QmlGyroscopeReading::z() const -{ - return m_z; -} - -QSensorReading *QmlGyroscopeReading::reading() const -{ - return m_sensor->reading(); -} - -void QmlGyroscopeReading::readingUpdate() -{ - qreal gx = m_sensor->reading()->x(); - if (m_x != gx) { - m_x = gx; - Q_EMIT xChanged(); - } - qreal gy = m_sensor->reading()->y(); - if (m_y != gy) { - m_y = gy; - Q_EMIT yChanged(); - } - qreal gz = m_sensor->reading()->z(); - if (m_z != gz) { - m_z = gz; - Q_EMIT zChanged(); - } -} diff --git a/src/imports/sensors/qmlgyroscope.h b/src/imports/sensors/qmlgyroscope.h deleted file mode 100644 index 010e4f04..00000000 --- a/src/imports/sensors/qmlgyroscope.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLGYROSCOPE_H -#define QMLGYROSCOPE_H - -#include "qmlsensor.h" - -QT_BEGIN_NAMESPACE - -class QGyroscope; - -class QmlGyroscope : public QmlSensor -{ - Q_OBJECT -public: - explicit QmlGyroscope(QObject *parent = 0); - ~QmlGyroscope(); - - -private: - QSensor *sensor() const override; - QGyroscope *m_sensor; - QmlSensorReading *createReading() const override; -}; - -class QmlGyroscopeReading : public QmlSensorReading -{ - Q_OBJECT - Q_PROPERTY(qreal x READ x NOTIFY xChanged) - Q_PROPERTY(qreal y READ y NOTIFY yChanged) - Q_PROPERTY(qreal z READ z NOTIFY zChanged) -public: - explicit QmlGyroscopeReading(QGyroscope *sensor); - ~QmlGyroscopeReading(); - - qreal x() const; - qreal y() const; - qreal z() const; - -Q_SIGNALS: - void xChanged(); - void yChanged(); - void zChanged(); - -private: - QSensorReading *reading() const override; - void readingUpdate() override; - QGyroscope *m_sensor; - qreal m_x; - qreal m_y; - qreal m_z; -}; - -QT_END_NAMESPACE -#endif diff --git a/src/imports/sensors/qmlholstersensor.cpp b/src/imports/sensors/qmlholstersensor.cpp deleted file mode 100644 index 704e2e97..00000000 --- a/src/imports/sensors/qmlholstersensor.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Research In Motion -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "qmlholstersensor.h" -#include - -/*! - \qmltype HolsterSensor - \instantiates QmlHolsterSensor - \ingroup qml-sensors_type - \inqmlmodule QtSensors - \since QtSensors 5.1 - \inherits Sensor - \brief The HolsterSensor element reports on whether a device is holstered. - - The HolsterSensor element reports on whether a device is holstered. - - This element wraps the QHolsterSensor class. Please see the documentation for - QHolsterSensor for details. - - \sa HolsterReading -*/ - -QmlHolsterSensor::QmlHolsterSensor(QObject *parent) - : QmlSensor(parent) - , m_sensor(new QHolsterSensor(this)) -{ -} - -QmlHolsterSensor::~QmlHolsterSensor() -{ -} - -QmlSensorReading *QmlHolsterSensor::createReading() const -{ - return new QmlHolsterReading(m_sensor); -} - -QSensor *QmlHolsterSensor::sensor() const -{ - return m_sensor; -} - -/*! - \qmltype HolsterReading - \instantiates QmlHolsterReading - \ingroup qml-sensors_reading - \inqmlmodule QtSensors - \since QtSensors 5.1 - \inherits SensorReading - \brief The HolsterReading element holds the most recent HolsterSensor reading. - - The HolsterReading element holds the most recent HolsterSensor reading. - - This element wraps the QHolsterReading class. Please see the documentation for - QHolsterReading for details. - - This element cannot be directly created. -*/ - -QmlHolsterReading::QmlHolsterReading(QHolsterSensor *sensor) - : QmlSensorReading(sensor) - , m_sensor(sensor) - , m_holstered(false) -{ -} - -QmlHolsterReading::~QmlHolsterReading() -{ -} - -/*! - \qmlproperty qreal HolsterReading::holstered - This property holds whether the device is holstered. - - Please see QHolsterReading::holstered for information about this property. -*/ - -bool QmlHolsterReading::holstered() const -{ - return m_holstered; -} - -QSensorReading *QmlHolsterReading::reading() const -{ - return m_sensor->reading(); -} - -void QmlHolsterReading::readingUpdate() -{ - const bool holstered = m_sensor->reading()->holstered(); - if (m_holstered != holstered) { - m_holstered = holstered; - Q_EMIT holsteredChanged(); - } -} diff --git a/src/imports/sensors/qmlholstersensor.h b/src/imports/sensors/qmlholstersensor.h deleted file mode 100644 index 630d1d85..00000000 --- a/src/imports/sensors/qmlholstersensor.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Research In Motion -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QMLHOLSTERSENSOR_H -#define QMLHOLSTERSENSOR_H - -#include "qmlsensor.h" - -QT_BEGIN_NAMESPACE - -class QHolsterSensor; - -class QmlHolsterSensor : public QmlSensor -{ - Q_OBJECT -public: - explicit QmlHolsterSensor(QObject *parent = 0); - ~QmlHolsterSensor(); - -private: - QSensor *sensor() const override; - QmlSensorReading *createReading() const override; - - QHolsterSensor *m_sensor; -}; - -class QmlHolsterReading : public QmlSensorReading -{ - Q_OBJECT - Q_PROPERTY(bool holstered READ holstered NOTIFY holsteredChanged) -public: - explicit QmlHolsterReading(QHolsterSensor *sensor); - ~QmlHolsterReading(); - - bool holstered() const; - -Q_SIGNALS: - void holsteredChanged(); - -private: - QSensorReading *reading() const override; - void readingUpdate() override; - - QHolsterSensor *m_sensor; - bool m_holstered; -}; - -QT_END_NAMESPACE -#endif diff --git a/src/imports/sensors/qmlhumiditysensor.cpp b/src/imports/sensors/qmlhumiditysensor.cpp deleted file mode 100644 index 3b30e972..00000000 --- a/src/imports/sensors/qmlhumiditysensor.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical Ltd -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmlhumiditysensor.h" -#include - -/*! - \qmltype HumiditySensor - \instantiates QmlHumiditySensor - \ingroup qml-sensors_type - \inqmlmodule QtSensors - \since QtSensors 5.9 - \inherits Sensor - \brief The HumiditySensor element reports on humidity. - - The HumiditySensor element reports on humidity. - - This element wraps the QHumiditySensor class. Please see the documentation for - QHumiditySensor for details. - - \sa HumidityReading -*/ - -QmlHumiditySensor::QmlHumiditySensor(QObject *parent) - : QmlSensor(parent) - , m_sensor(new QHumiditySensor(this)) -{ -} - -QmlHumiditySensor::~QmlHumiditySensor() -{ -} - -QmlSensorReading *QmlHumiditySensor::createReading() const -{ - return new QmlHumidityReading(m_sensor); -} - -QSensor *QmlHumiditySensor::sensor() const -{ - return m_sensor; -} - -/*! - \qmltype HumidityReading - \instantiates QmlHumidityReading - \ingroup qml-sensors_reading - \inqmlmodule QtSensors - \since QtSensors 5.9 - \inherits SensorReading - \brief The HumidityReading element holds the most recent HumiditySensor reading. - - The HumidityReading element holds the most recent HumiditySensor reading. - - This element wraps the QHumidityReading class. Please see the documentation for - QHumidityReading for details. - - This element cannot be directly created. -*/ - -QmlHumidityReading::QmlHumidityReading(QHumiditySensor *sensor) - : QmlSensorReading(sensor) - , m_sensor(sensor) - , m_relativeHumidity(0) - , m_absoluteHumidity(0) -{ -} - -QmlHumidityReading::~QmlHumidityReading() -{ -} - -/*! - \qmlproperty qreal HumidityReading::relativeHumidity - This property holds the relative humidity as a percentage. - - Please see QHumidityReading::relativeHumidity for information about this property. -*/ - -qreal QmlHumidityReading::relativeHumidity() const -{ - return m_relativeHumidity; -} - -/*! - \qmlproperty qreal HumidityReading::absoluteHumidity - This property holds the absolute humidity in grams per cubic meter (g/m3). - - Please see QHumidityReading::absoluteHumidity for information about this property. -*/ - -qreal QmlHumidityReading::absoluteHumidity() const -{ - return m_absoluteHumidity; -} - -QSensorReading *QmlHumidityReading::reading() const -{ - return m_sensor->reading(); -} - -void QmlHumidityReading::readingUpdate() -{ - qreal humidity = m_sensor->reading()->relativeHumidity(); - if (m_relativeHumidity != humidity) { - m_relativeHumidity = humidity; - Q_EMIT relativeHumidityChanged(); - } - qreal abs = m_sensor->reading()->absoluteHumidity(); - if (m_absoluteHumidity != abs) { - m_absoluteHumidity = abs; - Q_EMIT absoluteHumidityChanged(); - } -} diff --git a/src/imports/sensors/qmlhumiditysensor.h b/src/imports/sensors/qmlhumiditysensor.h deleted file mode 100644 index a84a428e..00000000 --- a/src/imports/sensors/qmlhumiditysensor.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical Ltd -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLHUMIDITYSENSOR_H -#define QMLHUMIDITYSENSOR_H - -#include "qmlsensor.h" - -QT_BEGIN_NAMESPACE - -class QHumiditySensor; - -class QmlHumiditySensor : public QmlSensor -{ - Q_OBJECT - -public: - explicit QmlHumiditySensor(QObject *parent = Q_NULLPTR); - ~QmlHumiditySensor(); - -private: - QSensor *sensor() const override; - QmlSensorReading *createReading() const override; - - QHumiditySensor *m_sensor; -}; - -class QmlHumidityReading : public QmlSensorReading -{ - Q_OBJECT - Q_PROPERTY(qreal relativeHumidity READ relativeHumidity NOTIFY relativeHumidityChanged) - Q_PROPERTY(qreal absoluteHumidity READ absoluteHumidity NOTIFY absoluteHumidityChanged) -public: - explicit QmlHumidityReading(QHumiditySensor *sensor); - ~QmlHumidityReading(); - - qreal relativeHumidity() const; - qreal absoluteHumidity() const; - -Q_SIGNALS: - void relativeHumidityChanged(); - void absoluteHumidityChanged(); - -private: - QSensorReading *reading() const override; - void readingUpdate() override; - - QHumiditySensor *m_sensor; - qreal m_relativeHumidity; - qreal m_absoluteHumidity; -}; - -QT_END_NAMESPACE -#endif diff --git a/src/imports/sensors/qmlirproximitysensor.cpp b/src/imports/sensors/qmlirproximitysensor.cpp deleted file mode 100644 index 9b1e72ac..00000000 --- a/src/imports/sensors/qmlirproximitysensor.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmlirproximitysensor.h" -#include - -/*! - \qmltype IRProximitySensor - \instantiates QmlIRProximitySensor - \ingroup qml-sensors_type - \inqmlmodule QtSensors - \since QtSensors 5.0 - \inherits Sensor - \brief The IRProximitySensor element reports on infra-red reflectance values. - - This element wraps the QIRProximitySensor class. Please see the documentation for - QIRProximitySensor for details. - - \sa IRProximityReading -*/ - -QmlIRProximitySensor::QmlIRProximitySensor(QObject *parent) - : QmlSensor(parent) - , m_sensor(new QIRProximitySensor(this)) -{ -} - -QmlIRProximitySensor::~QmlIRProximitySensor() -{ -} - -QmlSensorReading *QmlIRProximitySensor::createReading() const -{ - return new QmlIRProximitySensorReading(m_sensor); -} - -QSensor *QmlIRProximitySensor::sensor() const -{ - return m_sensor; -} - -/*! - \qmltype IRProximityReading - \instantiates QmlIRProximitySensorReading - \ingroup qml-sensors_reading - \inqmlmodule QtSensors - \since QtSensors 5.0 - \inherits SensorReading - \brief The IRProximityReading element holds the most recent IR proximity reading. - - The IRProximityReading element holds the most recent IR proximity reading. - - This element wraps the QIRProximityReading class. Please see the documentation for - QIRProximityReading for details. - - This element cannot be directly created. -*/ - -QmlIRProximitySensorReading::QmlIRProximitySensorReading(QIRProximitySensor *sensor) - : QmlSensorReading(sensor) - , m_sensor(sensor) -{ -} - -QmlIRProximitySensorReading::~QmlIRProximitySensorReading() -{ -} - -/*! - \qmlproperty qreal IRProximityReading::reflectance - This property holds the reflectance value. - - Please see QIRProximityReading::reflectance for information about this property. -*/ - -qreal QmlIRProximitySensorReading::reflectance() const -{ - return m_reflectance; -} - -QSensorReading *QmlIRProximitySensorReading::reading() const -{ - return m_sensor->reading(); -} - -void QmlIRProximitySensorReading::readingUpdate() -{ - qreal fl = m_sensor->reading()->reflectance(); - if (m_reflectance != fl) { - m_reflectance = fl; - Q_EMIT reflectanceChanged(); - } -} diff --git a/src/imports/sensors/qmlirproximitysensor.h b/src/imports/sensors/qmlirproximitysensor.h deleted file mode 100644 index 8ba1d489..00000000 --- a/src/imports/sensors/qmlirproximitysensor.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLIRPROXIMITYSENSOR_H -#define QMLIRPROXIMITYSENSOR_H - -#include "qmlsensor.h" - -QT_BEGIN_NAMESPACE - -class QIRProximitySensor; - -class QmlIRProximitySensor : public QmlSensor -{ - Q_OBJECT -public: - explicit QmlIRProximitySensor(QObject *parent = 0); - ~QmlIRProximitySensor(); - -private: - QSensor *sensor() const override; - QIRProximitySensor *m_sensor; - QmlSensorReading *createReading() const override; -}; - -class QmlIRProximitySensorReading : public QmlSensorReading -{ - Q_OBJECT - Q_PROPERTY(qreal reflectance READ reflectance NOTIFY reflectanceChanged) -public: - explicit QmlIRProximitySensorReading(QIRProximitySensor *sensor); - ~QmlIRProximitySensorReading(); - - qreal reflectance() const; - -Q_SIGNALS: - void reflectanceChanged(); - -private: - QSensorReading *reading() const override; - void readingUpdate() override; - QIRProximitySensor *m_sensor; - qreal m_reflectance; -}; - -QT_END_NAMESPACE -#endif diff --git a/src/imports/sensors/qmllidsensor.cpp b/src/imports/sensors/qmllidsensor.cpp deleted file mode 100644 index e6dfa4cb..00000000 --- a/src/imports/sensors/qmllidsensor.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "qmllidsensor.h" -#include - -/*! - \qmltype LidSensor - \instantiates QmlLidSensor - \ingroup qml-sensors_type - \inqmlmodule QtSensors - \since QtSensors 5.9 - \inherits Sensor - \brief The LidSensor element reports on whether a device is closed. - - The LidSensor element reports on whether a device is closed. - - This element wraps the QLidSensor class. Please see the documentation for - QLidSensor for details. - - \sa LidReading -*/ - -QmlLidSensor::QmlLidSensor(QObject *parent) - : QmlSensor(parent) - , m_sensor(new QLidSensor(this)) -{ -} - -QmlLidSensor::~QmlLidSensor() -{ -} - -QmlSensorReading *QmlLidSensor::createReading() const -{ - return new QmlLidReading(m_sensor); -} - -QSensor *QmlLidSensor::sensor() const -{ - return m_sensor; -} - -/*! - \qmltype LidReading - \instantiates QmlLidReading - \ingroup qml-sensors_reading - \inqmlmodule QtSensors - \since QtSensors 5.9 - \inherits SensorReading - \brief The LidReading element holds the most recent LidSensor reading. - - The LidReading element holds the most recent LidSensor reading. - - This element wraps the QLidReading class. Please see the documentation for - QLidReading for details. - - This element cannot be directly created. -*/ - -QmlLidReading::QmlLidReading(QLidSensor *sensor) - : QmlSensorReading(sensor) - , m_sensor(sensor) - , m_backClosed(false) - , m_frontClosed(true) -{ -} - -QmlLidReading::~QmlLidReading() -{ -} - -/*! - \qmlproperty qreal LidReading::backLidClosed - This property holds whether the back lid is closed. - - Please see QLidReading::backLidClosed for information about this property. -*/ - -bool QmlLidReading::backLidChanged() const -{ - return m_backClosed; -} - -/*! - \qmlproperty qreal LidReading::frontLidClosed - This property holds whether the front lid is closed. - - Please see QLidReading::frontLidClosed for information about this property. -*/ - -bool QmlLidReading::frontLidClosed() const -{ - return m_frontClosed; -} - -QSensorReading *QmlLidReading::reading() const -{ - return m_sensor->reading(); -} - -void QmlLidReading::readingUpdate() -{ - const bool backClosed = m_sensor->reading()->backLidClosed(); - if (m_backClosed != backClosed) { - m_backClosed = backClosed; - Q_EMIT backLidChanged(m_backClosed); - } - const bool frontClosed = m_sensor->reading()->frontLidClosed(); - if (m_frontClosed != frontClosed) { - m_frontClosed = frontClosed; - Q_EMIT frontLidChanged(m_frontClosed); - } -} diff --git a/src/imports/sensors/qmllidsensor.h b/src/imports/sensors/qmllidsensor.h deleted file mode 100644 index 37c2faeb..00000000 --- a/src/imports/sensors/qmllidsensor.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QMLLIDSENSOR_H -#define QMLLIDSENSOR_H - -#include "qmlsensor.h" - -QT_BEGIN_NAMESPACE - -class QLidSensor; - -class QmlLidSensor : public QmlSensor -{ - Q_OBJECT -public: - explicit QmlLidSensor(QObject *parent = 0); - ~QmlLidSensor(); - -private: - QSensor *sensor() const override; - QmlSensorReading *createReading() const override; - - QLidSensor *m_sensor; -}; - -class QmlLidReading : public QmlSensorReading -{ - Q_OBJECT - Q_PROPERTY(bool backLidChanged READ backLidChanged NOTIFY backLidChanged) - Q_PROPERTY(bool frontLidClosed READ frontLidClosed NOTIFY frontLidChanged) -public: - explicit QmlLidReading(QLidSensor *sensor); - ~QmlLidReading(); - - bool backLidChanged() const; - bool frontLidClosed() const; - -Q_SIGNALS: - void backLidChanged(bool closed); - bool frontLidChanged(bool closed); - -private: - QSensorReading *reading() const override; - void readingUpdate() override; - - QLidSensor *m_sensor; - bool m_backClosed; - bool m_frontClosed; -}; - -QT_END_NAMESPACE -#endif diff --git a/src/imports/sensors/qmllightsensor.cpp b/src/imports/sensors/qmllightsensor.cpp deleted file mode 100644 index 2c1eb860..00000000 --- a/src/imports/sensors/qmllightsensor.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmllightsensor.h" -#include - -/*! - \qmltype LightSensor - \instantiates QmlLightSensor - \ingroup qml-sensors_type - \inqmlmodule QtSensors - \since QtSensors 5.0 - \inherits Sensor - \brief The LightSensor element reports on light levels using LUX. - - The LightSensor element reports on light levels using LUX. - - This element wraps the QLightSensor class. Please see the documentation for - QLightSensor for details. - - \sa LightReading -*/ - -QmlLightSensor::QmlLightSensor(QObject *parent) - : QmlSensor(parent) - , m_sensor(new QLightSensor(this)) -{ - connect(m_sensor, SIGNAL(fieldOfViewChanged(qreal)), - this, SIGNAL(fieldOfViewChanged(qreal))); -} - -QmlLightSensor::~QmlLightSensor() -{ -} - -QmlSensorReading *QmlLightSensor::createReading() const -{ - return new QmlLightSensorReading(m_sensor); -} - -QSensor *QmlLightSensor::sensor() const -{ - return m_sensor; -} - -/*! - \qmlproperty qreal LightSensor::fieldOfView - This property holds a value indicating the field of view. - - Please see QLightSensor::fieldOfView for information about this property. -*/ - -qreal QmlLightSensor::fieldOfView() const -{ - return m_sensor->fieldOfView(); -} - -/*! - \qmltype LightReading - \instantiates QmlLightSensorReading - \ingroup qml-sensors_reading - \inqmlmodule QtSensors - \since QtSensors 5.0 - \inherits SensorReading - \brief The LightReading element holds the most recent LightSensor reading. - - The LightReading element holds the most recent LightSensor reading. - - This element wraps the QLightReading class. Please see the documentation for - QLightReading for details. - - This element cannot be directly created. -*/ - -QmlLightSensorReading::QmlLightSensorReading(QLightSensor *sensor) - : QmlSensorReading(sensor) - , m_sensor(sensor) -{ -} - -QmlLightSensorReading::~QmlLightSensorReading() -{ -} - -/*! - \qmlproperty qreal LightReading::illuminance - This property holds the light level. - - Please see QLightReading::illuminance for information about this property. -*/ - -qreal QmlLightSensorReading::illuminance() const -{ - return m_illuminance; -} - -QSensorReading *QmlLightSensorReading::reading() const -{ - return m_sensor->reading(); -} - -void QmlLightSensorReading::readingUpdate() -{ - qreal ill = m_sensor->reading()->lux(); - if (m_illuminance != ill) { - m_illuminance = ill; - Q_EMIT illuminanceChanged(); - } -} diff --git a/src/imports/sensors/qmllightsensor.h b/src/imports/sensors/qmllightsensor.h deleted file mode 100644 index c77b4bfe..00000000 --- a/src/imports/sensors/qmllightsensor.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLLightSensor_H -#define QMLLightSensor_H - -#include "qmlsensor.h" - -QT_BEGIN_NAMESPACE - -class QLightSensor; - -class QmlLightSensor : public QmlSensor -{ - Q_OBJECT - Q_PROPERTY(qreal fieldOfView READ fieldOfView NOTIFY fieldOfViewChanged) -public: - explicit QmlLightSensor(QObject *parent = 0); - ~QmlLightSensor(); - - qreal fieldOfView() const; - -Q_SIGNALS: - void fieldOfViewChanged(qreal fieldOfView); - -private: - QSensor *sensor() const override; - QLightSensor *m_sensor; - QmlSensorReading *createReading() const override; -}; - -class QmlLightSensorReading : public QmlSensorReading -{ - Q_OBJECT - Q_PROPERTY(qreal illuminance READ illuminance NOTIFY illuminanceChanged) -public: - explicit QmlLightSensorReading(QLightSensor *sensor); - ~QmlLightSensorReading(); - - qreal illuminance() const; - -Q_SIGNALS: - void illuminanceChanged(); - -private: - QSensorReading *reading() const override; - void readingUpdate() override; - QLightSensor *m_sensor; - qreal m_illuminance; -}; - -QT_END_NAMESPACE -#endif diff --git a/src/imports/sensors/qmlmagnetometer.cpp b/src/imports/sensors/qmlmagnetometer.cpp deleted file mode 100644 index dba0ec4e..00000000 --- a/src/imports/sensors/qmlmagnetometer.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmlmagnetometer.h" -#include - -/*! - \qmltype Magnetometer - \instantiates QmlMagnetometer - \ingroup qml-sensors_type - \inqmlmodule QtSensors - \since QtSensors 5.0 - \inherits Sensor - \brief The Magnetometer element reports on magnetic field strength - along the Z, Y and Z axes. - - The Magnetometer element reports on magnetic field strength - along the Z, Y and Z axes. - - This element wraps the QMagnetometer class. Please see the documentation for - QMagnetometer for details. - - \sa MagnetometerReading -*/ - -QmlMagnetometer::QmlMagnetometer(QObject *parent) - : QmlSensor(parent) - , m_sensor(new QMagnetometer(this)) -{ - connect(m_sensor, SIGNAL(returnGeoValuesChanged(bool)), - this, SIGNAL(returnGeoValuesChanged(bool))); -} - -QmlMagnetometer::~QmlMagnetometer() -{ -} - -QmlSensorReading *QmlMagnetometer::createReading() const -{ - return new QmlMagnetometerReading(m_sensor); -} - -QSensor *QmlMagnetometer::sensor() const -{ - return m_sensor; -} - -/*! - \qmlproperty bool Magnetometer::returnGeoValues - This property holds a value indicating if geomagnetic values should be returned. - - Please see QMagnetometer::returnGeoValues for information about this property. -*/ - -bool QmlMagnetometer::returnGeoValues() const -{ - return m_sensor->returnGeoValues(); -} - -void QmlMagnetometer::setReturnGeoValues(bool geo) -{ - m_sensor->setReturnGeoValues(geo); -} - -/*! - \qmltype MagnetometerReading - \instantiates QmlMagnetometerReading - \ingroup qml-sensors_reading - \inqmlmodule QtSensors - \since QtSensors 5.0 - \inherits SensorReading - \brief The MagnetometerReading element holds the most recent Magnetometer reading. - - The MagnetometerReading element holds the most recent Magnetometer reading. - - This element wraps the QMagnetometerReading class. Please see the documentation for - QMagnetometerReading for details. - - This element cannot be directly created. -*/ - -QmlMagnetometerReading::QmlMagnetometerReading(QMagnetometer *sensor) - : QmlSensorReading(sensor) - , m_sensor(sensor) -{ -} - -QmlMagnetometerReading::~QmlMagnetometerReading() -{ -} - -/*! - \qmlproperty qreal MagnetometerReading::x - This property holds the raw magnetic flux density on the X axis. - - Please see QMagnetometerReading::x for information about this property. -*/ - -qreal QmlMagnetometerReading::x() const -{ - return m_x; -} - -/*! - \qmlproperty qreal MagnetometerReading::y - This property holds the raw magnetic flux density on the Y axis. - - Please see QMagnetometerReading::y for information about this property. -*/ - -qreal QmlMagnetometerReading::y() const -{ - return m_y; -} - -/*! - \qmlproperty qreal MagnetometerReading::z - This property holds the raw magnetic flux density on the Z axis. - - Please see QMagnetometerReading::z for information about this property. -*/ - -qreal QmlMagnetometerReading::z() const -{ - return m_z; -} - -/*! - \qmlproperty qreal MagnetometerReading::calibrationLevel - This property holds the accuracy of the reading. - - Please see QMagnetometerReading::calibrationLevel for information about this property. -*/ - -qreal QmlMagnetometerReading::calibrationLevel() const -{ - return m_calibrationLevel; -} - -QSensorReading *QmlMagnetometerReading::reading() const -{ - return m_sensor->reading(); -} - -void QmlMagnetometerReading::readingUpdate() -{ - qreal magX = m_sensor->reading()->x(); - if (m_x != magX) { - m_x = magX; - Q_EMIT xChanged(); - } - qreal magY = m_sensor->reading()->y(); - if (m_y != magY) { - m_y = magY; - Q_EMIT yChanged(); - } - qreal magZ = m_sensor->reading()->z(); - if (m_z != magZ) { - m_z = magZ; - Q_EMIT zChanged(); - } - qreal calLevel = m_sensor->reading()->calibrationLevel(); - if (m_calibrationLevel != calLevel) { - m_calibrationLevel = calLevel; - Q_EMIT calibrationLevelChanged(); - } -} diff --git a/src/imports/sensors/qmlmagnetometer.h b/src/imports/sensors/qmlmagnetometer.h deleted file mode 100644 index 3c3c2bae..00000000 --- a/src/imports/sensors/qmlmagnetometer.h +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLMAGNETOMETER_H -#define QMLMAGNETOMETER_H - -#include "qmlsensor.h" - -QT_BEGIN_NAMESPACE - -class QMagnetometer; - -class QmlMagnetometer : public QmlSensor -{ - Q_OBJECT - Q_PROPERTY(bool returnGeoValues READ returnGeoValues WRITE setReturnGeoValues NOTIFY returnGeoValuesChanged) -public: - explicit QmlMagnetometer(QObject *parent = 0); - ~QmlMagnetometer(); - - bool returnGeoValues() const; - void setReturnGeoValues(bool geo); - -Q_SIGNALS: - void returnGeoValuesChanged(bool returnGeoValues); - -private: - QSensor *sensor() const override; - QMagnetometer *m_sensor; - QmlSensorReading *createReading() const override; -}; - -class QmlMagnetometerReading : public QmlSensorReading -{ - Q_OBJECT - Q_PROPERTY(qreal x READ x NOTIFY xChanged) - Q_PROPERTY(qreal y READ y NOTIFY yChanged) - Q_PROPERTY(qreal z READ z NOTIFY zChanged) - Q_PROPERTY(qreal calibrationLevel READ calibrationLevel NOTIFY calibrationLevelChanged) -public: - explicit QmlMagnetometerReading(QMagnetometer *sensor); - ~QmlMagnetometerReading(); - - qreal x() const; - qreal y() const; - qreal z() const; - qreal calibrationLevel() const; - -Q_SIGNALS: - void xChanged(); - void yChanged(); - void zChanged(); - void calibrationLevelChanged(); - -private: - QSensorReading *reading() const override; - void readingUpdate() override; - QMagnetometer *m_sensor; - qreal m_x; - qreal m_y; - qreal m_z; - qreal m_calibrationLevel; -}; - -QT_END_NAMESPACE -#endif diff --git a/src/imports/sensors/qmlorientationsensor.cpp b/src/imports/sensors/qmlorientationsensor.cpp deleted file mode 100644 index 25bda074..00000000 --- a/src/imports/sensors/qmlorientationsensor.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmlorientationsensor.h" -#include - -/*! - \qmltype OrientationSensor - \instantiates QmlOrientationSensor - \ingroup qml-sensors_type - \inqmlmodule QtSensors - \since QtSensors 5.0 - \inherits Sensor - \brief The OrientationSensor element reports device orientation. - - The OrientationSensor element reports device orientation. - - This element wraps the QOrientationSensor class. Please see the documentation for - QOrientationSensor for details. - - \sa OrientationReading -*/ - -QmlOrientationSensor::QmlOrientationSensor(QObject *parent) - : QmlSensor(parent) - , m_sensor(new QOrientationSensor(this)) -{ -} - -QmlOrientationSensor::~QmlOrientationSensor() -{ -} - -QmlSensorReading *QmlOrientationSensor::createReading() const -{ - return new QmlOrientationSensorReading(m_sensor); -} - -QSensor *QmlOrientationSensor::sensor() const -{ - return m_sensor; -} - -/*! - \qmltype OrientationReading - \instantiates QmlOrientationSensorReading - \ingroup qml-sensors_reading - \inqmlmodule QtSensors - \since QtSensors 5.0 - \inherits SensorReading - \brief The OrientationReading element holds the most recent OrientationSensor reading. - - The OrientationReading element holds the most recent OrientationSensor reading. - - This element wraps the QOrientationReading class. Please see the documentation for - QOrientationReading for details. - - This element cannot be directly created. -*/ - -QmlOrientationSensorReading::QmlOrientationSensorReading(QOrientationSensor *sensor) - : QmlSensorReading(sensor) - , m_sensor(sensor) -{ -} - -QmlOrientationSensorReading::~QmlOrientationSensorReading() -{ -} - -/*! - \qmlproperty Orientation OrientationReading::orientation - This property holds the orientation of the device. - - Please see QOrientationReading::orientation for information about this property. - - Note that Orientation constants are exposed through the OrientationReading class. - \code - OrientationSensor { - onReadingChanged: { - if (reading.orientation == OrientationReading.TopUp) - // do something - } - } - \endcode -*/ - -QOrientationReading::Orientation QmlOrientationSensorReading::orientation() const -{ - return m_orientation; -} - -QSensorReading *QmlOrientationSensorReading::reading() const -{ - return m_sensor->reading(); -} - -void QmlOrientationSensorReading::readingUpdate() -{ - QOrientationReading::Orientation o = m_sensor->reading()->orientation(); - if (m_orientation != o) { - m_orientation = o; - Q_EMIT orientationChanged(); - } -} diff --git a/src/imports/sensors/qmlorientationsensor.h b/src/imports/sensors/qmlorientationsensor.h deleted file mode 100644 index bdb1b1e4..00000000 --- a/src/imports/sensors/qmlorientationsensor.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLORIENTATIONSENSOR_H -#define QMLORIENTATIONSENSOR_H - -#include "qmlsensor.h" -#include - -QT_BEGIN_NAMESPACE - -class QOrientationSensor; - -class QmlOrientationSensor : public QmlSensor -{ - Q_OBJECT -public: - explicit QmlOrientationSensor(QObject *parent = 0); - ~QmlOrientationSensor(); - - -private: - QSensor *sensor() const override; - QOrientationSensor *m_sensor; - QmlSensorReading *createReading() const override; -}; - -class QmlOrientationSensorReading : public QmlSensorReading -{ - Q_OBJECT - Q_PROPERTY(QOrientationReading::Orientation orientation READ orientation NOTIFY orientationChanged) -public: - - explicit QmlOrientationSensorReading(QOrientationSensor *sensor); - ~QmlOrientationSensorReading(); - - QOrientationReading::Orientation orientation() const; - -Q_SIGNALS: - void orientationChanged(); - -private: - QSensorReading *reading() const override; - void readingUpdate() override; - QOrientationSensor *m_sensor; - QOrientationReading::Orientation m_orientation; -}; - -QT_END_NAMESPACE -#endif diff --git a/src/imports/sensors/qmlpressuresensor.cpp b/src/imports/sensors/qmlpressuresensor.cpp deleted file mode 100644 index 4ef27ba7..00000000 --- a/src/imports/sensors/qmlpressuresensor.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Research In Motion -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "qmlpressuresensor.h" -#include - -/*! - \qmltype PressureSensor - \instantiates QmlPressureSensor - \ingroup qml-sensors_type - \inqmlmodule QtSensors - \since QtSensors 5.1 - \inherits Sensor - \brief The PressureSensor element reports on atmospheric pressure values. - - The PressureSensor element reports on atmospheric pressure values. - - This element wraps the QPressureSensor class. Please see the documentation for - QPressureSensor for details. - - \sa PressureReading -*/ - -QmlPressureSensor::QmlPressureSensor(QObject *parent) - : QmlSensor(parent) - , m_sensor(new QPressureSensor(this)) -{ -} - -QmlPressureSensor::~QmlPressureSensor() -{ -} - -QmlSensorReading *QmlPressureSensor::createReading() const -{ - return new QmlPressureReading(m_sensor); -} - -QSensor *QmlPressureSensor::sensor() const -{ - return m_sensor; -} - -/*! - \qmltype PressureReading - \instantiates QmlPressureReading - \ingroup qml-sensors_reading - \inqmlmodule QtSensors - \since QtSensors 5.1 - \inherits SensorReading - \brief The PressureReading element holds the most recent PressureSensor reading. - - The PressureReading element holds the most recent PressureSensor reading. - - This element wraps the QPressureReading class. Please see the documentation for - QPressureReading for details. - - This element cannot be directly created. -*/ - -QmlPressureReading::QmlPressureReading(QPressureSensor *sensor) - : QmlSensorReading(sensor) - , m_sensor(sensor) - , m_pressure(0) - , m_temperature(0) -{ -} - -QmlPressureReading::~QmlPressureReading() -{ -} - -/*! - \qmlproperty qreal PressureReading::pressure - This property holds the atmospheric pressure value in Pascals. - - Please see QPressureReading::pressure for information about this property. -*/ - -qreal QmlPressureReading::pressure() const -{ - return m_pressure; -} - -/*! - \qmlproperty qreal PressureReading::temperature - This property holds the pressure sensor's temperature value in degrees Celsius. - - Please see QPressureReading::temperature for information about this property. - \since QtSensors 5.2 -*/ - -qreal QmlPressureReading::temperature() const -{ - return m_temperature; -} - -QSensorReading *QmlPressureReading::reading() const -{ - return m_sensor->reading(); -} - -void QmlPressureReading::readingUpdate() -{ - qreal pressure = m_sensor->reading()->pressure(); - if (m_pressure != pressure) { - m_pressure = pressure; - Q_EMIT pressureChanged(); - } - - qreal temperature = m_sensor->reading()->temperature(); - if (m_temperature != temperature) { - m_temperature = temperature; - Q_EMIT temperatureChanged(); - } -} diff --git a/src/imports/sensors/qmlpressuresensor.h b/src/imports/sensors/qmlpressuresensor.h deleted file mode 100644 index 6304d69c..00000000 --- a/src/imports/sensors/qmlpressuresensor.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Research In Motion -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QMLPRESSURESENSOR_H -#define QMLPRESSURESENSOR_H - -#include "qmlsensor.h" - -QT_BEGIN_NAMESPACE - -class QPressureSensor; - -class QmlPressureSensor : public QmlSensor -{ - Q_OBJECT -public: - explicit QmlPressureSensor(QObject *parent = 0); - ~QmlPressureSensor(); - -private: - QSensor *sensor() const override; - QmlSensorReading *createReading() const override; - - QPressureSensor *m_sensor; -}; - -class QmlPressureReading : public QmlSensorReading -{ - Q_OBJECT - Q_PROPERTY(qreal pressure READ pressure NOTIFY pressureChanged) - Q_PROPERTY(qreal temperature READ temperature NOTIFY temperatureChanged REVISION 1) -public: - explicit QmlPressureReading(QPressureSensor *sensor); - ~QmlPressureReading(); - - qreal pressure() const; - qreal temperature() const; - -Q_SIGNALS: - void pressureChanged(); - Q_REVISION(1) void temperatureChanged(); - -private: - QSensorReading *reading() const override; - void readingUpdate() override; - - QPressureSensor *m_sensor; - qreal m_pressure; - qreal m_temperature; -}; - -QT_END_NAMESPACE -#endif diff --git a/src/imports/sensors/qmlproximitysensor.cpp b/src/imports/sensors/qmlproximitysensor.cpp deleted file mode 100644 index 84993574..00000000 --- a/src/imports/sensors/qmlproximitysensor.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmlproximitysensor.h" -#include - -/*! - \qmltype ProximitySensor - \instantiates QmlProximitySensor - \ingroup qml-sensors_type - \inqmlmodule QtSensors - \since QtSensors 5.0 - \inherits Sensor - \brief The ProximitySensor element reports on object proximity. - - The ProximitySensor element reports on object proximity. - - This element wraps the QProximitySensor class. Please see the documentation for - QProximitySensor for details. - - \sa ProximityReading -*/ - -QmlProximitySensor::QmlProximitySensor(QObject *parent) - : QmlSensor(parent) - , m_sensor(new QProximitySensor(this)) -{ -} - -QmlProximitySensor::~QmlProximitySensor() -{ -} - -QmlSensorReading *QmlProximitySensor::createReading() const -{ - return new QmlProximitySensorReading(m_sensor); -} - -QSensor *QmlProximitySensor::sensor() const -{ - return m_sensor; -} - -/*! - \qmltype ProximityReading - \instantiates QmlProximitySensorReading - \ingroup qml-sensors_reading - \inqmlmodule QtSensors - \since QtSensors 5.0 - \inherits SensorReading - \brief The ProximityReading element holds the most recent ProximitySensor reading. - - The ProximityReading element holds the most recent ProximitySensor reading. - - This element wraps the QProximityReading class. Please see the documentation for - QProximityReading for details. - - This element cannot be directly created. -*/ - -QmlProximitySensorReading::QmlProximitySensorReading(QProximitySensor *sensor) - : QmlSensorReading(sensor) - , m_sensor(sensor) -{ -} - -QmlProximitySensorReading::~QmlProximitySensorReading() -{ -} - -/*! - \qmlproperty bool ProximityReading::near - This property holds a value indicating if something is near. - - Please see QProximityReading::near for information about this property. -*/ - -bool QmlProximitySensorReading::near() const -{ - return m_near; -} - -QSensorReading *QmlProximitySensorReading::reading() const -{ - return m_sensor->reading(); -} - -void QmlProximitySensorReading::readingUpdate() -{ - bool pNear = m_sensor->reading()->close(); - if (m_near != pNear) { - m_near = pNear; - Q_EMIT nearChanged(); - } -} diff --git a/src/imports/sensors/qmlproximitysensor.h b/src/imports/sensors/qmlproximitysensor.h deleted file mode 100644 index 8bab8cfa..00000000 --- a/src/imports/sensors/qmlproximitysensor.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLPROXIMITYSENSOR_H -#define QMLPROXIMITYSENSOR_H - -#include "qmlsensor.h" -#ifdef near -#undef near -#endif -QT_BEGIN_NAMESPACE - -class QProximitySensor; - -class QmlProximitySensor : public QmlSensor -{ - Q_OBJECT -public: - explicit QmlProximitySensor(QObject *parent = 0); - ~QmlProximitySensor(); - - -private: - QSensor *sensor() const override; - QProximitySensor *m_sensor; - QmlSensorReading *createReading() const override; -}; - -class QmlProximitySensorReading : public QmlSensorReading -{ - Q_OBJECT - Q_PROPERTY(bool near READ near NOTIFY nearChanged) -public: - explicit QmlProximitySensorReading(QProximitySensor *sensor); - ~QmlProximitySensorReading(); - - bool near() const; - -Q_SIGNALS: - void nearChanged(); - -private: - QSensorReading *reading() const override; - void readingUpdate() override; - QProximitySensor *m_sensor; - bool m_near; -}; - -QT_END_NAMESPACE -#endif diff --git a/src/imports/sensors/qmlrotationsensor.cpp b/src/imports/sensors/qmlrotationsensor.cpp deleted file mode 100644 index ffa47fd9..00000000 --- a/src/imports/sensors/qmlrotationsensor.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmlrotationsensor.h" -#include - -/*! - \qmltype RotationSensor - \instantiates QmlRotationSensor - \ingroup qml-sensors_type - \inqmlmodule QtSensors - \since QtSensors 5.0 - \inherits Sensor - \brief The RotationSensor element reports on device rotation - around the X, Y and Z axes. - - The RotationSensor element reports on device rotation - around the X, Y and Z axes. - - This element wraps the QRotationSensor class. Please see the documentation for - QRotationSensor for details. - - \sa RotationReading -*/ - -QmlRotationSensor::QmlRotationSensor(QObject *parent) - : QmlSensor(parent) - , m_sensor(new QRotationSensor(this)) -{ - connect(m_sensor, SIGNAL(hasZChanged(bool)), this, SIGNAL(hasZChanged(bool))); -} - -QmlRotationSensor::~QmlRotationSensor() -{ -} - -QmlSensorReading *QmlRotationSensor::createReading() const -{ - return new QmlRotationSensorReading(m_sensor); -} - -QSensor *QmlRotationSensor::sensor() const -{ - return m_sensor; -} - -/*! - \qmlproperty qreal RotationSensor::hasZ - This property holds a value indicating if the z angle is available. - - Please see QRotationSensor::hasZ for information about this property. -*/ - -bool QmlRotationSensor::hasZ() const -{ - return m_sensor->hasZ(); -} - -void QmlRotationSensor::_update() -{ -} - -/*! - \qmltype RotationReading - \instantiates QmlRotationSensorReading - \ingroup qml-sensors_reading - \inqmlmodule QtSensors - \since QtSensors 5.0 - \inherits SensorReading - \brief The RotationReading element holds the most recent RotationSensor reading. - - The RotationReading element holds the most recent RotationSensor reading. - - This element wraps the QRotationReading class. Please see the documentation for - QRotationReading for details. - - This element cannot be directly created. -*/ - -QmlRotationSensorReading::QmlRotationSensorReading(QRotationSensor *sensor) - : QmlSensorReading(sensor) - , m_sensor(sensor) -{ -} - -QmlRotationSensorReading::~QmlRotationSensorReading() -{ -} - -/*! - \qmlproperty qreal RotationReading::x - This property holds the rotation around the x axis. - - Please see QRotationReading::x for information about this property. -*/ - -qreal QmlRotationSensorReading::x() const -{ - return m_x; -} - -/*! - \qmlproperty qreal RotationReading::y - This property holds the rotation around the y axis. - - Please see QRotationReading::y for information about this property. -*/ - -qreal QmlRotationSensorReading::y() const -{ - return m_y; -} - -/*! - \qmlproperty qreal RotationReading::z - This property holds the rotation around the z axis. - - Please see QRotationReading::z for information about this property. -*/ - -qreal QmlRotationSensorReading::z() const -{ - return m_z; -} - -QSensorReading *QmlRotationSensorReading::reading() const -{ - return m_sensor->reading(); -} - -void QmlRotationSensorReading::readingUpdate() -{ - qreal rX = m_sensor->reading()->x(); - if (m_x != rX) { - m_x = rX; - Q_EMIT xChanged(); - } - qreal rY = m_sensor->reading()->y(); - if (m_y != rY) { - m_y = rY; - Q_EMIT yChanged(); - } - qreal rZ = m_sensor->reading()->z(); - if (m_z != rZ) { - m_z = rZ; - Q_EMIT zChanged(); - } -} diff --git a/src/imports/sensors/qmlrotationsensor.h b/src/imports/sensors/qmlrotationsensor.h deleted file mode 100644 index c0760ac9..00000000 --- a/src/imports/sensors/qmlrotationsensor.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLROTATIONSENSOR_H -#define QMLROTATIONSENSOR_H - -#include "qmlsensor.h" - -QT_BEGIN_NAMESPACE - -class QRotationSensor; - -class QmlRotationSensor : public QmlSensor -{ - Q_OBJECT - Q_PROPERTY(bool hasZ READ hasZ NOTIFY hasZChanged) -public: - explicit QmlRotationSensor(QObject *parent = 0); - ~QmlRotationSensor(); - - bool hasZ() const; - -Q_SIGNALS: - void hasZChanged(bool hasZ); - -private: - QSensor *sensor() const override; - void _update() override; - QRotationSensor *m_sensor; - QmlSensorReading *createReading() const override; -}; - -class QmlRotationSensorReading : public QmlSensorReading -{ - Q_OBJECT - Q_PROPERTY(qreal x READ x NOTIFY xChanged) - Q_PROPERTY(qreal y READ y NOTIFY yChanged) - Q_PROPERTY(qreal z READ z NOTIFY zChanged) -public: - explicit QmlRotationSensorReading(QRotationSensor *sensor); - ~QmlRotationSensorReading(); - - qreal x() const; - qreal y() const; - qreal z() const; - -Q_SIGNALS: - void xChanged(); - void yChanged(); - void zChanged(); - -private: - QSensorReading *reading() const override; - void readingUpdate() override; - QRotationSensor *m_sensor; - qreal m_x; - qreal m_y; - qreal m_z; -}; - -QT_END_NAMESPACE -#endif diff --git a/src/imports/sensors/qmlsensor.cpp b/src/imports/sensors/qmlsensor.cpp deleted file mode 100644 index be1f4588..00000000 --- a/src/imports/sensors/qmlsensor.cpp +++ /dev/null @@ -1,577 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmlsensor.h" -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QmlSensorPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QmlSensor) -public: - - QList availableRanges; - QList outputRanges; -}; - -template -qsizetype readonlyListCount(QQmlListProperty *p) -{ - return static_cast *>(p->data)->count(); -} - -template -Item *readonlyListAt(QQmlListProperty *p, qsizetype idx) -{ - return static_cast *>(p->data)->at(idx); -}; - -template -QQmlListProperty readonlyListProperty(const QObject *o, const QList *list) -{ - // Unfortunately QQmlListProperty won't accept a const object, even on the readonly ctor. - return QQmlListProperty(const_cast(o), const_cast *>(list), - readonlyListCount, readonlyListAt); -} - -/*! - \qmltype Sensor - \instantiates QmlSensor - \inqmlmodule QtSensors - \since QtSensors 5.0 - \brief The Sensor element serves as a base type for sensors. - - The Sensor element serves as a base type for sensors. - - This element wraps the QSensor class. Please see the documentation for - QSensor for details. - - This element cannot be directly created. Please use one of the sub-classes instead. -*/ - -QmlSensor::QmlSensor(QObject *parent) - : QObject(*(new QmlSensorPrivate), parent) - , m_parsed(false) - , m_active(false) - , m_reading(0) -{ -} - -QmlSensor::~QmlSensor() -{ -} - -/*! - \qmlproperty string Sensor::identifier - This property holds the backend identifier for the sensor. - - Please see QSensor::identifier for information about this property. -*/ - -QString QmlSensor::identifier() const -{ - return m_identifier; -} - -void QmlSensor::setIdentifier(const QString &identifier) -{ - if (m_parsed) return; - m_identifier = identifier; - Q_EMIT identifierChanged(); -} - -/*! - \qmlproperty string Sensor::type - This property holds the type of the sensor. -*/ - -QString QmlSensor::type() const -{ - return QString::fromLatin1(sensor()->type()); -} - -/*! - \qmlproperty bool Sensor::connectedToBackend - This property holds a value indicating if the sensor has connected to a backend. - - Please see QSensor::connectedToBackend for information about this property. -*/ - -bool QmlSensor::isConnectedToBackend() const -{ - return sensor()->isConnectedToBackend(); -} - -/*! - \qmlproperty bool Sensor::busy - This property holds a value to indicate if the sensor is busy. - - Please see QSensor::busy for information about this property. -*/ - -bool QmlSensor::isBusy() const -{ - return sensor()->isBusy(); -} - -/*! - \qmlproperty bool Sensor::active - This property holds a value to indicate if the sensor is active. - - Please see QSensor::active for information about this property. -*/ - -void QmlSensor::setActive(bool active) -{ - m_active = active; - if (!m_parsed) return; // delay (it'll get called again later)! - bool wasActive = sensor()->isActive(); - if (wasActive == active) return; - if (active) { - sensor()->start(); - m_active = sensor()->isActive(); - } else { - sensor()->stop(); - } - if (m_active != wasActive) - emit activeChanged(); -} - -bool QmlSensor::isActive() const -{ - return m_active; -} - -/*! - \qmlproperty bool Sensor::alwaysOn - This property holds a value to indicate if the sensor should remain running when the screen is off. - - Please see QSensor::alwaysOn for information about this property. -*/ - -bool QmlSensor::isAlwaysOn() const -{ - return sensor()->isAlwaysOn(); -} - -void QmlSensor::setAlwaysOn(bool alwaysOn) -{ - sensor()->setAlwaysOn(alwaysOn); -} - -/*! - \qmlproperty bool Sensor::skipDuplicates - \since QtSensors 5.1 - - This property indicates whether duplicate reading values should be omitted. - - Please see QSensor::skipDuplicates for information about this property. -*/ - -bool QmlSensor::skipDuplicates() const -{ - return sensor()->skipDuplicates(); -} - -void QmlSensor::setSkipDuplicates(bool skipDuplicates) -{ - sensor()->setSkipDuplicates(skipDuplicates); -} - -/*! - \qmlproperty list Sensor::availableDataRates - This property holds the data rates that the sensor supports. - - Please see QSensor::availableDataRates for information about this property. -*/ -QQmlListProperty QmlSensor::availableDataRates() const -{ - Q_D(const QmlSensor); - return readonlyListProperty(this, &d->availableRanges); -} - -/*! - \qmlproperty int Sensor::dataRate - This property holds the data rate that the sensor should be run at. - - Please see QSensor::dataRate for information about this property. -*/ - -int QmlSensor::dataRate() const -{ - return sensor()->dataRate(); -} - -void QmlSensor::setDataRate(int rate) -{ - if (rate != dataRate()) { - sensor()->setDataRate(rate); - Q_EMIT dataRateChanged(); - } -} - -/*! - \qmlproperty list Sensor::outputRanges - This property holds a list of output ranges the sensor supports. - - Please see QSensor::outputRanges for information about this property. -*/ - -QQmlListProperty QmlSensor::outputRanges() const -{ - Q_D(const QmlSensor); - return readonlyListProperty(this, &d->outputRanges); -} - -/*! - \qmlproperty int Sensor::outputRange - This property holds the output range in use by the sensor. - - Please see QSensor::outputRange for information about this property. -*/ - -int QmlSensor::outputRange() const -{ - return sensor()->outputRange(); -} - -void QmlSensor::setOutputRange(int index) -{ - int oldRange = outputRange(); - if (oldRange == index) return; - sensor()->setOutputRange(index); - if (sensor()->outputRange() == index) - Q_EMIT outputRangeChanged(); -} - -/*! - \qmlproperty string Sensor::description - This property holds a descriptive string for the sensor. -*/ - -QString QmlSensor::description() const -{ - return sensor()->description(); -} - -/*! - \qmlproperty int Sensor::error - This property holds the last error code set on the sensor. -*/ - -int QmlSensor::error() const -{ - return sensor()->error(); -} - -/*! - \qmlproperty SensorReading Sensor::reading - This property holds the reading class. - - Please see QSensor::reading for information about this property. - \sa {QML Reading types} -*/ - -QmlSensorReading *QmlSensor::reading() const -{ - return m_reading; -} - -/*! - \qmlproperty Sensor::AxesOrientationMode Sensor::axesOrientationMode - \since QtSensors 5.1 - This property holds the mode that affects how the screen orientation changes reading values. - - Please see QSensor::axesOrientationMode for information about this property. -*/ - -QmlSensor::AxesOrientationMode QmlSensor::axesOrientationMode() const -{ - return static_cast(sensor()->axesOrientationMode()); -} - -void QmlSensor::setAxesOrientationMode(QmlSensor::AxesOrientationMode axesOrientationMode) -{ - sensor()->setAxesOrientationMode(static_cast(axesOrientationMode)); -} - -/*! - \qmlproperty int Sensor::currentOrientation - \since QtSensors 5.1 - This property holds the current orientation that is used for rotating the reading values. - - Please see QSensor::currentOrientation for information about this property. -*/ - -int QmlSensor::currentOrientation() const -{ - return sensor()->currentOrientation(); -} - -/*! - \qmlproperty int Sensor::userOrientation - \since QtSensors 5.1 - This property holds the angle used for rotating the reading values in the UserOrientation mode. - - Please see QSensor::userOrientation for information about this property. -*/ - -int QmlSensor::userOrientation() const -{ - return sensor()->userOrientation(); -} - -void QmlSensor::setUserOrientation(int userOrientation) -{ - sensor()->setUserOrientation(userOrientation); -} - -/*! - \qmlproperty int Sensor::maxBufferSize - \since QtSensors 5.1 - This property holds the maximum buffer size. - - Please see QSensor::maxBufferSize for information about this property. -*/ - -int QmlSensor::maxBufferSize() const -{ - return sensor()->maxBufferSize(); -} - -/*! - \qmlproperty int Sensor::efficientBufferSize - \since QtSensors 5.1 - The property holds the most efficient buffer size. - - Please see QSensor::efficientBufferSize for information about this property. -*/ - -int QmlSensor::efficientBufferSize() const -{ - return sensor()->efficientBufferSize(); -} - -/*! - \qmlproperty int Sensor::bufferSize - \since QtSensors 5.1 - This property holds the size of the buffer. - - Please see QSensor::bufferSize for information about this property. -*/ - -int QmlSensor::bufferSize() const -{ - return sensor()->bufferSize(); -} - -void QmlSensor::setBufferSize(int bufferSize) -{ - sensor()->setBufferSize(bufferSize); -} - -/*! - \qmlmethod bool Sensor::start() - Start retrieving values from the sensor. Returns true if the sensor - was started, false otherwise. - - Please see QSensor::start() for information. -*/ - -bool QmlSensor::start() -{ - setActive(true); - return isActive(); -} - -/*! - \qmlmethod bool Sensor::stop() - Stop retrieving values from the sensor. - Returns true if the sensor was stopped, false otherwise. - - Please see QSensor::stop() for information. -*/ - -void QmlSensor::stop() -{ - setActive(false); -} - -void QmlSensor::classBegin() -{ -} - -void QmlSensor::componentComplete() -{ - m_parsed = true; - - connect(sensor(), SIGNAL(sensorError(int)), this, SIGNAL(errorChanged())); - connect(sensor(), SIGNAL(activeChanged()), this, SIGNAL(activeChanged())); - connect(sensor(), SIGNAL(alwaysOnChanged()), this, SIGNAL(alwaysOnChanged())); - connect(sensor(), SIGNAL(skipDuplicatesChanged(bool)), this, SIGNAL(skipDuplicatesChanged(bool))); - connect(sensor(), SIGNAL(axesOrientationModeChanged(AxesOrientationMode)), - this, SIGNAL(axesOrientationModeChanged(AxesOrientationMode))); - connect(sensor(), SIGNAL(userOrientationChanged(int)), this, SIGNAL(userOrientationChanged(int))); - connect(sensor(), SIGNAL(currentOrientationChanged(int)), this, SIGNAL(currentOrientationChanged(int))); - connect(sensor(), SIGNAL(bufferSizeChanged(int)), this, SIGNAL(bufferSizeChanged(int))); - connect(sensor(), SIGNAL(maxBufferSizeChanged(int)), this, SIGNAL(maxBufferSizeChanged(int))); - connect(sensor(), SIGNAL(efficientBufferSizeChanged(int)), this, SIGNAL(efficientBufferSizeChanged(int))); - - // We need to set this on the sensor object now - sensor()->setIdentifier(m_identifier.toLocal8Bit()); - - // These can change! - QByteArray oldIdentifier = sensor()->identifier(); - int oldDataRate = dataRate(); - int oldOutputRange = outputRange(); - - bool ok = sensor()->connectToBackend(); - if (ok) { - Q_EMIT connectedToBackendChanged(); - m_reading = createReading(); - m_reading->setParent(this); - } - - if (oldIdentifier != sensor()->identifier()) { - m_identifier = QString::fromLatin1(sensor()->identifier()); - Q_EMIT identifierChanged(); - } - if (oldDataRate != dataRate()) - Q_EMIT dataRateChanged(); - if (oldOutputRange != outputRange()) - Q_EMIT outputRangeChanged(); - - Q_D(QmlSensor); - const auto available = sensor()->availableDataRates(); - d->availableRanges.reserve(available.size()); - for (const qrange &r : available) { - auto *range = new QmlSensorRange(this); - range->setMinumum(r.first); - range->setMaximum(r.second); - d->availableRanges.append(range); - } - const auto output = sensor()->outputRanges(); - d->outputRanges.reserve(output.size()); - for (const qoutputrange &r : output) { - auto *range = new QmlSensorOutputRange(this); - range->setMinimum(r.minimum); - range->setMaximum(r.maximum); - range->setAccuracy(r.accuracy); - d->outputRanges.append(range); - } - - // meta-data should become non-empty - if (!description().isEmpty()) - Q_EMIT descriptionChanged(); - if (available.count()) - Q_EMIT availableDataRatesChanged(); - if (output.count()) - Q_EMIT outputRangesChanged(); - - _update(); - - connect(sensor(), SIGNAL(readingChanged()), this, SLOT(updateReading())); - if (m_active) { - m_active = false; - start(); - } -} - -void QmlSensor::_update() -{ -} - -void QmlSensor::updateReading() -{ - if (m_reading) { - m_reading->update(); - Q_EMIT readingChanged(); - } -} - -/*! - \qmltype SensorReading - \instantiates QmlSensorReading - \inqmlmodule QtSensors - \since QtSensors 5.0 - \brief The SensorReading element serves as a base type for sensor readings. - - The SensorReading element serves as a base type for sensor readings. - - This element wraps the QSensorReading class. Please see the documentation for - QSensorReading for details. - - This element cannot be directly created. -*/ - -QmlSensorReading::QmlSensorReading(QSensor *) - : QObject(0) -{ -} - -QmlSensorReading::~QmlSensorReading() -{ -} - -/*! - \qmlproperty quint64 SensorReading::timestamp - A timestamp for the reading. - - Please see QSensorReading::timestamp for information about this property. -*/ - -quint64 QmlSensorReading::timestamp() const -{ - return m_timestamp; -} - -void QmlSensorReading::update() -{ - quint64 ts = reading()->timestamp(); - if (m_timestamp != ts) { - m_timestamp = ts; - Q_EMIT timestampChanged(); - } - readingUpdate(); -} - -QT_END_NAMESPACE diff --git a/src/imports/sensors/qmlsensor.h b/src/imports/sensors/qmlsensor.h deleted file mode 100644 index 3ac82699..00000000 --- a/src/imports/sensors/qmlsensor.h +++ /dev/null @@ -1,206 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLSENSOR_H -#define QMLSENSOR_H - -#include -#include -#include -#include "qmlsensorrange.h" - -QT_BEGIN_NAMESPACE - -class QSensor; -class QSensorReading; - -class QmlSensorReading; - -class QmlSensorPrivate; -class QmlSensor : public QObject, public QQmlParserStatus -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QmlSensor) - Q_ENUMS(AxesOrientationMode) - Q_INTERFACES(QQmlParserStatus) - Q_PROPERTY(QString identifier READ identifier WRITE setIdentifier NOTIFY identifierChanged) - Q_PROPERTY(QString type READ type NOTIFY typeChanged) - Q_PROPERTY(bool connectedToBackend READ isConnectedToBackend NOTIFY connectedToBackendChanged) - Q_PROPERTY(QQmlListProperty availableDataRates READ availableDataRates NOTIFY availableDataRatesChanged) - Q_PROPERTY(int dataRate READ dataRate WRITE setDataRate NOTIFY dataRateChanged) - Q_PROPERTY(QmlSensorReading* reading READ reading NOTIFY readingChanged) - Q_PROPERTY(bool busy READ isBusy) - Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged) - Q_PROPERTY(QQmlListProperty outputRanges READ outputRanges NOTIFY outputRangesChanged) - Q_PROPERTY(int outputRange READ outputRange WRITE setOutputRange NOTIFY outputRangeChanged) - Q_PROPERTY(QString description READ description NOTIFY descriptionChanged) - Q_PROPERTY(int error READ error NOTIFY errorChanged) - Q_PROPERTY(bool alwaysOn READ isAlwaysOn WRITE setAlwaysOn NOTIFY alwaysOnChanged) - Q_PROPERTY(bool skipDuplicates READ skipDuplicates WRITE setSkipDuplicates NOTIFY skipDuplicatesChanged REVISION 1) - Q_PROPERTY(AxesOrientationMode axesOrientationMode READ axesOrientationMode WRITE setAxesOrientationMode NOTIFY axesOrientationModeChanged REVISION 1) - Q_PROPERTY(int currentOrientation READ currentOrientation NOTIFY currentOrientationChanged REVISION 1) - Q_PROPERTY(int userOrientation READ userOrientation WRITE setUserOrientation NOTIFY userOrientationChanged REVISION 1) - Q_PROPERTY(int maxBufferSize READ maxBufferSize NOTIFY maxBufferSizeChanged REVISION 1) - Q_PROPERTY(int efficientBufferSize READ efficientBufferSize NOTIFY efficientBufferSizeChanged REVISION 1) - Q_PROPERTY(int bufferSize READ bufferSize WRITE setBufferSize NOTIFY bufferSizeChanged REVISION 1) - -public: - // Keep in sync with QSensor::AxesOrientationMode - enum AxesOrientationMode { - FixedOrientation, - AutomaticOrientation, - UserOrientation - }; - - explicit QmlSensor(QObject *parent = 0); - ~QmlSensor(); - - QString identifier() const; - void setIdentifier(const QString &identifier); - - QString type() const; - - bool isConnectedToBackend() const; - - bool isBusy() const; - - void setActive(bool active); - bool isActive() const; - - bool isAlwaysOn() const; - void setAlwaysOn(bool alwaysOn); - - bool skipDuplicates() const; - void setSkipDuplicates(bool skipDuplicates); - - QQmlListProperty availableDataRates() const; - int dataRate() const; - void setDataRate(int rate); - - QQmlListProperty outputRanges() const; - int outputRange() const; - void setOutputRange(int index); - - QString description() const; - int error() const; - - QmlSensorReading *reading() const; - - AxesOrientationMode axesOrientationMode() const; - void setAxesOrientationMode(AxesOrientationMode axesOrientationMode); - - int currentOrientation() const; - - int userOrientation() const; - void setUserOrientation(int userOrientation); - - int maxBufferSize() const; - - int efficientBufferSize() const; - - int bufferSize() const; - void setBufferSize(int bufferSize); - -public Q_SLOTS: - bool start(); - void stop(); - -Q_SIGNALS: - void identifierChanged(); - void typeChanged(); - void connectedToBackendChanged(); - void availableDataRatesChanged(); - void dataRateChanged(); - void readingChanged(); - void activeChanged(); - void outputRangesChanged(); - void outputRangeChanged(); - void descriptionChanged(); - void errorChanged(); - void alwaysOnChanged(); - Q_REVISION(1) void skipDuplicatesChanged(bool skipDuplicates); - Q_REVISION(1) void axesOrientationModeChanged(AxesOrientationMode axesOrientationMode); - Q_REVISION(1) void currentOrientationChanged(int currentOrientation); - Q_REVISION(1) void userOrientationChanged(int userOrientation); - Q_REVISION(1) void maxBufferSizeChanged(int maxBufferSize); - Q_REVISION(1) void efficientBufferSizeChanged(int efficientBufferSize); - Q_REVISION(1) void bufferSizeChanged(int bufferSize); - -protected: - virtual QSensor *sensor() const = 0; - virtual QmlSensorReading *createReading() const = 0; - -private Q_SLOTS: - void updateReading(); - -protected Q_SLOTS: - void componentComplete() override; - -private: - void classBegin() override; - virtual void _update(); - bool m_parsed; - bool m_active; - QString m_identifier; - QmlSensorReading *m_reading; -}; - -class QmlSensorReading : public QObject -{ - Q_OBJECT - Q_PROPERTY(quint64 timestamp READ timestamp NOTIFY timestampChanged) -public: - explicit QmlSensorReading(QSensor *sensor); - ~QmlSensorReading(); - - quint64 timestamp() const; - void update(); - -Q_SIGNALS: - void timestampChanged(); - -private: - virtual QSensorReading *reading() const = 0; - virtual void readingUpdate() = 0; - quint64 m_timestamp; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/imports/sensors/qmlsensorgesture.cpp b/src/imports/sensors/qmlsensorgesture.cpp deleted file mode 100644 index 2e7f104c..00000000 --- a/src/imports/sensors/qmlsensorgesture.cpp +++ /dev/null @@ -1,262 +0,0 @@ - /**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmlsensorgesture.h" -#include -#include - -QT_BEGIN_NAMESPACE - -/*! - \qmltype SensorGesture - \instantiates QmlSensorGesture - \inqmlmodule QtSensors - \since QtSensors 5.0 - \brief Provides notifications when sensor-based gestures are detected. - - This type provides notification when sensor gestures are triggered. - - 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 - } - } - \endqml - - \l {Qt Sensor Gestures} contains a list of currently supported sensor gestures and their - descriptions. - - -*/ -QmlSensorGesture::QmlSensorGesture(QObject* parent) - : QObject(parent) - , isEnabled(false) - , initDone(false) - , sensorGesture(0) - , sensorGestureManager(new QSensorGestureManager(this)) -{ - connect(sensorGestureManager, SIGNAL(newSensorGestureAvailable()), SIGNAL(availableGesturesChanged())); -} - -QmlSensorGesture::~QmlSensorGesture() -{ -} - -/* - QQmlParserStatus interface implementation -*/ -void QmlSensorGesture::classBegin() -{ -} - -void QmlSensorGesture::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 SensorGesture::availableGestures - This property can be used to determine all available gestures on the system. -*/ -QStringList QmlSensorGesture::availableGestures() -{ - return sensorGestureManager->gestureIds(); -} - -/*! - \qmlproperty stringlist 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 {SensorGesture::availableGestures} {availableGestures} property. - - \sa {QtSensorGestures Plugins} -*/ -QStringList QmlSensorGesture::gestures() const -{ - return gestureList; -} - -void QmlSensorGesture::setGestures(const QStringList& value) -{ - if (gestureList == value) - return; - - if (initDone && enabled()) { - qWarning() << "Cannot change gestures while running."; - return; - } - gestureList = value; - createGesture(); - Q_EMIT gesturesChanged(); -} - - -/*! - \qmlproperty stringlist SensorGesture::validGestures - This property holds the requested gestures that were found on the system. -*/ -QStringList QmlSensorGesture::validGestures() const -{ - if (sensorGesture) - return sensorGesture->validIds(); - return QStringList(); -} - -/*! - \qmlproperty stringlist SensorGesture::invalidGestures - This property holds the requested gestures that were not found on the system. -*/ -QStringList QmlSensorGesture::invalidGestures() const -{ - if (sensorGesture) - return sensorGesture->invalidIds(); - return QStringList(); -} - -/*! - \qmlproperty bool SensorGesture::enabled - This property can be used to activate or deactivate the sensor gesture. - Default value is false; - \sa {SensorGesture::detected}, {detected} -*/ -bool QmlSensorGesture::enabled() const -{ - return isEnabled; -} - -void QmlSensorGesture::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 SensorGesture::detected(string gesture) - This signal is emitted whenever a gesture is detected. - The \a gesture parameter contains the gesture that was detected. - - The corresponding handler is \c onDetected. -*/ - -/* - private function implementation -*/ -void QmlSensorGesture::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 QmlSensorGesture::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 function implementation -*/ - -QT_END_NAMESPACE diff --git a/src/imports/sensors/qmlsensorgesture.h b/src/imports/sensors/qmlsensorgesture.h deleted file mode 100644 index 7cd4acaa..00000000 --- a/src/imports/sensors/qmlsensorgesture.h +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLSENSORGESTURE_H -#define QMLSENSORGESTURE_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class QSensorGesture; -class QSensorGestureManager; - -class QmlSensorGesture : 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 QmlSensorGesture(QObject* parent = 0); - ~QmlSensorGesture(); - void classBegin() override; - void componentComplete() 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 - -#endif diff --git a/src/imports/sensors/qmlsensorglobal.cpp b/src/imports/sensors/qmlsensorglobal.cpp deleted file mode 100644 index c2a67e85..00000000 --- a/src/imports/sensors/qmlsensorglobal.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmlsensorglobal.h" -#include - -QT_BEGIN_NAMESPACE - -/*! - \qmltype QmlSensors - \instantiates QmlSensorGlobal - \inqmlmodule QtSensors - \since QtSensors 5.0 - \brief The QmlSensors singleton provides the module API. - - The QmlSensors singleton provides the module API. - - This element cannot be directly created. It can only be accessed via a namespace import. - - \code - import QtSensors 5.11 - import QtSensors 5.11 as Sensors - ... - Component.onCompleted: { - var types = Sensors.QmlSensors.sensorTypes(); - console.log(types.join(", ")); - } - \endcode -*/ - -QmlSensorGlobal::QmlSensorGlobal(QObject *parent) - : QObject(parent) - , m_sensor(new QSensor(QByteArray(), this)) -{ - connect(m_sensor, SIGNAL(availableSensorsChanged()), this, SIGNAL(availableSensorsChanged())); -} - -QmlSensorGlobal::~QmlSensorGlobal() -{ -} - -/*! - \qmlmethod list QmlSensors::sensorTypes() - Returns a list of the sensor types that have been registered. - - Please see QSensor::sensorTypes() for information. -*/ -QStringList QmlSensorGlobal::sensorTypes() const -{ - QStringList ret; - const QList sensorTypes = QSensor::sensorTypes(); - ret.reserve(sensorTypes.count()); - foreach (const QByteArray &type, sensorTypes) - ret << QString::fromLocal8Bit(type); - return ret; -} - -/*! - \qmlmethod list QmlSensors::sensorsForType(type) - Returns a list of the sensor identifiers that have been registered for \a type. - - Please see QSensor::sensorsForType() for information. -*/ -QStringList QmlSensorGlobal::sensorsForType(const QString &type) const -{ - QStringList ret; - const QList sensors = QSensor::sensorsForType(type.toLocal8Bit()); - ret.reserve(sensors.count()); - foreach (const QByteArray &identifier, sensors) - ret << QString::fromLocal8Bit(identifier); - return ret; -} - -/*! - \qmlmethod string QmlSensors::defaultSensorForType(type) - Returns the default sensor identifier that has been registered for \a type. - - Please see QSensor::defaultSensorForType() for information. -*/ -QString QmlSensorGlobal::defaultSensorForType(const QString &type) const -{ - return QString::fromLocal8Bit(QSensor::defaultSensorForType(type.toLocal8Bit())); -} - -QT_END_NAMESPACE diff --git a/src/imports/sensors/qmlsensorglobal.h b/src/imports/sensors/qmlsensorglobal.h deleted file mode 100644 index b6524cd2..00000000 --- a/src/imports/sensors/qmlsensorglobal.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLSENSORGLOBAL_H -#define QMLSENSORGLOBAL_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class QSensor; - -class QmlSensorGlobal : public QObject -{ - Q_OBJECT -public: - explicit QmlSensorGlobal(QObject *parent = 0); - ~QmlSensorGlobal(); - - Q_INVOKABLE QStringList sensorTypes() const; - Q_INVOKABLE QStringList sensorsForType(const QString &type) const; - Q_INVOKABLE QString defaultSensorForType(const QString &type) const; - -Q_SIGNALS: - void availableSensorsChanged(); - -private: - QSensor *m_sensor; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/imports/sensors/qmlsensorrange.cpp b/src/imports/sensors/qmlsensorrange.cpp deleted file mode 100644 index 128f4a65..00000000 --- a/src/imports/sensors/qmlsensorrange.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmlsensorrange.h" - -QmlSensorRange::QmlSensorRange(QObject *parent) - : QObject(parent), - min(0), - max(0) -{ -} - -QmlSensorRange::~QmlSensorRange() -{ -} - -int QmlSensorRange::minimum() const -{ - return min; -} - -int QmlSensorRange::maximum() const -{ - return max; -} - -QmlSensorOutputRange::QmlSensorOutputRange(QObject *parent) - : QObject(parent), - min(0), - max(0), - acc(0) -{ -} - -QmlSensorOutputRange::~QmlSensorOutputRange() -{ -} - -qreal QmlSensorOutputRange::minimum() const -{ - return min; -} - -qreal QmlSensorOutputRange::maximum() const -{ - return max; -} - -qreal QmlSensorOutputRange::accuracy() const -{ - return acc; -} diff --git a/src/imports/sensors/qmlsensorrange.h b/src/imports/sensors/qmlsensorrange.h deleted file mode 100644 index 4c638f6f..00000000 --- a/src/imports/sensors/qmlsensorrange.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLSENSORRANGE_H -#define QMLSENSORRANGE_H - -#include - -QT_BEGIN_NAMESPACE - -class QmlSensorRange : public QObject -{ - Q_OBJECT - Q_PROPERTY(int minimum READ minimum) - Q_PROPERTY(int maximum READ maximum) -public: - explicit QmlSensorRange(QObject *parent = 0); - ~QmlSensorRange(); - - int minimum() const; - void setMinumum(int mini) { min = mini; } - - int maximum() const; - void setMaximum(int maxi) { max = maxi; } - -private: - - int min; - int max; -}; - -class QmlSensorOutputRange : public QObject -{ - Q_OBJECT - Q_PROPERTY(qreal minimum READ minimum) - Q_PROPERTY(qreal maximum READ maximum) - Q_PROPERTY(qreal accuracy READ accuracy) -public: - explicit QmlSensorOutputRange(QObject *parent = 0); - ~QmlSensorOutputRange(); - - qreal minimum() const; - void setMinimum(int mini) { min = mini; } - - qreal maximum() const; - void setMaximum(int maxi) { max = maxi; } - - qreal accuracy() const; - void setAccuracy(int accu) { acc = accu; } - -private: - qreal min; - qreal max; - qreal acc; -}; - -QT_END_NAMESPACE -#endif diff --git a/src/imports/sensors/qmltapsensor.cpp b/src/imports/sensors/qmltapsensor.cpp deleted file mode 100644 index 76f34c2e..00000000 --- a/src/imports/sensors/qmltapsensor.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmltapsensor.h" -#include - -/*! - \qmltype TapSensor - \instantiates QmlTapSensor - \ingroup qml-sensors_type - \inqmlmodule QtSensors - \since QtSensors 5.0 - \inherits Sensor - \brief The TapSensor element reports tap and double tap events - along the X, Y and Z axes. - - The TapSensor element reports tap and double tap events - along the X, Y and Z axes. - - This element wraps the QTapSensor class. Please see the documentation for - QTapSensor for details. - - \sa TapReading -*/ - -QmlTapSensor::QmlTapSensor(QObject *parent) - : QmlSensor(parent) - , m_sensor(new QTapSensor(this)) -{ - connect(m_sensor, SIGNAL(returnDoubleTapEventsChanged(bool)), - this, SIGNAL(returnDoubleTapEventsChanged(bool))); -} - -QmlTapSensor::~QmlTapSensor() -{ -} - -QmlSensorReading *QmlTapSensor::createReading() const -{ - return new QmlTapSensorReading(m_sensor); -} - -QSensor *QmlTapSensor::sensor() const -{ - return m_sensor; -} - -/*! - \qmlproperty bool TapSensor::returnDoubleTapEvents - This property holds a value indicating if double tap events should be reported. - - Please see QTapSensor::returnDoubleTapEvents for information about this property. -*/ - -bool QmlTapSensor::returnDoubleTapEvents() const -{ - return m_sensor->returnDoubleTapEvents(); -} - -void QmlTapSensor::setReturnDoubleTapEvents(bool ret) -{ - m_sensor->setReturnDoubleTapEvents(ret); -} - -/*! - \qmltype TapReading - \instantiates QmlTapSensorReading - \ingroup qml-sensors_reading - \inqmlmodule QtSensors - \since QtSensors 5.0 - \inherits SensorReading - \brief The TapReading element holds the most recent TapSensor reading. - - The TapReading element holds the most recent TapSensor reading. - - This element wraps the QTapReading class. Please see the documentation for - QTapReading for details. - - This element cannot be directly created. -*/ - -QmlTapSensorReading::QmlTapSensorReading(QTapSensor *sensor) - : QmlSensorReading(sensor) - , m_sensor(sensor) -{ -} - -QmlTapSensorReading::~QmlTapSensorReading() -{ -} - -/*! - \qmlproperty TapDirection TapReading::tapDirection - This property holds the direction of the tap. - - Please see QTapReading::tapDirection for information about this property. - - Note that TapDirection constants are exposed through the TapReading class. - \code - TapSensor { - onReadingChanged: { - if ((reading.tapDirection & TapReading.X_Both)) - // do something - } - } - \endcode -*/ - -QTapReading::TapDirection QmlTapSensorReading::tapDirection() const -{ - return m_tapDirection; -} - -/*! - \qmlproperty bool TapReading::doubleTap - This property holds a value indicating if there was a single or double tap. - - Please see QTapReading::doubleTap for information about this property. -*/ - -bool QmlTapSensorReading::isDoubleTap() const -{ - return m_isDoubleTap; -} - -QSensorReading *QmlTapSensorReading::reading() const -{ - return const_cast(m_sensor)->reading(); -} - -void QmlTapSensorReading::readingUpdate() -{ - QTapReading::TapDirection td = m_sensor->reading()->tapDirection(); - if (m_tapDirection != td) { - m_tapDirection = td; - Q_EMIT tapDirectionChanged(); - } - bool dTap = m_sensor->reading()->isDoubleTap(); - if (m_isDoubleTap != dTap) { - m_isDoubleTap = dTap; - Q_EMIT isDoubleTapChanged(); - } -} diff --git a/src/imports/sensors/qmltapsensor.h b/src/imports/sensors/qmltapsensor.h deleted file mode 100644 index 260cb2c2..00000000 --- a/src/imports/sensors/qmltapsensor.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLTAPSENSOR_H -#define QMLTAPSENSOR_H - -#include "qmlsensor.h" -#include - -QT_BEGIN_NAMESPACE - -class QTapSensor; - -class QmlTapSensor : public QmlSensor -{ - Q_OBJECT - Q_PROPERTY(bool returnDoubleTapEvents READ returnDoubleTapEvents WRITE setReturnDoubleTapEvents NOTIFY returnDoubleTapEventsChanged) -public: - explicit QmlTapSensor(QObject *parent = 0); - ~QmlTapSensor(); - - bool returnDoubleTapEvents() const; - void setReturnDoubleTapEvents(bool ret); - -Q_SIGNALS: - void returnDoubleTapEventsChanged(bool returnDoubleTapEvents); - -private: - QSensor *sensor() const override; - QTapSensor *m_sensor; - QmlSensorReading *createReading() const override; -}; - -class QmlTapSensorReading : public QmlSensorReading -{ - Q_OBJECT - Q_PROPERTY(QTapReading::TapDirection tapDirection READ tapDirection NOTIFY tapDirectionChanged) - Q_PROPERTY(bool doubleTap READ isDoubleTap NOTIFY isDoubleTapChanged) -public: - - explicit QmlTapSensorReading(QTapSensor *sensor); - ~QmlTapSensorReading(); - - QTapReading::TapDirection tapDirection() const; - bool isDoubleTap() const; - -Q_SIGNALS: - void tapDirectionChanged(); - void isDoubleTapChanged(); - -private: - QSensorReading *reading() const override; - void readingUpdate() override; - QTapSensor *m_sensor; - QTapReading::TapDirection m_tapDirection; - bool m_isDoubleTap; -}; - -QT_END_NAMESPACE -#endif diff --git a/src/imports/sensors/qmltiltsensor.cpp b/src/imports/sensors/qmltiltsensor.cpp deleted file mode 100644 index 6129a5c9..00000000 --- a/src/imports/sensors/qmltiltsensor.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmltiltsensor.h" -#include - -QT_BEGIN_NAMESPACE -QT_END_NAMESPACE - -/*! - \qmltype TiltSensor - \instantiates QmlTiltSensor - \ingroup qml-sensors_type - \inqmlmodule QtSensors - \since QtSensors 5.0 - \inherits Sensor - \brief The TiltSensor element reports tilt events - along the X and Y axes. - - The TiltSensor element reports tilt events along the X and Y axes. - - This element wraps the QTiltSensor class. Please see the documentation for - QTiltSensor for details. - - \sa TiltReading -*/ - -QmlTiltSensor::QmlTiltSensor(QObject *parent) - : QmlSensor(parent) - , m_sensor(new QTiltSensor(this)) -{ -} - -QmlTiltSensor::~QmlTiltSensor() -{ -} - -QmlSensorReading *QmlTiltSensor::createReading() const -{ - return new QmlTiltSensorReading(m_sensor); -} - -QSensor *QmlTiltSensor::sensor() const -{ - return m_sensor; -} - -/*! - \qmlmethod TiltSensor::calibrate() - Calibrate the tilt sensor. - - Please see QTiltSensor::calibrate() for information about this property. -*/ -void QmlTiltSensor::calibrate() -{ - m_sensor->calibrate(); -} - -/*! - \qmltype TiltReading - \instantiates QmlTiltSensorReading - \ingroup qml-sensors_reading - \inqmlmodule QtSensors - \since QtSensors 5.0 - \inherits SensorReading - \brief The TiltReading element holds the most recent TiltSensor reading. - - The TiltReading element holds the most recent TiltSensor reading. - - This element wraps the QTiltReading class. Please see the documentation for - QTiltReading for details. - - This element cannot be directly created. -*/ - -QmlTiltSensorReading::QmlTiltSensorReading(QTiltSensor *sensor) - : QmlSensorReading(sensor) - , m_sensor(sensor) -{ -} - -QmlTiltSensorReading::~QmlTiltSensorReading() -{ -} - -/*! - \qmlproperty qreal TiltReading::yRotation - This property holds the amount of tilt on the Y axis. - - Please see QTiltReading::yRotation for information about this property. -*/ - -qreal QmlTiltSensorReading::yRotation() const -{ - return m_yRotation; -} - -/*! - \qmlproperty qreal TiltReading::xRotation - This property holds the amount of tilt on the X axis. - - Please see QTiltReading::xRotation for information about this property. -*/ - -qreal QmlTiltSensorReading::xRotation() const -{ - return m_xRotation; -} - -QSensorReading *QmlTiltSensorReading::reading() const -{ - return m_sensor->reading(); -} - -void QmlTiltSensorReading::readingUpdate() -{ - qreal tiltY = m_sensor->reading()->yRotation(); - if (m_yRotation != tiltY) { - m_yRotation = tiltY; - Q_EMIT yRotationChanged(); - } - qreal tiltX = m_sensor->reading()->xRotation(); - if (m_xRotation != tiltX) { - m_xRotation = tiltX; - Q_EMIT xRotationChanged(); - } -} diff --git a/src/imports/sensors/qmltiltsensor.h b/src/imports/sensors/qmltiltsensor.h deleted file mode 100644 index c922cb8c..00000000 --- a/src/imports/sensors/qmltiltsensor.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLTILTSENSOR_H -#define QMLTILTSENSOR_H - -#include "qmlsensor.h" -#include - -QT_BEGIN_NAMESPACE - -class QTiltSensor; - -class QmlTiltSensor : public QmlSensor -{ - Q_OBJECT -public: - - explicit QmlTiltSensor(QObject *parent = 0); - ~QmlTiltSensor(); - Q_INVOKABLE void calibrate(); - -private: - QSensor *sensor() const override; - QTiltSensor *m_sensor; - QmlSensorReading *createReading() const override; -}; - -class QmlTiltSensorReading : public QmlSensorReading -{ - Q_OBJECT - Q_PROPERTY(qreal yRotation READ yRotation NOTIFY yRotationChanged) - Q_PROPERTY(qreal xRotation READ xRotation NOTIFY xRotationChanged) -public: - explicit QmlTiltSensorReading(QTiltSensor *sensor); - ~QmlTiltSensorReading(); - - qreal yRotation() const; - qreal xRotation() const; - -Q_SIGNALS: - void yRotationChanged(); - void xRotationChanged(); - -private: - QSensorReading *reading() const override; - void readingUpdate() override; - QTiltSensor *m_sensor; - qreal m_yRotation; - qreal m_xRotation; -}; - -QT_END_NAMESPACE -#endif diff --git a/src/imports/sensors/sensors.cpp b/src/imports/sensors/sensors.cpp index de872c48..3244707b 100644 --- a/src/imports/sensors/sensors.cpp +++ b/src/imports/sensors/sensors.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtSensors module of the Qt Toolkit. @@ -37,206 +37,24 @@ ** ****************************************************************************/ +#include #include #include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "qmlsensorglobal.h" -#include "qmlsensor.h" -#include "qmlaccelerometer.h" -#include "qmlaltimeter.h" -#include "qmlambientlightsensor.h" -#include "qmlambienttemperaturesensor.h" -#include "qmlcompass.h" -#include "qmldistancesensor.h" -#include "qmlgyroscope.h" -#include "qmlholstersensor.h" -#include "qmlhumiditysensor.h" -#include "qmlirproximitysensor.h" -#include "qmllightsensor.h" -#include "qmlmagnetometer.h" -#include "qmlorientationsensor.h" -#include "qmlpressuresensor.h" -#include "qmlproximitysensor.h" -#include "qmlrotationsensor.h" -#include "qmltapsensor.h" -#include "qmltiltsensor.h" -#include "qmlsensorgesture.h" -#include "qmllidsensor.h" QT_BEGIN_NAMESPACE -static QObject *global_object_50(QQmlEngine *, QJSEngine *) -{ - return new QmlSensorGlobal; -} - -class QtSensorsDeclarativeModule : public QQmlExtensionPlugin +class QSensorsQuickPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid FILE "plugin.json") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) + public: - QtSensorsDeclarativeModule(QObject *parent = 0) : QQmlExtensionPlugin(parent) { } - void registerTypes(const char *uri) override + QSensorsQuickPlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { } + void registerTypes(const char *) override { - char const * const package = "QtSensors"; - if (QLatin1String(uri) != QLatin1String(package)) return; - int major; - int minor; - - // Register the 5.0 interfaces - major = 5; - minor = 0; - qmlRegisterSingletonType (package, major, minor, "QmlSensors", global_object_50); - qmlRegisterUncreatableType(package, major, minor, "Range", QLatin1String("Cannot create Range")); - qmlRegisterUncreatableType(package, major, minor, "OutputRange", QLatin1String("Cannot create OutputRange")); - qmlRegisterUncreatableType(package, major, minor, "Sensor", QLatin1String("Cannot create Sensor")); - qmlRegisterUncreatableType(package, major, minor, "SensorReading", QLatin1String("Cannot create SensorReading")); - qmlRegisterType (package, major, minor, "Accelerometer"); - qmlRegisterUncreatableType(package, major, minor, "AccelerometerReading", QLatin1String("Cannot create AccelerometerReading")); - qmlRegisterType (package, major, minor, "AmbientLightSensor"); - qmlRegisterUncreatableType(package, major, minor, "AmbientLightReading", QLatin1String("Cannot create AmbientLightReading")); - qmlRegisterType (package, major, minor, "Compass"); - qmlRegisterUncreatableType(package, major, minor, "CompassReading", QLatin1String("Cannot create CompassReading")); - qmlRegisterType (package, major, minor, "Gyroscope"); - qmlRegisterUncreatableType(package, major, minor, "GyroscopeReading", QLatin1String("Cannot create GyroscopeReading")); - qmlRegisterType (package, major, minor, "IRProximitySensor"); - qmlRegisterUncreatableType(package, major, minor, "IRProximityReading", QLatin1String("Cannot create IRProximityReading")); - qmlRegisterType (package, major, minor, "LightSensor"); - qmlRegisterUncreatableType(package, major, minor, "LightReading", QLatin1String("Cannot create LightReading")); - qmlRegisterType (package, major, minor, "Magnetometer"); - qmlRegisterUncreatableType(package, major, minor, "MagnetometerReading", QLatin1String("Cannot create MagnetometerReading")); - qmlRegisterType (package, major, minor, "OrientationSensor"); - qmlRegisterUncreatableType(package, major, minor, "OrientationReading", QLatin1String("Cannot create OrientationReading")); - qmlRegisterType (package, major, minor, "ProximitySensor"); - qmlRegisterUncreatableType(package, major, minor, "ProximityReading", QLatin1String("Cannot create ProximityReading")); - qmlRegisterType (package, major, minor, "RotationSensor"); - qmlRegisterUncreatableType(package, major, minor, "RotationReading", QLatin1String("Cannot create RotationReading")); - qmlRegisterType (package, major, minor, "TapSensor"); - qmlRegisterUncreatableType(package, major, minor, "TapReading", QLatin1String("Cannot create TapReading")); - qmlRegisterType (package, major, minor, "TiltSensor"); - qmlRegisterUncreatableType(package, major, minor, "TiltReading", QLatin1String("Cannot create TiltReading")); - - qmlRegisterType (package, major, minor, "SensorGesture"); - - // Register the 5.1 interfaces - minor = 1; - qmlRegisterSingletonType (package, major, minor, "QmlSensors", global_object_50); - qmlRegisterUncreatableType(package, major, minor, "Range", QLatin1String("Cannot create Range")); - qmlRegisterUncreatableType(package, major, minor, "OutputRange", QLatin1String("Cannot create OutputRange")); - qmlRegisterUncreatableType(package, major, minor, "Sensor", QLatin1String("Cannot create Sensor")); - qmlRegisterUncreatableType(package, major, minor, "SensorReading", QLatin1String("Cannot create SensorReading")); - qmlRegisterType (package, major, minor, "Accelerometer"); - qmlRegisterUncreatableType(package, major, minor, "AccelerometerReading", QLatin1String("Cannot create AccelerometerReading")); - qmlRegisterType (package, major, minor, "Altimeter"); - qmlRegisterUncreatableType(package, major, minor, "AltimeterReading", QLatin1String("Cannot create AltimeterReading")); - qmlRegisterType (package, major, minor, "AmbientLightSensor"); - qmlRegisterUncreatableType(package, major, minor, "AmbientLightReading", QLatin1String("Cannot create AmbientLightReading")); - qmlRegisterType (package, major, minor, "AmbientTemperatureSensor"); - qmlRegisterUncreatableType(package, major, minor, "AmbientTemperatureReading", QLatin1String("Cannot create AmbientTemperatureReading")); - qmlRegisterType (package, major, minor, "Compass"); - qmlRegisterUncreatableType(package, major, minor, "CompassReading", QLatin1String("Cannot create CompassReading")); - qmlRegisterType (package, major, minor, "Gyroscope"); - qmlRegisterUncreatableType(package, major, minor, "GyroscopeReading", QLatin1String("Cannot create GyroscopeReading")); - qmlRegisterType (package, major, minor, "HolsterSensor"); - qmlRegisterUncreatableType(package, major, minor, "HolsterReading", QLatin1String("Cannot create HolsterReading")); - qmlRegisterType (package, major, minor, "IRProximitySensor"); - qmlRegisterUncreatableType(package, major, minor, "IRProximityReading", QLatin1String("Cannot create IRProximityReading")); - qmlRegisterType (package, major, minor, "LightSensor"); - qmlRegisterUncreatableType(package, major, minor, "LightReading", QLatin1String("Cannot create LightReading")); - qmlRegisterType (package, major, minor, "Magnetometer"); - qmlRegisterUncreatableType(package, major, minor, "MagnetometerReading", QLatin1String("Cannot create MagnetometerReading")); - qmlRegisterType (package, major, minor, "OrientationSensor"); - qmlRegisterUncreatableType(package, major, minor, "OrientationReading", QLatin1String("Cannot create OrientationReading")); - qmlRegisterType (package, major, minor, "PressureSensor"); - qmlRegisterUncreatableType(package, major, minor, "PressureReading", QLatin1String("Cannot create PressureReading")); - qmlRegisterType (package, major, minor, "ProximitySensor"); - qmlRegisterUncreatableType(package, major, minor, "ProximityReading", QLatin1String("Cannot create ProximityReading")); - qmlRegisterType (package, major, minor, "RotationSensor"); - qmlRegisterUncreatableType(package, major, minor, "RotationReading", QLatin1String("Cannot create RotationReading")); - qmlRegisterType (package, major, minor, "TapSensor"); - qmlRegisterUncreatableType(package, major, minor, "TapReading", QLatin1String("Cannot create TapReading")); - qmlRegisterType (package, major, minor, "TiltSensor"); - qmlRegisterUncreatableType(package, major, minor, "TiltReading", QLatin1String("Cannot create TiltReading")); - - qmlRegisterType (package, major, minor, "SensorGesture"); - - // Register the 5.2 interfaces - minor = 2; - qmlRegisterSingletonType (package, major, minor, "QmlSensors", global_object_50); - qmlRegisterUncreatableType(package, major, minor, "Range", QLatin1String("Cannot create Range")); - qmlRegisterUncreatableType(package, major, minor, "OutputRange", QLatin1String("Cannot create OutputRange")); - qmlRegisterUncreatableType(package, major, minor, "Sensor", QLatin1String("Cannot create Sensor")); - qmlRegisterUncreatableType(package, major, minor, "SensorReading", QLatin1String("Cannot create SensorReading")); - qmlRegisterType (package, major, minor, "Accelerometer"); - qmlRegisterUncreatableType(package, major, minor, "AccelerometerReading", QLatin1String("Cannot create AccelerometerReading")); - qmlRegisterType (package, major, minor, "Altimeter"); - qmlRegisterUncreatableType(package, major, minor, "AltimeterReading", QLatin1String("Cannot create AltimeterReading")); - qmlRegisterType (package, major, minor, "AmbientLightSensor"); - qmlRegisterUncreatableType(package, major, minor, "AmbientLightReading", QLatin1String("Cannot create AmbientLightReading")); - qmlRegisterType (package, major, minor, "AmbientTemperatureSensor"); - qmlRegisterUncreatableType(package, major, minor, "AmbientTemperatureReading", QLatin1String("Cannot create AmbientTemperatureReading")); - qmlRegisterType (package, major, minor, "Compass"); - qmlRegisterUncreatableType(package, major, minor, "CompassReading", QLatin1String("Cannot create CompassReading")); - qmlRegisterType (package, major, minor, "Gyroscope"); - qmlRegisterUncreatableType(package, major, minor, "GyroscopeReading", QLatin1String("Cannot create GyroscopeReading")); - qmlRegisterType (package, major, minor, "HolsterSensor"); - qmlRegisterUncreatableType(package, major, minor, "HolsterReading", QLatin1String("Cannot create HolsterReading")); - qmlRegisterType (package, major, minor, "IRProximitySensor"); - qmlRegisterUncreatableType(package, major, minor, "IRProximityReading", QLatin1String("Cannot create IRProximityReading")); - qmlRegisterType (package, major, minor, "LightSensor"); - qmlRegisterUncreatableType(package, major, minor, "LightReading", QLatin1String("Cannot create LightReading")); - qmlRegisterType (package, major, minor, "Magnetometer"); - qmlRegisterUncreatableType(package, major, minor, "MagnetometerReading", QLatin1String("Cannot create MagnetometerReading")); - qmlRegisterType (package, major, minor, "OrientationSensor"); - qmlRegisterUncreatableType(package, major, minor, "OrientationReading", QLatin1String("Cannot create OrientationReading")); - qmlRegisterType (package, major, minor, "PressureSensor"); - qmlRegisterUncreatableType(package, major, minor, "PressureReading", QLatin1String("Cannot create PressureReading")); - qmlRegisterType (package, major, minor, "ProximitySensor"); - qmlRegisterUncreatableType(package, major, minor, "ProximityReading", QLatin1String("Cannot create ProximityReading")); - qmlRegisterType (package, major, minor, "RotationSensor"); - qmlRegisterUncreatableType(package, major, minor, "RotationReading", QLatin1String("Cannot create RotationReading")); - qmlRegisterType (package, major, minor, "TapSensor"); - qmlRegisterUncreatableType(package, major, minor, "TapReading", QLatin1String("Cannot create TapReading")); - qmlRegisterType (package, major, minor, "TiltSensor"); - qmlRegisterUncreatableType(package, major, minor, "TiltReading", QLatin1String("Cannot create TiltReading")); - - qmlRegisterType (package, major, minor, "SensorGesture"); - - // Register the 5.4 interfaces - minor = 4; - qmlRegisterType (package, major, minor, "DistanceSensor"); - qmlRegisterUncreatableType(package, major, minor, "DistanceReading", QLatin1String("Cannot create DistanceReading")); - - // Register the new 5.9 interfaces - // Implicitly registers 5.3 - 5.8 too - minor = 9; - qmlRegisterType (package, major, minor, "LidSensor"); - qmlRegisterUncreatableType(package, major, minor, "LidReading", QLatin1String("Cannot create LidReading")); - qmlRegisterType (package, major, minor, "HumiditySensor"); - qmlRegisterUncreatableType(package, major, minor, "HumidityReading", QLatin1String("Cannot create HumidityReading")); - - // The minor version used to be the current Qt 5 minor. For compatibility it is the last - // Qt 5 release. - qmlRegisterModule(package, 5, 15); + // Build-time generated registration function + volatile auto registration = &qml_register_types_QtSensors; + Q_UNUSED(registration); } }; diff --git a/src/sensorsquick/CMakeLists.txt b/src/sensorsquick/CMakeLists.txt new file mode 100644 index 00000000..703974e1 --- /dev/null +++ b/src/sensorsquick/CMakeLists.txt @@ -0,0 +1,45 @@ +qt_internal_add_module(SensorsQuick + SOURCES + qmlaccelerometer.cpp qmlaccelerometer_p.h + qmlaltimeter.cpp qmlaltimeter_p.h + qmlambientlightsensor.cpp qmlambientlightsensor_p.h + qmlambienttemperaturesensor.cpp qmlambienttemperaturesensor_p.h + qmlcompass.cpp qmlcompass_p.h + qmldistancesensor.cpp qmldistancesensor_p.h + qmlgyroscope.cpp qmlgyroscope_p.h + qmlholstersensor.cpp qmlholstersensor_p.h + qmlhumiditysensor.cpp qmlhumiditysensor_p.h + qmlirproximitysensor.cpp qmlirproximitysensor_p.h + qmllidsensor.cpp qmllidsensor_p.h + qmllightsensor.cpp qmllightsensor_p.h + qmlmagnetometer.cpp qmlmagnetometer_p.h + qmlorientationsensor.cpp qmlorientationsensor_p.h + qmlpressuresensor.cpp qmlpressuresensor_p.h + qmlproximitysensor.cpp qmlproximitysensor_p.h + qmlrotationsensor.cpp qmlrotationsensor_p.h + qmlsensor.cpp qmlsensor_p.h + qmlsensorgesture.cpp qmlsensorgesture_p.h + qmlsensorglobal.cpp qmlsensorglobal_p.h + qmlsensorrange.cpp qmlsensorrange_p.h + qmltapsensor.cpp qmltapsensor_p.h + qmltiltsensor.cpp qmltiltsensor_p.h + qsensorsquickglobal_p.h + DEFINES + QT_BUILD_SENSORSQUICK_LIB + PUBLIC_LIBRARIES + Qt::Core + Qt::Qml + Qt::Sensors + LIBRARIES + Qt::CorePrivate +) + +set_target_properties(SensorsQuick PROPERTIES + QT_QML_MODULE_INSTALL_QMLTYPES TRUE + QT_QML_MODULE_VERSION ${PROJECT_VERSION} + QT_QML_MODULE_URI QtSensors + QT_QMLTYPES_FILENAME plugins.qmltypes + QT_QML_MODULE_INSTALL_DIR "${INSTALL_QMLDIR}/QtSensors" +) + +qt6_qml_type_registration(SensorsQuick) diff --git a/src/sensorsquick/qmlaccelerometer.cpp b/src/sensorsquick/qmlaccelerometer.cpp new file mode 100644 index 00000000..fc013837 --- /dev/null +++ b/src/sensorsquick/qmlaccelerometer.cpp @@ -0,0 +1,188 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmlaccelerometer_p.h" +#include + +/*! + \qmltype Accelerometer + \instantiates QmlAccelerometer + \ingroup qml-sensors_type + \inqmlmodule QtSensors + \since QtSensors 5.0 + \inherits Sensor + \brief The Accelerometer element reports on linear acceleration + along the X, Y and Z axes. + + The Accelerometer element reports on linear acceleration + along the X, Y and Z axes. + + This element wraps the QAccelerometer class. Please see the documentation for + QAccelerometer for details. + + \sa AccelerometerReading +*/ + +QmlAccelerometer::QmlAccelerometer(QObject *parent) + : QmlSensor(parent) + , m_sensor(new QAccelerometer(this)) +{ + connect(m_sensor, SIGNAL(accelerationModeChanged(AccelerationMode)), + this, SIGNAL(accelerationModeChanged(AccelerationMode))); +} + +QmlAccelerometer::~QmlAccelerometer() +{ +} + +/*! + \qmlproperty AccelerationMode Accelerometer::accelerationMode + \since QtSensors 5.1 + + This property holds the current acceleration mode. + + Please see QAccelerometer::accelerationMode for information about this property. +*/ + +QmlAccelerometer::AccelerationMode QmlAccelerometer::accelerationMode() const +{ + return static_cast(m_sensor->accelerationMode()); +} + +void QmlAccelerometer::setAccelerationMode(QmlAccelerometer::AccelerationMode accelerationMode) +{ + m_sensor->setAccelerationMode(static_cast(accelerationMode)); +} + +QmlSensorReading *QmlAccelerometer::createReading() const +{ + return new QmlAccelerometerReading(m_sensor); +} + +QSensor *QmlAccelerometer::sensor() const +{ + return m_sensor; +} + +/*! + \qmltype AccelerometerReading + \instantiates QmlAccelerometerReading + \ingroup qml-sensors_reading + \inqmlmodule QtSensors + \since QtSensors 5.0 + \inherits SensorReading + \brief The AccelerometerReading element holds the most recent Accelerometer reading. + + The AccelerometerReading element holds the most recent Accelerometer reading. + + This element wraps the QAccelerometerReading class. Please see the documentation for + QAccelerometerReading for details. + + This element cannot be directly created. +*/ + +QmlAccelerometerReading::QmlAccelerometerReading(QAccelerometer *sensor) + : QmlSensorReading(sensor) + , m_sensor(sensor) +{ +} + +QmlAccelerometerReading::~QmlAccelerometerReading() +{ +} + +/*! + \qmlproperty qreal AccelerometerReading::x + This property holds the acceleration on the X axis. + + Please see QAccelerometerReading::x for information about this property. +*/ + +qreal QmlAccelerometerReading::x() const +{ + return m_x; +} + +/*! + \qmlproperty qreal AccelerometerReading::y + This property holds the acceleration on the Y axis. + + Please see QAccelerometerReading::y for information about this property. +*/ + +qreal QmlAccelerometerReading::y() const +{ + return m_y; +} + +/*! + \qmlproperty qreal AccelerometerReading::z + This property holds the acceleration on the Z axis. + + Please see QAccelerometerReading::z for information about this property. +*/ + +qreal QmlAccelerometerReading::z() const +{ + return m_z; +} + +QSensorReading *QmlAccelerometerReading::reading() const +{ + return m_sensor->reading(); +} + +void QmlAccelerometerReading::readingUpdate() +{ + qreal aX = m_sensor->reading()->x(); + if (m_x != aX) { + m_x = aX; + Q_EMIT xChanged(); + } + qreal aY = m_sensor->reading()->y(); + if (m_y != aY) { + m_y = aY; + Q_EMIT yChanged(); + } + qreal aZ = m_sensor->reading()->z(); + if (m_z != aZ) { + m_z = aZ; + Q_EMIT zChanged(); + } +} diff --git a/src/sensorsquick/qmlaccelerometer_p.h b/src/sensorsquick/qmlaccelerometer_p.h new file mode 100644 index 00000000..9dcb2692 --- /dev/null +++ b/src/sensorsquick/qmlaccelerometer_p.h @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLACCELEROMETER_P_H +#define QMLACCELEROMETER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qmlsensor_p.h" + +QT_BEGIN_NAMESPACE + +class QAccelerometer; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlAccelerometer : public QmlSensor +{ + Q_OBJECT + Q_ENUMS(AccelerationMode) + Q_PROPERTY(AccelerationMode accelerationMode READ accelerationMode WRITE setAccelerationMode + NOTIFY accelerationModeChanged REVISION 1) + QML_NAMED_ELEMENT(Accelerometer) + QML_ADDED_IN_VERSION(5,0) +public: + explicit QmlAccelerometer(QObject *parent = 0); + ~QmlAccelerometer(); + + // Keep this enum in sync with QAccelerometer::AccelerationMode + enum AccelerationMode { + Combined, + Gravity, + User + }; + + AccelerationMode accelerationMode() const; + void setAccelerationMode(AccelerationMode accelerationMode); + +signals: + Q_REVISION(1) void accelerationModeChanged(AccelerationMode accelerationMode); + +private: + QSensor *sensor() const override; + QAccelerometer *m_sensor; + QmlSensorReading *createReading() const override; +}; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlAccelerometerReading : public QmlSensorReading +{ + Q_OBJECT + Q_PROPERTY(qreal x READ x NOTIFY xChanged) + Q_PROPERTY(qreal y READ y NOTIFY yChanged) + Q_PROPERTY(qreal z READ z NOTIFY zChanged) + QML_NAMED_ELEMENT(AccelerometerReading) + QML_UNCREATABLE("Cannot create AccelerometerReading") + QML_ADDED_IN_VERSION(5,0) +public: + explicit QmlAccelerometerReading(QAccelerometer *sensor); + ~QmlAccelerometerReading(); + + qreal x() const; + qreal y() const; + qreal z() const; + +Q_SIGNALS: + void xChanged(); + void yChanged(); + void zChanged(); + +private: + QSensorReading *reading() const override; + void readingUpdate() override; + QAccelerometer *m_sensor; + qreal m_x; + qreal m_y; + qreal m_z; +}; + +QT_END_NAMESPACE +#endif diff --git a/src/sensorsquick/qmlaltimeter.cpp b/src/sensorsquick/qmlaltimeter.cpp new file mode 100644 index 00000000..8ee3ccde --- /dev/null +++ b/src/sensorsquick/qmlaltimeter.cpp @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Research In Motion +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qmlaltimeter_p.h" +#include + +/*! + \qmltype Altimeter + \instantiates QmlAltimeter + \ingroup qml-sensors_type + \inqmlmodule QtSensors + \since QtSensors 5.1 + \inherits Sensor + \brief The Altimeter element reports on altitude. + + The Altimeter element reports on altitude. + + This element wraps the QAltimeter class. Please see the documentation for + QAltimeter for details. + + \sa AltimeterReading +*/ + +QmlAltimeter::QmlAltimeter(QObject *parent) + : QmlSensor(parent) + , m_sensor(new QAltimeter(this)) +{ +} + +QmlAltimeter::~QmlAltimeter() +{ +} + +QmlSensorReading *QmlAltimeter::createReading() const +{ + return new QmlAltimeterReading(m_sensor); +} + +QSensor *QmlAltimeter::sensor() const +{ + return m_sensor; +} + +/*! + \qmltype AltimeterReading + \instantiates QmlAltimeterReading + \ingroup qml-sensors_reading + \inqmlmodule QtSensors + \since QtSensors 5.1 + \inherits SensorReading + \brief The AltimeterReading element holds the most recent Altimeter reading. + + The AltimeterReading element holds the most recent Altimeter reading. + + This element wraps the QAltimeterReading class. Please see the documentation for + QAltimeterReading for details. + + This element cannot be directly created. +*/ + +QmlAltimeterReading::QmlAltimeterReading(QAltimeter *sensor) + : QmlSensorReading(sensor) + , m_sensor(sensor) + , m_altitude(0) +{ +} + +QmlAltimeterReading::~QmlAltimeterReading() +{ +} + +/*! + \qmlproperty qreal AltimeterReading::altitude + This property holds the altitude of the device. + + Please see QAltimeterReading::altitude for information about this property. +*/ + +qreal QmlAltimeterReading::altitude() const +{ + return m_altitude; +} + +QSensorReading *QmlAltimeterReading::reading() const +{ + return m_sensor->reading(); +} + +void QmlAltimeterReading::readingUpdate() +{ + qreal altitude = m_sensor->reading()->altitude(); + if (m_altitude != altitude) { + m_altitude = altitude; + Q_EMIT altitudeChanged(); + } +} diff --git a/src/sensorsquick/qmlaltimeter_p.h b/src/sensorsquick/qmlaltimeter_p.h new file mode 100644 index 00000000..322fbdfb --- /dev/null +++ b/src/sensorsquick/qmlaltimeter_p.h @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Research In Motion +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QMLALTIMETER_P_H +#define QMLALTIMETER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qmlsensor_p.h" + +QT_BEGIN_NAMESPACE + +class QAltimeter; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlAltimeter : public QmlSensor +{ + Q_OBJECT + QML_NAMED_ELEMENT(Altimeter) + QML_ADDED_IN_VERSION(5,1) +public: + explicit QmlAltimeter(QObject *parent = 0); + ~QmlAltimeter(); + +private: + QSensor *sensor() const override; + QmlSensorReading *createReading() const override; + + QAltimeter *m_sensor; +}; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlAltimeterReading : public QmlSensorReading +{ + Q_OBJECT + Q_PROPERTY(qreal altitude READ altitude NOTIFY altitudeChanged) + QML_NAMED_ELEMENT(AltimeterReading) + QML_UNCREATABLE("Cannot create AltimeterReading") + QML_ADDED_IN_VERSION(5,1) +public: + explicit QmlAltimeterReading(QAltimeter *sensor); + ~QmlAltimeterReading(); + + qreal altitude() const; + +Q_SIGNALS: + void altitudeChanged(); + +private: + QSensorReading *reading() const override; + void readingUpdate() override; + + QAltimeter *m_sensor; + qreal m_altitude; +}; + +QT_END_NAMESPACE +#endif diff --git a/src/sensorsquick/qmlambientlightsensor.cpp b/src/sensorsquick/qmlambientlightsensor.cpp new file mode 100644 index 00000000..a114f8b3 --- /dev/null +++ b/src/sensorsquick/qmlambientlightsensor.cpp @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmlambientlightsensor_p.h" +#include + +/*! + \qmltype AmbientLightSensor + \instantiates QmlAmbientLightSensor + \ingroup qml-sensors_type + \inqmlmodule QtSensors + \since QtSensors 5.0 + \inherits Sensor + \brief The AmbientLightSensor element repors on ambient lighting conditions. + + The AmbientLightSensor element repors on ambient lighting conditions. + + This element wraps the QAmbientLightSensor class. Please see the documentation for + QAmbientLightSensor for details. + + \sa AmbientLightReading +*/ + +QmlAmbientLightSensor::QmlAmbientLightSensor(QObject *parent) + : QmlSensor(parent) + , m_sensor(new QAmbientLightSensor(this)) +{ +} + +QmlAmbientLightSensor::~QmlAmbientLightSensor() +{ +} + +QmlSensorReading *QmlAmbientLightSensor::createReading() const +{ + return new QmlAmbientLightSensorReading(m_sensor); +} + +QSensor *QmlAmbientLightSensor::sensor() const +{ + return m_sensor; +} + +/*! + \qmltype AmbientLightReading + \instantiates QmlAmbientLightSensorReading + \ingroup qml-sensors_reading + \inqmlmodule QtSensors + \since QtSensors 5.0 + \inherits SensorReading + \brief The AmbientLightReading element holds the most AmbientLightSensor reading. + + The AmbientLightReading element holds the most AmbientLightSensor reading. + + This element wraps the QAmbientLightReading class. Please see the documentation for + QAmbientLightReading for details. + + This element cannot be directly created. +*/ + +QmlAmbientLightSensorReading::QmlAmbientLightSensorReading(QAmbientLightSensor *sensor) + : QmlSensorReading(sensor) + , m_sensor(sensor) +{ +} + +QmlAmbientLightSensorReading::~QmlAmbientLightSensorReading() +{ +} + +/*! + \qmlproperty LightLevel AmbientLightReading::lightLevel + This property holds the ambient light level. + + Please see QAmbientLightReading::lightLevel for information about this property. + + Note that LightLevel constants are exposed through the AmbientLightReading class. + \code + AmbientLightSensor { + onReadingChanged: { + if (reading.lightLevel == AmbientLightReading.Dark) + // do something + } + } + \endcode +*/ + +QAmbientLightReading::LightLevel QmlAmbientLightSensorReading::lightLevel() const +{ + return m_lightLevel; +} + +QSensorReading *QmlAmbientLightSensorReading::reading() const +{ + return m_sensor->reading(); +} + +void QmlAmbientLightSensorReading::readingUpdate() +{ + QAmbientLightReading::LightLevel ll = m_sensor->reading()->lightLevel(); + if (m_lightLevel != ll) { + m_lightLevel = ll; + Q_EMIT lightLevelChanged(); + } +} diff --git a/src/sensorsquick/qmlambientlightsensor_p.h b/src/sensorsquick/qmlambientlightsensor_p.h new file mode 100644 index 00000000..356a1128 --- /dev/null +++ b/src/sensorsquick/qmlambientlightsensor_p.h @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLAMBIENTLIGHTSENSOR_P_H +#define QMLAMBIENTLIGHTSENSOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qmlsensor_p.h" +#include + +QT_BEGIN_NAMESPACE + +class QAmbientLightSensor; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlAmbientLightSensor : public QmlSensor +{ + Q_OBJECT + QML_NAMED_ELEMENT(AmbientLightSensor) + QML_ADDED_IN_VERSION(5,0) +public: + explicit QmlAmbientLightSensor(QObject *parent = 0); + ~QmlAmbientLightSensor(); + +private: + QSensor *sensor() const override; + QAmbientLightSensor *m_sensor; + QmlSensorReading *createReading() const override; + +}; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlAmbientLightSensorReading : public QmlSensorReading +{ + Q_OBJECT + Q_PROPERTY(QAmbientLightReading::LightLevel lightLevel READ lightLevel NOTIFY lightLevelChanged) + QML_NAMED_ELEMENT(AmbientLightReading) + QML_UNCREATABLE("Cannot create AmbientLightReading") + QML_ADDED_IN_VERSION(5,0) +public: + + explicit QmlAmbientLightSensorReading(QAmbientLightSensor *sensor); + ~QmlAmbientLightSensorReading(); + + QAmbientLightReading::LightLevel lightLevel() const; + +Q_SIGNALS: + void lightLevelChanged(); + +private: + QSensorReading *reading() const override; + void readingUpdate() override; + QAmbientLightSensor *m_sensor; + QAmbientLightReading::LightLevel m_lightLevel; +}; + +QT_END_NAMESPACE +#endif diff --git a/src/sensorsquick/qmlambienttemperaturesensor.cpp b/src/sensorsquick/qmlambienttemperaturesensor.cpp new file mode 100644 index 00000000..3f1a4679 --- /dev/null +++ b/src/sensorsquick/qmlambienttemperaturesensor.cpp @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Research In Motion +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qmlambienttemperaturesensor_p.h" +#include + +/*! + \qmltype AmbientTemperatureSensor + \instantiates QmlAmbientTemperatureSensor + \ingroup qml-sensors_type + \inqmlmodule QtSensors + \since QtSensors 5.1 + \inherits Sensor + \brief The AmbientTemperatureSensor element reports on the ambient temperature. + + The AmbientTemperatureSensor element reports on the ambient temperature. + + This element wraps the QAmbientTemperatureSensor class. Please see the documentation for + QAmbientTemperatureSensor for details. + + \sa AmbientTemperatureReading +*/ + +QmlAmbientTemperatureSensor::QmlAmbientTemperatureSensor(QObject *parent) + : QmlSensor(parent) + , m_sensor(new QAmbientTemperatureSensor(this)) +{ +} + +QmlAmbientTemperatureSensor::~QmlAmbientTemperatureSensor() +{ +} + +QmlSensorReading *QmlAmbientTemperatureSensor::createReading() const +{ + return new QmlAmbientTemperatureReading(m_sensor); +} + +QSensor *QmlAmbientTemperatureSensor::sensor() const +{ + return m_sensor; +} + +/*! + \qmltype AmbientTemperatureReading + \instantiates QmlAmbientTemperatureReading + \ingroup qml-sensors_reading + \inqmlmodule QtSensors + \since QtSensors 5.1 + \inherits SensorReading + \brief The AmbientTemperatureReading element holds the most recent temperature reading. + + The AmbientTemperatureReading element holds the most recent temperature reading. + + This element wraps the QAmbientTemperatureReading class. Please see the documentation for + QAmbientTemperatureReading for details. + + This element cannot be directly created. +*/ + +QmlAmbientTemperatureReading::QmlAmbientTemperatureReading(QAmbientTemperatureSensor *sensor) + : QmlSensorReading(sensor) + , m_sensor(sensor) + , m_temperature(0) +{ +} + +QmlAmbientTemperatureReading::~QmlAmbientTemperatureReading() +{ +} + +/*! + \qmlproperty qreal AmbientTemperatureReading::temperature + This property holds the ambient temperature in degree Celsius. + + Please see QAmbientTemperatureReading::temperature for information about this property. +*/ + +qreal QmlAmbientTemperatureReading::temperature() const +{ + return m_temperature; +} + +QSensorReading *QmlAmbientTemperatureReading::reading() const +{ + return m_sensor->reading(); +} + +void QmlAmbientTemperatureReading::readingUpdate() +{ + const qreal temperature = m_sensor->reading()->temperature(); + if (m_temperature != temperature) { + m_temperature = temperature; + Q_EMIT temperatureChanged(); + } +} diff --git a/src/sensorsquick/qmlambienttemperaturesensor_p.h b/src/sensorsquick/qmlambienttemperaturesensor_p.h new file mode 100644 index 00000000..45183ee7 --- /dev/null +++ b/src/sensorsquick/qmlambienttemperaturesensor_p.h @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Research In Motion +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QMLAMBIENTTEMPERATURESENSOR_P_H +#define QMLAMBIENTTEMPERATURESENSOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qmlsensor_p.h" + +QT_BEGIN_NAMESPACE + +class QAmbientTemperatureSensor; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlAmbientTemperatureSensor : public QmlSensor +{ + Q_OBJECT + QML_NAMED_ELEMENT(AmbientTemperatureSensor) + QML_ADDED_IN_VERSION(5,1) +public: + explicit QmlAmbientTemperatureSensor(QObject *parent = 0); + ~QmlAmbientTemperatureSensor(); + +private: + QSensor *sensor() const override; + QmlSensorReading *createReading() const override; + + QAmbientTemperatureSensor *m_sensor; +}; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlAmbientTemperatureReading : public QmlSensorReading +{ + Q_OBJECT + Q_PROPERTY(qreal temperature READ temperature NOTIFY temperatureChanged) + QML_NAMED_ELEMENT(AmbientTemperatureReading) + QML_UNCREATABLE("Cannot create AmbientTemperatureReading") + QML_ADDED_IN_VERSION(5,1) +public: + explicit QmlAmbientTemperatureReading(QAmbientTemperatureSensor *sensor); + ~QmlAmbientTemperatureReading(); + + qreal temperature() const; + +Q_SIGNALS: + void temperatureChanged(); + +private: + QSensorReading *reading() const override; + void readingUpdate() override; + + QAmbientTemperatureSensor *m_sensor; + qreal m_temperature; +}; + +QT_END_NAMESPACE +#endif diff --git a/src/sensorsquick/qmlcompass.cpp b/src/sensorsquick/qmlcompass.cpp new file mode 100644 index 00000000..b3620d6c --- /dev/null +++ b/src/sensorsquick/qmlcompass.cpp @@ -0,0 +1,148 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmlcompass_p.h" +#include + +/*! + \qmltype Compass + \instantiates QmlCompass + \ingroup qml-sensors_type + \inqmlmodule QtSensors + \since QtSensors 5.0 + \inherits Sensor + \brief The Compass element reports on heading using magnetic north as a reference. + + The Compass element reports on heading using magnetic north as a reference. + + This element wraps the QCompass class. Please see the documentation for + QCompass for details. + + \sa CompassReading +*/ + +QmlCompass::QmlCompass(QObject *parent) + : QmlSensor(parent) + , m_sensor(new QCompass(this)) +{ +} + +QmlCompass::~QmlCompass() +{ +} + +QmlSensorReading *QmlCompass::createReading() const +{ + return new QmlCompassReading(m_sensor); +} + +QSensor *QmlCompass::sensor() const +{ + return m_sensor; +} + +/*! + \qmltype CompassReading + \instantiates QmlCompassReading + \ingroup qml-sensors_reading + \inqmlmodule QtSensors + \since QtSensors 5.0 + \inherits SensorReading + \brief The CompassReading element holds the most recent Compass reading. + + The CompassReading element holds the most recent Compass reading. + + This element wraps the QCompassReading class. Please see the documentation for + QCompassReading for details. + + This element cannot be directly created. +*/ + +QmlCompassReading::QmlCompassReading(QCompass *sensor) + : QmlSensorReading(sensor) + , m_sensor(sensor) +{ +} + +QmlCompassReading::~QmlCompassReading() +{ +} + +/*! + \qmlproperty qreal CompassReading::azimuth + This property holds the azimuth of the device. + + Please see QCompassReading::azimuth for information about this property. +*/ + +qreal QmlCompassReading::azimuth() const +{ + return m_azimuth; +} + +/*! + \qmlproperty qreal CompassReading::calibrationLevel + This property holds the calibration level of the reading. + + Please see QCompassReading::calibrationLevel for information about this property. +*/ + +qreal QmlCompassReading::calibrationLevel() const +{ + return m_calibrationLevel; +} + +QSensorReading *QmlCompassReading::reading() const +{ + return m_sensor->reading(); +} + +void QmlCompassReading::readingUpdate() +{ + qreal azm = m_sensor->reading()->azimuth(); + if (m_azimuth != azm) { + m_azimuth = azm; + Q_EMIT azimuthChanged(); + } + qreal calLevel = m_sensor->reading()->calibrationLevel(); + if (m_calibrationLevel != calLevel) { + m_calibrationLevel = calLevel; + Q_EMIT calibrationLevelChanged(); + } +} diff --git a/src/sensorsquick/qmlcompass_p.h b/src/sensorsquick/qmlcompass_p.h new file mode 100644 index 00000000..42c1b15c --- /dev/null +++ b/src/sensorsquick/qmlcompass_p.h @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLCOMPASS_P_H +#define QMLCOMPASS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qmlsensor_p.h" + +QT_BEGIN_NAMESPACE + +class QCompass; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlCompass : public QmlSensor +{ + Q_OBJECT + QML_NAMED_ELEMENT(Compass) + QML_ADDED_IN_VERSION(5,0) +public: + explicit QmlCompass(QObject *parent = 0); + ~QmlCompass(); + + +private: + QSensor *sensor() const override; + QCompass *m_sensor; + QmlSensorReading *createReading() const override; +}; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlCompassReading : public QmlSensorReading +{ + Q_OBJECT + Q_PROPERTY(qreal azimuth READ azimuth NOTIFY azimuthChanged) + Q_PROPERTY(qreal calibrationLevel READ calibrationLevel NOTIFY calibrationLevelChanged) + QML_NAMED_ELEMENT(CompassReading) + QML_UNCREATABLE("Cannot create CompassReading") + QML_ADDED_IN_VERSION(5,0) +public: + explicit QmlCompassReading(QCompass *sensor); + ~QmlCompassReading(); + + qreal azimuth() const; + qreal calibrationLevel() const; + +Q_SIGNALS: + void azimuthChanged(); + void calibrationLevelChanged(); + +private: + QSensorReading *reading() const override; + void readingUpdate() override; + QCompass *m_sensor; + qreal m_azimuth; + qreal m_calibrationLevel; +}; + +QT_END_NAMESPACE +#endif diff --git a/src/sensorsquick/qmldistancesensor.cpp b/src/sensorsquick/qmldistancesensor.cpp new file mode 100644 index 00000000..b1d9f6bb --- /dev/null +++ b/src/sensorsquick/qmldistancesensor.cpp @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2016 BlackBerry Limited. All rights reserved. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qmldistancesensor_p.h" +#include + +/*! + \qmltype DistanceSensor + \instantiates QmlDistanceSensor + \ingroup qml-sensors_type + \inqmlmodule QtSensors + \since QtSensors 5.4 + \inherits Sensor + \brief The DistanceSensor element reports the distance in cm from an object to the device. + + The DistanceSensor element reports the distance in cm from an object to the device. + + This element wraps the QDistanceSensor class. Please see the documentation for + QDistanceSensor for details. + + \sa DistanceReading +*/ + +QmlDistanceSensor::QmlDistanceSensor(QObject *parent) + : QmlSensor(parent) + , m_sensor(new QDistanceSensor(this)) +{ +} + +QmlDistanceSensor::~QmlDistanceSensor() +{ +} + +QmlSensorReading *QmlDistanceSensor::createReading() const +{ + return new QmlDistanceReading(m_sensor); +} + +QSensor *QmlDistanceSensor::sensor() const +{ + return m_sensor; +} + +/*! + \qmltype DistanceReading + \instantiates QmlDistanceReading + \ingroup qml-sensors_reading + \inqmlmodule QtSensors + \since QtSensors 5.4 + \inherits SensorReading + \brief The DistanceReading element holds the most recent DistanceSensor reading. + + The DistanceReading element holds the most recent DistanceSensor reading. + + This element wraps the QDistanceReading class. Please see the documentation for + QDistanceReading for details. + + This element cannot be directly created. +*/ + +QmlDistanceReading::QmlDistanceReading(QDistanceSensor *sensor) + : QmlSensorReading(sensor) + , m_sensor(sensor) + , m_distance(0.0) +{ +} + +QmlDistanceReading::~QmlDistanceReading() +{ +} + +/*! + \qmlproperty qreal DistanceReading::distance + This property holds the distance measurement + + Please see QDistanceReading::distance for information about this property. +*/ + +qreal QmlDistanceReading::distance() const +{ + return m_distance; +} + +QSensorReading *QmlDistanceReading::reading() const +{ + return m_sensor->reading(); +} + +void QmlDistanceReading::readingUpdate() +{ + qreal distance = m_sensor->reading()->distance(); + if (m_distance != distance) { + m_distance = distance; + Q_EMIT distanceChanged(); + } +} diff --git a/src/sensorsquick/qmldistancesensor_p.h b/src/sensorsquick/qmldistancesensor_p.h new file mode 100644 index 00000000..1f9d9425 --- /dev/null +++ b/src/sensorsquick/qmldistancesensor_p.h @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2016 BlackBerry Limited. All rights reserved. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLDISTANCESENSOR_P_H +#define QMLDISTANCESENSOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qmlsensor_p.h" + +QT_BEGIN_NAMESPACE + +class QDistanceSensor; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlDistanceSensor : public QmlSensor +{ + Q_OBJECT + QML_NAMED_ELEMENT(DistanceSensor) + QML_ADDED_IN_VERSION(5,4) +public: + explicit QmlDistanceSensor(QObject *parent = 0); + ~QmlDistanceSensor(); + +private: + QSensor *sensor() const override; + QmlSensorReading *createReading() const override; + + QDistanceSensor *m_sensor; +}; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlDistanceReading : public QmlSensorReading +{ + Q_OBJECT + Q_PROPERTY(qreal distance READ distance NOTIFY distanceChanged) + QML_NAMED_ELEMENT(DistanceReading) + QML_UNCREATABLE("Cannot create DistanceReading") + QML_ADDED_IN_VERSION(5,4) +public: + explicit QmlDistanceReading(QDistanceSensor *sensor); + ~QmlDistanceReading(); + + qreal distance() const; + +Q_SIGNALS: + void distanceChanged(); + +private: + QSensorReading *reading() const override; + void readingUpdate() override; + + QDistanceSensor *m_sensor; + qreal m_distance; +}; + +QT_END_NAMESPACE +#endif diff --git a/src/sensorsquick/qmlgyroscope.cpp b/src/sensorsquick/qmlgyroscope.cpp new file mode 100644 index 00000000..9983564a --- /dev/null +++ b/src/sensorsquick/qmlgyroscope.cpp @@ -0,0 +1,164 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmlgyroscope_p.h" +#include + +/*! + \qmltype Gyroscope + \instantiates QmlGyroscope + \ingroup qml-sensors_type + \inqmlmodule QtSensors + \since QtSensors 5.0 + \inherits Sensor + \brief The Gyroscope element reports on rotational acceleration + around the X, Y and Z axes. + + This element wraps the QGyroscope class. Please see the documentation for + QGyroscope for details. + + \sa GyroscopeReading +*/ + +QmlGyroscope::QmlGyroscope(QObject *parent) + : QmlSensor(parent) + , m_sensor(new QGyroscope(this)) +{ +} + +QmlGyroscope::~QmlGyroscope() +{ +} + +QmlSensorReading *QmlGyroscope::createReading() const +{ + return new QmlGyroscopeReading(m_sensor); +} + +QSensor *QmlGyroscope::sensor() const +{ + return m_sensor; +} + +/*! + \qmltype GyroscopeReading + \instantiates QmlGyroscopeReading + \ingroup qml-sensors_reading + \inqmlmodule QtSensors + \since QtSensors 5.0 + \inherits SensorReading + \brief The GyroscopeReading element holds the most recent Gyroscope reading. + + The GyroscopeReading element holds the most recent Gyroscope reading. + + This element wraps the QGyroscopeReading class. Please see the documentation for + QGyroscopeReading for details. + + This element cannot be directly created. +*/ + +QmlGyroscopeReading::QmlGyroscopeReading(QGyroscope *sensor) + : QmlSensorReading(sensor) + , m_sensor(sensor) +{ +} + +QmlGyroscopeReading::~QmlGyroscopeReading() +{ +} + +/*! + \qmlproperty qreal GyroscopeReading::x + This property holds the angular velocity around the x axis. + + Please see QGyroscopeReading::x for information about this property. +*/ + +qreal QmlGyroscopeReading::x() const +{ + return m_x; +} + +/*! + \qmlproperty qreal GyroscopeReading::y + This property holds the angular velocity around the y axis. + + Please see QGyroscopeReading::y for information about this property. +*/ + +qreal QmlGyroscopeReading::y() const +{ + return m_y; +} + +/*! + \qmlproperty qreal GyroscopeReading::z + This property holds the angular velocity around the z axis. + + Please see QGyroscopeReading::z for information about this property. +*/ + +qreal QmlGyroscopeReading::z() const +{ + return m_z; +} + +QSensorReading *QmlGyroscopeReading::reading() const +{ + return m_sensor->reading(); +} + +void QmlGyroscopeReading::readingUpdate() +{ + qreal gx = m_sensor->reading()->x(); + if (m_x != gx) { + m_x = gx; + Q_EMIT xChanged(); + } + qreal gy = m_sensor->reading()->y(); + if (m_y != gy) { + m_y = gy; + Q_EMIT yChanged(); + } + qreal gz = m_sensor->reading()->z(); + if (m_z != gz) { + m_z = gz; + Q_EMIT zChanged(); + } +} diff --git a/src/sensorsquick/qmlgyroscope_p.h b/src/sensorsquick/qmlgyroscope_p.h new file mode 100644 index 00000000..549a67e4 --- /dev/null +++ b/src/sensorsquick/qmlgyroscope_p.h @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLGYROSCOPE_P_H +#define QMLGYROSCOPE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qmlsensor_p.h" + +QT_BEGIN_NAMESPACE + +class QGyroscope; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlGyroscope : public QmlSensor +{ + Q_OBJECT + QML_NAMED_ELEMENT(Gyroscope) + QML_ADDED_IN_VERSION(5,0) +public: + explicit QmlGyroscope(QObject *parent = 0); + ~QmlGyroscope(); + + +private: + QSensor *sensor() const override; + QGyroscope *m_sensor; + QmlSensorReading *createReading() const override; +}; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlGyroscopeReading : public QmlSensorReading +{ + Q_OBJECT + Q_PROPERTY(qreal x READ x NOTIFY xChanged) + Q_PROPERTY(qreal y READ y NOTIFY yChanged) + Q_PROPERTY(qreal z READ z NOTIFY zChanged) + QML_NAMED_ELEMENT(GyroscopeReading) + QML_UNCREATABLE("Cannot create GyroscopeReading") + QML_ADDED_IN_VERSION(5,0) +public: + explicit QmlGyroscopeReading(QGyroscope *sensor); + ~QmlGyroscopeReading(); + + qreal x() const; + qreal y() const; + qreal z() const; + +Q_SIGNALS: + void xChanged(); + void yChanged(); + void zChanged(); + +private: + QSensorReading *reading() const override; + void readingUpdate() override; + QGyroscope *m_sensor; + qreal m_x; + qreal m_y; + qreal m_z; +}; + +QT_END_NAMESPACE +#endif diff --git a/src/sensorsquick/qmlholstersensor.cpp b/src/sensorsquick/qmlholstersensor.cpp new file mode 100644 index 00000000..cdefd683 --- /dev/null +++ b/src/sensorsquick/qmlholstersensor.cpp @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Research In Motion +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qmlholstersensor_p.h" +#include + +/*! + \qmltype HolsterSensor + \instantiates QmlHolsterSensor + \ingroup qml-sensors_type + \inqmlmodule QtSensors + \since QtSensors 5.1 + \inherits Sensor + \brief The HolsterSensor element reports on whether a device is holstered. + + The HolsterSensor element reports on whether a device is holstered. + + This element wraps the QHolsterSensor class. Please see the documentation for + QHolsterSensor for details. + + \sa HolsterReading +*/ + +QmlHolsterSensor::QmlHolsterSensor(QObject *parent) + : QmlSensor(parent) + , m_sensor(new QHolsterSensor(this)) +{ +} + +QmlHolsterSensor::~QmlHolsterSensor() +{ +} + +QmlSensorReading *QmlHolsterSensor::createReading() const +{ + return new QmlHolsterReading(m_sensor); +} + +QSensor *QmlHolsterSensor::sensor() const +{ + return m_sensor; +} + +/*! + \qmltype HolsterReading + \instantiates QmlHolsterReading + \ingroup qml-sensors_reading + \inqmlmodule QtSensors + \since QtSensors 5.1 + \inherits SensorReading + \brief The HolsterReading element holds the most recent HolsterSensor reading. + + The HolsterReading element holds the most recent HolsterSensor reading. + + This element wraps the QHolsterReading class. Please see the documentation for + QHolsterReading for details. + + This element cannot be directly created. +*/ + +QmlHolsterReading::QmlHolsterReading(QHolsterSensor *sensor) + : QmlSensorReading(sensor) + , m_sensor(sensor) + , m_holstered(false) +{ +} + +QmlHolsterReading::~QmlHolsterReading() +{ +} + +/*! + \qmlproperty qreal HolsterReading::holstered + This property holds whether the device is holstered. + + Please see QHolsterReading::holstered for information about this property. +*/ + +bool QmlHolsterReading::holstered() const +{ + return m_holstered; +} + +QSensorReading *QmlHolsterReading::reading() const +{ + return m_sensor->reading(); +} + +void QmlHolsterReading::readingUpdate() +{ + const bool holstered = m_sensor->reading()->holstered(); + if (m_holstered != holstered) { + m_holstered = holstered; + Q_EMIT holsteredChanged(); + } +} diff --git a/src/sensorsquick/qmlholstersensor_p.h b/src/sensorsquick/qmlholstersensor_p.h new file mode 100644 index 00000000..a64e2d12 --- /dev/null +++ b/src/sensorsquick/qmlholstersensor_p.h @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Research In Motion +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QMLHOLSTERSENSOR_P_H +#define QMLHOLSTERSENSOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qmlsensor_p.h" + +QT_BEGIN_NAMESPACE + +class QHolsterSensor; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlHolsterSensor : public QmlSensor +{ + Q_OBJECT + QML_NAMED_ELEMENT(HolsterSensor) + QML_ADDED_IN_VERSION(5,1) +public: + explicit QmlHolsterSensor(QObject *parent = 0); + ~QmlHolsterSensor(); + +private: + QSensor *sensor() const override; + QmlSensorReading *createReading() const override; + + QHolsterSensor *m_sensor; +}; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlHolsterReading : public QmlSensorReading +{ + Q_OBJECT + Q_PROPERTY(bool holstered READ holstered NOTIFY holsteredChanged) + QML_NAMED_ELEMENT(HolsterReading) + QML_UNCREATABLE("Cannot create HolsterReading") + QML_ADDED_IN_VERSION(5,1) +public: + explicit QmlHolsterReading(QHolsterSensor *sensor); + ~QmlHolsterReading(); + + bool holstered() const; + +Q_SIGNALS: + void holsteredChanged(); + +private: + QSensorReading *reading() const override; + void readingUpdate() override; + + QHolsterSensor *m_sensor; + bool m_holstered; +}; + +QT_END_NAMESPACE +#endif diff --git a/src/sensorsquick/qmlhumiditysensor.cpp b/src/sensorsquick/qmlhumiditysensor.cpp new file mode 100644 index 00000000..37bf7a18 --- /dev/null +++ b/src/sensorsquick/qmlhumiditysensor.cpp @@ -0,0 +1,150 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Canonical Ltd +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmlhumiditysensor_p.h" +#include + +/*! + \qmltype HumiditySensor + \instantiates QmlHumiditySensor + \ingroup qml-sensors_type + \inqmlmodule QtSensors + \since QtSensors 5.9 + \inherits Sensor + \brief The HumiditySensor element reports on humidity. + + The HumiditySensor element reports on humidity. + + This element wraps the QHumiditySensor class. Please see the documentation for + QHumiditySensor for details. + + \sa HumidityReading +*/ + +QmlHumiditySensor::QmlHumiditySensor(QObject *parent) + : QmlSensor(parent) + , m_sensor(new QHumiditySensor(this)) +{ +} + +QmlHumiditySensor::~QmlHumiditySensor() +{ +} + +QmlSensorReading *QmlHumiditySensor::createReading() const +{ + return new QmlHumidityReading(m_sensor); +} + +QSensor *QmlHumiditySensor::sensor() const +{ + return m_sensor; +} + +/*! + \qmltype HumidityReading + \instantiates QmlHumidityReading + \ingroup qml-sensors_reading + \inqmlmodule QtSensors + \since QtSensors 5.9 + \inherits SensorReading + \brief The HumidityReading element holds the most recent HumiditySensor reading. + + The HumidityReading element holds the most recent HumiditySensor reading. + + This element wraps the QHumidityReading class. Please see the documentation for + QHumidityReading for details. + + This element cannot be directly created. +*/ + +QmlHumidityReading::QmlHumidityReading(QHumiditySensor *sensor) + : QmlSensorReading(sensor) + , m_sensor(sensor) + , m_relativeHumidity(0) + , m_absoluteHumidity(0) +{ +} + +QmlHumidityReading::~QmlHumidityReading() +{ +} + +/*! + \qmlproperty qreal HumidityReading::relativeHumidity + This property holds the relative humidity as a percentage. + + Please see QHumidityReading::relativeHumidity for information about this property. +*/ + +qreal QmlHumidityReading::relativeHumidity() const +{ + return m_relativeHumidity; +} + +/*! + \qmlproperty qreal HumidityReading::absoluteHumidity + This property holds the absolute humidity in grams per cubic meter (g/m3). + + Please see QHumidityReading::absoluteHumidity for information about this property. +*/ + +qreal QmlHumidityReading::absoluteHumidity() const +{ + return m_absoluteHumidity; +} + +QSensorReading *QmlHumidityReading::reading() const +{ + return m_sensor->reading(); +} + +void QmlHumidityReading::readingUpdate() +{ + qreal humidity = m_sensor->reading()->relativeHumidity(); + if (m_relativeHumidity != humidity) { + m_relativeHumidity = humidity; + Q_EMIT relativeHumidityChanged(); + } + qreal abs = m_sensor->reading()->absoluteHumidity(); + if (m_absoluteHumidity != abs) { + m_absoluteHumidity = abs; + Q_EMIT absoluteHumidityChanged(); + } +} diff --git a/src/sensorsquick/qmlhumiditysensor_p.h b/src/sensorsquick/qmlhumiditysensor_p.h new file mode 100644 index 00000000..7a940b7c --- /dev/null +++ b/src/sensorsquick/qmlhumiditysensor_p.h @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Canonical Ltd +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLHUMIDITYSENSOR_P_H +#define QMLHUMIDITYSENSOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qmlsensor_p.h" + +QT_BEGIN_NAMESPACE + +class QHumiditySensor; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlHumiditySensor : public QmlSensor +{ + Q_OBJECT + + QML_NAMED_ELEMENT(HumiditySensor) + QML_ADDED_IN_VERSION(5,9) +public: + explicit QmlHumiditySensor(QObject *parent = Q_NULLPTR); + ~QmlHumiditySensor(); + +private: + QSensor *sensor() const override; + QmlSensorReading *createReading() const override; + + QHumiditySensor *m_sensor; +}; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlHumidityReading : public QmlSensorReading +{ + Q_OBJECT + Q_PROPERTY(qreal relativeHumidity READ relativeHumidity NOTIFY relativeHumidityChanged) + Q_PROPERTY(qreal absoluteHumidity READ absoluteHumidity NOTIFY absoluteHumidityChanged) + QML_NAMED_ELEMENT(HumidityReading) + QML_UNCREATABLE("Cannot create HumidityReading") + QML_ADDED_IN_VERSION(5,9) +public: + explicit QmlHumidityReading(QHumiditySensor *sensor); + ~QmlHumidityReading(); + + qreal relativeHumidity() const; + qreal absoluteHumidity() const; + +Q_SIGNALS: + void relativeHumidityChanged(); + void absoluteHumidityChanged(); + +private: + QSensorReading *reading() const override; + void readingUpdate() override; + + QHumiditySensor *m_sensor; + qreal m_relativeHumidity; + qreal m_absoluteHumidity; +}; + +QT_END_NAMESPACE +#endif diff --git a/src/sensorsquick/qmlirproximitysensor.cpp b/src/sensorsquick/qmlirproximitysensor.cpp new file mode 100644 index 00000000..42e9cfe9 --- /dev/null +++ b/src/sensorsquick/qmlirproximitysensor.cpp @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmlirproximitysensor_p.h" +#include + +/*! + \qmltype IRProximitySensor + \instantiates QmlIRProximitySensor + \ingroup qml-sensors_type + \inqmlmodule QtSensors + \since QtSensors 5.0 + \inherits Sensor + \brief The IRProximitySensor element reports on infra-red reflectance values. + + This element wraps the QIRProximitySensor class. Please see the documentation for + QIRProximitySensor for details. + + \sa IRProximityReading +*/ + +QmlIRProximitySensor::QmlIRProximitySensor(QObject *parent) + : QmlSensor(parent) + , m_sensor(new QIRProximitySensor(this)) +{ +} + +QmlIRProximitySensor::~QmlIRProximitySensor() +{ +} + +QmlSensorReading *QmlIRProximitySensor::createReading() const +{ + return new QmlIRProximitySensorReading(m_sensor); +} + +QSensor *QmlIRProximitySensor::sensor() const +{ + return m_sensor; +} + +/*! + \qmltype IRProximityReading + \instantiates QmlIRProximitySensorReading + \ingroup qml-sensors_reading + \inqmlmodule QtSensors + \since QtSensors 5.0 + \inherits SensorReading + \brief The IRProximityReading element holds the most recent IR proximity reading. + + The IRProximityReading element holds the most recent IR proximity reading. + + This element wraps the QIRProximityReading class. Please see the documentation for + QIRProximityReading for details. + + This element cannot be directly created. +*/ + +QmlIRProximitySensorReading::QmlIRProximitySensorReading(QIRProximitySensor *sensor) + : QmlSensorReading(sensor) + , m_sensor(sensor) +{ +} + +QmlIRProximitySensorReading::~QmlIRProximitySensorReading() +{ +} + +/*! + \qmlproperty qreal IRProximityReading::reflectance + This property holds the reflectance value. + + Please see QIRProximityReading::reflectance for information about this property. +*/ + +qreal QmlIRProximitySensorReading::reflectance() const +{ + return m_reflectance; +} + +QSensorReading *QmlIRProximitySensorReading::reading() const +{ + return m_sensor->reading(); +} + +void QmlIRProximitySensorReading::readingUpdate() +{ + qreal fl = m_sensor->reading()->reflectance(); + if (m_reflectance != fl) { + m_reflectance = fl; + Q_EMIT reflectanceChanged(); + } +} diff --git a/src/sensorsquick/qmlirproximitysensor_p.h b/src/sensorsquick/qmlirproximitysensor_p.h new file mode 100644 index 00000000..6039794d --- /dev/null +++ b/src/sensorsquick/qmlirproximitysensor_p.h @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLIRPROXIMITYSENSOR_P_H +#define QMLIRPROXIMITYSENSOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qmlsensor_p.h" + +QT_BEGIN_NAMESPACE + +class QIRProximitySensor; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlIRProximitySensor : public QmlSensor +{ + Q_OBJECT + QML_NAMED_ELEMENT(IRProximitySensor) + QML_ADDED_IN_VERSION(5,0) +public: + explicit QmlIRProximitySensor(QObject *parent = 0); + ~QmlIRProximitySensor(); + +private: + QSensor *sensor() const override; + QIRProximitySensor *m_sensor; + QmlSensorReading *createReading() const override; +}; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlIRProximitySensorReading : public QmlSensorReading +{ + Q_OBJECT + Q_PROPERTY(qreal reflectance READ reflectance NOTIFY reflectanceChanged) + QML_NAMED_ELEMENT(IRProximityReading) + QML_UNCREATABLE("Cannot create IRProximityReading") + QML_ADDED_IN_VERSION(5,0) +public: + explicit QmlIRProximitySensorReading(QIRProximitySensor *sensor); + ~QmlIRProximitySensorReading(); + + qreal reflectance() const; + +Q_SIGNALS: + void reflectanceChanged(); + +private: + QSensorReading *reading() const override; + void readingUpdate() override; + QIRProximitySensor *m_sensor; + qreal m_reflectance; +}; + +QT_END_NAMESPACE +#endif diff --git a/src/sensorsquick/qmllidsensor.cpp b/src/sensorsquick/qmllidsensor.cpp new file mode 100644 index 00000000..3725f0ca --- /dev/null +++ b/src/sensorsquick/qmllidsensor.cpp @@ -0,0 +1,149 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Canonical, Ltd +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qmllidsensor_p.h" +#include + +/*! + \qmltype LidSensor + \instantiates QmlLidSensor + \ingroup qml-sensors_type + \inqmlmodule QtSensors + \since QtSensors 5.9 + \inherits Sensor + \brief The LidSensor element reports on whether a device is closed. + + The LidSensor element reports on whether a device is closed. + + This element wraps the QLidSensor class. Please see the documentation for + QLidSensor for details. + + \sa LidReading +*/ + +QmlLidSensor::QmlLidSensor(QObject *parent) + : QmlSensor(parent) + , m_sensor(new QLidSensor(this)) +{ +} + +QmlLidSensor::~QmlLidSensor() +{ +} + +QmlSensorReading *QmlLidSensor::createReading() const +{ + return new QmlLidReading(m_sensor); +} + +QSensor *QmlLidSensor::sensor() const +{ + return m_sensor; +} + +/*! + \qmltype LidReading + \instantiates QmlLidReading + \ingroup qml-sensors_reading + \inqmlmodule QtSensors + \since QtSensors 5.9 + \inherits SensorReading + \brief The LidReading element holds the most recent LidSensor reading. + + The LidReading element holds the most recent LidSensor reading. + + This element wraps the QLidReading class. Please see the documentation for + QLidReading for details. + + This element cannot be directly created. +*/ + +QmlLidReading::QmlLidReading(QLidSensor *sensor) + : QmlSensorReading(sensor) + , m_sensor(sensor) + , m_backClosed(false) + , m_frontClosed(true) +{ +} + +QmlLidReading::~QmlLidReading() +{ +} + +/*! + \qmlproperty qreal LidReading::backLidClosed + This property holds whether the back lid is closed. + + Please see QLidReading::backLidClosed for information about this property. +*/ + +bool QmlLidReading::backLidChanged() const +{ + return m_backClosed; +} + +/*! + \qmlproperty qreal LidReading::frontLidClosed + This property holds whether the front lid is closed. + + Please see QLidReading::frontLidClosed for information about this property. +*/ + +bool QmlLidReading::frontLidClosed() const +{ + return m_frontClosed; +} + +QSensorReading *QmlLidReading::reading() const +{ + return m_sensor->reading(); +} + +void QmlLidReading::readingUpdate() +{ + const bool backClosed = m_sensor->reading()->backLidClosed(); + if (m_backClosed != backClosed) { + m_backClosed = backClosed; + Q_EMIT backLidChanged(m_backClosed); + } + const bool frontClosed = m_sensor->reading()->frontLidClosed(); + if (m_frontClosed != frontClosed) { + m_frontClosed = frontClosed; + Q_EMIT frontLidChanged(m_frontClosed); + } +} diff --git a/src/sensorsquick/qmllidsensor_p.h b/src/sensorsquick/qmllidsensor_p.h new file mode 100644 index 00000000..6a58ce53 --- /dev/null +++ b/src/sensorsquick/qmllidsensor_p.h @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Canonical, Ltd +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QMLLIDSENSOR_P_H +#define QMLLIDSENSOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qmlsensor_p.h" + +QT_BEGIN_NAMESPACE + +class QLidSensor; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlLidSensor : public QmlSensor +{ + Q_OBJECT + QML_NAMED_ELEMENT(LidSensor) + QML_ADDED_IN_VERSION(5,9) +public: + explicit QmlLidSensor(QObject *parent = 0); + ~QmlLidSensor(); + +private: + QSensor *sensor() const override; + QmlSensorReading *createReading() const override; + + QLidSensor *m_sensor; +}; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlLidReading : public QmlSensorReading +{ + Q_OBJECT + Q_PROPERTY(bool backLidChanged READ backLidChanged NOTIFY backLidChanged) + Q_PROPERTY(bool frontLidClosed READ frontLidClosed NOTIFY frontLidChanged) + QML_NAMED_ELEMENT(LidReading) + QML_UNCREATABLE("Cannot create LidReading") + QML_ADDED_IN_VERSION(5,9) +public: + explicit QmlLidReading(QLidSensor *sensor); + ~QmlLidReading(); + + bool backLidChanged() const; + bool frontLidClosed() const; + +Q_SIGNALS: + void backLidChanged(bool closed); + bool frontLidChanged(bool closed); + +private: + QSensorReading *reading() const override; + void readingUpdate() override; + + QLidSensor *m_sensor; + bool m_backClosed; + bool m_frontClosed; +}; + +QT_END_NAMESPACE +#endif diff --git a/src/sensorsquick/qmllightsensor.cpp b/src/sensorsquick/qmllightsensor.cpp new file mode 100644 index 00000000..f60390bf --- /dev/null +++ b/src/sensorsquick/qmllightsensor.cpp @@ -0,0 +1,145 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmllightsensor_p.h" +#include + +/*! + \qmltype LightSensor + \instantiates QmlLightSensor + \ingroup qml-sensors_type + \inqmlmodule QtSensors + \since QtSensors 5.0 + \inherits Sensor + \brief The LightSensor element reports on light levels using LUX. + + The LightSensor element reports on light levels using LUX. + + This element wraps the QLightSensor class. Please see the documentation for + QLightSensor for details. + + \sa LightReading +*/ + +QmlLightSensor::QmlLightSensor(QObject *parent) + : QmlSensor(parent) + , m_sensor(new QLightSensor(this)) +{ + connect(m_sensor, SIGNAL(fieldOfViewChanged(qreal)), + this, SIGNAL(fieldOfViewChanged(qreal))); +} + +QmlLightSensor::~QmlLightSensor() +{ +} + +QmlSensorReading *QmlLightSensor::createReading() const +{ + return new QmlLightSensorReading(m_sensor); +} + +QSensor *QmlLightSensor::sensor() const +{ + return m_sensor; +} + +/*! + \qmlproperty qreal LightSensor::fieldOfView + This property holds a value indicating the field of view. + + Please see QLightSensor::fieldOfView for information about this property. +*/ + +qreal QmlLightSensor::fieldOfView() const +{ + return m_sensor->fieldOfView(); +} + +/*! + \qmltype LightReading + \instantiates QmlLightSensorReading + \ingroup qml-sensors_reading + \inqmlmodule QtSensors + \since QtSensors 5.0 + \inherits SensorReading + \brief The LightReading element holds the most recent LightSensor reading. + + The LightReading element holds the most recent LightSensor reading. + + This element wraps the QLightReading class. Please see the documentation for + QLightReading for details. + + This element cannot be directly created. +*/ + +QmlLightSensorReading::QmlLightSensorReading(QLightSensor *sensor) + : QmlSensorReading(sensor) + , m_sensor(sensor) +{ +} + +QmlLightSensorReading::~QmlLightSensorReading() +{ +} + +/*! + \qmlproperty qreal LightReading::illuminance + This property holds the light level. + + Please see QLightReading::illuminance for information about this property. +*/ + +qreal QmlLightSensorReading::illuminance() const +{ + return m_illuminance; +} + +QSensorReading *QmlLightSensorReading::reading() const +{ + return m_sensor->reading(); +} + +void QmlLightSensorReading::readingUpdate() +{ + qreal ill = m_sensor->reading()->lux(); + if (m_illuminance != ill) { + m_illuminance = ill; + Q_EMIT illuminanceChanged(); + } +} diff --git a/src/sensorsquick/qmllightsensor_p.h b/src/sensorsquick/qmllightsensor_p.h new file mode 100644 index 00000000..137be444 --- /dev/null +++ b/src/sensorsquick/qmllightsensor_p.h @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLLIGHTSENSOR_P_H +#define QMLLIGHTSENSOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qmlsensor_p.h" + +QT_BEGIN_NAMESPACE + +class QLightSensor; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlLightSensor : public QmlSensor +{ + Q_OBJECT + Q_PROPERTY(qreal fieldOfView READ fieldOfView NOTIFY fieldOfViewChanged) + QML_NAMED_ELEMENT(LightSensor) + QML_ADDED_IN_VERSION(5,0) +public: + explicit QmlLightSensor(QObject *parent = 0); + ~QmlLightSensor(); + + qreal fieldOfView() const; + +Q_SIGNALS: + void fieldOfViewChanged(qreal fieldOfView); + +private: + QSensor *sensor() const override; + QLightSensor *m_sensor; + QmlSensorReading *createReading() const override; +}; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlLightSensorReading : public QmlSensorReading +{ + Q_OBJECT + Q_PROPERTY(qreal illuminance READ illuminance NOTIFY illuminanceChanged) + QML_NAMED_ELEMENT(LightReading) + QML_UNCREATABLE("Cannot create LightReading") + QML_ADDED_IN_VERSION(5,0) +public: + explicit QmlLightSensorReading(QLightSensor *sensor); + ~QmlLightSensorReading(); + + qreal illuminance() const; + +Q_SIGNALS: + void illuminanceChanged(); + +private: + QSensorReading *reading() const override; + void readingUpdate() override; + QLightSensor *m_sensor; + qreal m_illuminance; +}; + +QT_END_NAMESPACE +#endif diff --git a/src/sensorsquick/qmlmagnetometer.cpp b/src/sensorsquick/qmlmagnetometer.cpp new file mode 100644 index 00000000..e911d583 --- /dev/null +++ b/src/sensorsquick/qmlmagnetometer.cpp @@ -0,0 +1,203 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmlmagnetometer_p.h" +#include + +/*! + \qmltype Magnetometer + \instantiates QmlMagnetometer + \ingroup qml-sensors_type + \inqmlmodule QtSensors + \since QtSensors 5.0 + \inherits Sensor + \brief The Magnetometer element reports on magnetic field strength + along the Z, Y and Z axes. + + The Magnetometer element reports on magnetic field strength + along the Z, Y and Z axes. + + This element wraps the QMagnetometer class. Please see the documentation for + QMagnetometer for details. + + \sa MagnetometerReading +*/ + +QmlMagnetometer::QmlMagnetometer(QObject *parent) + : QmlSensor(parent) + , m_sensor(new QMagnetometer(this)) +{ + connect(m_sensor, SIGNAL(returnGeoValuesChanged(bool)), + this, SIGNAL(returnGeoValuesChanged(bool))); +} + +QmlMagnetometer::~QmlMagnetometer() +{ +} + +QmlSensorReading *QmlMagnetometer::createReading() const +{ + return new QmlMagnetometerReading(m_sensor); +} + +QSensor *QmlMagnetometer::sensor() const +{ + return m_sensor; +} + +/*! + \qmlproperty bool Magnetometer::returnGeoValues + This property holds a value indicating if geomagnetic values should be returned. + + Please see QMagnetometer::returnGeoValues for information about this property. +*/ + +bool QmlMagnetometer::returnGeoValues() const +{ + return m_sensor->returnGeoValues(); +} + +void QmlMagnetometer::setReturnGeoValues(bool geo) +{ + m_sensor->setReturnGeoValues(geo); +} + +/*! + \qmltype MagnetometerReading + \instantiates QmlMagnetometerReading + \ingroup qml-sensors_reading + \inqmlmodule QtSensors + \since QtSensors 5.0 + \inherits SensorReading + \brief The MagnetometerReading element holds the most recent Magnetometer reading. + + The MagnetometerReading element holds the most recent Magnetometer reading. + + This element wraps the QMagnetometerReading class. Please see the documentation for + QMagnetometerReading for details. + + This element cannot be directly created. +*/ + +QmlMagnetometerReading::QmlMagnetometerReading(QMagnetometer *sensor) + : QmlSensorReading(sensor) + , m_sensor(sensor) +{ +} + +QmlMagnetometerReading::~QmlMagnetometerReading() +{ +} + +/*! + \qmlproperty qreal MagnetometerReading::x + This property holds the raw magnetic flux density on the X axis. + + Please see QMagnetometerReading::x for information about this property. +*/ + +qreal QmlMagnetometerReading::x() const +{ + return m_x; +} + +/*! + \qmlproperty qreal MagnetometerReading::y + This property holds the raw magnetic flux density on the Y axis. + + Please see QMagnetometerReading::y for information about this property. +*/ + +qreal QmlMagnetometerReading::y() const +{ + return m_y; +} + +/*! + \qmlproperty qreal MagnetometerReading::z + This property holds the raw magnetic flux density on the Z axis. + + Please see QMagnetometerReading::z for information about this property. +*/ + +qreal QmlMagnetometerReading::z() const +{ + return m_z; +} + +/*! + \qmlproperty qreal MagnetometerReading::calibrationLevel + This property holds the accuracy of the reading. + + Please see QMagnetometerReading::calibrationLevel for information about this property. +*/ + +qreal QmlMagnetometerReading::calibrationLevel() const +{ + return m_calibrationLevel; +} + +QSensorReading *QmlMagnetometerReading::reading() const +{ + return m_sensor->reading(); +} + +void QmlMagnetometerReading::readingUpdate() +{ + qreal magX = m_sensor->reading()->x(); + if (m_x != magX) { + m_x = magX; + Q_EMIT xChanged(); + } + qreal magY = m_sensor->reading()->y(); + if (m_y != magY) { + m_y = magY; + Q_EMIT yChanged(); + } + qreal magZ = m_sensor->reading()->z(); + if (m_z != magZ) { + m_z = magZ; + Q_EMIT zChanged(); + } + qreal calLevel = m_sensor->reading()->calibrationLevel(); + if (m_calibrationLevel != calLevel) { + m_calibrationLevel = calLevel; + Q_EMIT calibrationLevelChanged(); + } +} diff --git a/src/sensorsquick/qmlmagnetometer_p.h b/src/sensorsquick/qmlmagnetometer_p.h new file mode 100644 index 00000000..ef30f6ff --- /dev/null +++ b/src/sensorsquick/qmlmagnetometer_p.h @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLMAGNETOMETER_P_H +#define QMLMAGNETOMETER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qmlsensor_p.h" + +QT_BEGIN_NAMESPACE + +class QMagnetometer; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlMagnetometer : public QmlSensor +{ + Q_OBJECT + Q_PROPERTY(bool returnGeoValues READ returnGeoValues WRITE setReturnGeoValues NOTIFY returnGeoValuesChanged) + QML_NAMED_ELEMENT(Magnetometer) + QML_ADDED_IN_VERSION(5,0) +public: + explicit QmlMagnetometer(QObject *parent = 0); + ~QmlMagnetometer(); + + bool returnGeoValues() const; + void setReturnGeoValues(bool geo); + +Q_SIGNALS: + void returnGeoValuesChanged(bool returnGeoValues); + +private: + QSensor *sensor() const override; + QMagnetometer *m_sensor; + QmlSensorReading *createReading() const override; +}; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlMagnetometerReading : public QmlSensorReading +{ + Q_OBJECT + Q_PROPERTY(qreal x READ x NOTIFY xChanged) + Q_PROPERTY(qreal y READ y NOTIFY yChanged) + Q_PROPERTY(qreal z READ z NOTIFY zChanged) + Q_PROPERTY(qreal calibrationLevel READ calibrationLevel NOTIFY calibrationLevelChanged) + QML_NAMED_ELEMENT(MagnetometerReading) + QML_UNCREATABLE("Cannot create MagnetometerReading") + QML_ADDED_IN_VERSION(5,0) +public: + explicit QmlMagnetometerReading(QMagnetometer *sensor); + ~QmlMagnetometerReading(); + + qreal x() const; + qreal y() const; + qreal z() const; + qreal calibrationLevel() const; + +Q_SIGNALS: + void xChanged(); + void yChanged(); + void zChanged(); + void calibrationLevelChanged(); + +private: + QSensorReading *reading() const override; + void readingUpdate() override; + QMagnetometer *m_sensor; + qreal m_x; + qreal m_y; + qreal m_z; + qreal m_calibrationLevel; +}; + +QT_END_NAMESPACE +#endif diff --git a/src/sensorsquick/qmlorientationsensor.cpp b/src/sensorsquick/qmlorientationsensor.cpp new file mode 100644 index 00000000..0cf9cc19 --- /dev/null +++ b/src/sensorsquick/qmlorientationsensor.cpp @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmlorientationsensor_p.h" +#include + +/*! + \qmltype OrientationSensor + \instantiates QmlOrientationSensor + \ingroup qml-sensors_type + \inqmlmodule QtSensors + \since QtSensors 5.0 + \inherits Sensor + \brief The OrientationSensor element reports device orientation. + + The OrientationSensor element reports device orientation. + + This element wraps the QOrientationSensor class. Please see the documentation for + QOrientationSensor for details. + + \sa OrientationReading +*/ + +QmlOrientationSensor::QmlOrientationSensor(QObject *parent) + : QmlSensor(parent) + , m_sensor(new QOrientationSensor(this)) +{ +} + +QmlOrientationSensor::~QmlOrientationSensor() +{ +} + +QmlSensorReading *QmlOrientationSensor::createReading() const +{ + return new QmlOrientationSensorReading(m_sensor); +} + +QSensor *QmlOrientationSensor::sensor() const +{ + return m_sensor; +} + +/*! + \qmltype OrientationReading + \instantiates QmlOrientationSensorReading + \ingroup qml-sensors_reading + \inqmlmodule QtSensors + \since QtSensors 5.0 + \inherits SensorReading + \brief The OrientationReading element holds the most recent OrientationSensor reading. + + The OrientationReading element holds the most recent OrientationSensor reading. + + This element wraps the QOrientationReading class. Please see the documentation for + QOrientationReading for details. + + This element cannot be directly created. +*/ + +QmlOrientationSensorReading::QmlOrientationSensorReading(QOrientationSensor *sensor) + : QmlSensorReading(sensor) + , m_sensor(sensor) +{ +} + +QmlOrientationSensorReading::~QmlOrientationSensorReading() +{ +} + +/*! + \qmlproperty Orientation OrientationReading::orientation + This property holds the orientation of the device. + + Please see QOrientationReading::orientation for information about this property. + + Note that Orientation constants are exposed through the OrientationReading class. + \code + OrientationSensor { + onReadingChanged: { + if (reading.orientation == OrientationReading.TopUp) + // do something + } + } + \endcode +*/ + +QOrientationReading::Orientation QmlOrientationSensorReading::orientation() const +{ + return m_orientation; +} + +QSensorReading *QmlOrientationSensorReading::reading() const +{ + return m_sensor->reading(); +} + +void QmlOrientationSensorReading::readingUpdate() +{ + QOrientationReading::Orientation o = m_sensor->reading()->orientation(); + if (m_orientation != o) { + m_orientation = o; + Q_EMIT orientationChanged(); + } +} diff --git a/src/sensorsquick/qmlorientationsensor_p.h b/src/sensorsquick/qmlorientationsensor_p.h new file mode 100644 index 00000000..4b04b3e8 --- /dev/null +++ b/src/sensorsquick/qmlorientationsensor_p.h @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLORIENTATIONSENSOR_P_H +#define QMLORIENTATIONSENSOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qmlsensor_p.h" +#include + +QT_BEGIN_NAMESPACE + +class QOrientationSensor; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlOrientationSensor : public QmlSensor +{ + Q_OBJECT + QML_NAMED_ELEMENT(OrientationSensor) + QML_ADDED_IN_VERSION(5,0) +public: + explicit QmlOrientationSensor(QObject *parent = 0); + ~QmlOrientationSensor(); + + +private: + QSensor *sensor() const override; + QOrientationSensor *m_sensor; + QmlSensorReading *createReading() const override; +}; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlOrientationSensorReading : public QmlSensorReading +{ + Q_OBJECT + Q_PROPERTY(QOrientationReading::Orientation orientation READ orientation NOTIFY orientationChanged) + QML_NAMED_ELEMENT(OrientationReading) + QML_UNCREATABLE("Cannot create OrientationReading") + QML_ADDED_IN_VERSION(5,0) +public: + + explicit QmlOrientationSensorReading(QOrientationSensor *sensor); + ~QmlOrientationSensorReading(); + + QOrientationReading::Orientation orientation() const; + +Q_SIGNALS: + void orientationChanged(); + +private: + QSensorReading *reading() const override; + void readingUpdate() override; + QOrientationSensor *m_sensor; + QOrientationReading::Orientation m_orientation; +}; + +QT_END_NAMESPACE +#endif diff --git a/src/sensorsquick/qmlpressuresensor.cpp b/src/sensorsquick/qmlpressuresensor.cpp new file mode 100644 index 00000000..08a434b0 --- /dev/null +++ b/src/sensorsquick/qmlpressuresensor.cpp @@ -0,0 +1,151 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Research In Motion +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qmlpressuresensor_p.h" +#include + +/*! + \qmltype PressureSensor + \instantiates QmlPressureSensor + \ingroup qml-sensors_type + \inqmlmodule QtSensors + \since QtSensors 5.1 + \inherits Sensor + \brief The PressureSensor element reports on atmospheric pressure values. + + The PressureSensor element reports on atmospheric pressure values. + + This element wraps the QPressureSensor class. Please see the documentation for + QPressureSensor for details. + + \sa PressureReading +*/ + +QmlPressureSensor::QmlPressureSensor(QObject *parent) + : QmlSensor(parent) + , m_sensor(new QPressureSensor(this)) +{ +} + +QmlPressureSensor::~QmlPressureSensor() +{ +} + +QmlSensorReading *QmlPressureSensor::createReading() const +{ + return new QmlPressureReading(m_sensor); +} + +QSensor *QmlPressureSensor::sensor() const +{ + return m_sensor; +} + +/*! + \qmltype PressureReading + \instantiates QmlPressureReading + \ingroup qml-sensors_reading + \inqmlmodule QtSensors + \since QtSensors 5.1 + \inherits SensorReading + \brief The PressureReading element holds the most recent PressureSensor reading. + + The PressureReading element holds the most recent PressureSensor reading. + + This element wraps the QPressureReading class. Please see the documentation for + QPressureReading for details. + + This element cannot be directly created. +*/ + +QmlPressureReading::QmlPressureReading(QPressureSensor *sensor) + : QmlSensorReading(sensor) + , m_sensor(sensor) + , m_pressure(0) + , m_temperature(0) +{ +} + +QmlPressureReading::~QmlPressureReading() +{ +} + +/*! + \qmlproperty qreal PressureReading::pressure + This property holds the atmospheric pressure value in Pascals. + + Please see QPressureReading::pressure for information about this property. +*/ + +qreal QmlPressureReading::pressure() const +{ + return m_pressure; +} + +/*! + \qmlproperty qreal PressureReading::temperature + This property holds the pressure sensor's temperature value in degrees Celsius. + + Please see QPressureReading::temperature for information about this property. + \since QtSensors 5.2 +*/ + +qreal QmlPressureReading::temperature() const +{ + return m_temperature; +} + +QSensorReading *QmlPressureReading::reading() const +{ + return m_sensor->reading(); +} + +void QmlPressureReading::readingUpdate() +{ + qreal pressure = m_sensor->reading()->pressure(); + if (m_pressure != pressure) { + m_pressure = pressure; + Q_EMIT pressureChanged(); + } + + qreal temperature = m_sensor->reading()->temperature(); + if (m_temperature != temperature) { + m_temperature = temperature; + Q_EMIT temperatureChanged(); + } +} diff --git a/src/sensorsquick/qmlpressuresensor_p.h b/src/sensorsquick/qmlpressuresensor_p.h new file mode 100644 index 00000000..b4b353d1 --- /dev/null +++ b/src/sensorsquick/qmlpressuresensor_p.h @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Research In Motion +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QMLPRESSURESENSOR_P_H +#define QMLPRESSURESENSOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qmlsensor_p.h" + +QT_BEGIN_NAMESPACE + +class QPressureSensor; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlPressureSensor : public QmlSensor +{ + Q_OBJECT + QML_NAMED_ELEMENT(PressureSensor) + QML_ADDED_IN_VERSION(5,1) +public: + explicit QmlPressureSensor(QObject *parent = 0); + ~QmlPressureSensor(); + +private: + QSensor *sensor() const override; + QmlSensorReading *createReading() const override; + + QPressureSensor *m_sensor; +}; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlPressureReading : public QmlSensorReading +{ + Q_OBJECT + Q_PROPERTY(qreal pressure READ pressure NOTIFY pressureChanged) + Q_PROPERTY(qreal temperature READ temperature NOTIFY temperatureChanged REVISION 1) + QML_NAMED_ELEMENT(PressureReading) + QML_UNCREATABLE("Cannot create PressureReading") + QML_ADDED_IN_VERSION(5,1) +public: + explicit QmlPressureReading(QPressureSensor *sensor); + ~QmlPressureReading(); + + qreal pressure() const; + qreal temperature() const; + +Q_SIGNALS: + void pressureChanged(); + Q_REVISION(1) void temperatureChanged(); + +private: + QSensorReading *reading() const override; + void readingUpdate() override; + + QPressureSensor *m_sensor; + qreal m_pressure; + qreal m_temperature; +}; + +QT_END_NAMESPACE +#endif diff --git a/src/sensorsquick/qmlproximitysensor.cpp b/src/sensorsquick/qmlproximitysensor.cpp new file mode 100644 index 00000000..73767f64 --- /dev/null +++ b/src/sensorsquick/qmlproximitysensor.cpp @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmlproximitysensor_p.h" +#include + +/*! + \qmltype ProximitySensor + \instantiates QmlProximitySensor + \ingroup qml-sensors_type + \inqmlmodule QtSensors + \since QtSensors 5.0 + \inherits Sensor + \brief The ProximitySensor element reports on object proximity. + + The ProximitySensor element reports on object proximity. + + This element wraps the QProximitySensor class. Please see the documentation for + QProximitySensor for details. + + \sa ProximityReading +*/ + +QmlProximitySensor::QmlProximitySensor(QObject *parent) + : QmlSensor(parent) + , m_sensor(new QProximitySensor(this)) +{ +} + +QmlProximitySensor::~QmlProximitySensor() +{ +} + +QmlSensorReading *QmlProximitySensor::createReading() const +{ + return new QmlProximitySensorReading(m_sensor); +} + +QSensor *QmlProximitySensor::sensor() const +{ + return m_sensor; +} + +/*! + \qmltype ProximityReading + \instantiates QmlProximitySensorReading + \ingroup qml-sensors_reading + \inqmlmodule QtSensors + \since QtSensors 5.0 + \inherits SensorReading + \brief The ProximityReading element holds the most recent ProximitySensor reading. + + The ProximityReading element holds the most recent ProximitySensor reading. + + This element wraps the QProximityReading class. Please see the documentation for + QProximityReading for details. + + This element cannot be directly created. +*/ + +QmlProximitySensorReading::QmlProximitySensorReading(QProximitySensor *sensor) + : QmlSensorReading(sensor) + , m_sensor(sensor) +{ +} + +QmlProximitySensorReading::~QmlProximitySensorReading() +{ +} + +/*! + \qmlproperty bool ProximityReading::near + This property holds a value indicating if something is near. + + Please see QProximityReading::near for information about this property. +*/ + +bool QmlProximitySensorReading::near() const +{ + return m_near; +} + +QSensorReading *QmlProximitySensorReading::reading() const +{ + return m_sensor->reading(); +} + +void QmlProximitySensorReading::readingUpdate() +{ + bool pNear = m_sensor->reading()->close(); + if (m_near != pNear) { + m_near = pNear; + Q_EMIT nearChanged(); + } +} diff --git a/src/sensorsquick/qmlproximitysensor_p.h b/src/sensorsquick/qmlproximitysensor_p.h new file mode 100644 index 00000000..9d28dfcf --- /dev/null +++ b/src/sensorsquick/qmlproximitysensor_p.h @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLPROXIMITYSENSOR_P_H +#define QMLPROXIMITYSENSOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qmlsensor_p.h" +#ifdef near +#undef near +#endif +QT_BEGIN_NAMESPACE + +class QProximitySensor; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlProximitySensor : public QmlSensor +{ + Q_OBJECT + QML_NAMED_ELEMENT(ProximitySensor) + QML_ADDED_IN_VERSION(5,0) +public: + explicit QmlProximitySensor(QObject *parent = 0); + ~QmlProximitySensor(); + + +private: + QSensor *sensor() const override; + QProximitySensor *m_sensor; + QmlSensorReading *createReading() const override; +}; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlProximitySensorReading : public QmlSensorReading +{ + Q_OBJECT + Q_PROPERTY(bool near READ near NOTIFY nearChanged) + QML_NAMED_ELEMENT(ProximityReading) + QML_UNCREATABLE("Cannot create ProximityReading") + QML_ADDED_IN_VERSION(5,0) +public: + explicit QmlProximitySensorReading(QProximitySensor *sensor); + ~QmlProximitySensorReading(); + + bool near() const; + +Q_SIGNALS: + void nearChanged(); + +private: + QSensorReading *reading() const override; + void readingUpdate() override; + QProximitySensor *m_sensor; + bool m_near; +}; + +QT_END_NAMESPACE +#endif diff --git a/src/sensorsquick/qmlrotationsensor.cpp b/src/sensorsquick/qmlrotationsensor.cpp new file mode 100644 index 00000000..ef04c6bb --- /dev/null +++ b/src/sensorsquick/qmlrotationsensor.cpp @@ -0,0 +1,184 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmlrotationsensor_p.h" +#include + +/*! + \qmltype RotationSensor + \instantiates QmlRotationSensor + \ingroup qml-sensors_type + \inqmlmodule QtSensors + \since QtSensors 5.0 + \inherits Sensor + \brief The RotationSensor element reports on device rotation + around the X, Y and Z axes. + + The RotationSensor element reports on device rotation + around the X, Y and Z axes. + + This element wraps the QRotationSensor class. Please see the documentation for + QRotationSensor for details. + + \sa RotationReading +*/ + +QmlRotationSensor::QmlRotationSensor(QObject *parent) + : QmlSensor(parent) + , m_sensor(new QRotationSensor(this)) +{ + connect(m_sensor, SIGNAL(hasZChanged(bool)), this, SIGNAL(hasZChanged(bool))); +} + +QmlRotationSensor::~QmlRotationSensor() +{ +} + +QmlSensorReading *QmlRotationSensor::createReading() const +{ + return new QmlRotationSensorReading(m_sensor); +} + +QSensor *QmlRotationSensor::sensor() const +{ + return m_sensor; +} + +/*! + \qmlproperty qreal RotationSensor::hasZ + This property holds a value indicating if the z angle is available. + + Please see QRotationSensor::hasZ for information about this property. +*/ + +bool QmlRotationSensor::hasZ() const +{ + return m_sensor->hasZ(); +} + +void QmlRotationSensor::_update() +{ +} + +/*! + \qmltype RotationReading + \instantiates QmlRotationSensorReading + \ingroup qml-sensors_reading + \inqmlmodule QtSensors + \since QtSensors 5.0 + \inherits SensorReading + \brief The RotationReading element holds the most recent RotationSensor reading. + + The RotationReading element holds the most recent RotationSensor reading. + + This element wraps the QRotationReading class. Please see the documentation for + QRotationReading for details. + + This element cannot be directly created. +*/ + +QmlRotationSensorReading::QmlRotationSensorReading(QRotationSensor *sensor) + : QmlSensorReading(sensor) + , m_sensor(sensor) +{ +} + +QmlRotationSensorReading::~QmlRotationSensorReading() +{ +} + +/*! + \qmlproperty qreal RotationReading::x + This property holds the rotation around the x axis. + + Please see QRotationReading::x for information about this property. +*/ + +qreal QmlRotationSensorReading::x() const +{ + return m_x; +} + +/*! + \qmlproperty qreal RotationReading::y + This property holds the rotation around the y axis. + + Please see QRotationReading::y for information about this property. +*/ + +qreal QmlRotationSensorReading::y() const +{ + return m_y; +} + +/*! + \qmlproperty qreal RotationReading::z + This property holds the rotation around the z axis. + + Please see QRotationReading::z for information about this property. +*/ + +qreal QmlRotationSensorReading::z() const +{ + return m_z; +} + +QSensorReading *QmlRotationSensorReading::reading() const +{ + return m_sensor->reading(); +} + +void QmlRotationSensorReading::readingUpdate() +{ + qreal rX = m_sensor->reading()->x(); + if (m_x != rX) { + m_x = rX; + Q_EMIT xChanged(); + } + qreal rY = m_sensor->reading()->y(); + if (m_y != rY) { + m_y = rY; + Q_EMIT yChanged(); + } + qreal rZ = m_sensor->reading()->z(); + if (m_z != rZ) { + m_z = rZ; + Q_EMIT zChanged(); + } +} diff --git a/src/sensorsquick/qmlrotationsensor_p.h b/src/sensorsquick/qmlrotationsensor_p.h new file mode 100644 index 00000000..f14ad791 --- /dev/null +++ b/src/sensorsquick/qmlrotationsensor_p.h @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLROTATIONSENSOR_P_H +#define QMLROTATIONSENSOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qmlsensor_p.h" + +QT_BEGIN_NAMESPACE + +class QRotationSensor; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlRotationSensor : public QmlSensor +{ + Q_OBJECT + Q_PROPERTY(bool hasZ READ hasZ NOTIFY hasZChanged) + QML_NAMED_ELEMENT(RotationSensor) + QML_ADDED_IN_VERSION(5,0) +public: + explicit QmlRotationSensor(QObject *parent = 0); + ~QmlRotationSensor(); + + bool hasZ() const; + +Q_SIGNALS: + void hasZChanged(bool hasZ); + +private: + QSensor *sensor() const override; + void _update() override; + QRotationSensor *m_sensor; + QmlSensorReading *createReading() const override; +}; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlRotationSensorReading : public QmlSensorReading +{ + Q_OBJECT + Q_PROPERTY(qreal x READ x NOTIFY xChanged) + Q_PROPERTY(qreal y READ y NOTIFY yChanged) + Q_PROPERTY(qreal z READ z NOTIFY zChanged) + QML_NAMED_ELEMENT(RotationReading) + QML_UNCREATABLE("Cannot create RotationReading") + QML_ADDED_IN_VERSION(5,0) +public: + explicit QmlRotationSensorReading(QRotationSensor *sensor); + ~QmlRotationSensorReading(); + + qreal x() const; + qreal y() const; + qreal z() const; + +Q_SIGNALS: + void xChanged(); + void yChanged(); + void zChanged(); + +private: + QSensorReading *reading() const override; + void readingUpdate() override; + QRotationSensor *m_sensor; + qreal m_x; + qreal m_y; + qreal m_z; +}; + +QT_END_NAMESPACE +#endif diff --git a/src/sensorsquick/qmlsensor.cpp b/src/sensorsquick/qmlsensor.cpp new file mode 100644 index 00000000..0afa91ea --- /dev/null +++ b/src/sensorsquick/qmlsensor.cpp @@ -0,0 +1,577 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmlsensor_p.h" +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QmlSensorPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QmlSensor) +public: + + QList availableRanges; + QList outputRanges; +}; + +template +qsizetype readonlyListCount(QQmlListProperty *p) +{ + return static_cast *>(p->data)->count(); +} + +template +Item *readonlyListAt(QQmlListProperty *p, qsizetype idx) +{ + return static_cast *>(p->data)->at(idx); +}; + +template +QQmlListProperty readonlyListProperty(const QObject *o, const QList *list) +{ + // Unfortunately QQmlListProperty won't accept a const object, even on the readonly ctor. + return QQmlListProperty(const_cast(o), const_cast *>(list), + readonlyListCount, readonlyListAt); +} + +/*! + \qmltype Sensor + \instantiates QmlSensor + \inqmlmodule QtSensors + \since QtSensors 5.0 + \brief The Sensor element serves as a base type for sensors. + + The Sensor element serves as a base type for sensors. + + This element wraps the QSensor class. Please see the documentation for + QSensor for details. + + This element cannot be directly created. Please use one of the sub-classes instead. +*/ + +QmlSensor::QmlSensor(QObject *parent) + : QObject(*(new QmlSensorPrivate), parent) + , m_parsed(false) + , m_active(false) + , m_reading(0) +{ +} + +QmlSensor::~QmlSensor() +{ +} + +/*! + \qmlproperty string Sensor::identifier + This property holds the backend identifier for the sensor. + + Please see QSensor::identifier for information about this property. +*/ + +QString QmlSensor::identifier() const +{ + return m_identifier; +} + +void QmlSensor::setIdentifier(const QString &identifier) +{ + if (m_parsed) return; + m_identifier = identifier; + Q_EMIT identifierChanged(); +} + +/*! + \qmlproperty string Sensor::type + This property holds the type of the sensor. +*/ + +QString QmlSensor::type() const +{ + return QString::fromLatin1(sensor()->type()); +} + +/*! + \qmlproperty bool Sensor::connectedToBackend + This property holds a value indicating if the sensor has connected to a backend. + + Please see QSensor::connectedToBackend for information about this property. +*/ + +bool QmlSensor::isConnectedToBackend() const +{ + return sensor()->isConnectedToBackend(); +} + +/*! + \qmlproperty bool Sensor::busy + This property holds a value to indicate if the sensor is busy. + + Please see QSensor::busy for information about this property. +*/ + +bool QmlSensor::isBusy() const +{ + return sensor()->isBusy(); +} + +/*! + \qmlproperty bool Sensor::active + This property holds a value to indicate if the sensor is active. + + Please see QSensor::active for information about this property. +*/ + +void QmlSensor::setActive(bool active) +{ + m_active = active; + if (!m_parsed) return; // delay (it'll get called again later)! + bool wasActive = sensor()->isActive(); + if (wasActive == active) return; + if (active) { + sensor()->start(); + m_active = sensor()->isActive(); + } else { + sensor()->stop(); + } + if (m_active != wasActive) + emit activeChanged(); +} + +bool QmlSensor::isActive() const +{ + return m_active; +} + +/*! + \qmlproperty bool Sensor::alwaysOn + This property holds a value to indicate if the sensor should remain running when the screen is off. + + Please see QSensor::alwaysOn for information about this property. +*/ + +bool QmlSensor::isAlwaysOn() const +{ + return sensor()->isAlwaysOn(); +} + +void QmlSensor::setAlwaysOn(bool alwaysOn) +{ + sensor()->setAlwaysOn(alwaysOn); +} + +/*! + \qmlproperty bool Sensor::skipDuplicates + \since QtSensors 5.1 + + This property indicates whether duplicate reading values should be omitted. + + Please see QSensor::skipDuplicates for information about this property. +*/ + +bool QmlSensor::skipDuplicates() const +{ + return sensor()->skipDuplicates(); +} + +void QmlSensor::setSkipDuplicates(bool skipDuplicates) +{ + sensor()->setSkipDuplicates(skipDuplicates); +} + +/*! + \qmlproperty list Sensor::availableDataRates + This property holds the data rates that the sensor supports. + + Please see QSensor::availableDataRates for information about this property. +*/ +QQmlListProperty QmlSensor::availableDataRates() const +{ + Q_D(const QmlSensor); + return readonlyListProperty(this, &d->availableRanges); +} + +/*! + \qmlproperty int Sensor::dataRate + This property holds the data rate that the sensor should be run at. + + Please see QSensor::dataRate for information about this property. +*/ + +int QmlSensor::dataRate() const +{ + return sensor()->dataRate(); +} + +void QmlSensor::setDataRate(int rate) +{ + if (rate != dataRate()) { + sensor()->setDataRate(rate); + Q_EMIT dataRateChanged(); + } +} + +/*! + \qmlproperty list Sensor::outputRanges + This property holds a list of output ranges the sensor supports. + + Please see QSensor::outputRanges for information about this property. +*/ + +QQmlListProperty QmlSensor::outputRanges() const +{ + Q_D(const QmlSensor); + return readonlyListProperty(this, &d->outputRanges); +} + +/*! + \qmlproperty int Sensor::outputRange + This property holds the output range in use by the sensor. + + Please see QSensor::outputRange for information about this property. +*/ + +int QmlSensor::outputRange() const +{ + return sensor()->outputRange(); +} + +void QmlSensor::setOutputRange(int index) +{ + int oldRange = outputRange(); + if (oldRange == index) return; + sensor()->setOutputRange(index); + if (sensor()->outputRange() == index) + Q_EMIT outputRangeChanged(); +} + +/*! + \qmlproperty string Sensor::description + This property holds a descriptive string for the sensor. +*/ + +QString QmlSensor::description() const +{ + return sensor()->description(); +} + +/*! + \qmlproperty int Sensor::error + This property holds the last error code set on the sensor. +*/ + +int QmlSensor::error() const +{ + return sensor()->error(); +} + +/*! + \qmlproperty SensorReading Sensor::reading + This property holds the reading class. + + Please see QSensor::reading for information about this property. + \sa {QML Reading types} +*/ + +QmlSensorReading *QmlSensor::reading() const +{ + return m_reading; +} + +/*! + \qmlproperty Sensor::AxesOrientationMode Sensor::axesOrientationMode + \since QtSensors 5.1 + This property holds the mode that affects how the screen orientation changes reading values. + + Please see QSensor::axesOrientationMode for information about this property. +*/ + +QmlSensor::AxesOrientationMode QmlSensor::axesOrientationMode() const +{ + return static_cast(sensor()->axesOrientationMode()); +} + +void QmlSensor::setAxesOrientationMode(QmlSensor::AxesOrientationMode axesOrientationMode) +{ + sensor()->setAxesOrientationMode(static_cast(axesOrientationMode)); +} + +/*! + \qmlproperty int Sensor::currentOrientation + \since QtSensors 5.1 + This property holds the current orientation that is used for rotating the reading values. + + Please see QSensor::currentOrientation for information about this property. +*/ + +int QmlSensor::currentOrientation() const +{ + return sensor()->currentOrientation(); +} + +/*! + \qmlproperty int Sensor::userOrientation + \since QtSensors 5.1 + This property holds the angle used for rotating the reading values in the UserOrientation mode. + + Please see QSensor::userOrientation for information about this property. +*/ + +int QmlSensor::userOrientation() const +{ + return sensor()->userOrientation(); +} + +void QmlSensor::setUserOrientation(int userOrientation) +{ + sensor()->setUserOrientation(userOrientation); +} + +/*! + \qmlproperty int Sensor::maxBufferSize + \since QtSensors 5.1 + This property holds the maximum buffer size. + + Please see QSensor::maxBufferSize for information about this property. +*/ + +int QmlSensor::maxBufferSize() const +{ + return sensor()->maxBufferSize(); +} + +/*! + \qmlproperty int Sensor::efficientBufferSize + \since QtSensors 5.1 + The property holds the most efficient buffer size. + + Please see QSensor::efficientBufferSize for information about this property. +*/ + +int QmlSensor::efficientBufferSize() const +{ + return sensor()->efficientBufferSize(); +} + +/*! + \qmlproperty int Sensor::bufferSize + \since QtSensors 5.1 + This property holds the size of the buffer. + + Please see QSensor::bufferSize for information about this property. +*/ + +int QmlSensor::bufferSize() const +{ + return sensor()->bufferSize(); +} + +void QmlSensor::setBufferSize(int bufferSize) +{ + sensor()->setBufferSize(bufferSize); +} + +/*! + \qmlmethod bool Sensor::start() + Start retrieving values from the sensor. Returns true if the sensor + was started, false otherwise. + + Please see QSensor::start() for information. +*/ + +bool QmlSensor::start() +{ + setActive(true); + return isActive(); +} + +/*! + \qmlmethod bool Sensor::stop() + Stop retrieving values from the sensor. + Returns true if the sensor was stopped, false otherwise. + + Please see QSensor::stop() for information. +*/ + +void QmlSensor::stop() +{ + setActive(false); +} + +void QmlSensor::classBegin() +{ +} + +void QmlSensor::componentComplete() +{ + m_parsed = true; + + connect(sensor(), SIGNAL(sensorError(int)), this, SIGNAL(errorChanged())); + connect(sensor(), SIGNAL(activeChanged()), this, SIGNAL(activeChanged())); + connect(sensor(), SIGNAL(alwaysOnChanged()), this, SIGNAL(alwaysOnChanged())); + connect(sensor(), SIGNAL(skipDuplicatesChanged(bool)), this, SIGNAL(skipDuplicatesChanged(bool))); + connect(sensor(), SIGNAL(axesOrientationModeChanged(AxesOrientationMode)), + this, SIGNAL(axesOrientationModeChanged(AxesOrientationMode))); + connect(sensor(), SIGNAL(userOrientationChanged(int)), this, SIGNAL(userOrientationChanged(int))); + connect(sensor(), SIGNAL(currentOrientationChanged(int)), this, SIGNAL(currentOrientationChanged(int))); + connect(sensor(), SIGNAL(bufferSizeChanged(int)), this, SIGNAL(bufferSizeChanged(int))); + connect(sensor(), SIGNAL(maxBufferSizeChanged(int)), this, SIGNAL(maxBufferSizeChanged(int))); + connect(sensor(), SIGNAL(efficientBufferSizeChanged(int)), this, SIGNAL(efficientBufferSizeChanged(int))); + + // We need to set this on the sensor object now + sensor()->setIdentifier(m_identifier.toLocal8Bit()); + + // These can change! + QByteArray oldIdentifier = sensor()->identifier(); + int oldDataRate = dataRate(); + int oldOutputRange = outputRange(); + + bool ok = sensor()->connectToBackend(); + if (ok) { + Q_EMIT connectedToBackendChanged(); + m_reading = createReading(); + m_reading->setParent(this); + } + + if (oldIdentifier != sensor()->identifier()) { + m_identifier = QString::fromLatin1(sensor()->identifier()); + Q_EMIT identifierChanged(); + } + if (oldDataRate != dataRate()) + Q_EMIT dataRateChanged(); + if (oldOutputRange != outputRange()) + Q_EMIT outputRangeChanged(); + + Q_D(QmlSensor); + const auto available = sensor()->availableDataRates(); + d->availableRanges.reserve(available.size()); + for (const qrange &r : available) { + auto *range = new QmlSensorRange(this); + range->setMinumum(r.first); + range->setMaximum(r.second); + d->availableRanges.append(range); + } + const auto output = sensor()->outputRanges(); + d->outputRanges.reserve(output.size()); + for (const qoutputrange &r : output) { + auto *range = new QmlSensorOutputRange(this); + range->setMinimum(r.minimum); + range->setMaximum(r.maximum); + range->setAccuracy(r.accuracy); + d->outputRanges.append(range); + } + + // meta-data should become non-empty + if (!description().isEmpty()) + Q_EMIT descriptionChanged(); + if (available.count()) + Q_EMIT availableDataRatesChanged(); + if (output.count()) + Q_EMIT outputRangesChanged(); + + _update(); + + connect(sensor(), SIGNAL(readingChanged()), this, SLOT(updateReading())); + if (m_active) { + m_active = false; + start(); + } +} + +void QmlSensor::_update() +{ +} + +void QmlSensor::updateReading() +{ + if (m_reading) { + m_reading->update(); + Q_EMIT readingChanged(); + } +} + +/*! + \qmltype SensorReading + \instantiates QmlSensorReading + \inqmlmodule QtSensors + \since QtSensors 5.0 + \brief The SensorReading element serves as a base type for sensor readings. + + The SensorReading element serves as a base type for sensor readings. + + This element wraps the QSensorReading class. Please see the documentation for + QSensorReading for details. + + This element cannot be directly created. +*/ + +QmlSensorReading::QmlSensorReading(QSensor *) + : QObject(0) +{ +} + +QmlSensorReading::~QmlSensorReading() +{ +} + +/*! + \qmlproperty quint64 SensorReading::timestamp + A timestamp for the reading. + + Please see QSensorReading::timestamp for information about this property. +*/ + +quint64 QmlSensorReading::timestamp() const +{ + return m_timestamp; +} + +void QmlSensorReading::update() +{ + quint64 ts = reading()->timestamp(); + if (m_timestamp != ts) { + m_timestamp = ts; + Q_EMIT timestampChanged(); + } + readingUpdate(); +} + +QT_END_NAMESPACE diff --git a/src/sensorsquick/qmlsensor_p.h b/src/sensorsquick/qmlsensor_p.h new file mode 100644 index 00000000..f31ee1bf --- /dev/null +++ b/src/sensorsquick/qmlsensor_p.h @@ -0,0 +1,226 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLSENSOR_P_H +#define QMLSENSOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qsensorsquickglobal_p.h" + +#include +#include +#include +#include +#include "qmlsensorrange_p.h" + +QT_BEGIN_NAMESPACE + +class QSensor; +class QSensorReading; + +class QmlSensorReading; + +class QmlSensorPrivate; +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlSensor : public QObject, public QQmlParserStatus +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QmlSensor) + Q_ENUMS(AxesOrientationMode) + Q_INTERFACES(QQmlParserStatus) + Q_PROPERTY(QString identifier READ identifier WRITE setIdentifier NOTIFY identifierChanged) + Q_PROPERTY(QString type READ type NOTIFY typeChanged) + Q_PROPERTY(bool connectedToBackend READ isConnectedToBackend NOTIFY connectedToBackendChanged) + Q_PROPERTY(QQmlListProperty availableDataRates READ availableDataRates NOTIFY availableDataRatesChanged) + Q_PROPERTY(int dataRate READ dataRate WRITE setDataRate NOTIFY dataRateChanged) + Q_PROPERTY(QmlSensorReading* reading READ reading NOTIFY readingChanged) + Q_PROPERTY(bool busy READ isBusy) + Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged) + Q_PROPERTY(QQmlListProperty outputRanges READ outputRanges NOTIFY outputRangesChanged) + Q_PROPERTY(int outputRange READ outputRange WRITE setOutputRange NOTIFY outputRangeChanged) + Q_PROPERTY(QString description READ description NOTIFY descriptionChanged) + Q_PROPERTY(int error READ error NOTIFY errorChanged) + Q_PROPERTY(bool alwaysOn READ isAlwaysOn WRITE setAlwaysOn NOTIFY alwaysOnChanged) + Q_PROPERTY(bool skipDuplicates READ skipDuplicates WRITE setSkipDuplicates NOTIFY skipDuplicatesChanged REVISION 1) + Q_PROPERTY(AxesOrientationMode axesOrientationMode READ axesOrientationMode WRITE setAxesOrientationMode NOTIFY axesOrientationModeChanged REVISION 1) + Q_PROPERTY(int currentOrientation READ currentOrientation NOTIFY currentOrientationChanged REVISION 1) + Q_PROPERTY(int userOrientation READ userOrientation WRITE setUserOrientation NOTIFY userOrientationChanged REVISION 1) + Q_PROPERTY(int maxBufferSize READ maxBufferSize NOTIFY maxBufferSizeChanged REVISION 1) + Q_PROPERTY(int efficientBufferSize READ efficientBufferSize NOTIFY efficientBufferSizeChanged REVISION 1) + Q_PROPERTY(int bufferSize READ bufferSize WRITE setBufferSize NOTIFY bufferSizeChanged REVISION 1) + + QML_NAMED_ELEMENT(Sensor) + QML_UNCREATABLE("Cannot create Sensor") + QML_ADDED_IN_VERSION(5,0) +public: + // Keep in sync with QSensor::AxesOrientationMode + enum AxesOrientationMode { + FixedOrientation, + AutomaticOrientation, + UserOrientation + }; + + explicit QmlSensor(QObject *parent = 0); + ~QmlSensor(); + + QString identifier() const; + void setIdentifier(const QString &identifier); + + QString type() const; + + bool isConnectedToBackend() const; + + bool isBusy() const; + + void setActive(bool active); + bool isActive() const; + + bool isAlwaysOn() const; + void setAlwaysOn(bool alwaysOn); + + bool skipDuplicates() const; + void setSkipDuplicates(bool skipDuplicates); + + QQmlListProperty availableDataRates() const; + int dataRate() const; + void setDataRate(int rate); + + QQmlListProperty outputRanges() const; + int outputRange() const; + void setOutputRange(int index); + + QString description() const; + int error() const; + + QmlSensorReading *reading() const; + + AxesOrientationMode axesOrientationMode() const; + void setAxesOrientationMode(AxesOrientationMode axesOrientationMode); + + int currentOrientation() const; + + int userOrientation() const; + void setUserOrientation(int userOrientation); + + int maxBufferSize() const; + + int efficientBufferSize() const; + + int bufferSize() const; + void setBufferSize(int bufferSize); + +public Q_SLOTS: + bool start(); + void stop(); + +Q_SIGNALS: + void identifierChanged(); + void typeChanged(); + void connectedToBackendChanged(); + void availableDataRatesChanged(); + void dataRateChanged(); + void readingChanged(); + void activeChanged(); + void outputRangesChanged(); + void outputRangeChanged(); + void descriptionChanged(); + void errorChanged(); + void alwaysOnChanged(); + Q_REVISION(1) void skipDuplicatesChanged(bool skipDuplicates); + Q_REVISION(1) void axesOrientationModeChanged(AxesOrientationMode axesOrientationMode); + Q_REVISION(1) void currentOrientationChanged(int currentOrientation); + Q_REVISION(1) void userOrientationChanged(int userOrientation); + Q_REVISION(1) void maxBufferSizeChanged(int maxBufferSize); + Q_REVISION(1) void efficientBufferSizeChanged(int efficientBufferSize); + Q_REVISION(1) void bufferSizeChanged(int bufferSize); + +protected: + virtual QSensor *sensor() const = 0; + virtual QmlSensorReading *createReading() const = 0; + +private Q_SLOTS: + void updateReading(); + +protected Q_SLOTS: + void componentComplete() override; + +private: + void classBegin() override; + virtual void _update(); + bool m_parsed; + bool m_active; + QString m_identifier; + QmlSensorReading *m_reading; +}; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlSensorReading : public QObject +{ + Q_OBJECT + Q_PROPERTY(quint64 timestamp READ timestamp NOTIFY timestampChanged) + QML_NAMED_ELEMENT(SensorReading) + QML_UNCREATABLE("Cannot create SensorReading") + QML_ADDED_IN_VERSION(5,0) +public: + explicit QmlSensorReading(QSensor *sensor); + ~QmlSensorReading(); + + quint64 timestamp() const; + void update(); + +Q_SIGNALS: + void timestampChanged(); + +private: + virtual QSensorReading *reading() const = 0; + virtual void readingUpdate() = 0; + quint64 m_timestamp; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/sensorsquick/qmlsensorgesture.cpp b/src/sensorsquick/qmlsensorgesture.cpp new file mode 100644 index 00000000..2879995c --- /dev/null +++ b/src/sensorsquick/qmlsensorgesture.cpp @@ -0,0 +1,262 @@ + /**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmlsensorgesture_p.h" +#include +#include + +QT_BEGIN_NAMESPACE + +/*! + \qmltype SensorGesture + \instantiates QmlSensorGesture + \inqmlmodule QtSensors + \since QtSensors 5.0 + \brief Provides notifications when sensor-based gestures are detected. + + This type provides notification when sensor gestures are triggered. + + 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 + } + } + \endqml + + \l {Qt Sensor Gestures} contains a list of currently supported sensor gestures and their + descriptions. + + +*/ +QmlSensorGesture::QmlSensorGesture(QObject* parent) + : QObject(parent) + , isEnabled(false) + , initDone(false) + , sensorGesture(0) + , sensorGestureManager(new QSensorGestureManager(this)) +{ + connect(sensorGestureManager, SIGNAL(newSensorGestureAvailable()), SIGNAL(availableGesturesChanged())); +} + +QmlSensorGesture::~QmlSensorGesture() +{ +} + +/* + QQmlParserStatus interface implementation +*/ +void QmlSensorGesture::classBegin() +{ +} + +void QmlSensorGesture::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 SensorGesture::availableGestures + This property can be used to determine all available gestures on the system. +*/ +QStringList QmlSensorGesture::availableGestures() +{ + return sensorGestureManager->gestureIds(); +} + +/*! + \qmlproperty stringlist 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 {SensorGesture::availableGestures} {availableGestures} property. + + \sa {QtSensorGestures Plugins} +*/ +QStringList QmlSensorGesture::gestures() const +{ + return gestureList; +} + +void QmlSensorGesture::setGestures(const QStringList& value) +{ + if (gestureList == value) + return; + + if (initDone && enabled()) { + qWarning() << "Cannot change gestures while running."; + return; + } + gestureList = value; + createGesture(); + Q_EMIT gesturesChanged(); +} + + +/*! + \qmlproperty stringlist SensorGesture::validGestures + This property holds the requested gestures that were found on the system. +*/ +QStringList QmlSensorGesture::validGestures() const +{ + if (sensorGesture) + return sensorGesture->validIds(); + return QStringList(); +} + +/*! + \qmlproperty stringlist SensorGesture::invalidGestures + This property holds the requested gestures that were not found on the system. +*/ +QStringList QmlSensorGesture::invalidGestures() const +{ + if (sensorGesture) + return sensorGesture->invalidIds(); + return QStringList(); +} + +/*! + \qmlproperty bool SensorGesture::enabled + This property can be used to activate or deactivate the sensor gesture. + Default value is false; + \sa {SensorGesture::detected}, {detected} +*/ +bool QmlSensorGesture::enabled() const +{ + return isEnabled; +} + +void QmlSensorGesture::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 SensorGesture::detected(string gesture) + This signal is emitted whenever a gesture is detected. + The \a gesture parameter contains the gesture that was detected. + + The corresponding handler is \c onDetected. +*/ + +/* + private function implementation +*/ +void QmlSensorGesture::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 QmlSensorGesture::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 function implementation +*/ + +QT_END_NAMESPACE diff --git a/src/sensorsquick/qmlsensorgesture_p.h b/src/sensorsquick/qmlsensorgesture_p.h new file mode 100644 index 00000000..75f3e19a --- /dev/null +++ b/src/sensorsquick/qmlsensorgesture_p.h @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLSENSORGESTURE_P_H +#define QMLSENSORGESTURE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +#include "qsensorsquickglobal_p.h" + +QT_BEGIN_NAMESPACE + +class QSensorGesture; +class QSensorGestureManager; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlSensorGesture : 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) + QML_NAMED_ELEMENT(SensorGesture) + QML_ADDED_IN_VERSION(5,0) + +public: + explicit QmlSensorGesture(QObject* parent = 0); + ~QmlSensorGesture(); + void classBegin() override; + void componentComplete() 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 + +#endif diff --git a/src/sensorsquick/qmlsensorglobal.cpp b/src/sensorsquick/qmlsensorglobal.cpp new file mode 100644 index 00000000..4699a33d --- /dev/null +++ b/src/sensorsquick/qmlsensorglobal.cpp @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmlsensorglobal_p.h" +#include + +QT_BEGIN_NAMESPACE + +/*! + \qmltype QmlSensors + \instantiates QmlSensorGlobal + \inqmlmodule QtSensors + \since QtSensors 5.0 + \brief The QmlSensors singleton provides the module API. + + The QmlSensors singleton provides the module API. + + This element cannot be directly created. It can only be accessed via a namespace import. + + \code + import QtSensors 5.11 + import QtSensors 5.11 as Sensors + ... + Component.onCompleted: { + var types = Sensors.QmlSensors.sensorTypes(); + console.log(types.join(", ")); + } + \endcode +*/ + +QmlSensorGlobal::QmlSensorGlobal(QObject *parent) + : QObject(parent) + , m_sensor(new QSensor(QByteArray(), this)) +{ + connect(m_sensor, SIGNAL(availableSensorsChanged()), this, SIGNAL(availableSensorsChanged())); +} + +QmlSensorGlobal::~QmlSensorGlobal() +{ +} + +/*! + \qmlmethod list QmlSensors::sensorTypes() + Returns a list of the sensor types that have been registered. + + Please see QSensor::sensorTypes() for information. +*/ +QStringList QmlSensorGlobal::sensorTypes() const +{ + QStringList ret; + const QList sensorTypes = QSensor::sensorTypes(); + ret.reserve(sensorTypes.count()); + foreach (const QByteArray &type, sensorTypes) + ret << QString::fromLocal8Bit(type); + return ret; +} + +/*! + \qmlmethod list QmlSensors::sensorsForType(type) + Returns a list of the sensor identifiers that have been registered for \a type. + + Please see QSensor::sensorsForType() for information. +*/ +QStringList QmlSensorGlobal::sensorsForType(const QString &type) const +{ + QStringList ret; + const QList sensors = QSensor::sensorsForType(type.toLocal8Bit()); + ret.reserve(sensors.count()); + foreach (const QByteArray &identifier, sensors) + ret << QString::fromLocal8Bit(identifier); + return ret; +} + +/*! + \qmlmethod string QmlSensors::defaultSensorForType(type) + Returns the default sensor identifier that has been registered for \a type. + + Please see QSensor::defaultSensorForType() for information. +*/ +QString QmlSensorGlobal::defaultSensorForType(const QString &type) const +{ + return QString::fromLocal8Bit(QSensor::defaultSensorForType(type.toLocal8Bit())); +} + +QT_END_NAMESPACE diff --git a/src/sensorsquick/qmlsensorglobal_p.h b/src/sensorsquick/qmlsensorglobal_p.h new file mode 100644 index 00000000..cf570d90 --- /dev/null +++ b/src/sensorsquick/qmlsensorglobal_p.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLSENSORGLOBAL_P_H +#define QMLSENSORGLOBAL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qsensorsquickglobal_p.h" +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QSensor; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlSensorGlobal : public QObject +{ + Q_OBJECT +public: + explicit QmlSensorGlobal(QObject *parent = 0); + ~QmlSensorGlobal(); + + Q_INVOKABLE QStringList sensorTypes() const; + Q_INVOKABLE QStringList sensorsForType(const QString &type) const; + Q_INVOKABLE QString defaultSensorForType(const QString &type) const; + QML_NAMED_ELEMENT(QmlSensors) + QML_SINGLETON + QML_ADDED_IN_VERSION(5,0) + +Q_SIGNALS: + void availableSensorsChanged(); + +private: + QSensor *m_sensor; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/sensorsquick/qmlsensorrange.cpp b/src/sensorsquick/qmlsensorrange.cpp new file mode 100644 index 00000000..3e9a56b2 --- /dev/null +++ b/src/sensorsquick/qmlsensorrange.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmlsensorrange_p.h" + +QmlSensorRange::QmlSensorRange(QObject *parent) + : QObject(parent), + min(0), + max(0) +{ +} + +QmlSensorRange::~QmlSensorRange() +{ +} + +int QmlSensorRange::minimum() const +{ + return min; +} + +int QmlSensorRange::maximum() const +{ + return max; +} + +QmlSensorOutputRange::QmlSensorOutputRange(QObject *parent) + : QObject(parent), + min(0), + max(0), + acc(0) +{ +} + +QmlSensorOutputRange::~QmlSensorOutputRange() +{ +} + +qreal QmlSensorOutputRange::minimum() const +{ + return min; +} + +qreal QmlSensorOutputRange::maximum() const +{ + return max; +} + +qreal QmlSensorOutputRange::accuracy() const +{ + return acc; +} diff --git a/src/sensorsquick/qmlsensorrange_p.h b/src/sensorsquick/qmlsensorrange_p.h new file mode 100644 index 00000000..7e32ede2 --- /dev/null +++ b/src/sensorsquick/qmlsensorrange_p.h @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLSENSORRANGE_P_H +#define QMLSENSORRANGE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include "qsensorsquickglobal_p.h" + +QT_BEGIN_NAMESPACE + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlSensorRange : public QObject +{ + Q_OBJECT + Q_PROPERTY(int minimum READ minimum) + Q_PROPERTY(int maximum READ maximum) + QML_NAMED_ELEMENT(Range) + QML_UNCREATABLE("Cannot create Range") + QML_ADDED_IN_VERSION(5,0) +public: + explicit QmlSensorRange(QObject *parent = 0); + ~QmlSensorRange(); + + int minimum() const; + void setMinumum(int mini) { min = mini; } + + int maximum() const; + void setMaximum(int maxi) { max = maxi; } + +private: + + int min; + int max; +}; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlSensorOutputRange : public QObject +{ + Q_OBJECT + Q_PROPERTY(qreal minimum READ minimum) + Q_PROPERTY(qreal maximum READ maximum) + Q_PROPERTY(qreal accuracy READ accuracy) + QML_NAMED_ELEMENT(OutputRange) + QML_UNCREATABLE("Cannot create OutputRange") + QML_ADDED_IN_VERSION(5,0) +public: + explicit QmlSensorOutputRange(QObject *parent = 0); + ~QmlSensorOutputRange(); + + qreal minimum() const; + void setMinimum(int mini) { min = mini; } + + qreal maximum() const; + void setMaximum(int maxi) { max = maxi; } + + qreal accuracy() const; + void setAccuracy(int accu) { acc = accu; } + +private: + qreal min; + qreal max; + qreal acc; +}; + +QT_END_NAMESPACE +#endif diff --git a/src/sensorsquick/qmltapsensor.cpp b/src/sensorsquick/qmltapsensor.cpp new file mode 100644 index 00000000..faeba623 --- /dev/null +++ b/src/sensorsquick/qmltapsensor.cpp @@ -0,0 +1,179 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmltapsensor_p.h" +#include + +/*! + \qmltype TapSensor + \instantiates QmlTapSensor + \ingroup qml-sensors_type + \inqmlmodule QtSensors + \since QtSensors 5.0 + \inherits Sensor + \brief The TapSensor element reports tap and double tap events + along the X, Y and Z axes. + + The TapSensor element reports tap and double tap events + along the X, Y and Z axes. + + This element wraps the QTapSensor class. Please see the documentation for + QTapSensor for details. + + \sa TapReading +*/ + +QmlTapSensor::QmlTapSensor(QObject *parent) + : QmlSensor(parent) + , m_sensor(new QTapSensor(this)) +{ + connect(m_sensor, SIGNAL(returnDoubleTapEventsChanged(bool)), + this, SIGNAL(returnDoubleTapEventsChanged(bool))); +} + +QmlTapSensor::~QmlTapSensor() +{ +} + +QmlSensorReading *QmlTapSensor::createReading() const +{ + return new QmlTapSensorReading(m_sensor); +} + +QSensor *QmlTapSensor::sensor() const +{ + return m_sensor; +} + +/*! + \qmlproperty bool TapSensor::returnDoubleTapEvents + This property holds a value indicating if double tap events should be reported. + + Please see QTapSensor::returnDoubleTapEvents for information about this property. +*/ + +bool QmlTapSensor::returnDoubleTapEvents() const +{ + return m_sensor->returnDoubleTapEvents(); +} + +void QmlTapSensor::setReturnDoubleTapEvents(bool ret) +{ + m_sensor->setReturnDoubleTapEvents(ret); +} + +/*! + \qmltype TapReading + \instantiates QmlTapSensorReading + \ingroup qml-sensors_reading + \inqmlmodule QtSensors + \since QtSensors 5.0 + \inherits SensorReading + \brief The TapReading element holds the most recent TapSensor reading. + + The TapReading element holds the most recent TapSensor reading. + + This element wraps the QTapReading class. Please see the documentation for + QTapReading for details. + + This element cannot be directly created. +*/ + +QmlTapSensorReading::QmlTapSensorReading(QTapSensor *sensor) + : QmlSensorReading(sensor) + , m_sensor(sensor) +{ +} + +QmlTapSensorReading::~QmlTapSensorReading() +{ +} + +/*! + \qmlproperty TapDirection TapReading::tapDirection + This property holds the direction of the tap. + + Please see QTapReading::tapDirection for information about this property. + + Note that TapDirection constants are exposed through the TapReading class. + \code + TapSensor { + onReadingChanged: { + if ((reading.tapDirection & TapReading.X_Both)) + // do something + } + } + \endcode +*/ + +QTapReading::TapDirection QmlTapSensorReading::tapDirection() const +{ + return m_tapDirection; +} + +/*! + \qmlproperty bool TapReading::doubleTap + This property holds a value indicating if there was a single or double tap. + + Please see QTapReading::doubleTap for information about this property. +*/ + +bool QmlTapSensorReading::isDoubleTap() const +{ + return m_isDoubleTap; +} + +QSensorReading *QmlTapSensorReading::reading() const +{ + return const_cast(m_sensor)->reading(); +} + +void QmlTapSensorReading::readingUpdate() +{ + QTapReading::TapDirection td = m_sensor->reading()->tapDirection(); + if (m_tapDirection != td) { + m_tapDirection = td; + Q_EMIT tapDirectionChanged(); + } + bool dTap = m_sensor->reading()->isDoubleTap(); + if (m_isDoubleTap != dTap) { + m_isDoubleTap = dTap; + Q_EMIT isDoubleTapChanged(); + } +} diff --git a/src/sensorsquick/qmltapsensor_p.h b/src/sensorsquick/qmltapsensor_p.h new file mode 100644 index 00000000..7d8800c0 --- /dev/null +++ b/src/sensorsquick/qmltapsensor_p.h @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLTAPSENSOR_P_H +#define QMLTAPSENSOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qmlsensor_p.h" +#include + +QT_BEGIN_NAMESPACE + +class QTapSensor; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlTapSensor : public QmlSensor +{ + Q_OBJECT + Q_PROPERTY(bool returnDoubleTapEvents READ returnDoubleTapEvents WRITE setReturnDoubleTapEvents NOTIFY returnDoubleTapEventsChanged) + QML_NAMED_ELEMENT(TapSensor) + QML_ADDED_IN_VERSION(5,0) +public: + explicit QmlTapSensor(QObject *parent = 0); + ~QmlTapSensor(); + + bool returnDoubleTapEvents() const; + void setReturnDoubleTapEvents(bool ret); + +Q_SIGNALS: + void returnDoubleTapEventsChanged(bool returnDoubleTapEvents); + +private: + QSensor *sensor() const override; + QTapSensor *m_sensor; + QmlSensorReading *createReading() const override; +}; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlTapSensorReading : public QmlSensorReading +{ + Q_OBJECT + Q_PROPERTY(QTapReading::TapDirection tapDirection READ tapDirection NOTIFY tapDirectionChanged) + Q_PROPERTY(bool doubleTap READ isDoubleTap NOTIFY isDoubleTapChanged) + QML_NAMED_ELEMENT(TapReading) + QML_UNCREATABLE("Cannot create TapReading") + QML_ADDED_IN_VERSION(5,0) +public: + + explicit QmlTapSensorReading(QTapSensor *sensor); + ~QmlTapSensorReading(); + + QTapReading::TapDirection tapDirection() const; + bool isDoubleTap() const; + +Q_SIGNALS: + void tapDirectionChanged(); + void isDoubleTapChanged(); + +private: + QSensorReading *reading() const override; + void readingUpdate() override; + QTapSensor *m_sensor; + QTapReading::TapDirection m_tapDirection; + bool m_isDoubleTap; +}; + +QT_END_NAMESPACE +#endif diff --git a/src/sensorsquick/qmltiltsensor.cpp b/src/sensorsquick/qmltiltsensor.cpp new file mode 100644 index 00000000..81b4e696 --- /dev/null +++ b/src/sensorsquick/qmltiltsensor.cpp @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmltiltsensor_p.h" +#include + +QT_BEGIN_NAMESPACE +QT_END_NAMESPACE + +/*! + \qmltype TiltSensor + \instantiates QmlTiltSensor + \ingroup qml-sensors_type + \inqmlmodule QtSensors + \since QtSensors 5.0 + \inherits Sensor + \brief The TiltSensor element reports tilt events + along the X and Y axes. + + The TiltSensor element reports tilt events along the X and Y axes. + + This element wraps the QTiltSensor class. Please see the documentation for + QTiltSensor for details. + + \sa TiltReading +*/ + +QmlTiltSensor::QmlTiltSensor(QObject *parent) + : QmlSensor(parent) + , m_sensor(new QTiltSensor(this)) +{ +} + +QmlTiltSensor::~QmlTiltSensor() +{ +} + +QmlSensorReading *QmlTiltSensor::createReading() const +{ + return new QmlTiltSensorReading(m_sensor); +} + +QSensor *QmlTiltSensor::sensor() const +{ + return m_sensor; +} + +/*! + \qmlmethod TiltSensor::calibrate() + Calibrate the tilt sensor. + + Please see QTiltSensor::calibrate() for information about this property. +*/ +void QmlTiltSensor::calibrate() +{ + m_sensor->calibrate(); +} + +/*! + \qmltype TiltReading + \instantiates QmlTiltSensorReading + \ingroup qml-sensors_reading + \inqmlmodule QtSensors + \since QtSensors 5.0 + \inherits SensorReading + \brief The TiltReading element holds the most recent TiltSensor reading. + + The TiltReading element holds the most recent TiltSensor reading. + + This element wraps the QTiltReading class. Please see the documentation for + QTiltReading for details. + + This element cannot be directly created. +*/ + +QmlTiltSensorReading::QmlTiltSensorReading(QTiltSensor *sensor) + : QmlSensorReading(sensor) + , m_sensor(sensor) +{ +} + +QmlTiltSensorReading::~QmlTiltSensorReading() +{ +} + +/*! + \qmlproperty qreal TiltReading::yRotation + This property holds the amount of tilt on the Y axis. + + Please see QTiltReading::yRotation for information about this property. +*/ + +qreal QmlTiltSensorReading::yRotation() const +{ + return m_yRotation; +} + +/*! + \qmlproperty qreal TiltReading::xRotation + This property holds the amount of tilt on the X axis. + + Please see QTiltReading::xRotation for information about this property. +*/ + +qreal QmlTiltSensorReading::xRotation() const +{ + return m_xRotation; +} + +QSensorReading *QmlTiltSensorReading::reading() const +{ + return m_sensor->reading(); +} + +void QmlTiltSensorReading::readingUpdate() +{ + qreal tiltY = m_sensor->reading()->yRotation(); + if (m_yRotation != tiltY) { + m_yRotation = tiltY; + Q_EMIT yRotationChanged(); + } + qreal tiltX = m_sensor->reading()->xRotation(); + if (m_xRotation != tiltX) { + m_xRotation = tiltX; + Q_EMIT xRotationChanged(); + } +} diff --git a/src/sensorsquick/qmltiltsensor_p.h b/src/sensorsquick/qmltiltsensor_p.h new file mode 100644 index 00000000..f41757b3 --- /dev/null +++ b/src/sensorsquick/qmltiltsensor_p.h @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLTILTSENSOR_P_H +#define QMLTILTSENSOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qmlsensor_p.h" +#include + +QT_BEGIN_NAMESPACE + +class QTiltSensor; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlTiltSensor : public QmlSensor +{ + Q_OBJECT + QML_NAMED_ELEMENT(TiltSensor) + QML_ADDED_IN_VERSION(5,0) +public: + + explicit QmlTiltSensor(QObject *parent = 0); + ~QmlTiltSensor(); + Q_INVOKABLE void calibrate(); + +private: + QSensor *sensor() const override; + QTiltSensor *m_sensor; + QmlSensorReading *createReading() const override; +}; + +class Q_SENSORSQUICK_PRIVATE_EXPORT QmlTiltSensorReading : public QmlSensorReading +{ + Q_OBJECT + Q_PROPERTY(qreal yRotation READ yRotation NOTIFY yRotationChanged) + Q_PROPERTY(qreal xRotation READ xRotation NOTIFY xRotationChanged) + QML_NAMED_ELEMENT(TiltReading) + QML_UNCREATABLE("Cannot create TiltReading") + QML_ADDED_IN_VERSION(5,0) +public: + explicit QmlTiltSensorReading(QTiltSensor *sensor); + ~QmlTiltSensorReading(); + + qreal yRotation() const; + qreal xRotation() const; + +Q_SIGNALS: + void yRotationChanged(); + void xRotationChanged(); + +private: + QSensorReading *reading() const override; + void readingUpdate() override; + QTiltSensor *m_sensor; + qreal m_yRotation; + qreal m_xRotation; +}; + +QT_END_NAMESPACE +#endif diff --git a/src/sensorsquick/qsensorsquickglobal_p.h b/src/sensorsquick/qsensorsquickglobal_p.h new file mode 100644 index 00000000..4f6034f6 --- /dev/null +++ b/src/sensorsquick/qsensorsquickglobal_p.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSENSORSQUICKGLOBALS_P_H +#define QSENSORSQUICKGLOBALS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +#if !defined(QT_STATIC) +# if defined(QT_BUILD_SENSORSQUICK_LIB) +# define Q_SENSORSQUICK_EXPORT Q_DECL_EXPORT +# else +# define Q_SENSORSQUICK_EXPORT Q_DECL_IMPORT +# endif +#else +# define Q_SENSORSQUICK_EXPORT +#endif + +#define Q_SENSORSQUICK_PRIVATE_EXPORT Q_SENSORSQUICK_EXPORT + +QT_END_NAMESPACE + +void Q_SENSORSQUICK_PRIVATE_EXPORT qml_register_types_QtSensors(); + +#endif // QSENSORSQUICKGLOBALS_P_H -- cgit v1.2.3