From: sln Date: Fri, 20 Apr 2012 07:59:38 +0000 (+0000) Subject: 1) Backup is switched off if SALOME_BACKUP_FOLDER is not defined. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7f28bcfd18edaf709bd903e2ddb619794d47f1b0;p=modules%2Fgui.git 1) Backup is switched off if SALOME_BACKUP_FOLDER is not defined. 2) “Activate module by default” option is removed in preferences in case of one module --- diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index dce1076b2..a19c39aec 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1846,7 +1846,9 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" ); pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" ); pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" ); - pref->addPreference( tr( "PREF_BACKUP" ), studyGroup, LightApp_Preferences::DblSpin, "Study", "backup_studies" ); + + if ( !SUIT_Session::session()->getBackupFolder().isEmpty() ) + pref->addPreference( tr( "PREF_BACKUP" ), studyGroup, LightApp_Preferences::DblSpin, "Study", "backup_studies" ); int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab ); QString platform; @@ -2123,14 +2125,27 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) } // Default Module Preferences - int moduleGroup = pref->addPreference( tr( "PREF_DEFAULT_MODULE" ), genTab ); - int moduleNameCombo = pref->addPreference( tr( "PREF_DEF_MODULE_NAME" ), moduleGroup, LightApp_Preferences::Selector, "Activate", "def_module" ); - aValuesList.clear(); - anIndicesList.clear(); - aValuesList << tr("PREF_DEF_MODULE_NONE") << tr("PREF_DEF_MODULE_CATHARE") << tr("PREF_DEF_MODULE_DIAGRAM"); - anIndicesList << 0 << 1 << 2 ; - pref->setItemProperty( "strings", aValuesList, moduleNameCombo ); - pref->setItemProperty( "indexes", anIndicesList, moduleNameCombo ); + QStringList aModuleNames; + modules( aModuleNames, false ); + if ( aModuleNames.count() > 1 ) + { + int moduleGroup = pref->addPreference( tr( "PREF_DEFAULT_MODULE" ), genTab ); + int moduleNameCombo = pref->addPreference( tr( "PREF_DEF_MODULE_NAME" ), moduleGroup, LightApp_Preferences::Selector, "Activate", "def_module" ); + aValuesList.clear(); + anIndicesList.clear(); + aValuesList.append( tr("PREF_DEF_MODULE_NONE") ); + anIndicesList.append( 0 ); + QStringList::iterator it = aModuleNames.begin(); + for ( int ind = 1; it != aModuleNames.end(); ++it, ++ind ) + { + const QString& modName = *it; + aValuesList.append( modName ); + anIndicesList.append( ind ); + } + + pref->setItemProperty( "strings", aValuesList, moduleNameCombo ); + pref->setItemProperty( "indexes", anIndicesList, moduleNameCombo ); + } // theme values Style_Model* aSModel = 0; diff --git a/src/SUIT/SUIT_Session.cxx b/src/SUIT/SUIT_Session.cxx index 9ab60b1ab..16b68a6fb 100755 --- a/src/SUIT/SUIT_Session.cxx +++ b/src/SUIT/SUIT_Session.cxx @@ -433,9 +433,6 @@ QString SUIT_Session::getBackupFolder() const if ( var ) aRes = var; - if ( aRes.isEmpty() || !QFileInfo( aRes ).exists() ) - aRes = QDir::tempPath(); - return aRes; } @@ -637,9 +634,13 @@ void SUIT_Session::restoreBackup() { QString pref = getBackupPrefix(); + QString bkpFold = getBackupFolder(); + if ( bkpFold .isEmpty() ) + return; + // checks whether temp folder contains old backups - QDir bkpDir( getBackupFolder() ); - + QDir bkpDir( bkpFold ); + QStringList filt; filt.append( pref + "*" ); bkpDir.setNameFilters( filt );