Salome HOME
Merge branch 'master' into V9_dev
[modules/gui.git] / src / LightApp / LightApp_Application.cxx
index 38acfcc60a49bc0ffca099611711ed5dfee39105..c040db4bb5911ec867e9931cc7da43d9571c77d6 100644 (file)
@@ -35,8 +35,8 @@
 #endif
 
 #ifndef DISABLE_PYCONSOLE
-  #include "LightApp_PyEditor.h"
   #include "PyConsole_Interp.h"
+  #include "LightApp_PyEditor.h"
   #include "PyConsole_Console.h"
 #endif
 
@@ -230,8 +230,6 @@ static const char* imageEmptyIcon[] = {
 "....................",
 "...................."};
 
-int LightApp_Application::lastStudyId = 0;
-
 // Markers used to parse array with dockable windows and toolbars state.
 // For more details please see the qdockarealayout.cpp && qtoolbararealayout.cpp
 // in the Qt source code.
@@ -295,14 +293,6 @@ namespace
   }
 }
 
-/*!
-  \return last global id of study
-*/
-int LightApp_Application::studyId()
-{
-  return LightApp_Application::lastStudyId;
-}
-
 /*!Create new instance of LightApp_Application.*/
 extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
 {
@@ -454,6 +444,8 @@ void LightApp_Application::start()
   desktop()->statusBar()->showMessage( "" );
 
   LightApp_EventFilter::Init();
+
+  onNewDoc();
 }
 
 /*!Closeapplication.*/
@@ -929,10 +921,8 @@ void LightApp_Application::onNewWindow()
 */
 void LightApp_Application::onNewDoc()
 {
-#ifdef SINGLE_DESKTOP
   if ( !checkExistingDoc() )
     return;
-#endif
 
   //asl: fix for 0020515
   saveDockWindowsState();
@@ -947,10 +937,8 @@ void LightApp_Application::onOpenDoc()
 {
   SUIT_Study* study = activeStudy();
   
-#ifdef SINGLE_DESKTOP
   if ( !checkExistingDoc() )
     return;
-#endif
   
   CAM_Application::onOpenDoc();
   
@@ -967,10 +955,8 @@ void LightApp_Application::onOpenDoc()
 */
 bool LightApp_Application::onOpenDoc( const QString& aName )
 {
-#ifdef SINGLE_DESKTOP
   if ( !checkExistingDoc() )
     return false;
-#endif
 
   saveDockWindowsState();
 
@@ -1354,10 +1340,9 @@ void LightApp_Application::placeDockWindow( const int id, Qt::DockWidgetArea pla
 /*!
   Gets window.
   \param flag - key for window
-  \param studyId - study id
   Flag used how identificator of window in windows list.
 */
-QWidget* LightApp_Application::getWindow( const int flag, const int )
+QWidget* LightApp_Application::getWindow( const int flag)
 {
   QWidget* wid = dockWindow( flag );
   if ( !wid )
@@ -1996,8 +1981,6 @@ void LightApp_Application::updateActions()
 */
 SUIT_Study* LightApp_Application::createNewStudy()
 {
-  LightApp_Application::lastStudyId++;
-
   LightApp_Study* aStudy = new LightApp_Study( this );
 
   // Set up processing of major study-related events
@@ -5120,19 +5103,20 @@ bool LightApp_Application::checkExistingDoc()
 {
   bool result = true;
   if( activeStudy() ) {
-    int answer = SUIT_MessageBox::question( desktop(),
-                                            tr( "APPCLOSE_CAPTION" ),
-                                            tr( "STUDYCLOSE_DESCRIPTION" ),
-                                            tr( "APPCLOSE_SAVE" ),
-                                            tr( "APPCLOSE_CLOSE" ),
-                                            tr( "APPCLOSE_CANCEL" ), 0 );
+    int answer = !activeStudy()->isModified() ? 1 :
+                 SUIT_MessageBox::question( desktop(),
+                                           tr( "APPCLOSE_CAPTION" ),
+                                           tr( "STUDYCLOSE_DESCRIPTION" ),
+                                           tr( "APPCLOSE_SAVE" ),
+                                           tr( "APPCLOSE_CLOSE" ),
+                                           tr( "APPCLOSE_CANCEL" ), 0 );
     if(answer == 0) {
       if ( activeStudy()->isSaved() ) {
         onSaveDoc();
         closeDoc( false );
       } else if ( onSaveAsDoc() ) {
-        if( !closeDoc( false ) ) {
-          result = false;
+         if( !closeDoc( false ) ) {
+           result = false;
         }
       } else {
         result = false;