summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qstandardpaths_unix.cpp
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2015-01-06 11:44:22 +0100
committerDavid Faure <david.faure@kdab.com>2015-01-09 12:15:59 +0100
commit4c980aedc17c1da8f7160989fbb845ea72b36f44 (patch)
tree31ad4926d76d3a92585cd473a2ea5e01bc1e6f82 /src/corelib/io/qstandardpaths_unix.cpp
parent3b9629e8bdbf23bb793c88f967b2cfe2b8256278 (diff)
QStandardPaths: add AppConfigLocation.
ConfigLocation was erroneously inconsistent, by adding the org name and app name on Windows (unintentionally) and not on Unix (while having subdirs in ~/.config is actually common practice for some XDG desktops) Therefore this adds AppConfigLocation, which always has the org name and app name (while GenericConfigLocation never does). [ChangeLog][QtCore][QStandardPaths] Added QStandardPaths::AppConfigLocation, for application-specific configuration directory. ConfigLocation was inconsistent. Task-number: QTBUG-38872 Task-number: QTBUG-38845 Change-Id: I80fb98f296436261f3996c9df87571c29b06ab35 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io/qstandardpaths_unix.cpp')
-rw-r--r--src/corelib/io/qstandardpaths_unix.cpp31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp
index 2ad6dfa121..94dcbaff9a 100644
--- a/src/corelib/io/qstandardpaths_unix.cpp
+++ b/src/corelib/io/qstandardpaths_unix.cpp
@@ -97,6 +97,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
}
case ConfigLocation:
case GenericConfigLocation:
+ case AppConfigLocation:
{
// http://standards.freedesktop.org/basedir-spec/latest/
QString xdgConfigHome = QFile::decodeName(qgetenv("XDG_CONFIG_HOME"));
@@ -104,6 +105,8 @@ QString QStandardPaths::writableLocation(StandardLocation type)
xdgConfigHome = QDir::homePath() + QLatin1String("/.qttest/config");
if (xdgConfigHome.isEmpty())
xdgConfigHome = QDir::homePath() + QLatin1String("/.config");
+ if (type == AppConfigLocation)
+ appendOrganizationAndApp(xdgConfigHome);
return xdgConfigHome;
}
case RuntimeLocation:
@@ -278,21 +281,31 @@ static QStringList xdgDataDirs()
return dirs;
}
+static QStringList xdgConfigDirs()
+{
+ QStringList dirs;
+ // http://standards.freedesktop.org/basedir-spec/latest/
+ const QString xdgConfigDirs = QFile::decodeName(qgetenv("XDG_CONFIG_DIRS"));
+ if (xdgConfigDirs.isEmpty())
+ dirs.append(QString::fromLatin1("/etc/xdg"));
+ else
+ dirs = xdgConfigDirs.split(QLatin1Char(':'));
+ return dirs;
+}
+
QStringList QStandardPaths::standardLocations(StandardLocation type)
{
QStringList dirs;
switch (type) {
case ConfigLocation:
case GenericConfigLocation:
- {
- // http://standards.freedesktop.org/basedir-spec/latest/
- const QString xdgConfigDirs = QFile::decodeName(qgetenv("XDG_CONFIG_DIRS"));
- if (xdgConfigDirs.isEmpty())
- dirs.append(QString::fromLatin1("/etc/xdg"));
- else
- dirs = xdgConfigDirs.split(QLatin1Char(':'));
- }
- break;
+ dirs = xdgConfigDirs();
+ break;
+ case AppConfigLocation:
+ dirs = xdgConfigDirs();
+ for (int i = 0; i < dirs.count(); ++i)
+ appendOrganizationAndApp(dirs[i]);
+ break;
case GenericDataLocation:
dirs = xdgDataDirs();
break;