summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qsettings.cpp
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2014-07-11 01:37:37 +0200
committerDavid Faure <david.faure@kdab.com>2014-07-23 20:05:07 +0200
commitc99dfd8f631289d66c5aa1d667073530e9c30860 (patch)
tree96878388bb811cee28cbab84ef042f999c872b8e /src/corelib/io/qsettings.cpp
parent8933d7c1f90d12a89ba6e8205efaaa8c3a53ec8e (diff)
QSettings: use QStandardPaths to get XDG_CONFIG_HOME.
This allows to use the "test mode" of QStandardPaths in unittests, to stay away from the user's real settings. Change-Id: I1cb1f63a4bff35dfe236924c4dcd7cf761ee50c1 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io/qsettings.cpp')
-rw-r--r--src/corelib/io/qsettings.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index 1748170324..5db545347d 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -53,6 +53,7 @@
#include "qmutex.h"
#include "qlibraryinfo.h"
#include "qtemporaryfile.h"
+#include "qstandardpaths.h"
#ifndef QT_NO_TEXTCODEC
# include "qtextcodec.h"
@@ -1140,6 +1141,8 @@ static void initDefaultPaths(QMutexLocker *locker)
pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::SystemScope),
windowsConfigPath(CSIDL_COMMON_APPDATA) + QDir::separator());
#else
+
+#ifdef QT_NO_STANDARDPATHS
QString userPath;
char *env = getenv("XDG_CONFIG_HOME");
if (env == 0) {
@@ -1153,6 +1156,9 @@ static void initDefaultPaths(QMutexLocker *locker)
userPath += QLatin1Char('/');
userPath += QFile::decodeName(env);
}
+#else
+ QString userPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
+#endif
userPath += QLatin1Char('/');
pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::UserScope), userPath);