1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "STD_Application.h"
21 #include "STD_MDIDesktop.h"
23 #include <SUIT_Tools.h>
24 #include <SUIT_Desktop.h>
25 #include <SUIT_Session.h>
26 #include <SUIT_ViewModel.h>
27 #include <SUIT_Operation.h>
28 #include <SUIT_MessageBox.h>
29 #include <SUIT_ResourceMgr.h>
30 #include <SUIT_MsgDlg.h>
32 #include <QtxDockAction.h>
33 #include <QtxActionMenuMgr.h>
34 #include <QtxActionToolMgr.h>
35 #include <QtxPopupMenu.h>
39 #include <qpopupmenu.h>
40 #include <qstatusbar.h>
41 #include <qfiledialog.h>
42 #include <qapplication.h>
43 #include <qmessagebox.h>
47 /*!Create and return new instance of STD_Application*/
48 extern "C" STD_EXPORT SUIT_Application* createApplication()
50 return new STD_Application();
54 STD_Application::STD_Application()
57 myExitConfirm( true ),
60 STD_MDIDesktop* desk = new STD_MDIDesktop();
66 STD_Application::~STD_Application()
71 /*! \retval requirement of exit confirmation*/
72 bool STD_Application::exitConfirmation() const
77 /*! Set the requirement of exit confirmation*/
78 void STD_Application::setExitConfirmation( const bool on )
83 /*! \retval QString "StdApplication"*/
84 QString STD_Application::applicationName() const
86 return QString( "StdApplication" );
89 /*!Start STD_Application*/
90 void STD_Application::start()
95 updateCommandsStatus();
96 setEditEnabled( myEditEnabled );
100 SUIT_Application::start();
104 Close the Application
106 void STD_Application::closeApplication()
110 SUIT_Study* study = activeStudy();
113 study->closeDocument();
121 SUIT_Application::closeApplication();
124 /*!Event on closing desktop*/
125 void STD_Application::onDesktopClosing( SUIT_Desktop*, QCloseEvent* e )
127 if ( SUIT_Session::session()->applications().count() < 2 )
133 bool closePermanently;
134 if ( !isPossibleToClose( closePermanently ) )
143 /*!Create actions, menus and tools*/
144 void STD_Application::createActions()
146 SUIT_Desktop* desk = desktop();
147 SUIT_ResourceMgr* resMgr = resourceMgr();
148 if ( !desk || !resMgr )
153 createAction( FileNewId, tr( "TOT_DESK_FILE_NEW" ),
154 resMgr->loadPixmap( "STD", tr( "ICON_FILE_NEW" ) ),
155 tr( "MEN_DESK_FILE_NEW" ), tr( "PRP_DESK_FILE_NEW" ),
156 CTRL+Key_N, desk, false, this, SLOT( onNewDoc() ) );
158 createAction( FileOpenId, tr( "TOT_DESK_FILE_OPEN" ),
159 resMgr->loadPixmap( "STD", tr( "ICON_FILE_OPEN" ) ),
160 tr( "MEN_DESK_FILE_OPEN" ), tr( "PRP_DESK_FILE_OPEN" ),
161 CTRL+Key_O, desk, false, this, SLOT( onOpenDoc() ) );
163 createAction( FileCloseId, tr( "TOT_DESK_FILE_CLOSE" ),
164 resMgr->loadPixmap( "STD", tr( "ICON_FILE_CLOSE" ) ),
165 tr( "MEN_DESK_FILE_CLOSE" ), tr( "PRP_DESK_FILE_CLOSE" ),
166 CTRL+Key_W, desk, false, this, SLOT( onCloseDoc() ) );
168 createAction( FileExitId, tr( "TOT_DESK_FILE_EXIT" ), QIconSet(),
169 tr( "MEN_DESK_FILE_EXIT" ), tr( "PRP_DESK_FILE_EXIT" ),
170 CTRL+Key_Q, desk, false, this, SLOT( onExit() ) );
172 createAction( FileSaveId, tr( "TOT_DESK_FILE_SAVE" ),
173 resMgr->loadPixmap( "STD", tr( "ICON_FILE_SAVE" ) ),
174 tr( "MEN_DESK_FILE_SAVE" ), tr( "PRP_DESK_FILE_SAVE" ),
175 CTRL+Key_S, desk, false, this, SLOT( onSaveDoc() ) );
177 createAction( FileSaveAsId, tr( "TOT_DESK_FILE_SAVEAS" ), QIconSet(),
178 tr( "MEN_DESK_FILE_SAVEAS" ), tr( "PRP_DESK_FILE_SAVEAS" ),
179 CTRL+Key_A, desk, false, this, SLOT( onSaveAsDoc() ) );
181 createAction( EditCopyId, tr( "TOT_DESK_EDIT_COPY" ),
182 resMgr->loadPixmap( "STD", tr( "ICON_EDIT_COPY" ) ),
183 tr( "MEN_DESK_EDIT_COPY" ), tr( "PRP_DESK_EDIT_COPY" ),
184 CTRL+Key_C, desk, false, this, SLOT( onCopy() ) );
186 createAction( EditPasteId, tr( "TOT_DESK_EDIT_PASTE" ),
187 resMgr->loadPixmap( "STD", tr( "ICON_EDIT_PASTE" ) ),
188 tr( "MEN_DESK_EDIT_PASTE" ), tr( "PRP_DESK_EDIT_PASTE" ),
189 CTRL+Key_V, desk, false, this, SLOT( onPaste() ) );
191 QAction* a = createAction( ViewStatusBarId, tr( "TOT_DESK_VIEW_STATUSBAR" ),
192 QIconSet(), tr( "MEN_DESK_VIEW_STATUSBAR" ),
193 tr( "PRP_DESK_VIEW_STATUSBAR" ), SHIFT+Key_S, desk, true );
194 a->setOn( desk->statusBar()->isVisibleTo( desk ) );
195 connect( a, SIGNAL( toggled( bool ) ), this, SLOT( onViewStatusBar( bool ) ) );
197 createAction( NewWindowId, tr( "TOT_DESK_NEWWINDOW" ), QIconSet(),
198 tr( "MEN_DESK_NEWWINDOW" ), tr( "PRP_DESK_NEWWINDOW" ), 0, desk );
200 createAction( HelpAboutId, tr( "TOT_DESK_HELP_ABOUT" ), QIconSet(),
201 tr( "MEN_DESK_HELP_ABOUT" ), tr( "PRP_DESK_HELP_ABOUT" ),
202 SHIFT+Key_A, desk, false, this, SLOT( onHelpAbout() ) );
204 QtxDockAction* da = new QtxDockAction( tr( "TOT_DOCK_WINDOWS" ), tr( "MEN_DOCK_WINDOWS" ), desk );
205 registerAction( ViewWindowsId, da );
206 da->setAutoPlace( false );
210 int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1, MenuFileId, 0 );
211 int editMenu = createMenu( tr( "MEN_DESK_EDIT" ), -1, MenuEditId, 10 );
212 int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1, MenuViewId, 10 );
213 int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, MenuHelpId, 1000 );
217 createMenu( FileNewId, fileMenu, 0 );
218 createMenu( FileOpenId, fileMenu, 0 );
219 createMenu( FileCloseId, fileMenu, 0 );
220 createMenu( separator(), fileMenu, -1, 0 );
221 createMenu( FileSaveId, fileMenu, 0 );
222 createMenu( FileSaveAsId, fileMenu, 0 );
223 createMenu( separator(), fileMenu, -1, 0 );
225 createMenu( separator(), fileMenu );
226 createMenu( FileExitId, fileMenu );
228 createMenu( EditCopyId, editMenu );
229 createMenu( EditPasteId, editMenu );
230 createMenu( separator(), editMenu );
232 createMenu( ViewWindowsId, viewMenu, 0 );
233 createMenu( separator(), viewMenu, -1, 10 );
234 createMenu( ViewStatusBarId, viewMenu, 10 );
235 createMenu( separator(), viewMenu );
237 createMenu( HelpAboutId, helpMenu );
238 createMenu( separator(), helpMenu );
242 int stdTBar = createTool( tr( "INF_DESK_TOOLBAR_STANDARD" ) );
246 createTool( FileNewId, stdTBar );
247 createTool( FileOpenId, stdTBar );
248 createTool( FileSaveId, stdTBar );
249 createTool( FileCloseId, stdTBar );
250 createTool( separator(), stdTBar );
251 createTool( EditCopyId, stdTBar );
252 createTool( EditPasteId, stdTBar );
255 /*!Opens new application*/
256 void STD_Application::onNewDoc()
258 QApplication::setOverrideCursor( Qt::waitCursor );
260 if ( !activeStudy() )
263 activeStudy()->createDocument();
264 studyCreated( activeStudy() );
268 SUIT_Application* aApp = startApplication( 0, 0 );
269 if ( aApp->inherits( "STD_Application" ) )
270 ((STD_Application*)aApp)->onNewDoc();
273 aApp->createEmptyStudy();
274 aApp->activeStudy()->createDocument();
278 QApplication::restoreOverrideCursor();
281 /*!Put file name from file dialog to onOpenDoc(const QString&) function*/
282 void STD_Application::onOpenDoc()
284 // It is preferrable to use OS-specific file dialog box here !!!
285 QString aName = getFileName( true, QString::null, getFileFilter(), QString::null, 0 );
286 if ( aName.isNull() )
292 /*! \retval true, if document was opened successful, else false.*/
293 bool STD_Application::onOpenDoc( const QString& aName )
295 QApplication::setOverrideCursor( Qt::waitCursor );
298 if ( !activeStudy() )
300 // if no study - open in current desktop
301 res = useFile( aName );
305 // if study exists - open in new desktop. Check: is the same file is opened?
306 SUIT_Session* aSession = SUIT_Session::session();
307 QPtrList<SUIT_Application> aAppList = aSession->applications();
308 bool isAlreadyOpen = false;
309 SUIT_Application* aApp = 0;
310 for ( QPtrListIterator<SUIT_Application> it( aAppList ); it.current() && !isAlreadyOpen; ++it )
313 if ( aApp->activeStudy()->studyName() == aName )
314 isAlreadyOpen = true;
316 if ( !isAlreadyOpen )
318 aApp = startApplication( 0, 0 );
320 res = aApp->useFile( aName );
322 aApp->closeApplication();
325 aApp->desktop()->setActiveWindow();
328 QApplication::restoreOverrideCursor();
333 /*! \retval true, if document was loaded successful, else false.*/
334 bool STD_Application::onLoadDoc( const QString& aName )
337 if ( !activeStudy() )
339 // if no study - load in current desktop
340 res = useStudy( aName );
344 // if study exists - load in new desktop. Check: is the same file is loaded?
345 SUIT_Session* aSession = SUIT_Session::session();
346 QPtrList<SUIT_Application> aAppList = aSession->applications();
347 bool isAlreadyOpen = false;
348 SUIT_Application* aApp = 0;
349 for ( QPtrListIterator<SUIT_Application> it( aAppList ); it.current() && !isAlreadyOpen; ++it )
352 if ( aApp->activeStudy()->studyName() == aName )
353 isAlreadyOpen = true;
355 if ( !isAlreadyOpen )
357 aApp = startApplication( 0, 0 );
359 res = aApp->useStudy( aName );
362 aApp->desktop()->setActiveWindow();
367 /*!Virtual function. Not implemented here.*/
368 void STD_Application::beforeCloseDoc( SUIT_Study* )
372 /*!Virtual function. Not implemented here.*/
373 void STD_Application::afterCloseDoc()
377 /*!Close document, if it's possible.*/
378 void STD_Application::onCloseDoc( bool ask )
380 bool closePermanently = true;
382 if ( ask && !isPossibleToClose( closePermanently ) )
385 SUIT_Study* study = activeStudy();
387 beforeCloseDoc( study );
390 study->closeDocument( closePermanently );
398 QPtrList<SUIT_Application> apps = SUIT_Session::session()->applications();
399 for ( unsigned i = 0; i < apps.count(); i++ )
400 aNbStudies += apps.at( i )->getNbStudies();
402 // STV: aNbStudies - number of currently existing studies (exclude currently closed)
403 // STV: aNbStudies should be compared with 0.
411 updateDesktopTitle();
412 updateCommandsStatus();
421 /*!Check the application on closing.
422 * \retval true if possible, else false
424 bool STD_Application::isPossibleToClose( bool& closePermanently )
428 activeStudy()->abortAllOperations();
429 if ( activeStudy()->isModified() )
431 QString sName = activeStudy()->studyName().stripWhiteSpace();
432 return closeAction( closeChoice( sName ), closePermanently );
439 \brief Show dialog box to propose possible user actions when study is closed.
440 \param docName study name
441 \return chosen action ID
444 int STD_Application::closeChoice( const QString& docName )
446 SUIT_MsgDlg dlg( desktop(), tr( "CLOSE_DLG_CAPTION" ), tr ( "CLOSE_DLG_DESCRIPTION" ),
447 QMessageBox::standardIcon( QMessageBox::Information ) );
448 dlg.addButton( tr ( "CLOSE_DLG_SAVE_CLOSE" ), CloseSave );
449 dlg.addButton( tr ( "CLOSE_DLG_CLOSE" ), CloseDiscard );
455 \brief Process user actions selected from the dialog box when study is closed.
456 \param choice chosen action ID
457 \param closePermanently "forced study closing" flag
458 \return operation status
461 bool STD_Application::closeAction( const int choice, bool& closePermanently )
467 if ( activeStudy()->isSaved() )
469 else if ( !onSaveAsDoc() )
482 /*!Save document if all ok, else error message.*/
483 void STD_Application::onSaveDoc()
485 if ( !activeStudy() )
489 if ( activeStudy()->isSaved() )
491 putInfo( tr( "INF_DOC_SAVING" ) + activeStudy()->studyName() );
493 QApplication::setOverrideCursor( Qt::waitCursor );
495 isOk = activeStudy()->saveDocument();
497 QApplication::restoreOverrideCursor();
502 // displaying a message box as SUIT_Validator in case file can't be written (the most frequent case)
503 SUIT_MessageBox::error1( desktop(),
505 tr( "ERR_PERMISSION_DENIED" ).arg( activeStudy()->studyName() ),
509 putInfo( tr( "INF_DOC_SAVED" ).arg( "" ) );
513 studySaved( activeStudy() );
518 /*! \retval TRUE, if doument saved successful, else FALSE.*/
519 bool STD_Application::onSaveAsDoc()
521 SUIT_Study* study = activeStudy();
528 QString aName = getFileName( false, study->studyName(), getFileFilter(), QString::null, 0 );
529 if ( aName.isNull() )
532 QApplication::setOverrideCursor( Qt::waitCursor );
534 putInfo( tr( "INF_DOC_SAVING" ) + aName );
535 isOk = study->saveDocumentAs( aName );
537 putInfo( isOk ? tr( "INF_DOC_SAVED" ).arg( aName ) : "" );
539 QApplication::restoreOverrideCursor();
542 SUIT_MessageBox::error1( desktop(), tr( "ERROR" ),
543 tr( "INF_DOC_SAVING_FAILS" ).arg( aName ),
547 studySaved( activeStudy() );
552 /*!Closing session.*/
553 void STD_Application::onExit()
555 if ( !exitConfirmation() ||
556 SUIT_MessageBox::info2( desktop(),
557 tr( "INF_DESK_EXIT" ),
558 tr( "QUE_DESK_EXIT" ),
560 tr( "BUT_CANCEL" ), 1, 2, 2 ) == 1 ) {
561 SUIT_Session::session()->closeSession();
565 /*!Virtual slot. Not implemented here.*/
566 void STD_Application::onCopy()
570 /*!Virtual slot. Not implemented here.*/
571 void STD_Application::onPaste()
575 /*!Sets \a theEnable for menu manager and for tool manager.*/
576 void STD_Application::setEditEnabled( bool theEnable )
578 myEditEnabled = theEnable;
580 QtxActionMenuMgr* mMgr = desktop()->menuMgr();
581 QtxActionToolMgr* tMgr = desktop()->toolMgr();
583 for ( int i = EditCopyId; i <= EditPasteId; i++ )
585 mMgr->setShown( mMgr->actionId(action(i)), myEditEnabled );
586 tMgr->setShown( tMgr->actionId(action(i)), myEditEnabled );
590 /*!\retval true, if document opened successful, else false.*/
591 bool STD_Application::useFile(const QString& theFileName)
593 bool res = SUIT_Application::useFile( theFileName );
596 studyOpened( activeStudy() );
601 /*!Update desktop title.*/
602 void STD_Application::updateDesktopTitle()
604 QString aTitle = applicationName();
605 QString aVer = applicationVersion();
606 if ( !aVer.isEmpty() )
607 aTitle += QString( " " ) + aVer;
611 QString sName = SUIT_Tools::file( activeStudy()->studyName().stripWhiteSpace(), false );
612 if ( !sName.isEmpty() )
613 aTitle += QString( " - [%1]" ).arg( sName );
616 desktop()->setCaption( aTitle );
619 /*!Update commands status.*/
620 void STD_Application::updateCommandsStatus()
622 SUIT_Application::updateCommandsStatus();
624 bool aHasStudy = activeStudy() != 0;
625 bool aIsNeedToSave = false;
627 aIsNeedToSave = !activeStudy()->isSaved() || activeStudy()->isModified();
629 if ( action( FileSaveId ) )
630 action( FileSaveId )->setEnabled( aIsNeedToSave );
631 if ( action( FileSaveAsId ) )
632 action( FileSaveAsId )->setEnabled( aHasStudy );
633 if ( action( FileCloseId ) )
634 action( FileCloseId )->setEnabled( aHasStudy );
635 if ( action( NewWindowId ) )
636 action( NewWindowId )->setEnabled( aHasStudy );
639 /*!\retval SUIT_ViewManager by viewer manager type name.*/
640 SUIT_ViewManager* STD_Application::viewManager( const QString& vmType ) const
642 SUIT_ViewManager* vm = 0;
643 for ( QPtrListIterator<SUIT_ViewManager> it( myViewMgrs ); it.current() && !vm; ++it )
645 if ( it.current()->getType() == vmType )
651 /*! \param vmType - input view manager type name
652 * \param lst - output list of view managers with types \a vmType.
654 void STD_Application::viewManagers( const QString& vmType, ViewManagerList& lst ) const
656 for ( QPtrListIterator<SUIT_ViewManager> it( myViewMgrs ); it.current(); ++it )
657 if ( it.current()->getType() == vmType )
658 lst.append( it.current() );
661 /*!\param lst - output list of all view managers.*/
662 void STD_Application::viewManagers( ViewManagerList& lst ) const
664 for ( QPtrListIterator<SUIT_ViewManager> it( myViewMgrs ); it.current(); ++it )
665 lst.append( it.current() );
668 /*!\retval ViewManagerList - const list of all view managers.*/
669 ViewManagerList STD_Application::viewManagers() const
676 /*!\retval SUIT_ViewManager - return pointer to active view manager.*/
677 SUIT_ViewManager* STD_Application::activeViewManager() const
679 return myActiveViewMgr;
682 /*!Add view manager to view managers list, if it not already there.*/
683 void STD_Application::addViewManager( SUIT_ViewManager* vm )
688 if ( !containsViewManager( vm ) )
690 myViewMgrs.append( vm );
691 connect( vm, SIGNAL( activated( SUIT_ViewManager* ) ),
692 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
693 vm->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
695 emit viewManagerAdded( vm );
698 if ( !activeViewManager() && myViewMgrs.count() == 1 )
699 setActiveViewManager( vm );
703 /*!Remove view manager from view managers list.*/
704 void STD_Application::removeViewManager( SUIT_ViewManager* vm )
711 emit viewManagerRemoved( vm );
713 vm->disconnectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
714 disconnect( vm, SIGNAL( activated( SUIT_ViewManager* ) ),
715 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
716 myViewMgrs.removeRef( vm );
718 if ( myActiveViewMgr == vm )
722 /*!Remove all view managers from view managers list.*/
723 void STD_Application::clearViewManagers()
728 for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current(); ++it ) {
729 QGuardedPtr<SUIT_ViewManager> vm = it.current();
730 removeViewManager( vm );
735 /*!\retval TRUE, if view manager \a vm, already in view manager list (\a myViewMgrs).*/
736 bool STD_Application::containsViewManager( SUIT_ViewManager* vm ) const
738 return myViewMgrs.contains( vm ) > 0;
741 /*!Private slot, sets active manager to \vm, if \vm in view managers list.*/
742 void STD_Application::onViewManagerActivated( SUIT_ViewManager* vm )
744 setActiveViewManager( vm );
747 /*!Sets status bar show, if \on = true, else status bar hide.*/
748 void STD_Application::onViewStatusBar( bool on )
751 desktop()->statusBar()->show();
753 desktop()->statusBar()->hide();
756 /*!Call SUIT_MessageBox::info1(...) with about information.*/
757 void STD_Application::onHelpAbout()
759 SUIT_MessageBox::info1( desktop(), tr( "About" ), tr( "ABOUT_INFO" ), "&OK" );
762 /*!Create empty study. \n
763 * Create new view manager and adding it to view managers list.
765 void STD_Application::createEmptyStudy()
767 SUIT_Application::createEmptyStudy();
769 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(), desktop(), new SUIT_ViewModel() );
771 addViewManager( vm );
774 /*!Sets active manager to \vm, if \vm in view managers list.*/
775 void STD_Application::setActiveViewManager( SUIT_ViewManager* vm )
777 if ( !containsViewManager( vm ) )
780 myActiveViewMgr = vm;
781 emit viewManagerActivated( vm );
785 void STD_Application::onConnectPopupRequest( SUIT_PopupClient* client, QContextMenuEvent* e )
787 QtxPopupMenu* popup = new QtxPopupMenu();
788 // fill popup by own items
790 contextMenuPopup( client->popupClientType(), popup, title );
791 popup->setTitleText( title );
793 popup->insertSeparator();
794 // add items from popup client
795 client->contextMenuPopup( popup );
797 SUIT_Tools::simplifySeparators( popup );
799 if ( popup->count() )
800 popup->exec( e->globalPos() );
806 /*!\retval QString - return file name from dialog.*/
807 QString STD_Application::getFileName( bool open, const QString& initial, const QString& filters,
808 const QString& caption, QWidget* parent )
814 return QFileDialog::getOpenFileName( initial, filters, parent, 0, caption );
820 QString anOldPath = initial;
825 // It is preferrable to use OS-specific file dialog box here !!!
826 aName = QFileDialog::getSaveFileName( anOldPath, filters, parent, 0, caption, &aUsedFilter );
828 if ( aName.isNull() )
832 int aEnd = aUsedFilter.findRev( ')' );
833 int aStart = aUsedFilter.findRev( '(', aEnd );
834 QString wcStr = aUsedFilter.mid( aStart + 1, aEnd - aStart - 1 );
838 QRegExp rx( "[\b\\*]*\\.([\\w]+)" );
839 while ( ( idx = rx.search( wcStr, idx ) ) != -1 )
841 extList.append( rx.cap( 1 ) );
842 idx += rx.matchedLength();
845 if ( !extList.isEmpty() && !extList.contains( QFileInfo( aName ).extension() ) )
846 aName += QString( ".%1" ).arg( extList.first() );
848 if ( QFileInfo( aName ).exists() )
850 int aAnswer = SUIT_MessageBox::warn3( desktop(), tr( "TIT_FILE_SAVEAS" ),
851 tr( "MSG_FILE_EXISTS" ).arg( aName ),
852 tr( "BUT_YES" ), tr( "BUT_NO" ), tr( "BUT_CANCEL" ), 1, 2, 3, 1 );
855 aName = QString::null;
858 else if ( aAnswer == 2 ) // not save to this file
859 anOldPath = aName; // not to return to the same initial dir at each "while" step
860 else // overwrite the existing file
871 /*!\retval QString - return directory name from dialog.*/
872 QString STD_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
876 return QFileDialog::getExistingDirectory( initial, parent, 0, caption, true );
881 \param desk - new desktop
883 void STD_Application::setDesktop( SUIT_Desktop* desk )
885 SUIT_Desktop* prev = desktop();
887 SUIT_Application::setDesktop( desk );
889 if ( prev != desk && desk )
890 connect( desk, SIGNAL( closing( SUIT_Desktop*, QCloseEvent* ) ),
891 this, SLOT( onDesktopClosing( SUIT_Desktop*, QCloseEvent* ) ) );
895 Allow to load preferences before the desktop will be shown.
897 void STD_Application::loadPreferences()
902 Allow to save preferences before the application will be closed.
904 void STD_Application::savePreferences()
909 Custom activity after study is created
910 Updates desktop and actions
912 void STD_Application::studyCreated( SUIT_Study* )
914 updateDesktopTitle();
915 updateCommandsStatus();
919 Custom activity after study is opened
920 Updates desktop and actions
922 void STD_Application::studyOpened( SUIT_Study* )
924 updateDesktopTitle();
925 updateCommandsStatus();
929 Custom activity after study is opened
930 Updates desktop and actions
932 void STD_Application::studySaved( SUIT_Study* )
934 updateDesktopTitle();
935 updateCommandsStatus();