STD_MDIDesktop.h \
STD_SDIDesktop.h \
STD_TabDesktop.h \
- STD_CloseDlg.h \
STD_LoadStudiesDlg.h
dist_libstd_la_SOURCES=\
STD_MDIDesktop.cxx \
STD_SDIDesktop.cxx \
STD_TabDesktop.cxx \
- STD_CloseDlg.cxx \
STD_LoadStudiesDlg.cxx
MOC_FILES= \
STD_MDIDesktop_moc.cxx \
STD_SDIDesktop_moc.cxx \
STD_TabDesktop_moc.cxx \
- STD_CloseDlg_moc.cxx \
STD_LoadStudiesDlg_moc.cxx
+
nodist_libstd_la_SOURCES= $(MOC_FILES)
dist_salomeres_DATA=\
#include "STD_MDIDesktop.h"
-#include "STD_CloseDlg.h"
-
#include <SUIT_Tools.h>
#include <SUIT_Desktop.h>
#include <SUIT_Session.h>
#include <SUIT_Operation.h>
#include <SUIT_MessageBox.h>
#include <SUIT_ResourceMgr.h>
+#include <SUIT_MsgDlg.h>
#include <QtxDockAction.h>
#include <QtxActionMenuMgr.h>
#include <qstatusbar.h>
#include <qfiledialog.h>
#include <qapplication.h>
+#include <qmessagebox.h>
#include <iostream>
/*!Constructor.*/
STD_Application::STD_Application()
: SUIT_Application(),
-myEditEnabled( true ),
-myActiveViewMgr( 0 )
+ myActiveViewMgr( 0 ),
+ myExitConfirm( true ),
+ myEditEnabled( true )
{
STD_MDIDesktop* desk = new STD_MDIDesktop();
clearViewManagers();
}
+/*! \retval requirement of exit confirmation*/
+bool STD_Application::exitConfirmation() const
+{
+ return myExitConfirm;
+}
+
+/*! Set the requirement of exit confirmation*/
+void STD_Application::setExitConfirmation( const bool on )
+{
+ myExitConfirm = on;
+}
+
/*! \retval QString "StdApplication"*/
QString STD_Application::applicationName() const
{
return;
}
- if ( !isPossibleToClose() )
+ bool closePermanently;
+ if ( !isPossibleToClose( closePermanently ) )
{
e->ignore();
return;
/*!Close document, if it's possible.*/
void STD_Application::onCloseDoc( bool ask )
{
- if ( ask && !isPossibleToClose() )
+ bool closePermanently = true;
+
+ if ( ask && !isPossibleToClose( closePermanently ) )
return;
SUIT_Study* study = activeStudy();
beforeCloseDoc( study );
if ( study )
- study->closeDocument(myClosePermanently);
+ study->closeDocument( closePermanently );
clearViewManagers();
/*!Check the application on closing.
* \retval true if possible, else false
*/
-bool STD_Application::isPossibleToClose()
+bool STD_Application::isPossibleToClose( bool& closePermanently )
{
- myClosePermanently = true; //SRN: BugID: IPAL9021
if ( activeStudy() )
{
activeStudy()->abortAllOperations();
if ( activeStudy()->isModified() )
{
QString sName = activeStudy()->studyName().stripWhiteSpace();
- QString msg = sName.isEmpty() ? tr( "INF_DOC_MODIFIED" ) : tr ( "INF_DOCUMENT_MODIFIED" ).arg( sName );
-
- //SRN: BugID: IPAL9021: Begin
- STD_CloseDlg dlg(desktop());
- switch( dlg.exec() )
- {
- case 1:
- if ( activeStudy()->isSaved() )
- onSaveDoc();
- else if ( !onSaveAsDoc() )
- return false;
- break;
- case 2:
- break;
- case 3:
- myClosePermanently = false;
- break;
- case 4:
- default:
- return false;
- }
- //SRN: BugID: IPAL9021: End
+ return closeAction( closeChoice( sName ), closePermanently );
}
}
return true;
}
+/*!
+ \brief Show dialog box to propose possible user actions when study is closed.
+ \param docName study name
+ \return chosen action ID
+ \sa closeAction()
+*/
+int STD_Application::closeChoice( const QString& docName )
+{
+ SUIT_MsgDlg dlg( desktop(), tr( "CLOSE_DLG_CAPTION" ), tr ( "CLOSE_DLG_DESCRIPTION" ),
+ QMessageBox::standardIcon( QMessageBox::Information ) );
+ dlg.addButton( tr ( "CLOSE_DLG_SAVE_CLOSE" ), CloseSave );
+ dlg.addButton( tr ( "CLOSE_DLG_CLOSE" ), CloseDiscard );
+
+ 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 STD_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 CloseCancel:
+ default:
+ res = false;
+ }
+
+ return res;
+}
+
/*!Save document if all ok, else error message.*/
void STD_Application::onSaveDoc()
{
/*!Closing session.*/
void STD_Application::onExit()
{
- STD_ExitDlg* dlg = new STD_ExitDlg(desktop());
- if( dlg->exec() == QDialog::Accepted ) {
- SUIT_Session::session()->serversShutdown(dlg->isServersShutdown());
- delete dlg;
+ if ( !exitConfirmation() ||
+ SUIT_MessageBox::info2( desktop(),
+ tr( "INF_DESK_EXIT" ),
+ tr( "QUE_DESK_EXIT" ),
+ tr( "BUT_OK" ),
+ tr( "BUT_CANCEL" ), 1, 2, 2 ) == 1 ) {
SUIT_Session::session()->closeSession();
}
}
virtual QString applicationName() const;
- virtual bool isPossibleToClose();
+ virtual bool isPossibleToClose( bool& );
virtual bool useFile( const QString& );
virtual void createEmptyStudy();
virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& ) {}
+ bool exitConfirmation() const;
+ void setExitConfirmation( const bool );
+
signals:
/*!emit that view manager added*/
void viewManagerAdded( SUIT_ViewManager* );
UserID
};
+ enum { CloseCancel, CloseSave, CloseDiscard };
+
protected:
virtual void createActions();
virtual void updateDesktopTitle();
virtual void setActiveViewManager( SUIT_ViewManager* );
+ virtual bool closeAction( const int, bool& );
+ virtual int closeChoice( const QString& );
+
private:
ViewManagerList myViewMgrs;
SUIT_ViewManager* myActiveViewMgr;
private:
+ bool myExitConfirm;
bool myEditEnabled;
- bool myClosePermanently;
};
#if defined WIN32
+++ /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
-//
-#include "STD_CloseDlg.h"
-
-#include <qlabel.h>
-#include <qlayout.h>
-#include <qpushbutton.h>
-#include <qmessagebox.h>
-#include <qhbuttongroup.h>
-
-#ifndef WNT
-using namespace std;
-#endif
-
-/*!
- * \brief creates a Close 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
- */
-
-STD_CloseDlg::STD_CloseDlg( QWidget* parent, bool modal, WFlags f )
-: QDialog( parent, "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
-{
- setSizeGripEnabled( true );
- setCaption( tr( "CLOSE_DLG_CAPTION" ) );
-
- 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::Warning );
- 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 ("CLOSE_DLG_DESCRIPTION") );
- m_lDescr->setAlignment( Qt::AlignCenter );
- m_lDescr->setMinimumHeight( m_lDescr->sizeHint().height()*5 );
- m_lDescr->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
-
- QHBoxLayout* m_hl1 = new QHBoxLayout();
- m_hl1->setMargin( 0 ); m_hl1->setSpacing( 6 );
- m_hl1->addWidget( m_lIcon );
- m_hl1->addWidget( m_lDescr );
-
- m_pb1 = new QPushButton( tr ("CLOSE_DLG_SAVE_CLOSE"), this );
- m_pb2 = new QPushButton( tr ("CLOSE_DLG_CLOSE"), this );
- m_pb3 = new QPushButton( tr ("CLOSE_DLG_UNLOAD"), this );
- m_pb4 = new QPushButton( tr ("BUT_CANCEL"), this );
-
- QGridLayout* m_hl2 = new QGridLayout();
- m_hl2->setMargin( 0 ); m_hl2->setSpacing( 6 );
- m_hl2->addWidget( m_pb1, 0, 0 );
- m_hl2->addWidget( m_pb2, 0, 1 );
- m_hl2->addWidget( m_pb3, 0, 2 );
- m_hl2->addColSpacing( 3, 10 );
- m_hl2->setColStretch( 3, 5 );
- m_hl2->addWidget( m_pb4, 0, 4 );
-
- m_vbL->addLayout( m_hl1 );
- m_vbL->addLayout( m_hl2 );
-
- connect( m_pb1, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
- connect( m_pb2, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
- connect( m_pb3, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
- connect( m_pb4, SIGNAL( clicked() ), this, SLOT( reject() ) );
-}
-
-/*!
- * \brief reaction on clicked(pressed) button
- */
-void STD_CloseDlg::onButtonClicked()
-{
- QPushButton* btn = ( QPushButton* )sender();
- if ( btn == m_pb1 )
- done( 1 );
- if ( btn == m_pb2 )
- done( 2 );
- if ( btn == m_pb3 )
- done( 3 );
-}
-
-/*!
- * \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
- */
-
-STD_ExitDlg::STD_ExitDlg( QWidget* parent, bool modal, WFlags f )
-: QDialog( parent, "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
-{
- 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 get the check box status
- */
-bool STD_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
-//
-#ifndef STD_CloseDlg_H
-#define STD_CloseDlg_H
-
-#include <qdialog.h>
-#include <qcheckbox.h>
-
-/*! \class QDialog
- * \brief For more information see <a href="http://doc.trolltech.com">QT documentation</a>.
- */
-/*!\class STD_CloseDlg
- * \brief Describes a dialog box shown on closing the active study
- */
-class STD_CloseDlg: public QDialog
-{
- Q_OBJECT
-
-public:
- STD_CloseDlg ( QWidget * parent = 0, bool modal = FALSE, WFlags f = 0 ) ;
- ~STD_CloseDlg ( ) { };
-
-private slots:
- void onButtonClicked();
-
-private:
- /*!\var m_pb1
- * \brief Private, stores a dialog button 1
- */
- QPushButton* m_pb1;
- /*!\var m_pb2
- * \brief Private, stores a dialog button 2
- */
- QPushButton* m_pb2;
- /*!\var m_pb3
- * \brief Private, stores a dialog button 3
- */
- QPushButton* m_pb3;
-
- /*!\var m_pb4
- * \brief Private, stores a dialog button 4
- */
- QPushButton* m_pb4;
-};
-
-/*!\class STD_ExitDlg
- * \brief Describes a dialog box shown on question about quit application
- */
-class STD_ExitDlg: public QDialog
-{
- Q_OBJECT
-
-public:
- STD_ExitDlg ( QWidget * parent = 0, bool modal = FALSE, WFlags f = 0 ) ;
- ~STD_ExitDlg ( ) { };
-
- bool isServersShutdown();
-
-private:
- QCheckBox* myServersShutdown;
-
-};
-
-#endif
-
msgstr "Can't save file \"%1\".\nPossible reason is permission denied or disc full.\nTry to use another file name."
msgid "CLOSE_DLG_SAVE_CLOSE"
-msgstr "&Save&&Close"
+msgstr "&Save && Close"
msgid "CLOSE_DLG_CLOSE"
msgstr "C&lose w/o saving"
msgstr "Close active study"
msgid "CLOSE_DLG_DESCRIPTION"
-msgstr "Do you want to close or only unload the study"
+msgstr "Study is modified. Do you want to save it?"
msgid "DLG_LOAD_STUDY_CAPTION"
msgstr "Load Study"
msgid "MEN_STUDIES_CHOICE"
msgstr "Choose existent study."
-msgid "SHUTDOWN_SERVERS"
-msgstr "Shutdown standalone servers"
-