commonlib/misc.cpp

changeset 56
bdbbde5f754e
parent 53
a5b53cc10436
--- a/commonlib/misc.cpp	Sun Jun 07 19:56:40 2015 +0300
+++ b/commonlib/misc.cpp	Mon Jun 22 01:44:30 2015 +0300
@@ -17,6 +17,7 @@
  */
 
 #include <QFileDialog>
+#include <QSettings>
 #include "misc.h"
 #include "config.h"
 
@@ -58,4 +59,59 @@
 
 	return QFileDialog::getOpenFileName (parent, "", "",
 		"Zandronum Binaries (" ZAN_EXE_NAME ");;All files (*)");
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+void assimilateWadPaths (QStringList& wadpaths)
+{
+	QString iniPath;
+
+#ifdef Q_OS_WIN32
+	{
+		char* appdata = getenv ("APPDATA");
+
+		if (appdata == NULL)
+			return;
+
+		iniPath = QString::fromLocal8Bit (appdata) + "/.doomseeker/doomseeker.ini";
+	}
+#else
+	iniPath = QDir::homePath() + "/.doomseeker/doomseeker.ini";
+#endif
+
+	if (not QFile (iniPath).exists())
+		return;
+
+	QSettings settings (iniPath, QSettings::IniFormat);
+	QVariant var = settings.value ("Doomseeker/WadPaths");
+	QStringList doomseekerPaths;
+
+	if (var.isValid() and var.toList().isEmpty())
+	{
+		doomseekerPaths = var.toString().split (";");
+	}
+	else
+	{
+		QVariantList collection = var.toList();
+
+		for (int i = 0; i < collection.size(); ++i)
+		{
+			QVariantList element = collection[i].toList();
+
+			if (element.size() > 0)
+				doomseekerPaths.append (element[0].toString());
+		}
+	}
+
+	for (int i = 0; i < doomseekerPaths.size(); ++i)
+	{
+		doomseekerPaths[i].replace ("\\", "/");
+		QString& path = doomseekerPaths[i];
+
+		if (not wadpaths.contains (path))
+			wadpaths.append (path);
+	}
 }
\ No newline at end of file

mercurial