Commit 23510b28 authored by Mike Kremer's avatar Mike Kremer

If removal of INI-files is requested, the removal takes place after the writeOnExit() method.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@9254 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 8416f825
......@@ -991,6 +991,26 @@ void Core::slotExit() {
logFile_->close();
OpenFlipper::Options::closeSettings();
// Test if ini-file should be cleaned
// If so, delete it...
if(OpenFlipper::Options::deleteIniFile()) {
bool success = true;
// Iterate over all ini files and clear them
QStringList optionFiles = OpenFlipper::Options::optionFiles();
for ( int i = 0 ; i < (int)optionFiles.size(); ++i) {
success &= QFile::remove(optionFiles[i]);
}
if(!success) {
QMessageBox::warning(0, tr("Warning"),
tr("One or more files could not be removed.\nDelete files manually."),
QMessageBox::Ok,
QMessageBox::Ok);
}
}
qApp->quit();
}
......
......@@ -122,6 +122,9 @@ static QDir currentScriptDir_;
/// Current texture directory of the application
static QDir currentTextureDir_;
/// Should ini-files be deleted on exit?
static bool deleteIniFile_ = false;
/// Show gui or not?
static bool nogui_ = false;
......@@ -356,6 +359,14 @@ bool currentTextureDir(QString _dir) {
return false;
}
void deleteIniFile(bool _delete) {
deleteIniFile_ = _delete;
}
bool deleteIniFile() {
return deleteIniFile_;
}
/// Store if a gui should be visible or not
void nogui( bool _nogui ) {
nogui_ = _nogui;
......
......@@ -253,6 +253,14 @@ QString helpDirStr();
/// Returns the base Path of the config Dir
DLLEXPORT
QDir configDir();
/// Returns true if ini-file should be deleted on exit
DLLEXPORT
bool deleteIniFile();
/// Set option to delete ini-files on exit
DLLEXPORT
void deleteIniFile(bool _delete);
/** @} */
......
......@@ -911,18 +911,8 @@ void OptionsWidget::slotClearSettings() {
void OptionsWidget::slotClearINI() {
bool success = true;
QMessageBox::information(this, tr("Restart required!"),
tr("The changes will take effect after next restart."));
// Iterate over all ini files and clear them
QStringList optionFiles = OpenFlipper::Options::optionFiles();
for ( int i = 0 ; i < (int)optionFiles.size(); ++i) {
success &= QFile::remove(optionFiles[i]);
}
if(!success) {
QMessageBox::warning(this, tr("Warning"),
tr("One or more files could not be removed.\nDelete files manually."),
QMessageBox::Ok,
QMessageBox::Ok);
}
OpenFlipper::Options::deleteIniFile(true);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment