SalomeApp_TypeFilter.h \
SalomeApp_StudyPropertiesDlg.h \
SalomeApp_CheckFileDlg.h \
- SalomeApp_VisualState.h
+ SalomeApp_VisualState.h \
+ SalomeApp_ExitDlg.h
dist_libSalomeApp_la_SOURCES= \
SalomeApp_Module.cxx \
SalomeApp_StudyPropertiesDlg.cxx \
SalomeApp_ListView.cxx \
SalomeApp_CheckFileDlg.cxx \
- SalomeApp_VisualState.cxx
+ SalomeApp_VisualState.cxx \
+ SalomeApp_ExitDlg.cxx
MOC_FILES= \
SalomeApp_Application_moc.cxx \
SalomeApp_Study_moc.cxx \
SalomeApp_StudyPropertiesDlg_moc.cxx \
SalomeApp_ListView_moc.cxx \
- SalomeApp_CheckFileDlg_moc.cxx
+ SalomeApp_CheckFileDlg_moc.cxx \
+ SalomeApp_ExitDlg_moc.cxx
+
nodist_libSalomeApp_la_SOURCES= $(MOC_FILES)
dist_salomeres_DATA= \
../PythonConsole/libPythonConsole.la ../LogWindow/libLogWindow.la \
../LightApp/libLightApp.la ../TOOLSGUI/libToolsGUI.la ../CASCatch/libCASCatch.la $(CAS_KERNEL)
-EXTRA_DIST+=SalomeApp_PyInterp.h
\ No newline at end of file
+EXTRA_DIST+=SalomeApp_PyInterp.h
#include "SalomeApp_DataObject.h"
#include "SalomeApp_EventFilter.h"
#include "SalomeApp_VisualState.h"
+#include "SalomeApp_ExitDlg.h"
#include "SalomeApp_StudyPropertiesDlg.h"
#include <SUIT_Tools.h>
#include <SUIT_Session.h>
+#include <SUIT_MsgDlg.h>
#include <QtxMRUAction.h>
#include <qcheckbox.h>
#include <qpushbutton.h>
#include <qlabel.h>
+#include <qmessagebox.h>
#include "SALOMEDSClient_ClientFactory.hxx"
#include "SALOMEDSClient_IParameters.hxx"
}
}
+/*!
+ \brief Close application.
+*/
+void SalomeApp_Application::onExit()
+{
+ bool killServers = false;
+ bool result = true;
+
+ if ( exitConfirmation() ) {
+ SalomeApp_ExitDlg dlg( desktop() );
+ result = dlg.exec() == QDialog::Accepted;
+ killServers = dlg.isServersShutdown();
+ }
+
+ if ( result )
+ SUIT_Session::session()->closeSession( SUIT_Session::ASK, killServers );
+}
/*!SLOT. Load document with \a aName.*/
bool SalomeApp_Application::onLoadDoc( const QString& aName )
desktop()->setCaption( aTitle );
}
+/*!
+ \brief Show dialog box to propose possible user actions when study is closed.
+ \param docName study name
+ \return chosen action ID
+ \sa closeAction()
+*/
+int SalomeApp_Application::closeChoice( const QString& docName )
+{
+ SUIT_MsgDlg dlg( desktop(), tr( "APPCLOSE_CAPTION" ), tr ( "APPCLOSE_DESCRIPTION" ),
+ QMessageBox::standardIcon( QMessageBox::Information ) );
+ dlg.addButton( tr ( "APPCLOSE_SAVE" ), CloseSave );
+ dlg.addButton( tr ( "APPCLOSE_CLOSE" ), CloseDiscard );
+ dlg.addButton( tr ( "APPCLOSE_UNLOAD" ), CloseUnload );
+
+ return dlg.exec();
+}
+
+/*!
+ \brief Process user actions selected from the dialog box when study is closed.
+ \param choice chosen action ID
+ \param closePermanently "forced study closing" flag
+ \return operation status
+ \sa closeChoice()
+*/
+bool SalomeApp_Application::closeAction( const int choice, bool& closePermanently )
+{
+ bool res = true;
+ switch( choice )
+ {
+ case CloseSave:
+ if ( activeStudy()->isSaved() )
+ onSaveDoc();
+ else if ( !onSaveAsDoc() )
+ res = false;
+ break;
+ case CloseDiscard:
+ break;
+ case CloseUnload:
+ closePermanently = false;
+ break;
+ case CloseCancel:
+ default:
+ res = false;
+ }
+ return res;
+}
+
+/*!
+ \brief Get module activation actions
+ \return map <action_id><action_name> where
+ - action_id is unique non-zero action identifier
+ - action_name is action title
+ \sa moduleActionSelected()
+*/
+QMap<int, QString> SalomeApp_Application::activateModuleActions() const
+{
+ QMap<int, QString> opmap = LightApp_Application::activateModuleActions();
+ opmap.insert( LoadStudyId, tr( "ACTIVATE_MODULE_OP_LOAD" ) );
+ return opmap;
+}
+
+/*!
+ \brief Process module activation action.
+ \param id action identifier
+ \sa activateModuleActions()
+*/
+void SalomeApp_Application::moduleActionSelected( const int id )
+{
+ if ( id == LoadStudyId )
+ onLoadDoc();
+ else
+ LightApp_Application::moduleActionSelected( id );
+}
+
/*!Gets CORBA::ORB_var*/
CORBA::ORB_var SalomeApp_Application::orb()
{
enum { DumpStudyId = LightApp_Application::UserID, LoadScriptId, PropertiesId,
CatalogGenId, RegDisplayId, SaveGUIStateId, FileLoadId, UserID };
+protected:
+ enum { CloseUnload = CloseDiscard + 1 };
+ enum { LoadStudyId = OpenStudyId + 1 };
+
public:
SalomeApp_Application();
virtual ~SalomeApp_Application();
virtual bool onOpenDoc( const QString& );
virtual void onLoadDoc();
virtual bool onLoadDoc( const QString& );
+ virtual void onExit();
virtual void onCopy();
virtual void onPaste();
void onSaveGUIState();// called from VISU
virtual void createPreferences( LightApp_Preferences* );
virtual void updateDesktopTitle();
+ virtual bool closeAction( const int, bool& );
+ virtual int closeChoice( const QString& );
+
+ virtual QMap<int, QString> activateModuleActions() const;
+ virtual void moduleActionSelected( const int );
+
private slots:
void onDeleteInvalidReferences();
void onDblClick( QListViewItem* );
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File: SalomeApp_ExitDlg.cxx
+// Author: Margarita KARPUNINA, Open CASCADE S.A.S.
+//
+
+#include "SalomeApp_ExitDlg.h"
+
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qpushbutton.h>
+#include <qmessagebox.h>
+#include <qcheckbox.h>
+
+/*!
+ * \brief creates a Exit dialog box
+ * \param parent a parent widget
+ * \param modal bool argument, if true the dialog box is a modal dialog box
+ * \param f style flags
+ */
+SalomeApp_ExitDlg::SalomeApp_ExitDlg( QWidget* parent )
+ : QDialog( parent, "SalomeApp_ExitDlg", true )
+{
+ setSizeGripEnabled( true );
+ setCaption( tr( "INF_DESK_EXIT" ) );
+
+ QVBoxLayout* m_vbL = new QVBoxLayout( this );
+ m_vbL->setMargin( 11 );
+ m_vbL->setSpacing( 6 );
+
+ QLabel* m_lIcon = new QLabel( this, "m_lDescr" );
+ QPixmap pm = QMessageBox::standardIcon( QMessageBox::Question );
+ m_lIcon->setPixmap( pm );
+ m_lIcon->setScaledContents( false );
+ m_lIcon->setAlignment( Qt::AlignCenter );
+
+ QLabel* m_lDescr = new QLabel (this, "m_lDescr");
+ m_lDescr->setText ( tr ("QUE_DESK_EXIT") );
+ m_lDescr->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
+
+ myServersShutdown = new QCheckBox( tr("SHUTDOWN_SERVERS"), this );
+ myServersShutdown->setChecked(true);
+
+ QVBoxLayout* m_vl1 = new QVBoxLayout();
+ m_vl1->setMargin( 10 ); m_vl1->setSpacing( 16 );
+ m_vl1->addWidget( m_lDescr );
+ m_vl1->addWidget( myServersShutdown );
+
+ QHBoxLayout* m_hl1 = new QHBoxLayout();
+ m_hl1->setMargin( 0 ); m_hl1->setSpacing( 6 );
+ m_hl1->addWidget( m_lIcon );
+ m_hl1->addStretch();
+ m_hl1->addLayout( m_vl1 );
+ m_hl1->addStretch();
+
+ QPushButton* m_pbOk = new QPushButton( tr( "BUT_OK" ), this );
+ QPushButton* m_pbCancel = new QPushButton( tr( "BUT_CANCEL" ), this );
+
+ QGridLayout* m_hl2 = new QGridLayout();
+ m_hl2->setMargin( 0 ); m_hl2->setSpacing( 6 );
+ m_hl2->addWidget( m_pbOk, 0, 0 );
+ m_hl2->setColStretch( 1, 5 );
+ m_hl2->addWidget( m_pbCancel, 0, 2 );
+
+ m_vbL->addStretch();
+ m_vbL->addLayout( m_hl1 );
+ m_vbL->addStretch();
+ m_vbL->addLayout( m_hl2 );
+
+ connect( m_pbOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
+ connect( m_pbCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
+}
+
+/*!
+ * \brief Destructor
+ */
+SalomeApp_ExitDlg::~SalomeApp_ExitDlg()
+{
+}
+
+/*!
+ * \brief get the check box status
+ */
+bool SalomeApp_ExitDlg::isServersShutdown()
+{
+ return myServersShutdown->isChecked();
+}
+
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File: SalomeApp_ExitDlg.h
+// Author: Margarita KARPUNINA, Open CASCADE S.A.S.
+//
+
+#ifndef SALOMEAPP_EXITDLG_H
+#define SALOMEAPP_EXITDLG_H
+
+#include <qdialog.h>
+
+class QCheckBox;
+
+/*!\class SalomeApp_ExitDlg
+ * \brief Describes a dialog box shown on question about quit application
+ */
+class SalomeApp_ExitDlg: public QDialog
+{
+ Q_OBJECT
+
+public:
+ SalomeApp_ExitDlg( QWidget* ) ;
+ ~SalomeApp_ExitDlg();
+
+ bool isServersShutdown();
+
+private:
+ QCheckBox* myServersShutdown;
+};
+
+#endif // SALOMEAPP_EXITDLG_H
+
msgid "SalomeApp_Application::MEN_DELETE_VS"
msgstr "Delete"
+
+msgid "SalomeApp_Application::APPCLOSE_CAPTION"
+msgstr "Close study"
+
+msgid "SalomeApp_Application::APPCLOSE_DESCRIPTION"
+msgstr "Do you want to save or unload study before closing?"
+
+msgid "SalomeApp_Application::APPCLOSE_CLOSE"
+msgstr "&Close w/o saving"
+
+msgid "SalomeApp_Application::APPCLOSE_SAVE"
+msgstr "&Save && Close"
+
+msgid "SalomeApp_Application::APPCLOSE_UNLOAD"
+msgstr "&Unload"
+
+msgid "SalomeApp_ExitDlg::SHUTDOWN_SERVERS"
+msgstr "Shutdown standalone servers"
+
+msgid "SalomeApp_Application::ACTIVATE_MODULE_OP_LOAD"
+msgstr "&Load..."
delete splash;
splash = 0;
- if ( result == SUIT_Session::FROM_GUI ) { // desktop is closed by user from GUI
- if ( aGUISession->isServersShutdown() )
+ if ( result == SUIT_Session::NORMAL ) { // desktop is closed by user from GUI
+ if ( aGUISession->exitFlags() )
shutdownServers( _NS );
break;
}