summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJuha Vuolle <juha.vuolle@insta.fi>2021-06-28 12:58:09 +0300
committerJuha Vuolle <juha.vuolle@insta.fi>2021-07-01 12:42:33 +0300
commit108e7d9e5fad438e565305104ec3712bff6561b6 (patch)
tree32e8166483325cf96f73fe8cac74bab9a8fd7f7d /src
parent763b64cca21817af24d944d631c0fb676da8ba23 (diff)
Fix and improve sensor configuration file lookup
This commit addresses some of the sensor configuration lookup issues - The CMake rule to use compile-time flag was opposite than intended - The configuration file is now looked from all returned configuration paths, not just the last one which seemed a bit arbitrary - Update related documentation, and while doing that also remove references to "N900" which probably won't say that much to people these days (N900 was a smart phone released 12 years ago) Pick-to: 6.2 Task-number: QTBUG-92505 Task-number: QTBUG-92512 Change-Id: Ib66ae052a815bbe3af32bd896931e65375e8546e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/sensors/CMakeLists.txt2
-rw-r--r--src/sensors/doc/src/qtsensors-backend.qdoc25
-rw-r--r--src/sensors/qsensormanager.cpp10
3 files changed, 23 insertions, 14 deletions
diff --git a/src/sensors/CMakeLists.txt b/src/sensors/CMakeLists.txt
index d57b7b62..beeda6a5 100644
--- a/src/sensors/CMakeLists.txt
+++ b/src/sensors/CMakeLists.txt
@@ -85,7 +85,7 @@ endif()
## Scopes:
#####################################################################
-qt_internal_extend_target(Sensors CONDITION NOT SENSORS_CONFIG_PATH
+qt_internal_extend_target(Sensors CONDITION SENSORS_CONFIG_PATH
DEFINES
QTSENSORS_CONFIG_PATH="${SENSORS_CONFIG_PATH}"
)
diff --git a/src/sensors/doc/src/qtsensors-backend.qdoc b/src/sensors/doc/src/qtsensors-backend.qdoc
index 7e62186d..752e8f92 100644
--- a/src/sensors/doc/src/qtsensors-backend.qdoc
+++ b/src/sensors/doc/src/qtsensors-backend.qdoc
@@ -89,9 +89,9 @@ An example follows.
Sensors was designed so that multiple sensors could exist for a given type. Why?
Consider this example.
-The N900 has an accelerometer built-in. It also features bluetooth and can pair
-with a gaming controller that features an accelerometer. To a developer writing
-a game these two devices are conceptually the same type.
+An Android device has an accelerometer built-in. It also features bluetooth and
+can pair with a gaming controller that features an accelerometer. To a developer
+writing a game these two devices are conceptually the same type.
\section1 Default Sensor for a Type
@@ -109,21 +109,28 @@ instead.
\section1 Sensors.conf
-The config file that determines the default sensor for a type is called Sensors.conf.
-If present, it is located in /etc/xdg/QtProject. It has the standard formatting
-of an ini file.
+The config file that determines the default sensor for a type is called
+\e Sensors.conf. The configuration file is looked for from \e QtProject
+directory under the directories given by
+QStandardPaths::standardLocations(QStandardPaths::ConfigLocation).
+An example of a complete file path is:
+\badcode
+/etc/xdg/QtProject/Sensors.conf
+\endcode
+The first found configuration file is used.
+The configuration file has the standard formatting of an ini file.
The settings live in the Default group and the general format is:
\code
type = identifier
\endcode
-An example: Sensors.conf ensures that the N900 accelerometer is used by default,
-not considering the order in which backends were registered.
+An example: Sensors.conf ensures that the \e sensorfw accelerometer is used by
+default, ignoring the order in which backends were registered.
\code
[Default]
-QAccelerometer = n900.accelerometer
+QAccelerometer=sensorfw.accelerometer
\endcode
If Sensors.conf specifies an identifier that is not registered, the system will
diff --git a/src/sensors/qsensormanager.cpp b/src/sensors/qsensormanager.cpp
index 43286467..95d9b6c0 100644
--- a/src/sensors/qsensormanager.cpp
+++ b/src/sensors/qsensormanager.cpp
@@ -96,10 +96,12 @@ public:
QString config = QString::fromLocal8Bit(QTSENSORS_CONFIG_PATH);
#else
QStringList configs = QStandardPaths::standardLocations(QStandardPaths::ConfigLocation);
- if (configs.count() == 0) return; // QStandardPaths is broken?
- QString config = configs.at(configs.count()-1);
- if (config.isEmpty()) return; // QStandardPaths is broken?
- config += QLatin1String("/QtProject/Sensors.conf");
+ QString config;
+ for (const QString& c : configs) {
+ config = c + QLatin1String("/QtProject/Sensors.conf");
+ if (QFile::exists(config))
+ break;
+ }
#endif
qCDebug(sensorsCategory) << "Loading config from" << config;
if (!QFile::exists(config)) {