From a7b94516e1412073eb9d3fb57e49315ef966b183 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Thu, 20 Aug 2015 16:00:05 +1000 Subject: Only register plugins that sensorfw plugin can instantiate This makes it possible to use Tilt sensor from generic plugin. Task-number: QTBUG-47854 Change-Id: I14883e8d4a18a56c52845a4a5172c8c46bfe385f Reviewed-by: Alex Blasche --- src/plugins/sensors/sensorfw/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/sensors/sensorfw/main.cpp b/src/plugins/sensors/sensorfw/main.cpp index b22b6474..9951f096 100644 --- a/src/plugins/sensors/sensorfw/main.cpp +++ b/src/plugins/sensors/sensorfw/main.cpp @@ -65,7 +65,8 @@ public: QStringList keys = settings.allKeys(); for (int i=0,l=keys.size(); i Date: Tue, 29 Sep 2015 15:06:16 +0300 Subject: 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 --- src/plugins/sensors/generic/main.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/sensors/generic/main.cpp b/src/plugins/sensors/generic/main.cpp index 257e47e4..0fe3126d 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,13 +85,21 @@ 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 } } -- cgit v1.2.3