QTfrontend/util/DataManager.cpp
changeset 8918 512753ea4b1b
parent 8508 f849b7b3af1d
child 8920 caa614af152d
equal deleted inserted replaced
8917:263f2a8475bc 8918:512753ea4b1b
    23 
    23 
    24 #include <QMap>
    24 #include <QMap>
    25 #include <QStringList>
    25 #include <QStringList>
    26 #include <QStandardItemModel>
    26 #include <QStandardItemModel>
    27 #include <QFileInfo>
    27 #include <QFileInfo>
       
    28 #include <QSettings>
    28 
    29 
    29 #include "hwconsts.h"
    30 #include "hwconsts.h"
    30 #include "HWApplication.h"
    31 #include "HWApplication.h"
    31 #include "sdlkeys.h"
    32 #include "sdlkeys.h"
    32 
    33 
   160     }
   161     }
   161 
   162 
   162     return m_bindsModel;
   163     return m_bindsModel;
   163 }
   164 }
   164 
   165 
       
   166 QString DataManager::settingsFileName()
       
   167 {
       
   168     if(m_settingsFileName.isEmpty())
       
   169     {
       
   170         QFile settingsFile("physfs://settings.ini");
       
   171 
       
   172         if(!settingsFile.exists())
       
   173         {
       
   174             QFile oldSettingsFile("physfs://hedgewars.ini");
       
   175 
       
   176             settingsFile.open(QFile::WriteOnly);
       
   177             settingsFile.close();
       
   178 
       
   179             if(oldSettingsFile.exists())
       
   180             {
       
   181                 QSettings sOld(oldSettingsFile.fileName(), QSettings::IniFormat);
       
   182                 QSettings sNew(settingsFile.fileName(), QSettings::IniFormat);
       
   183                 sNew.setIniCodec("UTF-8");
       
   184 
       
   185                 foreach(const QString & key, sOld.allKeys())
       
   186                     sNew.setValue(key, sOld.value(key));
       
   187             }
       
   188         }
       
   189 
       
   190         m_settingsFileName = settingsFile.fileName();
       
   191     }
       
   192 
       
   193     return m_settingsFileName;
       
   194 }
       
   195 
   165 void DataManager::reload()
   196 void DataManager::reload()
   166 {
   197 {
   167     // removed for now (also code was a bit unclean, could lead to segfault if
   198     // removed for now (also code was a bit unclean, could lead to segfault if
   168     // reload() is called before all members are initialized - because currently
   199     // reload() is called before all members are initialized - because currently
   169     // they are initialized in the getter methods rather than the constructor)
   200     // they are initialized in the getter methods rather than the constructor)