QTfrontend/util/DataManager.cpp
changeset 8918 512753ea4b1b
parent 8508 f849b7b3af1d
child 8920 caa614af152d
--- a/QTfrontend/util/DataManager.cpp	Wed Apr 17 11:24:06 2013 -0400
+++ b/QTfrontend/util/DataManager.cpp	Thu Apr 18 00:41:27 2013 +0400
@@ -25,6 +25,7 @@
 #include <QStringList>
 #include <QStandardItemModel>
 #include <QFileInfo>
+#include <QSettings>
 
 #include "hwconsts.h"
 #include "HWApplication.h"
@@ -162,6 +163,36 @@
     return m_bindsModel;
 }
 
+QString DataManager::settingsFileName()
+{
+    if(m_settingsFileName.isEmpty())
+    {
+        QFile settingsFile("physfs://settings.ini");
+
+        if(!settingsFile.exists())
+        {
+            QFile oldSettingsFile("physfs://hedgewars.ini");
+
+            settingsFile.open(QFile::WriteOnly);
+            settingsFile.close();
+
+            if(oldSettingsFile.exists())
+            {
+                QSettings sOld(oldSettingsFile.fileName(), QSettings::IniFormat);
+                QSettings sNew(settingsFile.fileName(), QSettings::IniFormat);
+                sNew.setIniCodec("UTF-8");
+
+                foreach(const QString & key, sOld.allKeys())
+                    sNew.setValue(key, sOld.value(key));
+            }
+        }
+
+        m_settingsFileName = settingsFile.fileName();
+    }
+
+    return m_settingsFileName;
+}
+
 void DataManager::reload()
 {
     // removed for now (also code was a bit unclean, could lead to segfault if