on xenial help sign in
use XDG_CONFIG_HOME for the local config override instead of .
1890820Michael Zanetti
plugins/Utils/deviceconfigparser.cpp+10−3
@@ -19,15 +19,22 @@
19#include <QSettings>
19#include <QSettings>
20#include <QFileInfo>
20#include <QFileInfo>
21#include <QDebug>
21#include <QDebug>
22+#include <QStandardPaths>
22
23
23DeviceConfigParser::DeviceConfigParser(QObject *parent): QObject(parent)
24DeviceConfigParser::DeviceConfigParser(QObject *parent): QObject(parent)
24{
25{
25 QString path;
26 QString path;
27+ Q_FOREACH (const QString &standardPath, QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation)) {
26− if (QFileInfo("./devices.conf").exists()) {
28+ if (QFileInfo(standardPath + "/devices.conf").exists()) {
27− path = "./devices.conf";
29+ path = standardPath + "/devices.conf";
28− } else {
30+ break;
31+ }
32+ }
33+
34+ if (path.isEmpty()) {
29 path = "/etc/ubuntu/devices.conf";
35 path = "/etc/ubuntu/devices.conf";
30 }
36 }
37+ qDebug() << "Using" << path << "as device configuration file";
31 m_config = new QSettings(path, QSettings::IniFormat, this);
38 m_config = new QSettings(path, QSettings::IniFormat, this);
32}
39}
33
40
tests/plugins/Utils/CMakeLists.txt+4−1
@@ -15,7 +15,10 @@ foreach(util_test
15 add_executable(${util_test}TestExec ${util_test}Test.cpp ModelTest.cpp)
15 add_executable(${util_test}TestExec ${util_test}Test.cpp ModelTest.cpp)
16 qt5_use_modules(${util_test}TestExec Test Core Qml)
16 qt5_use_modules(${util_test}TestExec Test Core Qml)
17 target_link_libraries(${util_test}TestExec Utils-qml)
17 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+
19endforeach()
22endforeach()
20
23
21# plain qml test
24# plain qml test