<li><b>Store positions of windows</b> - if checked in, positions of windows
will be saved in a special file at the end of the current session and
then restored for a new session.</li>
+<li><b>Auto-save interval (min)</b> - allows specify time interval (in
+minutes) for automatic study saving operation. If the time interval is
+equal to 0 ("Disabled" value is shown) the automatic saving is not
+performed.</li>
<li><b>Store/restore last GUI state</b> - if checked in, all GUI settings are
saved with the rest of the data whenever you save the study. When the
study is reopened, the GUI state is restored.</li>
<b>Entry</b>, <b>IOR</b> and <b>Reference entry</b> columns in the Object Browser.</li>
</ul>
-*/
\ No newline at end of file
+*/
\b New - creates a new study. The study will be created
with default name \b Study1. It is possible to create
several studies, each accessible from the task bar.
+
\b Open - allows to open an existing study by browsing for it in a
standard Search File dialog box, choosing the required
*.hdf file and clicking \b Open button.
+
+\b Reopen - reloads the current study from the *.hdf file. This menu command
+can be used to reverse the study to the latest saved state.
+
\b Connect - allows to open an unloaded study.
\image html loadstudy2.png
Select one of the studies, which has been previously
\b Exit - unlike \b Close, closes not only the current, but all opened
Salome studies.
-*/
\ No newline at end of file
+*/
#include <QByteArray>
#include <QMenu>
#include <QProcess>
+#include <QTimer>
#include <utilities.h>
setDesktop( desk );
+ // initialize auto save timer
+ myAutoSaveTimer = new QTimer( this );
+ myAutoSaveTimer->setSingleShot( true );
+ connect( myAutoSaveTimer, SIGNAL( timeout() ), this, SLOT( onSaveDoc() ) );
+
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
/*!Protected SLOT. On study closed.*/
void LightApp_Application::onStudyClosed( SUIT_Study* s )
{
+ // stop auto-save timer
+ myAutoSaveTimer->stop();
+
// Bug 10396: clear selection
mySelMgr->clearSelected();
updateViewManagers();
}
+void LightApp_Application::studySaved( SUIT_Study* s )
+{
+ CAM_Application::studyOpened( s );
+ SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+ if ( aResMgr && activeStudy() ) {
+ int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
+ if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
+ }
+}
+
void LightApp_Application::studyCreated( SUIT_Study* s )
{
CAM_Application::studyCreated( s );
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" );
+ int autoSaveInterval = pref->addPreference( tr( "PREF_AUTO_SAVE" ), studyGroup,
+ LightApp_Preferences::IntSpin, "Study", "auto_save_interval" );
+ pref->setItemProperty( "min", 0, autoSaveInterval );
+ pref->setItemProperty( "max", 1440, autoSaveInterval );
+ pref->setItemProperty( "special", tr( "PREF_AUTO_SAVE_DISABLED" ), autoSaveInterval );
+
int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab );
QString platform;
#ifdef WIN32
{
if( param=="store_positions" )
updateWindows();
+ if( param=="auto_save_interval" ) {
+ myAutoSaveTimer->stop();
+ int autoSaveInterval = resMgr->integerValue( "Study", "auto_save_interval", 0 );
+ if ( activeStudy() && autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
+ }
}
#ifndef DISABLE_PYCONSOLE
if ( objectBrowser() )
objectBrowser()->updateTree();
+
+ SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+ if ( aResMgr && activeStudy() ) {
+ int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
+ if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
+ }
}
/*!
class QWidget;
class QStringList;
class QDockWidget;
+class QTimer;
#ifdef WIN32
#pragma warning( disable:4251 )
virtual void studyOpened( SUIT_Study* );
virtual void studyCreated( SUIT_Study* );
+ virtual void studySaved( SUIT_Study* );
void updatePreference( const QString&, const QString&, const QString& );
WinGeom myWinGeom;
SUIT_Accel* myAccel;
+ QTimer* myAutoSaveTimer;
static LightApp_Preferences* _prefs_;
</section>
<section name="Study">
<!-- General study settings -->
- <parameter name="store_positions" value="true" />
+ <parameter name="store_positions" value="true" />
+ <parameter name="auto_save_interval" value="0" />
</section>
<section name="OCCViewer" >
<!-- OCC viewer preferences -->
<source>PREF_STORE_POS</source>
<translation>Store positions of windows</translation>
</message>
+ <message>
+ <source>PREF_AUTO_SAVE</source>
+ <translation>Auto-save interval (min)</translation>
+ </message>
+ <message>
+ <source>PREF_AUTO_SAVE_DISABLED</source>
+ <translation>Disabled</translation>
+ </message>
<message>
<source>PREF_PROJECTION_MODE</source>
<translation>Projection mode:</translation>
tr( "MEN_DESK_FILE_OPEN" ), tr( "PRP_DESK_FILE_OPEN" ),
Qt::CTRL+Qt::Key_O, desk, false, this, SLOT( onOpenDoc() ) );
+ createAction( FileReopenId, tr( "TOT_DESK_FILE_REOPEN" ), QIcon(),
+ tr( "MEN_DESK_FILE_REOPEN" ), tr( "PRP_DESK_FILE_REOPEN" ),
+ 0, desk, false, this, SLOT( onReopenDoc() ) );
+
createAction( FileCloseId, tr( "TOT_DESK_FILE_CLOSE" ),
resMgr->loadPixmap( "STD", tr( "ICON_FILE_CLOSE" ) ),
tr( "MEN_DESK_FILE_CLOSE" ), tr( "PRP_DESK_FILE_CLOSE" ),
createMenu( FileNewId, fileMenu, 0 );
createMenu( FileOpenId, fileMenu, 0 );
+ createMenu( FileReopenId, fileMenu, 0 );
createMenu( FileCloseId, fileMenu, 5 );
createMenu( separator(), fileMenu, -1, 5 );
createMenu( FileSaveId, fileMenu, 5 );
return res;
}
+/*! Reload document from the file.*/
+bool STD_Application::onReopenDoc()
+{
+ bool res = false;
+
+ SUIT_Study* study = activeStudy();
+ if ( study && study->isSaved() ) {
+ // remember study name
+ QString studyName = study->studyName();
+
+ // close study
+ beforeCloseDoc( study );
+ study->closeDocument( true );
+
+ // update views / windows / status bar / title
+ clearViewManagers();
+ setActiveStudy( 0 );
+ updateDesktopTitle();
+ updateCommandsStatus();
+
+ // delete study
+ delete study;
+ study = 0;
+
+ // post closing actions
+ afterCloseDoc();
+
+ // reload study from the file
+ res = useFile( studyName ) && activeStudy();
+
+ // if reloading is failed, close the desktop
+ if ( !res ) {
+ setDesktop( 0 );
+ closeApplication();
+ }
+ }
+ return res;
+}
+
/*!Virtual function. Not implemented here.*/
void STD_Application::beforeCloseDoc( SUIT_Study* )
{
{
SUIT_Application::updateCommandsStatus();
- bool aHasStudy = activeStudy() != 0;
- bool aIsNeedToSave = false;
- if ( aHasStudy )
- aIsNeedToSave = !activeStudy()->isSaved() || activeStudy()->isModified();
+ bool aHasStudy = activeStudy() != 0;
+ bool aSaved = aHasStudy && activeStudy()->isSaved();
+ bool aModified = aHasStudy && activeStudy()->isModified();
+ bool aIsNeedToSave = aHasStudy && ( !aSaved || aModified );
- if ( action( FileSaveId ) )
+ if ( action( FileReopenId ) )
+ action( FileReopenId )->setEnabled( aSaved );
+ if ( action( FileSaveId ) )
action( FileSaveId )->setEnabled( aIsNeedToSave );
if ( action( FileSaveAsId ) )
action( FileSaveAsId )->setEnabled( aHasStudy );
Q_OBJECT
public:
- enum { MenuFileId, FileNewId, FileOpenId, FileCloseId, FileSaveId, FileSaveAsId, FileExitId,
+ enum { MenuFileId, FileNewId, FileOpenId, FileReopenId, FileCloseId, FileSaveId, FileSaveAsId, FileExitId,
MenuViewId, ViewWindowsId, ViewToolBarsId, ViewStatusBarId, NewWindowId,
MenuEditId, EditCutId, EditCopyId, EditPasteId,
MenuHelpId, HelpAboutId,
virtual void onOpenDoc();
virtual bool onOpenDoc( const QString& );
+ virtual bool onReopenDoc();
+
virtual void onExit();
virtual void onCopy();
<source>TOT_DESK_FILE_OPEN</source>
<translation>Open document</translation>
</message>
+ <message>
+ <source>TOT_DESK_FILE_REOPEN</source>
+ <translation>Reopen document</translation>
+ </message>
<message>
<source>PRP_DESK_FILE_EXIT</source>
<translation>Exits the application</translation>
<source>PRP_DESK_FILE_OPEN</source>
<translation>Opens an existing document</translation>
</message>
+ <message>
+ <source>PRP_DESK_FILE_REOPEN</source>
+ <translation>Reload the current document from the file</translation>
+ </message>
<message>
<source>PRP_DESK_FILE_SAVE</source>
<translation>Saves the active document</translation>
<source>MEN_DESK_FILE_OPEN</source>
<translation>&Open...</translation>
</message>
+ <message>
+ <source>MEN_DESK_FILE_REOPEN</source>
+ <translation>Reopen</translation>
+ </message>
<message>
<source>MEN_DESK_FILE_LOAD</source>
<translation>Conn&ect...</translation>
<!-- General study settings -->
<parameter name="store_positions" value="false" />
<parameter name="store_visual_state" value="false" />
+ <parameter name="auto_save_interval" value="0" />
</section>
<section name="ExternalBrowser" >
<!-- External HELP browser settings -->