diff options
author | Alexander Volkov <a.volkov@rusbitech.ru> | 2015-09-29 15:06:16 +0300 |
---|---|---|
committer | Alexander Volkov <a.volkov@rusbitech.ru> | 2015-10-08 08:41:12 +0000 |
commit | a7427878d0c097791469cf80ef561a21d74d06e1 (patch) | |
tree | ec3a6f2f37957f14392865c6431c9eddb7427d3d /src/plugins | |
parent | d47a557bd8af545ad39a9bd848d17a0c5c779ee4 (diff) | |
download | qtsensors-a7427878d0c097791469cf80ef561a21d74d06e1.tar.gz |
Fix registration of the ambient light sensor in the generic plugin
It should be registered/unregistered depending on the availability
of the default light sensor rather than the default accelerometer.
Also mark the ambient light sensor as supported by the generic plugin
in the documentation.
Change-Id: Iff3828140b9549d994563fb736014091e568e867
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/sensors/generic/main.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/plugins/sensors/generic/main.cpp b/src/plugins/sensors/generic/main.cpp index 257e47e..0fe3126 100644 --- a/src/plugins/sensors/generic/main.cpp +++ b/src/plugins/sensors/generic/main.cpp @@ -72,10 +72,6 @@ public: if (!QSensorManager::isBackendRegistered(QRotationSensor::type, genericrotationsensor::id)) QSensorManager::registerBackend(QRotationSensor::type, genericrotationsensor::id, this); #endif -#ifdef QTSENSORS_GENERICALSSENSOR - if (!QSensorManager::isBackendRegistered(QAmbientLightSensor::type, genericalssensor::id)) - QSensorManager::registerBackend(QAmbientLightSensor::type, genericalssensor::id, this); -#endif #ifdef QTSENSORS_GENERICTILTSENSOR if (!QSensorManager::isBackendRegistered(QTiltSensor::type, GenericTiltSensor::id)) QSensorManager::registerBackend(QTiltSensor::type, GenericTiltSensor::id, this); @@ -89,15 +85,23 @@ public: if (QSensorManager::isBackendRegistered(QRotationSensor::type, genericrotationsensor::id)) QSensorManager::unregisterBackend(QRotationSensor::type, genericrotationsensor::id); #endif -#ifdef QTSENSORS_GENERICALSSENSOR - if (QSensorManager::isBackendRegistered(QAmbientLightSensor::type, genericalssensor::id)) - QSensorManager::unregisterBackend(QAmbientLightSensor::type, genericalssensor::id); -#endif #ifdef QTSENSORS_GENERICTILTSENSOR if (QSensorManager::isBackendRegistered(QTiltSensor::type, GenericTiltSensor::id)) QSensorManager::unregisterBackend(QTiltSensor::type, GenericTiltSensor::id); #endif } + + if (!QSensor::defaultSensorForType(QLightSensor::type).isEmpty()) { +#ifdef QTSENSORS_GENERICALSSENSOR + if (!QSensorManager::isBackendRegistered(QAmbientLightSensor::type, genericalssensor::id)) + QSensorManager::registerBackend(QAmbientLightSensor::type, genericalssensor::id, this); +#endif + } else { +#ifdef QTSENSORS_GENERICALSSENSOR + if (QSensorManager::isBackendRegistered(QAmbientLightSensor::type, genericalssensor::id)) + QSensorManager::unregisterBackend(QAmbientLightSensor::type, genericalssensor::id); +#endif + } } QSensorBackend *createBackend(QSensor *sensor) |