[PATCH 3/5] qthelper.cpp: use QStandardPaths::DataLocation for older Qt

Lubomir I. Ivanov neolit123 at gmail.com
Sun Feb 15 10:25:20 PST 2015


From: "Lubomir I. Ivanov" <neolit123 at gmail.com>

system_default_directory():

QStandardPaths::AppDataLocation was introduced in Qt 5.4.
For older versions we use the deprecated ::DataLocation.

Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---
 qthelper.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/qthelper.cpp b/qthelper.cpp
index c591f90..b26bdf4 100644
--- a/qthelper.cpp
+++ b/qthelper.cpp
@@ -304,7 +304,13 @@ extern "C" const char *system_default_directory(void)
 	static char filename[PATH_MAX];
 
 	if (!*filename) {
-		QString name = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).first();
+		enum QStandardPaths::StandardLocation location;
+#if QT_VERSION >= 0x050400
+		location = QStandardPaths::AppDataLocation;
+#else
+		location = QStandardPaths::DataLocation;
+#endif
+		QString name = QStandardPaths::standardLocations(location).first();
 		QDir dir(name);
 		dir.mkpath(name);
 		// Why no "dir.encodeName()"? Crazy Qt
-- 
1.7.11.msysgit.0



More information about the subsurface mailing list