1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-24 08:09:43 +00:00

fixed check for missing ini files

This commit is contained in:
graffy76 2014-05-05 06:07:41 -05:00
parent 475214ab62
commit 74fa115d20
2 changed files with 28 additions and 23 deletions

View file

@ -21,6 +21,7 @@ CSMSettings::SettingManager::SettingManager(QObject *parent) :
} }
CSMSettings::Setting *CSMSettings::SettingManager::createSetting CSMSettings::Setting *CSMSettings::SettingManager::createSetting
(CSMSettings::SettingType typ, const QString &page, const QString &name) (CSMSettings::SettingType typ, const QString &page, const QString &name)
{ {
@ -113,7 +114,7 @@ CSMSettings::Setting *CSMSettings::SettingManager::findSetting
{ {
foreach (Setting *setting, mSettings) foreach (Setting *setting, mSettings)
{ {
if (settingName.isEmpty() || (setting->name() == settingName)) if (setting->name() == settingName)
{ {
if (setting->page() == pageName) if (setting->page() == pageName)
return setting; return setting;
@ -121,7 +122,7 @@ CSMSettings::Setting *CSMSettings::SettingManager::findSetting
} }
return 0; return 0;
} }
/*
QList <CSMSettings::Setting *> CSMSettings::SettingManager::findSettings QList <CSMSettings::Setting *> CSMSettings::SettingManager::findSettings
(const QString &pageName) (const QString &pageName)
{ {
@ -134,7 +135,7 @@ QList <CSMSettings::Setting *> CSMSettings::SettingManager::findSettings
} }
return settings; return settings;
} }
*/
CSMSettings::SettingPageMap CSMSettings::SettingManager::settingPageMap() const CSMSettings::SettingPageMap CSMSettings::SettingManager::settingPageMap() const
{ {
SettingPageMap pageMap; SettingPageMap pageMap;

View file

@ -288,44 +288,48 @@ CSMSettings::UserSettings::~UserSettings()
void CSMSettings::UserSettings::loadSettings (const QString &fileName) void CSMSettings::UserSettings::loadSettings (const QString &fileName)
{ {
mUserFilePath = QString::fromUtf8 mUserFilePath = QString::fromUtf8
(mCfgMgr.getUserConfigPath().string().c_str()) + fileName.toUtf8(); (mCfgMgr.getUserConfigPath().string().c_str());
QString global = QString::fromUtf8 QString globalFilePath = QString::fromUtf8
(mCfgMgr.getGlobalPath().string().c_str()) + fileName.toUtf8(); (mCfgMgr.getGlobalPath().string().c_str());
QString local = QString::fromUtf8 QString localFilePath = QString::fromUtf8
(mCfgMgr.getLocalPath().string().c_str()) + fileName.toUtf8(); (mCfgMgr.getLocalPath().string().c_str());
//open user and global streams bool isUser = QFile (mUserFilePath + fileName).exists();
//QTextStream *userStream = openFilestream (mUserFilePath, true); bool isSystem = QFile (globalFilePath + fileName).exists();
// QTextStream *otherStream = openFilestream (global, true);
//failed stream, try for local QString otherFilePath = globalFilePath;
// if (!otherStream)
// otherStream = openFilestream (local, true); //test for local only if global fails (uninstalled copy)
if (!isSystem)
{
isSystem = QFile (localFilePath + fileName).exists();
otherFilePath = localFilePath;
}
//error condition - notify and return //error condition - notify and return
// if (!otherStream || !userStream) if (!isUser || !isSystem)
/* { {
QString message = QObject::tr("<br><b>An error was encountered loading \ QString message = QObject::tr("<br><b>An error was encountered loading \
user settings files.</b><br><br> One or several files could not \ user settings files.</b><br><br> One or several files could not \
be read. This may be caused by a missing configuration file, \ be read. This may be caused by a missing configuration file, \
incorrect file permissions or a corrupted installation of \ incorrect file permissions or a corrupted installation of \
OpenCS.<br>"); OpenCS.<br>");
message += QObject::tr("<br>Global filepath: ") + global; message += QObject::tr("<br>Global filepath: ") + globalFilePath;
message += QObject::tr("<br>Local filepath: ") + local; message += QObject::tr("<br>Local filepath: ") + localFilePath;
message += QObject::tr("<br>User filepath: ") + mUserFilePath; message += QObject::tr("<br>User filepath: ") + mUserFilePath;
displayFileErrorMessage ( message, true); displayFileErrorMessage ( message, true);
return; return;
} }
*/
//QSETTINGS TEST
qDebug() << mCfgMgr.getUserConfigPath().string().c_str() << ',' << mCfgMgr.getGlobalPath().string().c_str();
QSettings::setPath (QSettings::IniFormat, QSettings::UserScope, mCfgMgr.getUserConfigPath().string().c_str()); QSettings::setPath
QSettings::setPath (QSettings::IniFormat, QSettings::SystemScope, mCfgMgr.getGlobalPath().string().c_str()); (QSettings::IniFormat, QSettings::UserScope, mUserFilePath);
QSettings::setPath
(QSettings::IniFormat, QSettings::SystemScope, otherFilePath);
if (mSettings) if (mSettings)
delete mSettings; delete mSettings;