Salome HOME
updated copyright message
[modules/gui.git] / src / STD / STD_Application.cxx
old mode 100755 (executable)
new mode 100644 (file)
index e724096..0bd46ea
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -88,6 +88,7 @@ QString STD_Application::applicationName() const
 void STD_Application::start()
 {
   createActions();
+  customize();
 
   updateDesktopTitle();
   updateCommandsStatus();
@@ -114,7 +115,7 @@ void STD_Application::closeApplication()
     study->closeDocument();
     emit appClosed();
     setActiveStudy( 0 );
-    delete study;
+    //delete study;
 
     afterCloseDoc();
   }
@@ -157,8 +158,6 @@ void STD_Application::createActions()
                 resMgr->loadPixmap( "STD", tr( "ICON_FILE_NEW" ) ),
                 tr( "MEN_DESK_FILE_NEW" ), tr( "PRP_DESK_FILE_NEW" ),
                 Qt::CTRL+Qt::Key_N, desk, false, this, SLOT( onNewDoc() ) );
-  //no need at this action for mono-study application because study is always exists
-  action( FileNewId )->setVisible( false );
 
   createAction( FileOpenId, tr( "TOT_DESK_FILE_OPEN" ),
                 resMgr->loadPixmap( "STD", tr( "ICON_FILE_OPEN" ) ),
@@ -173,6 +172,8 @@ void STD_Application::createActions()
                 resMgr->loadPixmap( "STD", tr( "ICON_FILE_CLOSE" ) ),
                 tr( "MEN_DESK_FILE_CLOSE" ), tr( "PRP_DESK_FILE_CLOSE" ),
                 Qt::CTRL+Qt::Key_W, desk, false, this, SLOT( onCloseDoc() ) );
+  //no need in this action for mono-study application as it is same as NewDoc
+  action( FileCloseId )->setVisible( false );
 
   createAction( FileExitId, tr( "TOT_DESK_FILE_EXIT" ), QIcon(),
                 tr( "MEN_DESK_FILE_EXIT" ), tr( "PRP_DESK_FILE_EXIT" ),
@@ -257,7 +258,7 @@ void STD_Application::createActions()
   // Create tool bars
 
   int stdTBar = createTool( tr( "INF_DESK_TOOLBAR_STANDARD" ),  // title (language-dependant)
-                           QString( "SalomeStandard" ) );      // name (language-independant)
+                            QString( "SalomeStandard" ) );      // name (language-independant)
 
   // Create tool items
 
@@ -270,6 +271,13 @@ void STD_Application::createActions()
   createTool( EditPasteId, stdTBar );
 }
 
+/*!
+  Customize actions.
+*/
+void STD_Application::customize()
+{
+}
+
 /*!Opens new application*/
 void STD_Application::onNewDoc()
 {
@@ -472,7 +480,7 @@ bool STD_Application::isPossibleToClose( bool& closePermanently )
   return true;
 }
 
-int STD_Application::closeChoice( const QString& docName )
+int STD_Application::closeChoice( const QString& /*docName*/ )
 {
   int answer = SUIT_MessageBox::question( desktop(), tr( "CLOSE_STUDY" ), tr( "CLOSE_QUESTION" ),
                                           SUIT_MessageBox::Save | SUIT_MessageBox::Discard | SUIT_MessageBox::Cancel,
@@ -487,7 +495,7 @@ int STD_Application::closeChoice( const QString& docName )
   return res;
 }
 
-bool STD_Application::closeAction( const int choice, bool& closePermanently )
+bool STD_Application::closeAction( const int choice, bool& /*closePermanently*/ )
 {
   bool res = true;
   switch( choice )
@@ -561,13 +569,13 @@ bool STD_Application::openAction( const int choice, const QString& aName )
 }
 
 /*!Save document if all ok, else error message.*/
-void STD_Application::onSaveDoc()
+bool STD_Application::onSaveDoc()
 {
   if ( !activeStudy() )
-    return;
+    return false;
 
   if ( !abortAllOperations() )
-    return;
+    return false;
 
   bool isOk = false;
   if ( activeStudy()->isSaved() )
@@ -594,7 +602,8 @@ void STD_Application::onSaveDoc()
   if ( isOk )
     studySaved( activeStudy() );
   else
-    onSaveAsDoc();
+    isOk = onSaveAsDoc();
+  return isOk;
 }
 
 /*! \retval \c true, if document saved successfully, else \c false.*/
@@ -742,7 +751,7 @@ int STD_Application::showNotification(const QString& message, const QString& tit
     {
       SUIT_ResourceMgr* aResMgr = resourceMgr();
       if (aResMgr)
-       delay = aResMgr->integerValue("notification", "timeout", 0) * 1000;
+        delay = aResMgr->integerValue("notification", "timeout", 0) * 1000;
     }
     uid = ntfMgr->showNotification(message, title, qMax(delay, 0));
   }
@@ -777,7 +786,8 @@ SUIT_ViewManager* STD_Application::viewManager( const QString& vmType ) const
   SUIT_ViewManager* vm = 0;
   for ( QList<SUIT_ViewManager*>::const_iterator it = myViewMgrs.begin(); it != myViewMgrs.end() && !vm; ++it )
   {
-    if ( (*it)->getType() == vmType && !(*it)->getDetached())
+    bool keepDetached = property("keep_detached").toBool();
+    if ( (*it)->getType() == vmType && (!(*it)->getDetached() || keepDetached))
       vm = *it;
   }
   return vm;