diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-07-22 06:41:31 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-07-22 06:41:37 +0200 |
commit | 4dfa95538ff15f59880c93675676ce609b365d89 (patch) | |
tree | e3b1aded9bca7fe5280da8865cddc1214303ea55 /src | |
parent | a28678b83ac3a5a7530026027e2c16a23379168a (diff) | |
parent | c20fa3ee91cdef22f270fea7159b4a8a4eab4a50 (diff) | |
download | qtsensors-4dfa95538ff15f59880c93675676ce609b365d89.tar.gz |
Merge "Merge remote-tracking branch 'origin/5.13' into dev"
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/sensors/plugins.qmltypes | 29 | ||||
-rw-r--r-- | src/imports/sensors/sensors.cpp | 11 | ||||
-rw-r--r-- | src/plugins/sensors/android/androidaccelerometer.cpp | 12 | ||||
-rw-r--r-- | src/plugins/sensors/android/sensormanager.cpp | 2 | ||||
-rw-r--r-- | src/plugins/sensors/iio-sensor-proxy/main.cpp | 17 | ||||
-rw-r--r-- | src/sensors/doc/qtsensors.qdocconf | 1 | ||||
-rw-r--r-- | src/sensors/doc/src/qtsensors-cpp.qdoc | 2 | ||||
-rw-r--r-- | src/sensors/qcompass.cpp | 2 |
8 files changed, 64 insertions, 12 deletions
diff --git a/src/imports/sensors/plugins.qmltypes b/src/imports/sensors/plugins.qmltypes index 80e1df3..b78e63c 100644 --- a/src/imports/sensors/plugins.qmltypes +++ b/src/imports/sensors/plugins.qmltypes @@ -129,6 +129,20 @@ Module { 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: [ @@ -173,6 +187,21 @@ Module { 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: [ diff --git a/src/imports/sensors/sensors.cpp b/src/imports/sensors/sensors.cpp index fa4cb3c..ce80a45 100644 --- a/src/imports/sensors/sensors.cpp +++ b/src/imports/sensors/sensors.cpp @@ -46,6 +46,8 @@ #include <QtSensors/qambientlightsensor.h> #include <QtSensors/qambienttemperaturesensor.h> #include <QtSensors/qcompass.h> +#include <QtSensors/qdistancesensor.h> +#include <QtSensors/qhumiditysensor.h> #include <QtSensors/qmagnetometer.h> #include <QtSensors/qorientationsensor.h> #include <QtSensors/qproximitysensor.h> @@ -64,8 +66,10 @@ #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" @@ -217,11 +221,18 @@ public: qmlRegisterType <QmlSensorGesture >(package, major, minor, "SensorGesture"); + // Register the 5.4 interfaces + minor = 4; + qmlRegisterType <QmlDistanceSensor >(package, major, minor, "DistanceSensor"); + qmlRegisterUncreatableType<QmlDistanceReading >(package, major, minor, "DistanceReading", QLatin1String("Cannot create DistanceReading")); + // Register the new 5.9 interfaces // Implicitly registers 5.3 - 5.8 too minor = 9; qmlRegisterType <QmlLidSensor >(package, major, minor, "LidSensor"); qmlRegisterUncreatableType<QmlLidReading >(package, major, minor, "LidReading", QLatin1String("Cannot create LidReading")); + qmlRegisterType <QmlHumiditySensor >(package, major, minor, "HumiditySensor"); + qmlRegisterUncreatableType<QmlHumidityReading >(package, major, minor, "HumidityReading", QLatin1String("Cannot create HumidityReading")); // Register the latest Qt version as QML type version qmlRegisterModule(package, QT_VERSION_MAJOR, QT_VERSION_MINOR); diff --git a/src/plugins/sensors/android/androidaccelerometer.cpp b/src/plugins/sensors/android/androidaccelerometer.cpp index c9f5141..f38e004 100644 --- a/src/plugins/sensors/android/androidaccelerometer.cpp +++ b/src/plugins/sensors/android/androidaccelerometer.cpp @@ -82,18 +82,24 @@ void AndroidAccelerometer::applyAccelerationMode(QAccelerometer::AccelerationMod { switch (accelerationMode) { case QAccelerometer::Gravity: - if (!(m_accelerationModes & Gravity)) + if (!(m_accelerationModes & Gravity)) { qWarning() << "Gravity sensor missing"; + return; + } setSensorType(ASENSOR_TYPE_GRAVITY); break; case QAccelerometer::User: - if (!(m_accelerationModes & LinearAcceleration)) + if (!(m_accelerationModes & LinearAcceleration)) { qWarning() << "Linear acceleration sensor missing"; + return; + } setSensorType(ASENSOR_TYPE_LINEAR_ACCELERATION); break; case QAccelerometer::Combined: - if (!(m_accelerationModes & Accelerometer)) + if (!(m_accelerationModes & Accelerometer)) { qWarning() << "Accelerometer sensor missing"; + return; + } setSensorType(ASENSOR_TYPE_ACCELEROMETER); break; } diff --git a/src/plugins/sensors/android/sensormanager.cpp b/src/plugins/sensors/android/sensormanager.cpp index 590f478..542e54c 100644 --- a/src/plugins/sensors/android/sensormanager.cpp +++ b/src/plugins/sensors/android/sensormanager.cpp @@ -73,7 +73,7 @@ ALooper *SensorManager::looper() const static inline ASensorManager* androidManager() { #if __ANDROID_API__ >= 26 - retrun ASensorManager_getInstanceForPackage(QJNIObjectPrivate{QtAndroidPrivate::context()} + return ASensorManager_getInstanceForPackage(QJNIObjectPrivate{QtAndroidPrivate::context()} .callObjectMethod("getPackageName", "()Ljava/lang/String;") .toString().toUtf8().constData()); #else diff --git a/src/plugins/sensors/iio-sensor-proxy/main.cpp b/src/plugins/sensors/iio-sensor-proxy/main.cpp index 136dd40..580e2c4 100644 --- a/src/plugins/sensors/iio-sensor-proxy/main.cpp +++ b/src/plugins/sensors/iio-sensor-proxy/main.cpp @@ -46,6 +46,9 @@ #include <qsensorbackend.h> #include <qsensormanager.h> +#include <QtDBus/QDBusConnection> +#include <QtDBus/QDBusConnectionInterface> + #include <QtCore/QFile> #include <QtCore/QDebug> @@ -57,12 +60,14 @@ class IIOSensorProxySensorPlugin : public QObject, public QSensorPluginInterface public: void registerSensors() override { - if (!QSensorManager::isBackendRegistered(QOrientationSensor::type, IIOSensorProxyOrientationSensor::id)) - QSensorManager::registerBackend(QOrientationSensor::type, IIOSensorProxyOrientationSensor::id, this); - if (!QSensorManager::isBackendRegistered(QLightSensor::type, IIOSensorProxyLightSensor::id)) - QSensorManager::registerBackend(QLightSensor::type, IIOSensorProxyLightSensor::id, this); - if (!QSensorManager::isBackendRegistered(QCompass::type, IIOSensorProxyCompass::id)) - QSensorManager::registerBackend(QCompass::type, IIOSensorProxyCompass::id, this); + if (QDBusConnection::systemBus().interface()->isServiceRegistered("net.hadess.SensorProxy")) { + if (!QSensorManager::isBackendRegistered(QOrientationSensor::type, IIOSensorProxyOrientationSensor::id)) + QSensorManager::registerBackend(QOrientationSensor::type, IIOSensorProxyOrientationSensor::id, this); + if (!QSensorManager::isBackendRegistered(QLightSensor::type, IIOSensorProxyLightSensor::id)) + QSensorManager::registerBackend(QLightSensor::type, IIOSensorProxyLightSensor::id, this); + if (!QSensorManager::isBackendRegistered(QCompass::type, IIOSensorProxyCompass::id)) + QSensorManager::registerBackend(QCompass::type, IIOSensorProxyCompass::id, this); + } } QSensorBackend *createBackend(QSensor *sensor) override diff --git a/src/sensors/doc/qtsensors.qdocconf b/src/sensors/doc/qtsensors.qdocconf index 8b9b95d..0845e70 100644 --- a/src/sensors/doc/qtsensors.qdocconf +++ b/src/sensors/doc/qtsensors.qdocconf @@ -1,5 +1,6 @@ include($QT_INSTALL_DOCS/global/qt-html-templates-offline.qdocconf) include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) +include($QT_INSTALL_DOCS/config/exampleurl-qtsensors.qdocconf) project = QtSensors description = Qt Sensors Reference Documentation diff --git a/src/sensors/doc/src/qtsensors-cpp.qdoc b/src/sensors/doc/src/qtsensors-cpp.qdoc index b0d2726..d732a0d 100644 --- a/src/sensors/doc/src/qtsensors-cpp.qdoc +++ b/src/sensors/doc/src/qtsensors-cpp.qdoc @@ -56,7 +56,7 @@ Where rotation around an axis is used, the rotation shall be expressed as a Righ \image sensors-coordinates3.jpg -In general, sensor data is oriented relative to \l QPlatformScreen::nativeOrientation, +In general, sensor data is oriented relative to \l QScreen::nativeOrientation, that is to the top of the device when the device is held in its natural orientation (normally when the device logo appears the right side up). If values are to be displayed on the screen, the values may need to be transformed so that they match diff --git a/src/sensors/qcompass.cpp b/src/sensors/qcompass.cpp index a24e08e..5bd2101 100644 --- a/src/sensors/qcompass.cpp +++ b/src/sensors/qcompass.cpp @@ -74,7 +74,7 @@ IMPLEMENT_READING(QCompassReading) \brief the azimuth of the device. Measured in degrees from magnetic north in a clockwise direction based on - the top of the device, as defined by QPlatformScreen::nativeOrientation. + the top of the device, as defined by QScreen::nativeOrientation. \sa {QCompassReading Units} */ |