on xenial help sign in
use XDG_CONFIG_HOME for the local config override instead of .
commit189082023947b43aabe62249c3a7c8f46ad3119a authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 18 Feb 2016, 17:53 (11 years ago) parent857bd90
2 files changed+14−4
plugins/Utils/deviceconfigparser.cpp+10−3 tests/plugins/Utils/CMakeLists.txt+4−1
plugins/Utils/deviceconfigparser.cpp+10−3
@@ -19,15 +19,22 @@
1919#include <QSettings>
2020#include <QFileInfo>
2121#include <QDebug>
22+#include <QStandardPaths>
2223
2324DeviceConfigParser::DeviceConfigParser(QObject *parent): QObject(parent)
2425{
2526 QString path;
26− if (QFileInfo("./devices.conf").exists()) {
27− path = "./devices.conf";
28− } else {
27+ Q_FOREACH (const QString &standardPath, QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation)) {
28+ if (QFileInfo(standardPath + "/devices.conf").exists()) {
29+ path = standardPath + "/devices.conf";
30+ break;
31+ }
32+ }
33+
34+ if (path.isEmpty()) {
2935 path = "/etc/ubuntu/devices.conf";
3036 }
37+ qDebug() << "Using" << path << "as device configuration file";
3138 m_config = new QSettings(path, QSettings::IniFormat, this);
3239}
3340
tests/plugins/Utils/CMakeLists.txt+4−1
@@ -15,7 +15,10 @@ foreach(util_test
1515 add_executable(${util_test}TestExec ${util_test}Test.cpp ModelTest.cpp)
1616 qt5_use_modules(${util_test}TestExec Test Core Qml)
1717 target_link_libraries(${util_test}TestExec Utils-qml)
18− add_unity8_unittest(${util_test} ${util_test}TestExec ADD_TEST)
18+ add_unity8_unittest(${util_test} ${util_test}TestExec ADD_TEST
19+ ENVIRONMENT XDG_CONFIG_HOME=${CMAKE_CURRENT_BINARY_DIR}
20+ )
21+
1922endforeach()
2023
2124# plain qml test