From: vsr Date: Thu, 2 Oct 2014 08:07:36 +0000 (+0400) Subject: Multi-study support removal: finalization X-Git-Tag: V7_5_0a1~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=193f48b32206c11c833dda79a2d0c660c68afd6a;p=modules%2Fgui.git Multi-study support removal: finalization - additional change: show "Save & Disconnect" & "Disconnect w/o saving" buttons in the "Close active study" dialog box when exiting application --- diff --git a/src/LightApp/resources/LightApp_msg_en.ts b/src/LightApp/resources/LightApp_msg_en.ts index 7922e42b9..9272921f6 100644 --- a/src/LightApp/resources/LightApp_msg_en.ts +++ b/src/LightApp/resources/LightApp_msg_en.ts @@ -64,7 +64,7 @@ CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS APPCLOSE_CLOSE - &Close w/o saving + Close &w/o saving APPCLOSE_CANCEL diff --git a/src/SUIT/SUIT_MessageBox.cxx b/src/SUIT/SUIT_MessageBox.cxx index bbc7701d7..77e244fd6 100755 --- a/src/SUIT/SUIT_MessageBox.cxx +++ b/src/SUIT/SUIT_MessageBox.cxx @@ -762,6 +762,150 @@ int SUIT_MessageBox::question( QWidget* parent, const QString& title, const QStr defaultButton, escapeButton ); } +/*! + \brief Show critical message box with arbitrary number of user-specified + buttons. + + List of buttons to be shown is specified via \a buttons parameter. + + The function returns clicked button id. The identifiers for the buttons + are assigned automatically. The first button is identified as 0, the + second one as 1, etc. + + The \a defaultButton parameter allows to specify the button which is assigned + for the \c Return or \c Enter key. Similarly, \a escapeButton parameter + allows specifing the button which is assigned for \c Escape key. + If these parameters are not specified (-1 by default), the first button + is set as default button and the last one is defined as escape button. + + \param parent parent widget + \param title message box title + \param text message box text + \param defaultButton default button + \param escapeButton escape button + \param buttons list of buttons to be shown + \return button used button id +*/ +int SUIT_MessageBox::critical( QWidget* parent, const QString& title, const QString& text, + const QStringList& buttons, + const int defaultButton, const int escapeButton ) +{ + ButtonInfos lst; + int id = 0; + Q_FOREACH( QString button, buttons ) + lst.append( ButtonInfo( id++, button ) ); + return messageBox( SUIT_MessageBox::Critical, parent, title, text, lst, + defaultButton, escapeButton ); +} + +/*! + \brief Show warning message box with arbitrary number of user-specified + buttons. + + List of buttons to be shown is specified via \a buttons parameter. + + The function returns clicked button id. The identifiers for the buttons + are assigned automatically. The first button is identified as 0, the + second one as 1, etc. + + The \a defaultButton parameter allows to specify the button which is assigned + for the \c Return or \c Enter key. Similarly, \a escapeButton parameter + allows specifing the button which is assigned for \c Escape key. + If these parameters are not specified (-1 by default), the first button + is set as default button and the last one is defined as escape button. + + \param parent parent widget + \param title message box title + \param text message box text + \param defaultButton default button + \param escapeButton escape button + \param buttons list of buttons to be shown + \return button used button id +*/ +int SUIT_MessageBox::warning( QWidget* parent, const QString& title, const QString& text, + const QStringList& buttons, + const int defaultButton, const int escapeButton ) +{ + ButtonInfos lst; + int id = 0; + Q_FOREACH( QString button, buttons ) + lst.append( ButtonInfo( id++, button ) ); + return messageBox( SUIT_MessageBox::Warning, parent, title, text, lst, + defaultButton, escapeButton ); +} + +/*! + \brief Show information message box with arbitrary number of user-specified + buttons. + + List of buttons to be shown is specified via \a buttons parameter. + + The function returns clicked button id. The identifiers for the buttons + are assigned automatically. The first button is identified as 0, the + second one as 1, etc. + + The \a defaultButton parameter allows to specify the button which is assigned + for the \c Return or \c Enter key. Similarly, \a escapeButton parameter + allows specifing the button which is assigned for \c Escape key. + If these parameters are not specified (-1 by default), the first button + is set as default button and the last one is defined as escape button. + + \param parent parent widget + \param title message box title + \param text message box text + \param defaultButton default button + \param escapeButton escape button + \param buttons list of buttons to be shown + \return button used button id +*/ +int SUIT_MessageBox::information( QWidget* parent, const QString& title, const QString& text, + const QStringList& buttons, + const int defaultButton, const int escapeButton ) +{ + ButtonInfos lst; + int id = 0; + Q_FOREACH( QString button, buttons ) + lst.append( ButtonInfo( id++, button ) ); + return messageBox( SUIT_MessageBox::Information, parent, title, text, lst, + defaultButton, escapeButton ); +} + +/*! + \brief Show question message box with arbitrary number of user-specified + buttons. + + List of buttons to be shown is specified via \a buttons parameter. + + The function returns clicked button id. The identifiers for the buttons + are assigned automatically. The first button is identified as 0, the + second one as 1, etc. + + The \a defaultButton parameter allows to specify the button which is assigned + for the \c Return or \c Enter key. Similarly, \a escapeButton parameter + allows specifing the button which is assigned for \c Escape key. + If these parameters are not specified (-1 by default), the first button + is set as default button and the last one is defined as escape button. + + \param parent parent widget + \param title message box title + \param text message box text + \param defaultButton default button + \param escapeButton escape button + \param buttons list of buttons to be shown + \return button used button id +*/ +int SUIT_MessageBox::question( QWidget* parent, const QString& title, const QString& text, + const QStringList& buttons, + const int defaultButton, const int escapeButton ) +{ + ButtonInfos lst; + int id = 0; + Q_FOREACH( QString button, buttons ) + lst.append( ButtonInfo( id++, button ) ); + return messageBox( SUIT_MessageBox::Question, parent, title, text, lst, + defaultButton, escapeButton ); +} + /*! \brief Show critical message box with arbitrary number of user-specified buttons. diff --git a/src/SUIT/SUIT_MessageBox.h b/src/SUIT/SUIT_MessageBox.h index d52308833..29bfc10f8 100755 --- a/src/SUIT/SUIT_MessageBox.h +++ b/src/SUIT/SUIT_MessageBox.h @@ -110,6 +110,19 @@ public: const int defaultButton = -1, const int escapeButton = -1 ); // message boxes with arbitrary number of buttons + static int critical( QWidget* parent, const QString& title, const QString& text, + const QStringList& buttons, + const int defaultButton = -1, const int escapeButton = -1 ); + static int warning( QWidget* parent, const QString& title, const QString& text, + const QStringList& buttons, + const int defaultButton = -1, const int escapeButton = -1 ); + static int information( QWidget* parent, const QString& title, const QString& text, + const QStringList& buttons, + const int defaultButton = -1, const int escapeButton = -1 ); + static int question( QWidget* parent, const QString& title, const QString& text, + const QStringList& buttons, + const int defaultButton = -1, const int escapeButton = -1 ); + static int critical( QWidget* parent, const QString& title, const QString& text, const int defaultButton, const int escapeButton, char*, ... ); diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 32d2f1d5d..d8a18ca83 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -162,9 +162,10 @@ extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication() /*!Constructor.*/ SalomeApp_Application::SalomeApp_Application() - : LightApp_Application() + : LightApp_Application(), + myIsSiman( false ), + myIsCloseFromExit( false ) { - myIsSiman = false; // default } /*!Destructor. @@ -401,8 +402,11 @@ void SalomeApp_Application::onExit() killServers = dlg.isServersShutdown(); } - if ( result ) + if ( result ) { + if ( !killServers ) myIsCloseFromExit = true; SUIT_Session::session()->closeSession( SUIT_Session::ASK, killServers ); + myIsCloseFromExit = false; + } } /*!SLOT. Load document.*/ @@ -1193,20 +1197,25 @@ void SalomeApp_Application::updateDesktopTitle() { int SalomeApp_Application::closeChoice( const QString& docName ) { - int answer = SUIT_MessageBox::question( desktop(), tr( "APPCLOSE_CAPTION" ), tr( "APPCLOSE_DESCRIPTION" ), - tr ("APPCLOSE_SAVE"), tr ("APPCLOSE_CLOSE"), - //tr ("APPCLOSE_UNLOAD"), - tr ("APPCLOSE_CANCEL"), 0 ); - - int res = CloseCancel; - if ( answer == 0 ) - res = CloseSave; - else if ( answer == 1 ) - res = CloseDiscard; - // else if ( answer == 2 ) - // res = CloseUnload; + QStringList buttons; + QMap choices; + int idx = 0; + buttons << tr ("APPCLOSE_SAVE"); // Save & Close + choices.insert( idx++, CloseSave ); // ... + buttons << tr ("APPCLOSE_CLOSE"); // Close w/o saving + choices.insert( idx++, CloseDiscard ); // ... + if ( myIsCloseFromExit ) { + buttons << tr ("APPCLOSE_UNLOAD_SAVE"); // Save & Disconnect + choices.insert( idx++, CloseDisconnectSave ); // ... + buttons << tr ("APPCLOSE_UNLOAD"); // Disconnect + choices.insert( idx++, CloseDisconnect ); // ... + } + buttons << tr ("APPCLOSE_CANCEL"); // Cancel + choices.insert( idx++, CloseCancel ); // ... - return res; + int answer = SUIT_MessageBox::question( desktop(), tr( "APPCLOSE_CAPTION" ), + tr( "APPCLOSE_DESCRIPTION" ), buttons, 0 ); + return choices[answer]; } bool SalomeApp_Application::closeAction( const int choice, bool& closePermanently ) @@ -1222,14 +1231,19 @@ bool SalomeApp_Application::closeAction( const int choice, bool& closePermanentl break; case CloseDiscard: break; - case CloseUnload: + case CloseDisconnectSave: + if ( activeStudy()->isSaved() ) + onSaveDoc(); + else if ( !onSaveAsDoc() ) + res = false; + case CloseDisconnect: + closeActiveDoc( false ); closePermanently = false; break; case CloseCancel: default: res = false; } - return res; } diff --git a/src/SalomeApp/SalomeApp_Application.h b/src/SalomeApp/SalomeApp_Application.h index d54a6b8c2..b9833a1dc 100644 --- a/src/SalomeApp/SalomeApp_Application.h +++ b/src/SalomeApp/SalomeApp_Application.h @@ -79,7 +79,7 @@ public: protected: enum { OpenRefresh = LightApp_Application::OpenReload + 1 }; - enum { CloseUnload = LightApp_Application::CloseDiscard + 1 }; + enum { CloseDisconnectSave = LightApp_Application::CloseDiscard + 1, CloseDisconnect }; enum { LoadStudyId = LightApp_Application::OpenStudyId + 1, NewAndScriptId }; public: @@ -192,10 +192,11 @@ private: private: #ifndef DISABLE_PYCONSOLE - QPointer myNoteBook; + QPointer myNoteBook; // Notebook instance #endif - QMap myExtActions; // Map - bool myIsSiman; // application corresponds to the siman study flag + QMap myExtActions; // Map + bool myIsSiman; // application corresponds to the siman study flag + bool myIsCloseFromExit; // "Close from Exit" flag signals: void dumpedStudyClosed( const QString& theDumpScript, diff --git a/src/SalomeApp/resources/SalomeApp_msg_en.ts b/src/SalomeApp/resources/SalomeApp_msg_en.ts index d73f74105..8eaa1aaa7 100644 --- a/src/SalomeApp/resources/SalomeApp_msg_en.ts +++ b/src/SalomeApp/resources/SalomeApp_msg_en.ts @@ -143,7 +143,11 @@ Launch a new session or close the study. APPCLOSE_UNLOAD - &Unload + &Disconnect w/o saving + + + APPCLOSE_UNLOAD_SAVE + S&ave && Disconnect MEN_WINDOWS_NEW diff --git a/src/SalomeApp/resources/SalomeApp_msg_fr.ts b/src/SalomeApp/resources/SalomeApp_msg_fr.ts index dade025d2..7aa34a06b 100755 --- a/src/SalomeApp/resources/SalomeApp_msg_fr.ts +++ b/src/SalomeApp/resources/SalomeApp_msg_fr.ts @@ -131,7 +131,11 @@ Lancez une nouvelle session ou fermez l'étude en cours. APPCLOSE_UNLOAD - &Déconnecter + &Déconnecter sans sauvegarder + + + APPCLOSE_UNLOAD_SAVE + Sauvegarder && D&éconnecter MEN_WINDOWS_NEW diff --git a/src/SalomeApp/resources/SalomeApp_msg_ja.ts b/src/SalomeApp/resources/SalomeApp_msg_ja.ts index c11f45b10..3c4804f36 100644 --- a/src/SalomeApp/resources/SalomeApp_msg_ja.ts +++ b/src/SalomeApp/resources/SalomeApp_msg_ja.ts @@ -141,8 +141,12 @@ すべてのファイル (*. *) - APPCLOSE_UNLOAD - アンロード(&U) + APPCLOSE_UNLOAD + &Disconnect w/o saving + + + APPCLOSE_UNLOAD_SAVE + S&ave && Disconnect MEN_WINDOWS_NEW