diff options
Diffstat (limited to 'src/plugins/sensors')
-rw-r--r-- | src/plugins/sensors/generic/main.cpp | 20 | ||||
-rw-r--r-- | src/plugins/sensors/sensorfw/main.cpp | 3 |
2 files changed, 14 insertions, 9 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) diff --git a/src/plugins/sensors/sensorfw/main.cpp b/src/plugins/sensors/sensorfw/main.cpp index b22b647..9951f09 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<l; i++) { QString type = keys.at(i); - QSensorManager::registerBackend(type.toLocal8Bit(), settings.value(type).toByteArray(), this); + if (settings.value(type).toString().contains(QStringLiteral("sensorfw")))//register only ones we know + QSensorManager::registerBackend(type.toLocal8Bit(), settings.value(type).toByteArray(), this); } } |