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>
This commit is contained in:
parent
8933d7c1f9
commit
c99dfd8f63
@ -103,7 +103,7 @@ CPPFLAGS = -g $(EXTRA_CPPFLAGS) \
|
||||
-DQT_BUILD_QMAKE -DQT_BOOTSTRAPPED -DPROEVALUATOR_FULL \
|
||||
-DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_NO_COMPONENT -DQT_NO_COMPRESS \
|
||||
-DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM \
|
||||
-DQT_CRYPTOGRAPHICHASH_ONLY_SHA1 -DQT_JSON_READONLY
|
||||
-DQT_CRYPTOGRAPHICHASH_ONLY_SHA1 -DQT_JSON_READONLY -DQT_NO_STANDARDPATHS
|
||||
|
||||
CXXFLAGS = $(EXTRA_CXXFLAGS) $(CPPFLAGS)
|
||||
|
||||
|
@ -41,7 +41,7 @@ CFLAGS_BARE = -c -Fo./ -Fdqmake.pdb \
|
||||
-DQT_BUILD_QMAKE -DQT_BOOTSTRAPPED -DPROEVALUATOR_FULL \
|
||||
-DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_NO_COMPONENT -DQT_NO_COMPRESS \
|
||||
-DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM \
|
||||
-DUNICODE -DQT_CRYPTOGRAPHICHASH_ONLY_SHA1 -DQT_JSON_READONLY
|
||||
-DUNICODE -DQT_CRYPTOGRAPHICHASH_ONLY_SHA1 -DQT_JSON_READONLY -DQT_NO_STANDARDPATHS
|
||||
CFLAGS = -Yuqmake_pch.h -FIqmake_pch.h -Fpqmake_pch.pch $(CFLAGS_BARE) $(CFLAGS) $(EXTRA_CPPFLAGS)
|
||||
|
||||
CXXFLAGS_BARE = $(CFLAGS_BARE)
|
||||
|
@ -159,7 +159,7 @@ bootstrap { #Qt code
|
||||
QT_BOOTSTRAPPED \
|
||||
QT_NO_TEXTCODEC QT_NO_UNICODETABLES QT_NO_COMPONENT QT_NO_COMPRESS \
|
||||
QT_NO_THREAD QT_NO_QOBJECT QT_NO_GEOM_VARIANT QT_NO_DATASTREAM \
|
||||
QT_CRYPTOGRAPHICHASH_ONLY_SHA1 QT_JSON_READONLY
|
||||
QT_CRYPTOGRAPHICHASH_ONLY_SHA1 QT_JSON_READONLY QT_NO_STANDARDPATHS
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$QT.core.includes $$QT.core_private.includes \
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user