1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-30 12:32:36 +00:00

Some fixes to the way data paths are saved and settings are handled

This commit is contained in:
pvdk 2013-03-10 21:12:26 +01:00
parent dad66cd968
commit 52e5dcc7f0
3 changed files with 11 additions and 17 deletions

View File

@ -213,8 +213,6 @@ bool MainDialog::showFirstRunDialog()
return false; return false;
// Re-read the game settings // Re-read the game settings
mGameSettings.clear();
if (!setupGameSettings()) if (!setupGameSettings())
return false; return false;
@ -389,7 +387,7 @@ bool MainDialog::setupGameSettings()
QFileInfo info(selectedFile); QFileInfo info(selectedFile);
// Add the new dir to the settings file and to the data dir container // Add the new dir to the settings file and to the data dir container
mGameSettings.setValue(QString("data"), info.absolutePath()); mGameSettings.setMultiValue(QString("data"), info.absolutePath());
mGameSettings.addDataDir(info.absolutePath()); mGameSettings.addDataDir(info.absolutePath());
} }
@ -478,7 +476,7 @@ void MainDialog::saveSettings()
} }
void MainDialog::writeSettings() bool MainDialog::writeSettings()
{ {
// Now write all config files // Now write all config files
saveSettings(); saveSettings();
@ -498,7 +496,7 @@ void MainDialog::writeSettings()
Please make sure you have the right permissions \ Please make sure you have the right permissions \
and try again.<br>").arg(userPath)); and try again.<br>").arg(userPath));
msgBox.exec(); msgBox.exec();
return; return false;
} }
} }
@ -515,7 +513,7 @@ void MainDialog::writeSettings()
Please make sure you have the right permissions \ Please make sure you have the right permissions \
and try again.<br>").arg(file.fileName())); and try again.<br>").arg(file.fileName()));
msgBox.exec(); msgBox.exec();
return; return false;
} }
QTextStream stream(&file); QTextStream stream(&file);
@ -537,7 +535,7 @@ void MainDialog::writeSettings()
Please make sure you have the right permissions \ Please make sure you have the right permissions \
and try again.<br>").arg(file.fileName())); and try again.<br>").arg(file.fileName()));
msgBox.exec(); msgBox.exec();
return; return false;
} }
stream.setDevice(&file); stream.setDevice(&file);
@ -559,7 +557,7 @@ void MainDialog::writeSettings()
Please make sure you have the right permissions \ Please make sure you have the right permissions \
and try again.<br>").arg(file.fileName())); and try again.<br>").arg(file.fileName()));
msgBox.exec(); msgBox.exec();
return; return false;
} }
stream.setDevice(&file); stream.setDevice(&file);
@ -567,19 +565,20 @@ void MainDialog::writeSettings()
mLauncherSettings.writeFile(stream); mLauncherSettings.writeFile(stream);
file.close(); file.close();
return true;
} }
void MainDialog::closeEvent(QCloseEvent *event) void MainDialog::closeEvent(QCloseEvent *event)
{ {
saveSettings();
writeSettings(); writeSettings();
event->accept(); event->accept();
} }
void MainDialog::play() void MainDialog::play()
{ {
saveSettings(); if (!writeSettings())
writeSettings(); qApp->quit();
// Launch the game detached // Launch the game detached
startProgram(QString("openmw"), true); startProgram(QString("openmw"), true);

View File

@ -45,7 +45,7 @@ private:
void loadSettings(); void loadSettings();
void saveSettings(); void saveSettings();
void writeSettings(); bool writeSettings();
inline bool startProgram(const QString &name, bool detached = false) { return startProgram(name, QStringList(), detached); } inline bool startProgram(const QString &name, bool detached = false) { return startProgram(name, QStringList(), detached); }
bool startProgram(const QString &name, const QStringList &arguments, bool detached = false); bool startProgram(const QString &name, const QStringList &arguments, bool detached = false);

View File

@ -40,11 +40,6 @@ public:
mSettings.remove(key); mSettings.remove(key);
} }
inline void clear()
{
mSettings.clear();
}
inline QStringList getDataDirs() { return mDataDirs; } inline QStringList getDataDirs() { return mDataDirs; }
inline void addDataDir(const QString &dir) { if(!dir.isEmpty()) mDataDirs.append(dir); } inline void addDataDir(const QString &dir) { if(!dir.isEmpty()) mDataDirs.append(dir); }
inline QString getDataLocal() {return mDataLocal; } inline QString getDataLocal() {return mDataLocal; }