Commit 9d8e5655 authored by Jan Möbius's avatar Jan Möbius

Save program settings only if requested

IniInterface documentation
Core ini documentation

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4579 383ad7c9-94d9-4d36-a494-682f7c89f535
parent cf4f78e3
......@@ -418,7 +418,8 @@ Core::init() {
QApplication::processEvents();
}
openIniFile( optionFiles[i] );
// Load global ini files. Use plugin and global options from these files
openIniFile( optionFiles[i] ,true,true);
}
......
......@@ -446,8 +446,16 @@ private:
/// after ini-files have been loaded and core is up or if options have been changed -> apply Options
void applyOptions();
/// Open an ini file and load everything in it ( Application/File Options )
void openIniFile(QString _filename);
/** \brief Load information from an ini file
*
* This function will open an ini file and load the information in it.
*
* @param _filename Name of the ini file
* @param _perPluginSettings Load per plugin settings from the file
* @param _coreSettings Load core settings from the file
*
*/
void openIniFile(QString _filename, bool _coreSettings , bool _perPluginSettings);
/// Open an obj file and load everything in it ( Application/File Options )
void openObjFile(QString _filename);
......
......@@ -457,7 +457,7 @@ void Core::writeApplicationOptions(INIFile& _ini) {
_ini.add_entry("Options","Stereo",OpenFlipper::Options::stereo() );
}
void Core::openIniFile(QString _filename) {
void Core::openIniFile(QString _filename, bool _coreSettings, bool _perPluginSettings ){
INIFile ini;
if ( ! ini.connect(_filename,false) ) {
......@@ -472,7 +472,9 @@ void Core::openIniFile(QString _filename) {
OpenFlipper::Options::loadingSettings(true);
readApplicationOptions(ini);
// Load Core settings only if requested
if ( _coreSettings )
readApplicationOptions(ini);
QStringList openFiles;
......@@ -539,9 +541,9 @@ void Core::openIniFile(QString _filename) {
}
emit iniLoadOptions( ini );
// if requested load per Plugin settings from the settings file
if ( _perPluginSettings )
emit iniLoadOptions( ini );
ini.disconnect();
......@@ -558,7 +560,7 @@ void Core::openIniFile(QString _filename) {
void Core::writeIniFile(QString _filename, bool _relativePaths, bool _targetOnly, bool _systemSettings ) {
if ( ! _systemSettings )
std::cerr << "Currently unsupported : Saving ini files without including global settings" << std::endl;
INIFile ini;
......@@ -573,7 +575,9 @@ void Core::writeIniFile(QString _filename, bool _relativePaths, bool _targetOnly
coreWidget_->setStatus(ApplicationStatus::BLOCKED );
}
writeApplicationOptions(ini);
// Only save application settings when requested
if ( _systemSettings )
writeApplicationOptions(ini);
// This vector will hold the file sections to open
QStringList openFiles;
......@@ -621,6 +625,7 @@ void Core::writeIniFile(QString _filename, bool _relativePaths, bool _targetOnly
o_it != PluginFunctions::objects_end(); ++o_it)
emit iniSave( ini , o_it->id() );
// TODO : Save per plugin options only if requested
emit iniSaveOptions( ini );
ini.disconnect();
......
......@@ -99,9 +99,13 @@ void Core::commandLineScript(const char* _filename ) {
/// Load object by guessing DataType depending on the files extension
int Core::loadObject ( QString _filename ) {
if (_filename.endsWith(".ini")) {
openIniFile(_filename);
// Load all information from the given ini file
openIniFile(_filename,true,true);
if ( OpenFlipper::Options::gui() )
coreWidget_->addRecent(_filename, DATA_NONE);
return -2;
} else
if (_filename.endsWith(".ofs")) {
......@@ -304,7 +308,8 @@ void Core::loadSettings(){
OpenFlipper::Options::currentDir(newpath);
if ( complete_name.endsWith("ini") ) {
openIniFile(complete_name);
// TODO OptionsDialog for choosing which information should be read
openIniFile(complete_name,true,true);
applyOptions();
} else if ( complete_name.endsWith("obj") ) {
openObjFile(complete_name);
......@@ -325,7 +330,8 @@ void Core::loadSettings(QString _filename){
OpenFlipper::Options::currentDir(newpath);
if ( _filename.endsWith("ini") ) {
openIniFile(_filename);
// Loaded function for recent files. Load everything.
openIniFile(_filename,true,true);
applyOptions();
} else if ( _filename.endsWith("obj") ) {
openObjFile(_filename);
......
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