1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "STD_Application.h"
24 #include "STD_MDIDesktop.h"
26 #include <SUIT_Tools.h>
27 #include <SUIT_Study.h>
28 #include <SUIT_Desktop.h>
29 #include <SUIT_Session.h>
30 #include <SUIT_MessageBox.h>
31 #include <SUIT_ViewManager.h>
32 #include <SUIT_ResourceMgr.h>
34 #include <QtxDockAction.h>
36 #include <QtxActionMenuMgr.h>
37 #include <QtxActionToolMgr.h>
41 #include <QCloseEvent>
42 #include <QFileDialog>
43 #include <QApplication>
45 /*!Create and return new instance of STD_Application*/
46 extern "C" STD_EXPORT SUIT_Application* createApplication()
48 return new STD_Application();
52 STD_Application::STD_Application()
55 myExitConfirm( true ),
58 setDesktop( new STD_MDIDesktop() );
62 STD_Application::~STD_Application()
67 /*! \retval requirement of exit confirmation*/
68 bool STD_Application::exitConfirmation() const
73 /*! Set the requirement of exit confirmation*/
74 void STD_Application::setExitConfirmation( const bool on )
79 /*! \retval QString "StdApplication"*/
80 QString STD_Application::applicationName() const
82 return QString( "StdApplication" );
85 /*!Start STD_Application*/
86 void STD_Application::start()
91 updateCommandsStatus();
92 setEditEnabled( myEditEnabled );
96 SUIT_Application::start();
100 Close the Application
102 void STD_Application::closeApplication()
106 SUIT_Study* study = activeStudy();
110 beforeCloseDoc( study );
112 study->closeDocument();
122 SUIT_Application::closeApplication();
125 /*!Event on closing desktop*/
126 void STD_Application::onDesktopClosing( SUIT_Desktop*, QCloseEvent* e )
128 if ( SUIT_Session::session()->applications().count() < 2 )
134 bool closePermanently;
135 if ( !isPossibleToClose( closePermanently ) )
144 /*!Create actions, menus and tools*/
145 void STD_Application::createActions()
147 SUIT_Desktop* desk = desktop();
148 SUIT_ResourceMgr* resMgr = resourceMgr();
149 if ( !desk || !resMgr )
154 createAction( FileNewId, tr( "TOT_DESK_FILE_NEW" ),
155 resMgr->loadPixmap( "STD", tr( "ICON_FILE_NEW" ) ),
156 tr( "MEN_DESK_FILE_NEW" ), tr( "PRP_DESK_FILE_NEW" ),
157 Qt::CTRL+Qt::Key_N, desk, false, this, SLOT( onNewDoc() ) );
159 createAction( FileOpenId, tr( "TOT_DESK_FILE_OPEN" ),
160 resMgr->loadPixmap( "STD", tr( "ICON_FILE_OPEN" ) ),
161 tr( "MEN_DESK_FILE_OPEN" ), tr( "PRP_DESK_FILE_OPEN" ),
162 Qt::CTRL+Qt::Key_O, desk, false, this, SLOT( onOpenDoc() ) );
164 createAction( FileCloseId, tr( "TOT_DESK_FILE_CLOSE" ),
165 resMgr->loadPixmap( "STD", tr( "ICON_FILE_CLOSE" ) ),
166 tr( "MEN_DESK_FILE_CLOSE" ), tr( "PRP_DESK_FILE_CLOSE" ),
167 Qt::CTRL+Qt::Key_W, desk, false, this, SLOT( onCloseDoc() ) );
169 createAction( FileExitId, tr( "TOT_DESK_FILE_EXIT" ), QIcon(),
170 tr( "MEN_DESK_FILE_EXIT" ), tr( "PRP_DESK_FILE_EXIT" ),
171 Qt::CTRL+Qt::Key_Q, desk, false, this, SLOT( onExit() ) );
173 createAction( FileSaveId, tr( "TOT_DESK_FILE_SAVE" ),
174 resMgr->loadPixmap( "STD", tr( "ICON_FILE_SAVE" ) ),
175 tr( "MEN_DESK_FILE_SAVE" ), tr( "PRP_DESK_FILE_SAVE" ),
176 Qt::CTRL+Qt::Key_S, desk, false, this, SLOT( onSaveDoc() ) );
178 createAction( FileSaveAsId, tr( "TOT_DESK_FILE_SAVEAS" ), QIcon(),
179 tr( "MEN_DESK_FILE_SAVEAS" ), tr( "PRP_DESK_FILE_SAVEAS" ),
180 Qt::CTRL+Qt::Key_A, desk, false, this, SLOT( onSaveAsDoc() ) );
182 createAction( EditCopyId, tr( "TOT_DESK_EDIT_COPY" ),
183 resMgr->loadPixmap( "STD", tr( "ICON_EDIT_COPY" ) ),
184 tr( "MEN_DESK_EDIT_COPY" ), tr( "PRP_DESK_EDIT_COPY" ),
185 Qt::CTRL+Qt::Key_C, desk, false, this, SLOT( onCopy() ) );
187 createAction( EditPasteId, tr( "TOT_DESK_EDIT_PASTE" ),
188 resMgr->loadPixmap( "STD", tr( "ICON_EDIT_PASTE" ) ),
189 tr( "MEN_DESK_EDIT_PASTE" ), tr( "PRP_DESK_EDIT_PASTE" ),
190 Qt::CTRL+Qt::Key_V, desk, false, this, SLOT( onPaste() ) );
192 QAction* a = createAction( ViewStatusBarId, tr( "TOT_DESK_VIEW_STATUSBAR" ),
193 QIcon(), tr( "MEN_DESK_VIEW_STATUSBAR" ),
194 tr( "PRP_DESK_VIEW_STATUSBAR" ), Qt::SHIFT+Qt::Key_S, desk, true );
195 a->setChecked( desk->statusBar()->isVisibleTo( desk ) );
196 connect( a, SIGNAL( toggled( bool ) ), this, SLOT( onViewStatusBar( bool ) ) );
198 createAction( NewWindowId, tr( "TOT_DESK_NEWWINDOW" ), QIcon(),
199 tr( "MEN_DESK_NEWWINDOW" ), tr( "PRP_DESK_NEWWINDOW" ), 0, desk );
201 createAction( HelpAboutId, tr( "TOT_DESK_HELP_ABOUT" ), QIcon(),
202 tr( "MEN_DESK_HELP_ABOUT" ), tr( "PRP_DESK_HELP_ABOUT" ),
203 Qt::SHIFT+Qt::Key_A, desk, false, this, SLOT( onHelpAbout() ) );
206 QtxDockAction* dwa = new QtxDockAction( tr( "TOT_DOCKWINDOWS" ), tr( "MEN_DESK_VIEW_DOCKWINDOWS" ), desk );
207 dwa->setDockType( QtxDockAction::DockWidget );
208 registerAction( ViewWindowsId, dwa );
210 QtxDockAction* tba = new QtxDockAction( tr( "TOT_TOOLBARS" ), tr( "MEN_DESK_VIEW_TOOLBARS" ), desk );
211 tba->setDockType( QtxDockAction::ToolBar );
212 registerAction( ViewToolBarsId, tba );
216 int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1, MenuFileId, 0 );
217 int editMenu = createMenu( tr( "MEN_DESK_EDIT" ), -1, MenuEditId, 10 );
218 int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1, MenuViewId, 10 );
219 int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, MenuHelpId, 1000 );
223 createMenu( FileNewId, fileMenu, 0 );
224 createMenu( FileOpenId, fileMenu, 0 );
225 createMenu( FileCloseId, fileMenu, 5 );
226 createMenu( separator(), fileMenu, -1, 5 );
227 createMenu( FileSaveId, fileMenu, 5 );
228 createMenu( FileSaveAsId, fileMenu, 5 );
229 createMenu( separator(), fileMenu, -1, 5 );
231 createMenu( separator(), fileMenu );
232 createMenu( FileExitId, fileMenu );
234 createMenu( EditCopyId, editMenu );
235 createMenu( EditPasteId, editMenu );
236 createMenu( separator(), editMenu );
238 createMenu( ViewToolBarsId, viewMenu, 0 );
239 createMenu( ViewWindowsId, viewMenu, 0 );
240 createMenu( separator(), viewMenu, -1, 10 );
241 createMenu( ViewStatusBarId, viewMenu, 10 );
242 createMenu( separator(), viewMenu );
244 createMenu( HelpAboutId, helpMenu );
245 createMenu( separator(), helpMenu );
249 int stdTBar = createTool( tr( "INF_DESK_TOOLBAR_STANDARD" ) );
253 createTool( FileNewId, stdTBar );
254 createTool( FileOpenId, stdTBar );
255 createTool( FileSaveId, stdTBar );
256 createTool( FileCloseId, stdTBar );
257 createTool( separator(), stdTBar );
258 createTool( EditCopyId, stdTBar );
259 createTool( EditPasteId, stdTBar );
262 /*!Opens new application*/
263 void STD_Application::onNewDoc()
265 onNewDoc( QString() );
268 /*!Opens new application*/
269 bool STD_Application::onNewDoc( const QString& name )
271 QApplication::setOverrideCursor( Qt::WaitCursor );
274 if ( !activeStudy() )
277 res = activeStudy()->createDocument( name );
279 studyCreated( activeStudy() );
282 SUIT_Study* st = activeStudy();
289 SUIT_Application* aApp = startApplication( 0, 0 );
290 if ( aApp->inherits( "STD_Application" ) )
291 res = ((STD_Application*)aApp)->onNewDoc( name );
294 aApp->createEmptyStudy();
295 res = aApp->activeStudy()->createDocument( name );
298 aApp->closeApplication();
301 QApplication::restoreOverrideCursor();
306 /*!Put file name from file dialog to onOpenDoc(const QString&) function*/
307 void STD_Application::onOpenDoc()
309 // It is preferrable to use OS-specific file dialog box here !!!
310 QString aName = getFileName( true, QString(), getFileFilter(), QString(), 0 );
311 if ( aName.isNull() )
317 /*! \retval true, if document was opened successful, else false.*/
318 bool STD_Application::onOpenDoc( const QString& aName )
320 QApplication::setOverrideCursor( Qt::WaitCursor );
322 bool res = openAction( openChoice( aName ), aName );
324 QApplication::restoreOverrideCursor();
329 /*!Virtual function. Not implemented here.*/
330 void STD_Application::beforeCloseDoc( SUIT_Study* )
334 /*!Virtual function. Not implemented here.*/
335 void STD_Application::afterCloseDoc()
339 /*!Close document, if it's possible.*/
340 void STD_Application::onCloseDoc( bool ask )
342 bool closePermanently = true;
344 if ( ask && !isPossibleToClose( closePermanently ) )
347 SUIT_Study* study = activeStudy();
349 beforeCloseDoc( study );
352 study->closeDocument( closePermanently );
359 QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
360 for ( int i = 0; i < apps.count(); i++ )
361 aNbStudies += apps.at( i )->getNbStudies();
370 updateDesktopTitle();
371 updateCommandsStatus();
374 // IPAL19532: deleting study should be performed after calling setDesktop(0)
383 /*!Check the application on closing.
384 * \retval true if possible, else false
386 bool STD_Application::isPossibleToClose( bool& closePermanently )
390 activeStudy()->abortAllOperations();
391 if ( activeStudy()->isModified() )
393 QString sName = activeStudy()->studyName().trimmed();
394 return closeAction( closeChoice( sName ), closePermanently );
400 int STD_Application::closeChoice( const QString& docName )
402 int answer = SUIT_MessageBox::question( desktop(), tr( "CLOSE_STUDY" ), tr( "CLOSE_QUESTION" ).arg( docName ),
403 SUIT_MessageBox::Save | SUIT_MessageBox::Discard | SUIT_MessageBox::Cancel,
404 SUIT_MessageBox::Save );
406 int res = CloseCancel;
407 if ( answer == SUIT_MessageBox::Save )
409 else if ( answer == SUIT_MessageBox::Discard )
415 bool STD_Application::closeAction( const int choice, bool& closePermanently )
421 if ( activeStudy()->isSaved() )
423 else if ( !onSaveAsDoc() )
436 int STD_Application::openChoice( const QString& aName )
438 SUIT_Session* aSession = SUIT_Session::session();
440 bool isAlreadyOpen = false;
441 QList<SUIT_Application*> aAppList = aSession->applications();
442 for ( QList<SUIT_Application*>::iterator it = aAppList.begin(); it != aAppList.end() && !isAlreadyOpen; ++it )
443 isAlreadyOpen = (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName;
444 return isAlreadyOpen ? OpenExist : OpenNew;
447 bool STD_Application::openAction( const int choice, const QString& aName )
454 SUIT_Application* aApp = 0;
455 SUIT_Session* aSession = SUIT_Session::session();
456 QList<SUIT_Application*> aAppList = aSession->applications();
457 for ( QList<SUIT_Application*>::iterator it = aAppList.begin(); it != aAppList.end() && !aApp; ++it )
459 if ( (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName )
463 aApp->desktop()->activateWindow();
469 if ( !activeStudy() )
470 res = useFile( aName );
473 SUIT_Application* aApp = startApplication( 0, 0 );
475 res = aApp->useFile( aName );
477 aApp->closeApplication();
488 /*!Save document if all ok, else error message.*/
489 void STD_Application::onSaveDoc()
491 if ( !activeStudy() )
495 if ( activeStudy()->isSaved() )
497 putInfo( tr( "INF_DOC_SAVING" ) + activeStudy()->studyName() );
499 QApplication::setOverrideCursor( Qt::WaitCursor );
501 isOk = activeStudy()->saveDocument();
503 QApplication::restoreOverrideCursor();
508 // displaying a message box as SUIT_Validator in case file can't be written (the most frequent case)
509 SUIT_MessageBox::critical( desktop(), tr( "ERR_ERROR" ),
510 tr( "ERR_PERMISSION_DENIED" ).arg( activeStudy()->studyName() ) );
513 putInfo( tr( "INF_DOC_SAVED" ).arg( "" ) );
517 studySaved( activeStudy() );
522 /*! \retval TRUE, if doument saved successful, else FALSE.*/
523 bool STD_Application::onSaveAsDoc()
525 SUIT_Study* study = activeStudy();
532 QString aName = getFileName( false, study->studyName(), getFileFilter(), QString(), 0 );
533 if ( aName.isNull() )
536 QApplication::setOverrideCursor( Qt::WaitCursor );
538 putInfo( tr( "INF_DOC_SAVING" ) + aName );
539 isOk = study->saveDocumentAs( aName );
541 putInfo( isOk ? tr( "INF_DOC_SAVED" ).arg( aName ) : "" );
543 QApplication::restoreOverrideCursor();
546 SUIT_MessageBox::critical( desktop(), tr( "ERROR" ), tr( "INF_DOC_SAVING_FAILS" ).arg( aName ) );
549 studySaved( activeStudy() );
554 /*!Closing session.*/
555 void STD_Application::onExit()
557 int aAnswer = SUIT_MessageBox::Ok;
558 if ( exitConfirmation() )
559 aAnswer = SUIT_MessageBox::question( desktop(), tr( "INF_DESK_EXIT" ), tr( "QUE_DESK_EXIT" ),
560 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel, SUIT_MessageBox::Cancel );
561 if ( aAnswer == SUIT_MessageBox::Ok )
562 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().trimmed(), false );
612 if ( !sName.isEmpty() )
613 aTitle += QString( " - [%1]" ).arg( sName );
616 desktop()->setWindowTitle( 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 ( QList<SUIT_ViewManager*>::const_iterator it = myViewMgrs.begin(); it != myViewMgrs.end() && !vm; ++it )
645 if ( (*it)->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 ( QList<SUIT_ViewManager*>::const_iterator it = myViewMgrs.begin(); it != myViewMgrs.end(); ++it )
658 if ( (*it)->getType() == vmType )
663 /*!\param lst - output list of all view managers.*/
664 void STD_Application::viewManagers( ViewManagerList& lst ) const
666 for ( QList<SUIT_ViewManager*>::const_iterator it = myViewMgrs.begin(); it != myViewMgrs.end(); ++it )
670 /*!\retval ViewManagerList - const list of all view managers.*/
671 ViewManagerList STD_Application::viewManagers() const
678 /*!\retval SUIT_ViewManager - return pointer to active view manager.*/
679 SUIT_ViewManager* STD_Application::activeViewManager() const
681 return myActiveViewMgr;
684 /*!Add view manager to view managers list, if it not already there.*/
685 void STD_Application::addViewManager( SUIT_ViewManager* vm )
690 if ( !containsViewManager( vm ) )
692 myViewMgrs.append( vm );
693 connect( vm, SIGNAL( activated( SUIT_ViewManager* ) ),
694 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
695 vm->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
697 emit viewManagerAdded( vm );
700 if ( !activeViewManager() && myViewMgrs.count() == 1 )
701 setActiveViewManager( vm );
705 /*!Remove view manager from view managers list.*/
706 void STD_Application::removeViewManager( SUIT_ViewManager* vm )
713 emit viewManagerRemoved( vm );
715 vm->disconnectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
716 disconnect( vm, SIGNAL( activated( SUIT_ViewManager* ) ),
717 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
718 myViewMgrs.removeAll( vm );
720 if ( myActiveViewMgr == vm )
724 /*!Remove all view managers from view managers list.*/
725 void STD_Application::clearViewManagers()
730 for ( QList<SUIT_ViewManager*>::iterator it = lst.begin(); it != lst.end(); ++it )
732 QPointer<SUIT_ViewManager> vm = *it;
733 removeViewManager( vm );
738 /*!\retval TRUE, if view manager \a vm, already in view manager list (\a myViewMgrs).*/
739 bool STD_Application::containsViewManager( SUIT_ViewManager* vm ) const
741 return myViewMgrs.contains( vm );
744 /*!Private slot, sets active manager to \vm, if \vm in view managers list.*/
745 void STD_Application::onViewManagerActivated( SUIT_ViewManager* vm )
747 setActiveViewManager( vm );
750 /*!Sets status bar show, if \on = true, else status bar hide.*/
751 void STD_Application::onViewStatusBar( bool on )
754 desktop()->statusBar()->show();
756 desktop()->statusBar()->hide();
759 /*!Call SUIT_MessageBox::info1(...) with about information.*/
760 void STD_Application::onHelpAbout()
762 SUIT_MessageBox::information( desktop(), tr( "About" ), tr( "ABOUT_INFO" ) );
765 /*!Create empty study. \n
766 * Create new view manager and adding it to view managers list.
768 void STD_Application::createEmptyStudy()
770 SUIT_Application::createEmptyStudy();
773 /*!Sets active manager to \vm, if \vm in view managers list.*/
774 void STD_Application::setActiveViewManager( SUIT_ViewManager* vm )
776 if ( !containsViewManager( vm ) )
779 myActiveViewMgr = vm;
780 emit viewManagerActivated( vm );
784 void STD_Application::onConnectPopupRequest( SUIT_PopupClient* client, QContextMenuEvent* e )
786 QtxMenu* popup = new QtxMenu();
787 // fill popup by own items
789 contextMenuPopup( client->popupClientType(), popup, title );
790 popup->setTitleText( title );
792 popup->addSeparator();
793 // add items from popup client
794 client->contextMenuPopup( popup );
796 SUIT_Tools::simplifySeparators( popup );
798 if ( !popup->actions().isEmpty() )
799 popup->exec( e->globalPos() );
803 /*!\retval QString - return file name from dialog.*/
804 QString STD_Application::getFileName( bool open, const QString& initial, const QString& filters,
805 const QString& caption, QWidget* parent )
810 return QFileDialog::getOpenFileName( parent, caption, initial, filters );
815 QString anOldPath = initial;
820 // It is preferrable to use OS-specific file dialog box here !!!
821 aName = QFileDialog::getSaveFileName( parent, caption, anOldPath, filters, &aUsedFilter );
823 if ( aName.isNull() )
827 int aEnd = aUsedFilter.lastIndexOf( ')' );
828 int aStart = aUsedFilter.lastIndexOf( '(', aEnd );
829 QString wcStr = aUsedFilter.mid( aStart + 1, aEnd - aStart - 1 );
833 QRegExp rx( "[\b\\*]*\\.([\\w]+)" );
834 while ( ( idx = rx.indexIn( wcStr, idx ) ) != -1 )
836 extList.append( rx.cap( 1 ) );
837 idx += rx.matchedLength();
840 if ( !extList.isEmpty() && !extList.contains( SUIT_Tools::extension( aName ) ) )
841 aName += QString( ".%1" ).arg( extList.first() );
843 if ( QFileInfo( aName ).exists() )
845 int aAnswer = SUIT_MessageBox::question( desktop(), tr( "TIT_FILE_SAVEAS" ),
846 tr( "MSG_FILE_EXISTS" ).arg( aName ),
847 SUIT_MessageBox::Yes | SUIT_MessageBox::No | SUIT_MessageBox::Cancel, SUIT_MessageBox::Yes );
848 if ( aAnswer == SUIT_MessageBox::Cancel )
853 else if ( aAnswer == SUIT_MessageBox::No ) // not save to this file
854 anOldPath = aName; // not to return to the same initial dir at each "while" step
855 else // overwrite the existing file
866 /*!\retval QString - return directory name from dialog.*/
867 QString STD_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
872 return QFileDialog::getExistingDirectory( parent, caption, initial );
877 \param desk - new desktop
879 void STD_Application::setDesktop( SUIT_Desktop* desk )
881 SUIT_Desktop* prev = desktop();
883 SUIT_Application::setDesktop( desk );
885 if ( prev != desk && desk )
886 connect( desk, SIGNAL( closing( SUIT_Desktop*, QCloseEvent* ) ),
887 this, SLOT( onDesktopClosing( SUIT_Desktop*, QCloseEvent* ) ) );
891 Allow to load preferences before the desktop will be shown.
893 void STD_Application::loadPreferences()
898 Allow to save preferences before the application will be closed.
900 void STD_Application::savePreferences()
905 Custom activity after study is created
906 Updates desktop and actions
908 void STD_Application::studyCreated( SUIT_Study* )
910 updateDesktopTitle();
911 updateCommandsStatus();
915 Custom activity after study is opened
916 Updates desktop and actions
918 void STD_Application::studyOpened( SUIT_Study* )
920 updateDesktopTitle();
921 updateCommandsStatus();
925 Custom activity after study is opened
926 Updates desktop and actions
928 void STD_Application::studySaved( SUIT_Study* )
930 updateDesktopTitle();
931 updateCommandsStatus();