summary refs log tree commit diff
path: root/pkgs/development/libraries/qt-5/5.5/qtbase/0008-xdg-config-dirs.patch
blob: 4d23d640df0099fa1f42a44886bcc0d5c58125e9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
From a7dc6209542ef8aa54191c0e17fbb9b41cbad67f Mon Sep 17 00:00:00 2001
From: Thomas Tuegel <ttuegel@gmail.com>
Date: Sun, 23 Aug 2015 08:52:57 -0500
Subject: [PATCH 8/9] xdg config dirs

---
 qtbase/src/corelib/io/qsettings.cpp | 18 ++++++++++++++++++
 qtbase/src/corelib/io/qsettings_p.h |  2 +-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/qtbase/src/corelib/io/qsettings.cpp b/qtbase/src/corelib/io/qsettings.cpp
index 413f569..8ff4974 100644
--- a/qtbase/src/corelib/io/qsettings.cpp
+++ b/qtbase/src/corelib/io/qsettings.cpp
@@ -1131,6 +1131,24 @@ QConfFileSettingsPrivate::QConfFileSettingsPrivate(QSettings::Format format,
     if (!application.isEmpty())
         confFiles[F_System | F_Application].reset(QConfFile::fromName(systemPath + appFile, false));
     confFiles[F_System | F_Organization].reset(QConfFile::fromName(systemPath + orgFile, false));
+
+#if !defined(Q_OS_WIN)
+    // Add directories specified in $XDG_CONFIG_DIRS
+    const QString pathEnv = QString::fromLocal8Bit(getenv("XDG_CONFIG_DIRS"));
+    if (!pathEnv.isEmpty()) {
+        const QStringList pathEntries = pathEnv.split(QLatin1Char(':'), QString::SkipEmptyParts);
+        if (!pathEntries.isEmpty()) {
+            int j = 4; // This is the number of confFiles set above -- we need to start adding $XDG_CONFIG_DIRS after those.
+            for (int k = 0; k < pathEntries.size() && j < NumConfFiles - 1; ++k) {
+                const QString& path = pathEntries.at(k);
+                if (!application.isEmpty())
+                    confFiles[j++].reset(QConfFile::fromName(path + QDir::separator() + appFile, false));
+                confFiles[j++].reset(QConfFile::fromName(path + QDir::separator() + orgFile, false));
+            }
+        }
+    }
+#endif
+
 #else
     QString confName = getPath(format, QSettings::UserScope) + org;
     if (!application.isEmpty())
diff --git a/qtbase/src/corelib/io/qsettings_p.h b/qtbase/src/corelib/io/qsettings_p.h
index 93d63fd..160b197 100644
--- a/qtbase/src/corelib/io/qsettings_p.h
+++ b/qtbase/src/corelib/io/qsettings_p.h
@@ -240,7 +240,7 @@ public:
         F_Organization = 0x1,
         F_User = 0x0,
         F_System = 0x2,
-        NumConfFiles = 4
+        NumConfFiles = 40 // HACK: increase NumConfFiles from 4 to 40 in order to accommodate more paths in $XDG_CONFIG_DIRS -- ellis
 #else
         SandboxConfFile = 0,
         NumConfFiles = 1
-- 
2.5.0