// New window
int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
+ int restoreWinMenu = createMenu( tr( "MEN_DESK_RESTORE" ), windowMenu, -1, 0 );
createAction( CloseId, tr( "TOT_CLOSE" ), QIcon(), tr( "MEN_DESK_CLOSE" ), tr( "PRP_CLOSE" ),
Qt::SHIFT+Qt::Key_C, desk, false, this, SLOT( onCloseWindow() ) );
createActionForViewer( NewGraphicsViewId, newWinMenu, QString::number( 5 ), Qt::ALT+Qt::Key_R );
#endif
+ createAction( RestoreDefaultId, tr( "TOT_RESTORE_DEFAULT" ), QIcon(),
+ tr( "MEN_DESK_RESTORE_DEFAULT" ), tr( "PRP_RESTORE_DEFAULT" ),
+ 0, desk, false, this, SLOT( onRestoreDefault() ) );
+
+ createAction( RestoreFromPrefsId, tr( "TOT_RESTORE_FROM_PREFERENCES" ), QIcon(),
+ tr( "MEN_DESK_RESTORE_FROM_PREFERENCES" ), tr( "PRP_RESTORE_FROM_PREFERENCES" ),
+ 0, desk, false, this, SLOT( onRestoreFromPreferences() ) );
+
+ createMenu( RestoreDefaultId, restoreWinMenu, -1 );
+ createMenu( RestoreFromPrefsId, restoreWinMenu, -1 );
+
createAction( RenameId, tr( "TOT_RENAME" ), QIcon(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ),
Qt::SHIFT+Qt::Key_R, desk, false, this, SLOT( onRenameWindow() ) );
createMenu( RenameId, windowMenu, -1 );
if( a )
a->setEnabled( activeStudy() );
#endif
+
+ a = action( RestoreDefaultId );
+ if( a )
+ a->setEnabled( activeStudy() );
+
+ a = action( RestoreFromPrefsId );
+ if( a )
+ a->setEnabled( activeStudy() );
}
/*!
/*!
Loads windows geometry
*/
-void LightApp_Application::loadDockWindowsState()
+void LightApp_Application::loadDockWindowsState( const bool theIsForced )
{
if ( !desktop() )
return;
bool store = resourceMgr()->booleanValue( "Study", "store_positions", true );
- if( !store )
+ if ( !theIsForced && !store )
return;
QString modName;
wgStack->stack();
}
+/*!
+ Restore default state of application windows
+*/
+void LightApp_Application::onRestoreDefault()
+{
+ if ( !activeStudy() || !desktop() )
+ return;
+
+ QMap<int, int> winMap;
+ bool restored = false;
+
+ if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
+ {
+ ((LightApp_Module*)activeModule())->windows( winMap );
+ restored = ((LightApp_Module*)activeModule())->defaultWindowsState();
+ }
+
+ if ( !restored )
+ {
+ if( winMap.isEmpty() )
+ defaultWindows( winMap );
+
+ QMap<int, int>::const_iterator winMapIt = winMap.constBegin();
+ for ( ; winMapIt != winMap.constEnd(); ++winMapIt )
+ {
+ QWidget* win = dockWindow( winMapIt.key() );
+ QDockWidget* dock = ::qobject_cast<QDockWidget*>( win );
+ if ( !dock )
+ dock = windowDock( win );
+
+ if ( dock )
+ {
+ if ( !dock->isVisible() )
+ dock->setVisible( true );
+
+ if ( dock->isFloating() )
+ dock->setFloating( false );
+
+ desktop()->addDockWidget( (Qt::DockWidgetArea)winMapIt.value(), dock );
+ }
+ }
+
+ QList<QToolBar*> tbList = qFindChildren<QToolBar*>( desktop() );
+ for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit )
+ {
+ QToolBar* tb = *tit;
+
+ QObject* po = Qtx::findParent( tb, "QMainWindow" );
+ if ( po != desktop() )
+ continue;
+
+ if ( !tb->isVisible() )
+ tb->setVisible( true );
+
+ desktop()->addToolBar( Qt::TopToolBarArea, tb );
+ }
+ }
+}
+
+/*!
+ Restore application windows state from preferences file
+*/
+void LightApp_Application::onRestoreFromPreferences()
+{
+ if ( !activeStudy() || !desktop() )
+ return;
+
+ loadDockWindowsState( true );
+}
+
/*!
\return if the library of module exists
\param moduleTitle - title of module
enum { RenameId = CAM_Application::UserID,
CloseId, CloseAllId, GroupAllId,
+ RestoreDefaultId, RestoreFromPrefsId,
PreferencesId, MRUId, ModulesListId,
NewGLViewId, NewPlot2dId, NewOCCViewId, NewVTKViewId, NewQxGraphViewId,
NewGraphicsViewId, UserID };
void onCloseWindow();
void onCloseAllWindow();
void onGroupAllWindow();
+ void onRestoreDefault();
+ void onRestoreFromPreferences();
protected:
void updateWindows();
void updateViewManagers();
void updateModuleActions();
- void loadDockWindowsState();
+ void loadDockWindowsState( const bool theIsForced = false );
void saveDockWindowsState();
virtual void studyOpened( SUIT_Study* );
<source>PRP_GROUP_ALL</source>
<translation>Group all windows</translation>
</message>
+ <message>
+ <source>MEN_DESK_RESTORE</source>
+ <translation>Restore windows &state</translation>
+ </message>
+ <message>
+ <source>TOT_RESTORE_DEFAULT</source>
+ <translation>By Default</translation>
+ </message>
+ <message>
+ <source>MEN_DESK_RESTORE_DEFAULT</source>
+ <translation>&By Default</translation>
+ </message>
+ <message>
+ <source>PRP_RESTORE_DEFAULT</source>
+ <translation>Restore windows state by default</translation>
+ </message>
+ <message>
+ <source>TOT_RESTORE_FROM_PREFERENCES</source>
+ <translation>From Preferences</translation>
+ </message>
+ <message>
+ <source>MEN_DESK_RESTORE_FROM_PREFERENCES</source>
+ <translation>&From Preferences</translation>
+ </message>
+ <message>
+ <source>PRP_RESTORE_FROM_PREFERENCES</source>
+ <translation>Restore windows state from preferences file</translation>
+ </message>
<message>
<source>ERR_DOC_NOT_EXISTS</source>
<translation>Can not open %1.
<source>PRP_GROUP_ALL</source>
<translation type="unfinished">Grouper toutes les fenêtres</translation>
</message>
+ <message>
+ <source>MEN_DESK_RESTORE</source>
+ <translation>Redimensionner les fenêtres</translation>
+ </message>
+ <message>
+ <source>TOT_RESTORE_DEFAULT</source>
+ <translation>Par défaut</translation>
+ </message>
+ <message>
+ <source>MEN_DESK_RESTORE_DEFAULT</source>
+ <translation>&Défaut</translation>
+ </message>
+ <message>
+ <source>PRP_RESTORE_DEFAULT</source>
+ <translation>Redimensionner les fenêtres par défaut.</translation>
+ </message>
+ <message>
+ <source>TOT_RESTORE_FROM_PREFERENCES</source>
+ <translation>Selon les préférences</translation>
+ </message>
+ <message>
+ <source>MEN_DESK_RESTORE_FROM_PREFERENCES</source>
+ <translation>&Préférences</translation>
+ </message>
+ <message>
+ <source>PRP_RESTORE_FROM_PREFERENCES</source>
+ <translation> Redimensionner les fenêtres selon le fichier de préférences.</translation>
+ </message>
<message>
<source>ERR_DOC_NOT_EXISTS</source>
<translation type="unfinished">Impossible d'ouvrir %1.