1 // SALOME SALOMEGUI : implementation of desktop and GUI kernel
3 // Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : QAD_Desktop.cxx
25 // Author : Nicolas REJNERI
30 \class QAD_Desktop QAD_Desktop.h
31 \brief Main desktop of QAD-based application.
33 # include "Utils_ORB_INIT.hxx"
34 # include "Utils_SINGLETON.hxx"
36 #define INCLUDE_MENUITEM_DEF
37 #define DEFAULT_BROWSER "mozilla"
42 #include "QAD_Tools.h"
43 #include "QAD_Desktop.h"
44 #include "QAD_LeftFrame.h"
45 #include "QAD_RightFrame.h"
46 #include "QAD_PyEditor.h"
47 #include "QAD_Operation.h"
48 #include "QAD_XmlHandler.h"
49 #include "QAD_MessageBox.h"
50 #include "QAD_Application.h"
51 #include "QAD_Settings.h"
52 #include "QAD_Config.h"
53 #include "QAD_ObjectBrowser.h"
54 #include "QAD_Resource.h"
55 #include "QAD_FileDlg.h"
56 //NRI #include "QAD_HelpWindow.h"
57 #include "QAD_DirListDlg.h"
58 #include "QAD_WaitCursor.h"
59 #include "SALOMEGUI.h"
60 #include "SALOMEGUI_OpenWith.h"
61 #include "SALOMEGUI_StudyPropertiesDlg.h"
62 #include "SALOMEGUI_TrihedronSizeDlg.h"
63 #include "SALOMEGUI_ExternalBrowserDlg.h"
64 #include "SALOMEGUI_LoadStudiesDlg.h"
65 //#include "SALOME_Selection.h"
66 #include "SALOME_InteractiveObject.hxx"
67 #include "SALOME_ListIteratorOfListIO.hxx"
68 #include "SALOMEGUI_AboutDlg.h"
69 #include "SALOMEGUI_ViewChoiceDlg.h"
70 #include "SALOMEGUI_SetValueDlg.h"
71 #include "utilities.h"
73 #include "SALOMEGUI_CloseDlg.h"
74 #include "SALOMEGUI_ActivateComponentDlg.h"
75 #include "SALOMEGUI_QtCatchCorbaException.hxx"
77 #include "SALOME_Event.hxx"
82 #include <qmessagebox.h>
83 #include <qcolordialog.h>
84 #include <qradiobutton.h>
85 #include <qapplication.h>
86 #include <qvbuttongroup.h>
88 #include <qmessagebox.h>
91 #include <qpopupmenu.h>
92 #include <qlistview.h>
96 #include <qfontdialog.h>
97 #include <qlineedit.h>
98 #include <qdatetime.h>
101 #include <qstringlist.h>
104 #include <qlistbox.h>
108 // Open CASCADE Includes
109 #include <OSD_SharedLibrary.hxx>
110 #include <OSD_LoadMode.hxx>
111 #include <OSD_Function.hxx>
112 #include <TCollection_AsciiString.hxx>
115 static const char* SEPARATOR = ":";
122 QAD_ResourceMgr* QAD_Desktop::resourceMgr = 0;
123 QPalette* QAD_Desktop::palette = 0;
125 static QString createString( int theItemId, int thePosId )
127 QString aRetString = QString("item-id=");
129 QString aItemId = aString.setNum(theItemId);
130 QString aPosId = aString.setNum(thePosId);
131 aRetString = aRetString + '"'; aRetString = aRetString + aItemId; aRetString = aRetString + '"';
132 aRetString = aRetString + " pos-id="; aRetString = aRetString + '"';
133 aRetString = aRetString + aPosId;
134 aRetString = aRetString + '"'; aRetString = aRetString + ">";
139 Creates the resource manager [ static ]
141 QAD_ResourceMgr* QAD_Desktop::createResourceManager()
144 resourceMgr = new QAD_ResourceMgr;
149 Returns the resource manager [ static ]
151 QAD_ResourceMgr* QAD_Desktop::getResourceManager()
158 Loads the palette from settings [ static ]
160 QPalette* QAD_Desktop::createPalette()
163 palette = new QPalette();
169 Returns the palette [ static ]
171 QPalette* QAD_Desktop::getPalette()
177 // Gets window ratio width/heght [ static ]
180 //static double getWindowRatio()
182 // return myWindowRatio;
186 // Sets window ratio width/heght [ static ]
188 //static void setWindowRatio(double aRatio)
190 // myWindowRatio = aRatio;
196 QAD_Desktop::QAD_Desktop(SALOME_NamingService* name_service) :
197 QMainWindow(0, 0, WType_TopLevel | WDestructiveClose),
203 //NRImyHelpWindow(0),
204 myDefaultTitle( tr("DESK_DEFAULTTITLE") ),
205 myQueryClose( true ),
206 myAboutToClose( false )
208 /* Force reading of user config file */
209 QAD_CONFIG->readConfigFile();
211 /* menubar and status bar */
212 myStatusBar = statusBar();
213 myMainMenu = menuBar();
215 myNameService = name_service;
217 /* default background icon */
218 QPixmap backgroundicon ( QAD_Desktop::getResourceManager()->loadPixmap( "CLIENT",
219 tr("ICON_DESK_BACKGROUNDICON") ));
220 //myToolBarAction.setAutoDelete( true );
222 /* default icon and title */
223 QPixmap icon ( QAD_Desktop::getResourceManager()->loadPixmap( "CLIENT",
224 tr("ICON_DESK_DEFAULTICON") ));
225 if ( !icon.isNull() ) {
226 myDefaultIcon = icon;
227 setIcon( myDefaultIcon );
229 setCaption( myDefaultTitle );
231 /* set size as 1/2 of the screen and center it */
232 QWidget* d = QApplication::desktop();
233 resize( 2*d->width()/3, 2*d->height()/3 );
234 QAD_Tools::centerWidget( this, d );
236 /* workspace will manage child frames */
237 QHBox* border = new QHBox ( this );
238 border->setFrameStyle ( QFrame::Panel | QFrame::Sunken );
239 setCentralWidget( border );
240 myWorkspace = new QWorkspaceP( border );
242 QPalette pal = QAD_Application::getPalette();
244 QColorGroup cgA = pal.active();
245 QColorGroup cgI = pal.inactive();
246 QColorGroup cgD = pal.disabled();
247 cgA.setColor( QColorGroup::Background, QColor(192, 192, 192));
248 cgI.setColor( QColorGroup::Background, QColor(192, 192, 192));
249 cgD.setColor( QColorGroup::Background, QColor(192, 192, 192));
250 pal.setActive ( cgA );
251 pal.setInactive( cgI );
252 pal.setDisabled( cgD );
253 myWorkspace->setPalette( pal );
254 if ( !backgroundicon.isNull() ) {
255 MESSAGE("!!!DESKTOP background icon found!!!");
256 myWorkspace->setPaletteBackgroundPixmap(backgroundicon);
259 /* define standard file commands */
262 /* define operator menus for xml */
263 myOperatorMenus = new QAD_OperatorMenus(this);
264 myXmlHandler = new QAD_XmlHandler();
267 CORBA::Object_var objVarN = myNameService->Resolve("/Kernel/ModulCatalog");
268 myCatalogue = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
270 SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants =
271 myCatalogue->GetComponentIconeList();
274 QToolBar* tbComponent = new QToolBar( tr("MEN_DESK_COMPONENTTOOLBAR"), this );
275 tbComponent->setCloseMode( QDockWindow::Undocked );
276 addToolBar(tbComponent, tr("MEN_DESK_COMPONENTTOOLBAR"), Bottom, TRUE );
277 setDockEnabled( tbComponent, DockLeft, false );
278 setDockEnabled( tbComponent, DockRight, false );
280 myCombo = new QComboBox( FALSE, tbComponent, "comboBox" );
281 myCombo->setFocusPolicy( NoFocus );
283 tbComponent->addSeparator();
285 // PG : add ResourceManager to get function findFile !!
286 QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager();
288 for (unsigned int ind = 0; ind < list_composants->length();ind++) {
291 /* find component icon */
292 QString iconfile = CORBA::string_dup(list_composants[ind].moduleicone) ;
293 QString modulename = CORBA::string_dup(list_composants[ind].modulename) ;
294 QString moduleusername = CORBA::string_dup(list_composants[ind].moduleusername) ;
296 // MESSAGE ( " MODULE = " << modulename )
297 // MESSAGE ( " MODULE icon = " << iconfile )
298 // MESSAGE ( " MODULE username = " << moduleusername )
300 if ( mapComponentName.contains( moduleusername ) ) {
301 QMessageBox::warning( this, tr("WRN_WARNING"), QString( moduleusername + " is already associated with " + mapComponentName[moduleusername] + ".\nPlease, change the component username of " + modulename) , tr ("BUT_OK") );
304 mapComponentName.insert( moduleusername, modulename );
306 resDir = resMgr->findFile(iconfile,modulename) ;
309 MESSAGE ( "resDir" << resDir )
310 //resDir = QAD_Tools::addSlash(resDir) ;
311 //QPixmap Icone(resDir+iconfile) ;
312 QPixmap Icone( QAD_Tools::addSlash( resDir ) + iconfile );
313 QToolButton * toolb =
314 new QToolButton( QIconSet( Icone ), moduleusername, QString::null, this,
315 SLOT( onButtonActiveComponent () ),tbComponent );
316 toolb->setToggleButton( true );
317 myComponentButton.append(toolb);
321 QString errMsg = tr("INF_ICON_RESOURCES").arg(iconfile).arg(modulename) +
323 //QMessageBox::warning( this, tr("WRN_WARNING"), errMsg, tr ("BUT_OK") );
325 if ( ( resDir || moduleusername == "Salome" ) && !modulename.isEmpty() ) // VSR: Force "Salome" component to appear in the combo box
326 myCombo->insertItem( moduleusername );
329 myCombo->adjustSize();
330 connect( myCombo, SIGNAL(activated(const QString&)),
331 this, SLOT( onComboActiveComponent(const QString&) ) );
333 /* new LifeCycleCORBA client, for Engines */
334 myEnginesLifeCycle = new SALOME_LifeCycleCORBA(name_service);
336 /* VSR 13/01/03 : installing global event filter for the application */
337 qApp->installEventFilter( this );
339 /* init pseudo random numbers generator */
340 QTime cTime = QTime::currentTime();
341 int secs = cTime.second() + 1;
342 for ( int s = 0; s < secs; s++ ) random();
348 QAD_Desktop::~QAD_Desktop ()
350 qApp->removeEventFilter( this );
354 myObjBrowserPopup.clear();
355 //VRV: T2.5 - add default viewer
356 myDefaultViewer.clear();
357 //VRV: T2.5 - add default viewer
358 myViewerPopup.clear();
360 myNewViewPopup.clear();
362 myHelpContentsModulePopup.clear();
363 myToolsPopup.clear();
365 myStdActions.clear();
367 myToolBarsPopup.clear();
368 myToolBarAction.clear();
371 //NRI if (myHelpWindow)
372 // myHelpWindow->close();
374 QAD_Application::desktop = 0;
377 const int IdCut = 1001;
378 const int IdCopy = 1002;
379 const int IdPaste = 1003;
380 const int IdSelectAll = 1004;
382 #include <qkeysequence.h>
383 #define ACCEL_KEY(k) "\t" + QString(QKeySequence( Qt::CTRL | Qt::Key_ ## k ))
385 #define ACCEL_KEY(k) "\t" + QString("Ctrl+" #k)
387 #include <qclipboard.h>
389 Global event filter for qapplication (VSR 13/01/03)
391 bool QAD_Desktop::eventFilter( QObject* o, QEvent* e )
393 if (e->type() == QEvent::Close && o == this )
394 myAboutToClose = true;
395 else if (e->type() == 2000 ) {
396 QMessageBox::information (this, tr ( "Help Information" ), tr ( "Can't run choosen browser.\nRunning default browser (Mozilla). "));
399 else if (e->type() == 2001 ) {
400 QMessageBox::critical(this, tr ( "Help Error" ), tr ( "Can't run the default browser.") );
403 else if ( e->type() == QEvent::ContextMenu ) {
404 QContextMenuEvent* ce = (QContextMenuEvent*)e;
405 if ( o->inherits("QRenameEdit") ) {
408 else if ( o->inherits("QLineEdit") ) {
409 QLineEdit* le = (QLineEdit*)o;
410 if ( le->parentWidget() ) {
411 if ( ( le->parentWidget()->inherits("QSpinBox") ||
412 le->parentWidget()->inherits("QSpinWidget") ||
413 le->parentWidget()->inherits("QAD_SpinBoxDbl") ) &&
415 QPopupMenu* popup = new QPopupMenu( 0, "qt_edit_menu" );
416 popup->insertItem( tr( "EDIT_CUT_CMD" ) + ACCEL_KEY( X ), IdCut );
417 popup->insertItem( tr( "EDIT_COPY_CMD" ) + ACCEL_KEY( C ), IdCopy );
418 popup->insertItem( tr( "EDIT_PASTE_CMD" ) + ACCEL_KEY( V ), IdPaste );
419 popup->insertSeparator();
420 #if defined(Q_WS_X11)
421 popup->insertItem( tr( "EDIT_SELECTALL_CMD" ), IdSelectAll );
423 popup->insertItem( tr( "EDIT_SELECTALL_CMD" ) + ACCEL_KEY( A ), IdSelectAll );
425 bool enableCut = !le->isReadOnly() && le->hasSelectedText();
426 popup->setItemEnabled( IdCut, enableCut );
427 popup->setItemEnabled( IdCopy, le->hasSelectedText() );
428 bool enablePaste = !le->isReadOnly() && !QApplication::clipboard()->text().isEmpty();
429 popup->setItemEnabled( IdPaste, enablePaste );
430 bool allSelected = (le->selectedText() == le->text() );
431 popup->setItemEnabled( IdSelectAll, (bool)(le->text().length()) && !allSelected );
433 QPoint pos = ce->reason() == QContextMenuEvent::Mouse ? ce->globalPos() :
434 le->mapToGlobal( QPoint(ce->pos().x(), 0) ) + QPoint( le->width() / 2, le->height() / 2 );
436 int r = popup->exec( pos );
458 else if ( e->type() == SALOME_EVENT ) {
459 SALOME_Event* aSE = (SALOME_Event*)((QCustomEvent*)e)->data();
461 ((QCustomEvent*)e)->setData( 0 );
464 return QMainWindow::eventFilter( o, e );
468 Dispatches <theEvent> to the target component GUI
470 void QAD_Desktop::processEvent( SALOME_Event* theEvent )
474 // Signal the calling thread that the event has been processed
475 theEvent->processed();
480 Creates and initializes the standard file operations
481 such as 'New/Open/Save/SaveAs/Close' and 'Help'.
483 void QAD_Desktop::createActions()
486 /* Used for string compare */
487 const QString& aTrueQString = "true" ;
489 /* create 'standard' toolbar */
490 if ( !myStdToolBar ) {
491 myStdToolBar = new QToolBar ( tr("MEN_DESK_VIEW_STDTOOLBAR"), this );
492 myStdToolBar->setCloseMode( QDockWindow::Undocked );
495 if ( !myMainMenu->count() ) {
496 /* Create main menu bar */
497 myMainMenu->insertItem ( tr("MEN_DESK_FILE"), &myFilePopup, 1 ); /* add popup FILE */
498 myMainMenu->insertItem ( tr("MEN_DESK_VIEW"), &myViewPopup, 2 ); /* add popup VIEW */
499 myMainMenu->insertItem ( tr("MEN_DESK_TOOLS"), &myToolsPopup, 5 ); /* add popup TOOLS */
500 myMainMenu->insertItem ( tr("MEN_DESK_PREF"), &myPrefPopup, 4 ); /* add popup PREF */
501 myMainMenu->insertItem ( tr("MEN_DESK_WINDOW"), &myWindowPopup, 6 ); /* add popup WINDOW */
502 myMainMenu->insertItem ( tr("MEN_DESK_HELP"), &myHelpPopup, 7 ); /* add popup HELP */
504 /* Applications will insert their items after 'File' 'Edit' and 'View'
505 ( 'Edit' will be inserted later )
510 /* insert logo picture to menu bar */
511 QHBox* aLogoFrm = new QHBox(this);
512 aLogoFrm->setFrameStyle( QFrame::Plain | QFrame::NoFrame );
513 QPixmap aLogoPixmap ( QAD_Desktop::getResourceManager()->loadPixmap( "CLIENT",
514 tr("ICON_DESK_LOGO") ));
515 QLabel* aLogoLab = new QLabel(aLogoFrm);
516 aLogoLab->setPixmap(aLogoPixmap);
517 aLogoLab->setAlignment(AlignCenter);
518 aLogoLab->setScaledContents(false);
519 myMainMenu->insertItem(aLogoFrm);
521 if ( myStdActions.isEmpty() ) {
522 /* Define standard actions. They should be inserted
523 into the list in order of their IDs.
528 QAD_ResourceMgr* rmgr = QAD_Desktop::getResourceManager();
529 QActionP* fileNewAction = new QActionP ( tr("TOT_DESK_FILE_NEW"),
530 rmgr->loadPixmap( "QAD", tr("ICON_FILE_NEW") ) ,
531 tr("MEN_DESK_FILE_NEW"), CTRL+Key_N, this );
532 fileNewAction->setStatusTip ( tr("PRP_DESK_FILE_NEW") );
533 fileNewAction->setEnabled ( true );
534 QAD_ASSERT ( connect( fileNewAction, SIGNAL( activated() ), this, SLOT( onNewStudy() )));
535 fileNewAction->addTo( myStdToolBar );
536 fileNewAction->addTo( &myFilePopup );
537 myStdActions.insert ( FileNewId, fileNewAction );
540 QActionP* fileOpenAction = new QActionP( tr("TOT_DESK_FILE_OPEN"), rmgr->loadPixmap( "QAD", tr("ICON_FILE_OPEN") ),
541 tr("MEN_DESK_FILE_OPEN"), CTRL+Key_O, this );
542 fileOpenAction->setStatusTip ( tr("PRP_DESK_FILE_OPEN") );
543 fileOpenAction->setEnabled ( true );
544 QAD_ASSERT ( connect( fileOpenAction, SIGNAL( activated() ), this, SLOT( onOpenStudy() )));
545 fileOpenAction->addTo( myStdToolBar );
546 fileOpenAction->addTo( &myFilePopup );
547 myStdActions.insert ( FileOpenId, fileOpenAction );
550 QActionP* fileLoadAction = new QActionP( tr("TOT_DESK_FILE_LOAD"), rmgr->loadPixmap( "QAD", tr("ICON_FILE_LOAD") ),
551 tr("MEN_DESK_FILE_LOAD"), CTRL+Key_L, this );
552 fileLoadAction->setStatusTip ( tr("PRP_DESK_FILE_LOAD") );
553 fileLoadAction->setEnabled ( true );
554 QAD_ASSERT ( connect( fileLoadAction, SIGNAL( activated() ), this, SLOT( onLoadStudy() )));
555 fileLoadAction->addTo( &myFilePopup );
556 myStdActions.insert ( FileLoadId, fileLoadAction );
559 QActionP* fileCloseAction = new QActionP( "", rmgr->loadPixmap( "QAD", tr("ICON_FILE_CLOSE") ),
560 tr("MEN_DESK_FILE_CLOSE"), CTRL+Key_W, this );
561 fileCloseAction->setStatusTip ( tr("PRP_DESK_FILE_CLOSE") );
562 QAD_ASSERT ( connect( fileCloseAction, SIGNAL( activated() ), this, SLOT( onCloseStudy() )));
563 fileCloseAction->addTo( &myFilePopup );
564 myStdActions.insert ( FileCloseId, fileCloseAction );
567 myFilePopup.insertSeparator();
570 QActionP* fileSaveAction = new QActionP( tr("TOT_DESK_FILE_SAVE"), rmgr->loadPixmap( "QAD", tr("ICON_FILE_SAVE") ),
571 tr("MEN_DESK_FILE_SAVE"), CTRL+Key_S, this );
572 fileSaveAction->setStatusTip ( tr("PRP_DESK_FILE_SAVE") );
573 QAD_ASSERT ( connect( fileSaveAction, SIGNAL( activated() ), this, SLOT( onSaveStudy() )));
574 fileSaveAction->addTo( myStdToolBar );
575 fileSaveAction->addTo( &myFilePopup );
576 myStdActions.insert ( FileSaveId, fileSaveAction );
579 QActionP* fileSaveAsAction = new QActionP( "", tr("MEN_DESK_FILE_SAVEAS"), 0, this );
580 fileSaveAsAction->setStatusTip ( tr("PRP_DESK_FILE_SAVEAS") );
581 QAD_ASSERT ( connect( fileSaveAsAction, SIGNAL( activated() ),
582 this, SLOT( onSaveAsStudy() )));
583 fileSaveAsAction->addTo( &myFilePopup );
584 myStdActions.insert ( FileSaveAsId, fileSaveAsAction );
588 myFilePopup.insertSeparator();
591 QActionP* filePropsAction = new QActionP( "", QPixmap(), tr("MEN_DESK_FILE_PROPERTIES"), 0, this );
592 filePropsAction->setStatusTip ( tr("PRP_DESK_FILE_PROPERTIES") );
593 filePropsAction->setEnabled(false);
594 QAD_ASSERT ( connect( filePropsAction, SIGNAL( activated() ), this, SLOT( onStudyProperties() )));
595 filePropsAction->addTo( &myFilePopup );
596 myStdActions.insert ( FilePropsId, filePropsAction );
599 int id = myFilePopup.insertSeparator();
600 /* keep the position from which an application will insert its items
601 to menu 'File' at the time of customization of the desktop */
603 myFilePos = myFilePopup.indexOf( id ) + 1;
605 /* exit application */
606 QActionP* exitAction = new QActionP( "", tr("MEN_DESK_FILE_EXIT"),
608 exitAction->setStatusTip ( tr("PRP_DESK_FILE_EXIT") );
609 QAD_ASSERT ( connect( exitAction, SIGNAL( activated() ),
610 this, SLOT( onExit() )));
611 exitAction->addTo( &myFilePopup );
612 myStdActions.insert ( FileExitId, exitAction );
614 QAD_ASSERT( connect( &myFilePopup, SIGNAL(highlighted( int )),
615 this, SLOT(onFilePopupStatusText( int )) ));
618 /* 'Edit' actions : provided by application only */
621 QAD_ASSERT( connect( &myEditPopup, SIGNAL(highlighted( int )),
622 this, SLOT(onEditPopupStatusText( int )) ));
625 /* toolbars popup menu */
626 myViewPopup.insertItem( tr("MEN_DESK_VIEW_TOOLBARS"), &myToolBarsPopup );
627 QAD_ASSERT( connect ( &myViewPopup, SIGNAL(aboutToShow()),
628 this, SLOT(onToolBarPopupAboutToShow()) ));
631 QActionP* viewStatusBarAction = new QActionP( "",
632 tr("MEN_DESK_VIEW_STATUSBAR"),
634 viewStatusBarAction->setStatusTip ( tr("PRP_DESK_VIEW_STATUSBAR") );
635 viewStatusBarAction->setOn( true );
636 QAD_ASSERT(connect( viewStatusBarAction, SIGNAL(activated()), this, SLOT(onViewStatusBar() )));
637 viewStatusBarAction->addTo( &myViewPopup );
638 myStdActions.insert( ViewStatusBarId, viewStatusBarAction );
640 // myViewPopup.insertItem( tr("MEN_DESK_SELECTION_MODE"), &mySelectionModePopup );
642 QActionP* SelectionPointAction = new QActionP( "", tr("MEN_DESK_SELECTION_POINT"), 0, this, 0, true );
643 QAD_ASSERT(connect( SelectionPointAction, SIGNAL(activated()), this, SLOT(onSelectionMode() )));
644 SelectionPointAction->addTo( &mySelectionModePopup );
645 myStdActions.insert( SelectionPointId, SelectionPointAction );
647 QActionP* SelectionEdgeAction = new QActionP( "", tr("MEN_DESK_SELECTION_EDGE"), 0, this, 0, true );
648 QAD_ASSERT(connect( SelectionEdgeAction, SIGNAL(activated()), this, SLOT(onSelectionMode() )));
649 SelectionEdgeAction->addTo( &mySelectionModePopup );
650 myStdActions.insert( SelectionEdgeId, SelectionEdgeAction );
652 QActionP* SelectionCellAction = new QActionP( "", tr("MEN_DESK_SELECTION_CELL"), 0, this, 0, true );
653 QAD_ASSERT(connect( SelectionCellAction, SIGNAL(activated()), this, SLOT(onSelectionMode() )));
654 SelectionCellAction->addTo( &mySelectionModePopup );
655 myStdActions.insert( SelectionCellId, SelectionCellAction );
657 QActionP* SelectionActorAction = new QActionP( "", tr("MEN_DESK_SELECTION_ACTOR"), 0, this, 0, true );
658 QAD_ASSERT(connect( SelectionActorAction, SIGNAL(activated()), this, SLOT(onSelectionMode() )));
659 SelectionActorAction->addTo( &mySelectionModePopup );
660 myStdActions.insert( SelectionActorId, SelectionActorAction );
661 SelectionActorAction->setOn(true);
663 myViewPos = myViewPopup.count();
665 QAD_ASSERT( connect( &myViewPopup, SIGNAL(highlighted( int )),
666 this, SLOT(onViewPopupStatusText( int )) ));
669 QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager();
672 if(!resMgr->loadResources( "ToolsGUI", msg ))
674 //NRI QCString errMsg;
675 // errMsg.sprintf( "Do not load all resources for module ToolsGUI.\n" );
676 QMessageBox::warning( this, tr("WRN_WARNING"), msg, tr ("BUT_OK") );
680 myOperatorMenus = new QAD_OperatorMenus(this);
681 myXmlHandler = new QAD_XmlHandler();
682 ASSERT(myXmlHandler) ;
683 myXmlHandler->setMainWindow(this);
684 if ( myXmlHandler->setComponent( resMgr->resources( "ToolsGUI" ) ) ) {
685 QString language = resMgr->language( "ToolsGUI" );
686 QString ToolsXml = QString( "Tools_" ) + language + QString( ".xml" );
688 //ToolsXml = resMgr->resources("ToolsGUI") ;
689 //ToolsXml = QAD_Tools::addSlash(ToolsXml) ;
690 //ToolsXml = ToolsXml + "Tools_" + language + ".xml" ;
691 ToolsXml = QAD_Tools::addSlash( resMgr->findFile( ToolsXml, "ToolsGUI" ) ) + ToolsXml;
693 QFile file( QAD_Tools::unix2win( ToolsXml ) );
694 if ( file.exists() && file.open( IO_ReadOnly ) ) {
696 QXmlInputSource source( file );
697 QXmlSimpleReader reader;
698 reader.setContentHandler( myXmlHandler );
699 reader.setErrorHandler( myXmlHandler );
700 bool ok = reader.parse( source );
703 QMessageBox::critical( 0,
704 tr( "INF_PARSE_ERROR" ),
705 tr( myXmlHandler->errorProtocol() ) );
707 myMenusList=myXmlHandler->myMenusList;
708 myActiveMenus=myMenusList.at(0);
709 myOperatorMenus->showMenuBar(0);
710 myActiveMenus->showAllToolBars();
716 if ( myToolsPopup.count() == 0 ) {
717 myMainMenu->removeItem(5);
721 /* Viewer BackgroundColor */
722 myPrefPopup.insertItem( tr("MEN_DESK_PREF_VIEWER"), &myViewerPopup );
724 QActionP* viewerOCCAction = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_OCC"), 0, this );
725 QAD_ASSERT(connect( viewerOCCAction, SIGNAL(activated()), this, SLOT(onViewerOCC() )));
726 viewerOCCAction->addTo( &myViewerPopup );
727 myStdActions.insert( PrefViewerOCCId, viewerOCCAction );
729 QActionP* viewerVTKAction = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_VTK"), 0, this );
730 QAD_ASSERT(connect( viewerVTKAction, SIGNAL(activated()), this, SLOT(onViewerVTK() )));
731 viewerVTKAction->addTo( &myViewerPopup );
732 myStdActions.insert( PrefViewerVTKId, viewerVTKAction );
734 QActionP* graphSupervisorAction = new QActionP( "", tr("MEN_DESK_PREF_GRAPH_SUPERVISOR"), 0, this );
735 QAD_ASSERT(connect( graphSupervisorAction, SIGNAL(activated()), this, SLOT(onGraphSupervisor() )));
736 graphSupervisorAction->addTo( &myViewerPopup );
737 myStdActions.insert( PrefGraphSupervisorId, graphSupervisorAction );
739 QActionP* viewerPlot2dAction = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_PLOT2D"), 0, this );
740 QAD_ASSERT(connect( viewerPlot2dAction, SIGNAL(activated()), this, SLOT(onPlot2d() )));
741 viewerPlot2dAction->addTo( &myViewerPopup );
742 myStdActions.insert( PrefViewerPlot2dId, viewerPlot2dAction );
744 //VRV: T2.5 - add default viewer
745 QString viewerValue = QAD_CONFIG->getSetting( "Viewer:DefaultViewer" );
747 int aViewerValue = viewerValue.toInt( &ok, 10 );
748 if (!ok || aViewerValue < VIEW_OCC || aViewerValue >= VIEW_TYPE_MAX)
749 aViewerValue = VIEW_VTK;
751 myPrefPopup.insertItem( tr("MEN_DESK_PREF_DEFAULT_VIEWER"), &myDefaultViewer );
752 QActionPGroup* myQAG = new QActionPGroup ( this);
753 QActionP* viewerOCCAction1 = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_OCC"), 0, this );
754 viewerOCCAction1->setToggleAction ( true);
755 viewerOCCAction1->setOn ( aViewerValue == VIEW_OCC );
756 myQAG->insert( viewerOCCAction1 );
757 myStdActions.insert( DefaultViewerOCCId, viewerOCCAction1 );
759 QActionP* viewerVTKAction1 = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_VTK"), 0, this );
760 viewerVTKAction1->setToggleAction ( true);
761 viewerVTKAction1->setOn ( aViewerValue == VIEW_VTK );
762 myQAG->insert( viewerVTKAction1 );
763 myStdActions.insert( DefaultViewerVTKId, viewerVTKAction1 );
765 /* Remove Supervisor viewer from setting the background */
766 // QActionP* graphSupervisorAction1 = new QActionP( "", tr("MEN_DESK_PREF_GRAPH_SUPERVISOR"), 0, this );
767 // graphSupervisorAction1->setToggleAction ( true);
768 // graphSupervisorAction1->setOn ( aViewerValue == VIEW_GRAPHSUPERV );
769 // myQAG->insert( graphSupervisorAction1 );
770 // myStdActions.insert( DefaultGraphSupervisorId, graphSupervisorAction1 );
772 QActionP* viewerPlot2dAction1 = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_PLOT2D"), 0, this );
773 viewerPlot2dAction1->setToggleAction ( true);
774 viewerPlot2dAction1->setOn ( aViewerValue == VIEW_PLOT2D );
775 myQAG->insert( viewerPlot2dAction1 );
776 myStdActions.insert( DefaultPlot2dId, viewerPlot2dAction1 );
778 myQAG->addTo( &myDefaultViewer );
779 QAD_ASSERT(connect( myQAG, SIGNAL(selected(QActionP * )), this, SLOT(onDefaultViewer(QActionP *) )));
780 //VRV: T2.5 - add default viewer
782 myPrefPopup.insertSeparator();
784 QActionP* viewerTrihedronAction = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_TRIHEDRON"), 0, this );
785 QAD_ASSERT(connect( viewerTrihedronAction, SIGNAL(activated()), this, SLOT(onViewerTrihedron() )));
786 viewerTrihedronAction->addTo( &myPrefPopup );
787 myStdActions.insert( PrefViewerTrihedronId, viewerTrihedronAction );
789 QActionP* consoleFontAction = new QActionP( "", tr("MEN_DESK_PREF_CONSOLE_FONT"), 0, this );
790 QAD_ASSERT(connect( consoleFontAction, SIGNAL(activated()), this, SLOT(onConsoleFontAction() )));
791 consoleFontAction->addTo( &myPrefPopup );
792 myStdActions.insert( PrefConsoleFontId, consoleFontAction );
795 QActionP* multiFileSaveAction = new QActionP( "", tr("MEN_DESK_PREF_MULTI_FILE_SAVE"), 0, this, 0, true );
796 QAD_ASSERT(connect( multiFileSaveAction, SIGNAL(activated()), this, SLOT(onMultiFileSave() )));
797 multiFileSaveAction->setToggleAction( true );
798 QString MultiSave = QAD_CONFIG->getSetting("Desktop:MultiFileSave");
799 multiFileSaveAction->setOn( MultiSave.compare( aTrueQString ) == 0 );
800 multiFileSaveAction->addTo( &myPrefPopup );
801 myStdActions.insert( PrefMultiFileSave, multiFileSaveAction );
804 QActionP* ASCIISaveAction = new QActionP( "", tr("MEN_DESK_PREF_ASCII_SAVE"), 0, this, 0, true );
805 QAD_ASSERT(connect( ASCIISaveAction, SIGNAL(activated()), this, SLOT(onASCIISave() )));
806 ASCIISaveAction->setToggleAction( true );
807 QString ASCIISave = QAD_CONFIG->getSetting("Desktop:ASCIISave");
808 ASCIISaveAction->setOn( ASCIISave.compare( aTrueQString ) == 0 );
809 ASCIISaveAction->addTo( &myPrefPopup );
810 myStdActions.insert( PrefASCIISave, ASCIISaveAction );
813 QActionP* UndoLevelAction = new QActionP( "", tr("MEN_DESK_PREF_UNDO_LEVEL"), 0, this );
814 QAD_ASSERT(connect( UndoLevelAction, SIGNAL(activated()), this, SLOT(onUndoLevel() )));
815 UndoLevelAction->addTo( &myPrefPopup );
816 myStdActions.insert( PrefUndoLevelId, UndoLevelAction );
818 myPrefPopup.insertSeparator();
820 /* External Browser */
821 QActionP* externalBrowserAction = new QActionP( "", tr("MEN_DESK_PREF_EXTERNAL_BROWSER"), 0, this );
822 QAD_ASSERT(connect( externalBrowserAction, SIGNAL(activated()), this, SLOT(onExternalBrowser() )));
823 externalBrowserAction->addTo( &myPrefPopup );
824 myStdActions.insert( PrefExternalBrowserId, externalBrowserAction );
826 myPrefPopup.insertSeparator();
828 myPrefPopup.insertItem( tr("MEN_DESK_PREF_OBJECTBROWSER"), &myObjBrowserPopup );
830 QActionP* objectBrowserEntryAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_ENTRY"), 0, this, 0, true );
831 QAD_ASSERT(connect( objectBrowserEntryAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
832 objectBrowserEntryAction->setToggleAction(true);
833 QString AddColumn = QAD_CONFIG->getSetting("ObjectBrowser:AddColumn");
835 if ( AddColumn.compare( aTrueQString ) == 0 )
836 objectBrowserEntryAction->setOn(true);
838 objectBrowserEntryAction->setOn(false);
840 objectBrowserEntryAction->addTo( &myObjBrowserPopup );
841 myStdActions.insert( PrefObjectBrowserEntryId, objectBrowserEntryAction );
843 QActionP* objectBrowserValueAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_VALUE"), 0, this, 0, true );
844 QAD_ASSERT(connect( objectBrowserValueAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
845 objectBrowserValueAction->setToggleAction(true);
846 QString ValueColumn = QAD_CONFIG->getSetting("ObjectBrowser:ValueColumn");
848 if ( ValueColumn.compare( aTrueQString ) == 0 )
849 objectBrowserValueAction->setOn(true);
851 objectBrowserValueAction->setOn(false);
853 objectBrowserValueAction->addTo( &myObjBrowserPopup );
854 myStdActions.insert( PrefObjectBrowserValueId, objectBrowserValueAction );
856 QActionP* objectBrowserIAPPAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_IAPP"), 0, this, 0, true );
857 QAD_ASSERT(connect( objectBrowserIAPPAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
858 objectBrowserIAPPAction->setToggleAction(true);
859 QString showIAPP = QAD_CONFIG->getSetting("ObjectBrowser:IAPP");
861 if ( showIAPP.compare( aTrueQString ) == 0 )
862 objectBrowserIAPPAction->setOn(true);
864 objectBrowserIAPPAction->setOn(false);
866 objectBrowserIAPPAction->addTo( &myObjBrowserPopup );
867 myStdActions.insert( PrefObjectBrowserIAPPId, objectBrowserIAPPAction );
869 /* Chronological sorting of shapes on the entry creation */
870 QActionP* objectBrowserCHRONO_SORTAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_CHRONO_SORT"), 0, this, 0, true );
871 QAD_ASSERT(connect( objectBrowserCHRONO_SORTAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
872 objectBrowserCHRONO_SORTAction->setToggleAction(true);
873 QString showSORT = QAD_CONFIG->getSetting("ObjectBrowser:ChronologicalSort");
875 if ( showSORT.compare( aTrueQString ) == 0 )
876 objectBrowserCHRONO_SORTAction->setOn(true) ;
878 objectBrowserCHRONO_SORTAction->setOn(false) ;
880 objectBrowserCHRONO_SORTAction->addTo( &myObjBrowserPopup );
881 myStdActions.insert( PrefObjectBrowserCHRONO_SORTId, objectBrowserCHRONO_SORTAction ) ;
883 /* Show or don't Show UseCase browser */
884 QActionP* objectBrowserShowUseCaseAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_SHOW_USECASE"), 0, this, 0, true );
885 QAD_ASSERT(connect( objectBrowserShowUseCaseAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
886 objectBrowserShowUseCaseAction->setToggleAction(true);
887 QString showUseCase = QAD_CONFIG->getSetting("ObjectBrowser:ShowUseCaseBrowser");
889 if ( showUseCase.compare( aTrueQString ) == 0 )
890 objectBrowserShowUseCaseAction->setOn(true) ;
892 objectBrowserShowUseCaseAction->setOn(false) ;
894 objectBrowserShowUseCaseAction->addTo( &myObjBrowserPopup );
895 myStdActions.insert( PrefObjectBrowserShowUseCaseId, objectBrowserShowUseCaseAction ) ;
897 /* Resize or don't resize columns automatically */
898 QActionP* objectBrowserNoAutoSizeAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_NO_AUTOSIZE"), 0, this, 0, true );
899 QAD_ASSERT(connect( objectBrowserNoAutoSizeAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
900 objectBrowserNoAutoSizeAction->setToggleAction(true);
901 QString noAutoSize = QAD_CONFIG->getSetting("ObjectBrowser:NoAutoSizeColumns");
903 if ( noAutoSize.compare( aTrueQString ) == 0 )
904 objectBrowserNoAutoSizeAction->setOn(true) ;
906 objectBrowserNoAutoSizeAction->setOn(false) ;
908 objectBrowserNoAutoSizeAction->addTo( &myObjBrowserPopup );
909 myStdActions.insert( PrefObjectBrowserNoAutoSizeColumnsId, objectBrowserNoAutoSizeAction ) ;
911 myPrefPopup.insertSeparator();
913 QActionP* dirAction = new QActionP( "", tr("MEN_DESK_PREF_DIRICTORIES"), ALT+Key_D, this );
914 QAD_ASSERT(connect( dirAction, SIGNAL(activated()), this, SLOT(onDirList() )));
915 dirAction->addTo( &myPrefPopup );
916 myStdActions.insert( PrefDirsId, dirAction );
918 myPrefPopup.insertSeparator();
920 QActionP* saveAction = new QActionP( "", tr("MEN_DESK_PREF_SAVE"), 0, this );
921 QAD_ASSERT(connect( saveAction, SIGNAL(activated()), this, SLOT(onSavePref() )));
922 saveAction->addTo( &myPrefPopup );
923 myStdActions.insert( PrefSaveId, saveAction );
925 /* 'Window' actions */
928 myWindowPopup.insertItem( tr("MEN_DESK_WINDOW_NEW3D"), &myNewViewPopup, WindowNew3dId );
930 QActionP* viewOCCAction = new QActionP( "", tr("MEN_DESK_VIEW_OCC"), ALT+Key_O, this );
931 QAD_ASSERT(connect( viewOCCAction, SIGNAL(activated()), this, SLOT(onNewWindow3d() )));
932 viewOCCAction->addTo( &myNewViewPopup );
933 myStdActions.insert( ViewOCCId, viewOCCAction );
935 QActionP* viewVTKAction = new QActionP( "", tr("MEN_DESK_VIEW_VTK"), ALT+Key_K, this );
936 QAD_ASSERT(connect( viewVTKAction, SIGNAL(activated()), this, SLOT(onNewWindow3d() )));
937 viewVTKAction->addTo( &myNewViewPopup );
938 myStdActions.insert( ViewVTKId, viewVTKAction );
940 QActionP* viewPlot2dAction = new QActionP( "", tr("MEN_DESK_VIEW_PLOT2D"), ALT+Key_P, this );
941 QAD_ASSERT(connect( viewPlot2dAction, SIGNAL(activated()), this, SLOT(onNewWindow3d() )));
942 viewPlot2dAction->addTo( &myNewViewPopup );
943 myStdActions.insert( ViewPlot2dId, viewPlot2dAction );
945 // QActionP* windowNew3dAction = new QActionP( "",/* rmgr->loadPixmap( "QAD", tr("ICON_DESK_WINDOW_NEW3D") ), */
946 /*tr("MEN_DESK_WINDOW_NEW3D"), 0, this );
947 windowNew3dAction->addTo( &myWindowPopup );
948 QAD_ASSERT( connect( windowNew3dAction, SIGNAL(activated()), this ,
949 SLOT( onNewWindow3d() )));
950 myStdActions.insert( WindowNew3dId, windowNew3dAction );
956 QActionP* windowCascadeAction = new QActionP( "", rmgr->loadPixmap( "QAD", tr("ICON_DESK_WINDOW_CASCADE") ),
957 tr("MEN_DESK_WINDOW_CASCADE"), 0, this );
958 windowCascadeAction->setStatusTip ( tr("PRP_DESK_WINDOW_CASCADE") );
959 QAD_ASSERT( connect( windowCascadeAction, SIGNAL(activated()), this,
960 SLOT( onCascade() )));
961 myStdActions.insert( WindowCascadeId, windowCascadeAction );
964 QActionP* windowTileAction = new QActionP( "", rmgr->loadPixmap( "QAD", tr("ICON_DESK_WINDOW_TILE") ),
965 tr("MEN_DESK_WINDOW_TILE"), 0, this );
966 windowTileAction->setStatusTip ( tr("PRP_DESK_WINDOW_TILE") );
967 QAD_ASSERT( connect( windowTileAction, SIGNAL(activated()), myWorkspace, SLOT( tile() )));
968 myStdActions.insert( WindowTileId, windowTileAction );
970 QAD_ASSERT( connect ( &myWindowPopup, SIGNAL(aboutToShow()),
971 this, SLOT(onWindowPopupAboutToShow()) ));
976 // QActionP* helpContentsAction = new QActionP( "", tr("MEN_DESK_HELP_CONTENTS"), Key_F1, this );
977 // helpContentsAction->setStatusTip ( tr("PRP_DESK_HELP_CONTENTS") );
978 // QAD_ASSERT(connect( helpContentsAction, SIGNAL(activated()),
979 // this, SLOT( onHelpContents() )));
980 // helpContentsAction->addTo( &myHelpPopup );
981 // myStdActions.insert( HelpContentsId , helpContentsAction );
983 // id = myHelpPopup.insertSeparator();
986 myHelpPopup.insertItem( tr("MEN_DESK_HELP_MODULECONTENTS"), &myHelpContentsModulePopup, HelpContentsModuleId);
987 bool toEnable = false;
989 CORBA::Object_var objVarN = myNameService->Resolve("/Kernel/ModulCatalog");
990 myCatalogue = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
992 SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants =
993 myCatalogue->GetComponentIconeList();
995 for (unsigned int ind = 0; ind < list_composants->length(); ind++) {
996 QString aModuleName = CORBA::string_dup(list_composants[ind].modulename) ;
998 if (dir = getenv( aModuleName + "_ROOT_DIR")) {
999 dir = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + "doc/salome/" );
1000 QString aFileName = aModuleName + "_index.html";
1001 if ( QFileInfo( dir + aFileName ).exists() ) {
1002 QString aModuleUserName = CORBA::string_dup(list_composants[ind].moduleusername) ;
1003 if ( aModuleUserName == "Salome" ) aModuleUserName = "Kernel" ;
1004 QActionP* moduleHelpAction = new QActionP( "", aModuleUserName + " Help" , 0, this, aModuleName);
1005 QAD_ASSERT(connect( moduleHelpAction, SIGNAL(activated()), this, SLOT(onHelpContentsModule() )));
1006 moduleHelpAction->addTo( &myHelpContentsModulePopup );
1007 if (!toEnable) toEnable = true;
1012 myHelpContentsModulePopup.setEnabled(toEnable);
1014 // NRI : Temporary commented
1016 // QActionP* helpContentsActionGUI = new QActionP( "", tr("MEN_DESK_HELP_GUICONTENTS"), 0, this );
1017 // helpContentsActionGUI->setStatusTip ( tr("PRP_DESK_HELP_GUICONTENTS") );
1018 // QAD_ASSERT(connect( helpContentsActionGUI, SIGNAL(activated()),
1019 // this, SLOT( onHelpContentsGUI() )));
1020 // helpContentsActionGUI->addTo( &myHelpPopup );
1021 // myStdActions.insert( HelpContentsId , helpContentsActionGUI );
1026 QActionP* helpContentsActionTUI = new QActionP( "", tr("MEN_DESK_HELP_TUICONTENTS"), 0, this );
1027 helpContentsActionTUI->setStatusTip ( tr("PRP_DESK_HELP_TUICONTENTS") );
1028 QAD_ASSERT(connect( helpContentsActionTUI, SIGNAL(activated()),
1029 this, SLOT( onHelpContentsTUI() )));
1030 helpContentsActionTUI->addTo( &myHelpPopup );
1031 myStdActions.insert( HelpContentsId , helpContentsActionTUI );
1035 // Provide status tip for Module help menu item
1036 QAD_ASSERT( connect( &myHelpPopup, SIGNAL(highlighted( int )), this,
1037 SLOT(onHelpModulePopupStatusText( int )) ));
1041 // QActionP* helpSearchAction = new QActionP( "", tr("MEN_DESK_HELP_SEARCH"), 0, this );
1042 // helpSearchAction->setStatusTip ( tr("PRP_DESK_HELP_SEARCH") );
1043 // QAD_ASSERT( connect( helpSearchAction, SIGNAL(activated()), this, SLOT( onHelpSearch() )));
1044 // helpSearchAction->addTo( &myHelpPopup );
1045 // myStdActions.insert( HelpSearchId, helpSearchAction );
1048 // QActionP* helpWhatsThisAction = new QActionP( "", tr("MEN_DESK_HELP_WHATSTHIS"), SHIFT+Key_F1, this );
1049 // helpWhatsThisAction->setStatusTip ( tr("PRP_DESK_HELP_WHATSTHIS" ));
1050 // QAD_ASSERT( connect( helpWhatsThisAction, SIGNAL(activated()), this, SLOT( whatsThis() )));
1051 // helpWhatsThisAction->addTo( &myHelpPopup );
1052 // myStdActions.insert( HelpWhatsThisId, helpWhatsThisAction );
1053 // (void)QWhatsThis::whatsThisButton( myStdToolBar );
1055 id = myHelpPopup.insertSeparator();
1056 myHelpPos = myHelpPopup.indexOf( id );
1059 QActionP* helpAboutAction = new QActionP( "", tr("MEN_DESK_HELP_ABOUT"), 0, this );
1060 helpAboutAction->setStatusTip ( tr("PRP_DESK_HELP_ABOUT") );
1061 QAD_ASSERT( connect( helpAboutAction, SIGNAL(activated()), this, SLOT( onHelpAbout() )));
1062 helpAboutAction->addTo( &myHelpPopup );
1063 myStdActions.insert(HelpAboutId, helpAboutAction );
1069 Adds the given application into the list of supported applications
1071 void QAD_Desktop::addApplication(QAD_Application* app)
1073 /* add only if is not already in the list */
1074 if ( myApps.findRef( app ) == -1 )
1076 myApps.append( app );
1078 /* set activation/deactivation listener */
1079 QAD_ASSERT ( connect( app, SIGNAL(appActivated(QAD_Application*)),
1080 this, SLOT(onActivateApp(QAD_Application*))) );
1082 QAD_ASSERT ( connect( app, SIGNAL(appDeactivated(QAD_Application*)),
1083 this, SLOT(onDeactivateApp(QAD_Application*))) );
1088 Displays the control panel of the application.
1089 This function is called when the desktop is shown first time.
1091 void QAD_Desktop::showDesktop()
1097 Closes Desktop. If <forceClose> is true query for exit will be skipped.
1099 void QAD_Desktop::closeDesktop( bool forceClose )
1102 myQueryClose = false;
1107 Puts the message to the status bar
1109 void QAD_Desktop::putInfo ( const QString& msg )
1112 //NRI : bug 1209. message is now displayed during 3000 ms
1113 myStatusBar->message ( msg, 3000 );
1117 Puts the message to the status bar for ms milli-seconds
1119 void QAD_Desktop::putInfo ( const QString& msg, int ms )
1122 myStatusBar->message ( msg, ms );
1126 Returns the standard toolbar
1128 QMenuBar* QAD_Desktop::getMainMenuBar() const
1134 Returns the standard toolbar
1136 QToolBar* QAD_Desktop::getStdToolBar() const
1138 return myStdToolBar;
1142 Updates desktop panel (menu, toolbar and status bar) according to current state of
1143 the application. Calls update() for the active application.
1144 The command { UD_ADD_APP or UD_REMOVE_APP ) specifies the desktop components
1145 will be changed according to new active application.
1146 This function is called after activating new study, closing current study etc.
1148 void QAD_Desktop::updateDesktop( UpdateCommand cmd )
1151 updateToolBars( cmd );
1152 updateStatusBar( cmd );
1157 Updates the desktop caption
1159 void QAD_Desktop::updateCaption( UpdateCommand cmd )
1161 if ( cmd == ActivateApp )
1162 { /* application's icon and title */
1163 setIcon( myActiveApp->getApplicationIcon() );
1164 setCaption( myActiveApp->getApplicationName() );
1167 { /* default icon and title */
1168 setIcon( myDefaultIcon );
1169 qApp->processEvents();
1170 setCaption( myDefaultTitle );
1175 Updates status bar when a new application becomes current
1177 void QAD_Desktop::updateStatusBar( UpdateCommand cmd )
1181 bool activate = ( cmd == ActivateApp );
1182 myActiveApp->updateStatusBar ( myStatusBar, activate );
1187 Updates toolbars according to current active application.
1188 This function is called from updateDesktop().
1190 void QAD_Desktop::updateToolBars( UpdateCommand cmd )
1194 bool activate = ( cmd == ActivateApp );
1195 myActiveApp->updateToolBars ( activate );
1200 Updates main menu bar of the application when application is activated
1202 This function is called by updateDesktop()
1204 void QAD_Desktop::updateMenu( UpdateCommand cmd )
1208 bool activate = ( cmd == ActivateApp );
1209 myActiveApp->updateFilePopup( &myFilePopup, activate, myFilePos );
1210 myActiveApp->updateEditPopup( &myEditPopup, activate, myEditPos );
1211 myActiveApp->updateViewPopup( &myViewPopup, activate, myViewPos );
1212 myActiveApp->updateHelpPopup( &myHelpPopup, activate, myHelpPos );
1213 myActiveApp->updateMainMenu( myMainMenu, activate, myMainMenuPos );
1216 Since 'Edit' popup is completely customized by applications
1217 desktop doesn't show it in main menubar without the active
1218 application and we insert/remove this popup from the menubar
1219 when activating/deactivating applications.
1221 We can't have 'Edit' popup be customized by an application
1222 via UpdateMainMenu() method because applications may insert
1223 its items to the menubar only AFTER 'View' item ( this fact
1224 is respected by myMainMenuPos ) and the possibility of an
1225 application to add its items into any arbitrary positions of
1226 the main menubar requires a bit sophisticated implementation,
1227 so we decided to avoid it, sorry :-(.
1229 #if defined( DEBUG )
1231 /* applications MUST clear 'Edit' after themselves */
1232 QAD_ASSERT_DEBUG_ONLY( !myEditPopup.count() );
1235 if ( activate ) /* insert after 'File' item */
1236 myMainMenu->insertItem( tr("MEN_DESK_EDIT"), &myEditPopup, 3, 1 );
1238 myMainMenu->removeItem( 3 );
1243 Returns icon file name used by the application
1245 const QPixmap& QAD_Desktop::getDefaultIcon() const
1247 static QPixmap defaultPixmap( QAD_Desktop::getResourceManager()->loadPixmap( "QAD",
1248 tr("ICON_DESK_DEFAULTICON") ));
1249 return defaultPixmap;
1253 Returns name of the application used as the title of desktop panel
1255 const QString& QAD_Desktop::getDefaultTitle() const
1257 static QString defaultTitle ( tr("DESK_DEFAULTTITLE") );
1258 return defaultTitle;
1262 Returns default name of new studies
1264 const QString& QAD_Desktop::getDefaultStudyName() const
1266 static QString defaultStudyName( tr("DESK_DEFAULTDOC") );
1267 return defaultStudyName;
1271 Returns next name for new study
1273 QString QAD_Desktop::getNewStudyName()
1276 number.sprintf( "%d", ++myCntUntitled );
1277 return ( getDefaultStudyName() + number );
1281 Searches QAD_Study corresponding to <study>, returns NULL if fails
1283 QAD_Study* QAD_Desktop::findStudy( SALOMEDS::Study_ptr theStudy )
1285 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() ) {
1286 QList<QAD_Study> studies;
1287 studies.setAutoDelete( false );
1288 studies = app->getStudies();
1289 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
1290 if ( study->getStudyDocument()->_is_equivalent( theStudy ) )
1298 Gets value of max undo level for SALOMEDS::Study's from preferences
1300 int QAD_Desktop::getUndoLevel()
1302 static int MAX_UNDO = 10;
1303 int anUndoLevel = MAX_UNDO;
1304 QString aLevel = QAD_CONFIG->getSetting("Desktop:UndoLevel");
1305 if(!aLevel.isEmpty()) anUndoLevel = aLevel.toInt();
1310 Returns current active application
1312 QAD_Application* QAD_Desktop::getActiveApp() const
1318 Returns current active study
1320 QAD_Study* QAD_Desktop::getActiveStudy() const
1322 return myActiveStudy;
1328 QWorkspaceP* QAD_Desktop::getMainFrame() const
1334 Find or load Engine, given a container name and an engine name
1336 Engines::Component_var QAD_Desktop::getEngine(const char *containerName,
1337 const char *componentName)
1339 Engines::Component_var eng =
1340 myEnginesLifeCycle->FindOrLoad_Component(containerName,
1345 QString QAD_Desktop::getComponentName(const char *componentUserName)
1347 if ( mapComponentName.contains(componentUserName) )
1348 return mapComponentName[ componentUserName ] ;
1353 QString QAD_Desktop::getComponentUserName(const char *componentName)
1355 QMap<QString,QString>::Iterator it;
1356 for( it = mapComponentName.begin(); it != mapComponentName.end(); ++it )
1357 if (it.data() == componentName )
1363 // gets application Help Window (and creates if necessary)
1365 // QAD_HelpWindow* QAD_Desktop::getHelpWindow()
1367 // if (!myHelpWindow) {
1368 // myHelpWindow = new QAD_HelpWindow();
1370 // QMap<QString,QString>::Iterator it;
1371 // for( it = mapComponentName.begin(); it != mapComponentName.end(); ++it ) {
1375 // // look for index.html and set homeDir
1376 // // 1. $(MODULE_ROOT_DIR)/doc/index.html
1377 // // 2. $(MODULE_ROOT_DIR)/doc/html/index.html
1378 // // 3. $(MODULE_ROOT_DIR)/doc/html/html/index.html
1380 // if (dir = getenv( QString( it.data() + "_ROOT_DIR")) ) {
1381 // root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share") + QAD_Tools::addSlash("salome") + "doc" );
1382 // if ( QFileInfo( root + "index.html" ).exists() ) {
1383 // helpContext( root + "index.html", "" );
1386 // root = QAD_Tools::addSlash( root + "html" );
1387 // if ( QFileInfo( root + "index.html" ).exists() ) {
1388 // helpContext( root + "index.html", "" );
1391 // root = QAD_Tools::addSlash( root + "html" );
1392 // if ( QFileInfo( root + "index.html" ).exists() ) {
1393 // helpContext( root + "index.html", "" );
1400 // connect(myHelpWindow, SIGNAL(helpWindowClosed()), this, SLOT(onHelpWindowClosed()));
1402 // return myHelpWindow;
1406 Called when desktop is closing
1408 void QAD_Desktop::closeEvent ( QCloseEvent* e )
1410 bool doClose = true;
1411 if ( myQueryClose ) {
1412 doClose = QAD_MessageBox::info2 ( this, tr("INF_DESK_EXIT"),
1413 tr("QUE_DESK_EXIT"), tr ("BUT_OK"),
1414 tr ("BUT_CANCEL"), QAD_YES,
1415 QAD_NO, QAD_NO ) == QAD_YES;
1418 for ( QAD_Application* app = myApps.first(); doClose && app; app = myApps.next() ) {
1419 QList<QAD_Study>& studies = app->getStudies();
1420 for(QAD_Study* study = studies.first(); doClose && study != 0; study = studies.next()) {
1421 if(myQueryClose && study->getStudyDocument()->IsModified()) {
1422 SALOMEGUI_CloseDlg aDlg( this );
1423 switch ( aDlg.exec() ) {
1425 if ( !onSaveStudy( study ) ) {
1426 putInfo( tr("INF_CANCELLED") );
1436 putInfo( tr("INF_CANCELLED") );
1444 myQueryClose = true;
1447 myAboutToClose = false;
1448 // onActiveStudyChanged() is normally caused by QWorkspace::eventFilter(),
1449 // but this call was blocked by myAboutToClose == true, so now we should do it manually
1450 onActiveStudyChanged();
1459 Called when desktop is resized
1461 void QAD_Desktop::resizeEvent( QResizeEvent* e )
1463 QMainWindow::resizeEvent( e );
1464 myWorkspace->setGeometry( 1,1, centralWidget()->width()-2,
1465 centralWidget()->height()-2 );
1470 Terminates the application.
1472 void QAD_Desktop::onExit()
1477 /************************************************************************
1479 *************************************************************************/
1483 If several application are supported it displays dialog window
1484 to choose type of study.
1486 void QAD_Desktop::createStudy(){
1489 void QAD_Desktop::onNewStudy()
1491 unsigned numApps = myApps.count();
1494 onNewStudy ( myApps.at(0) );
1495 else { /* select the type of application for new study */
1496 Desktop_AppSelectionDlg selDlg( this, myApps );
1497 if ( selDlg.exec() == QDialog::Accepted ) {
1498 onNewStudy ( selDlg.selectedApp() );
1501 } else { /* no applications available in desktop */
1502 QAD_MessageBox::error1( this,
1504 tr("ERR_APP_NOAPP"),
1510 Creates new study for the given application.
1511 Calls the respective function of the application class.
1513 void QAD_Desktop::onNewStudy( QAD_Application* app )
1517 /* create new study of the specific app */
1518 putInfo ( tr ("INF_DOC_CREATING") );
1519 QAD_Study* newStudy = app->newStudy();
1522 /* can't create new study */
1523 QAD_MessageBox::error1( this, tr("ERR_ERROR"),
1524 tr("ERR_DOC_CANTCREATE"),
1527 putInfo ( tr("INF_READY") );
1531 Loads the existing study.
1533 void QAD_Desktop::onLoadStudy()
1535 QString name, studyname, ext;
1537 SALOMEGUI_LoadStudiesDlg* aDlg = new SALOMEGUI_LoadStudiesDlg( this, "Load Study", TRUE);
1539 CORBA::Object_var obj = myNameService->Resolve("/myStudyManager");
1540 SALOMEDS::StudyManager_var myStudyMgr = SALOMEDS::StudyManager::_narrow(obj);
1541 ASSERT(! CORBA::is_nil(myStudyMgr));
1542 SALOMEDS::ListOfOpenStudies_var List = myStudyMgr->GetOpenStudies();
1543 for (unsigned int ind = 0; ind < List->length();ind++) {
1544 studyname = List[ind];
1545 aDlg->ListComponent->insertItem( studyname );
1548 int retVal = aDlg->exec();
1549 studyname = aDlg->ListComponent->currentText();
1551 if (retVal == QDialog::Rejected)
1554 if ( studyname.isNull() || studyname.isEmpty() )
1558 name.replace( QRegExp(":"), "/" );
1561 Try to associate an application to the opened study.
1562 Assumed that the association study<->application is unique.
1564 bool appFound = false;
1565 putInfo ( tr("INF_DOC_OPENING") + " " + name );
1566 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() )
1568 /* application found */
1569 if ( app->isStudyOpened( name ) )
1571 /* already opened: prompt for reopen */
1572 if ( QAD_MessageBox::warn2 ( this, tr("WRN_WARNING"),
1573 tr("QUE_DOC_ALREADYOPEN").arg( name ),
1574 tr ("BUT_YES"), tr ("BUT_NO"), QAD_YES, QAD_NO,
1575 QAD_NO ) == QAD_NO )
1577 putInfo ( tr("INF_READY") );
1580 /* now the study is closed to be re-opened */
1581 //don't ask user to remove study permanently
1582 if (app->getStudyByName ( name ) != NULL)
1583 onCloseStudy ( app->getStudyByName ( name ), false );
1584 else if (app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, true )) != NULL)
1585 onCloseStudy ( app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, true )), false );
1589 /* open the study */
1590 QAD_Study* openStudy = app->loadStudy( studyname );
1592 QAD_MessageBox::error1( this,
1594 tr("ERR_DOC_CANTOPEN") + "\n" + name,
1601 QAD_MessageBox::error1( this,
1603 tr("ERR_DOC_UNKNOWNTYPE"),
1606 putInfo ( tr("INF_READY") );
1611 QAD_Study* QAD_Desktop::loadStudy(QString theStudyName) {
1612 QString studyname("");
1614 CORBA::Object_var obj = myNameService->Resolve("/myStudyManager");
1615 SALOMEDS::StudyManager_var myStudyMgr = SALOMEDS::StudyManager::_narrow(obj);
1616 ASSERT(! CORBA::is_nil(myStudyMgr));
1618 SALOMEDS::ListOfOpenStudies_var List = myStudyMgr->GetOpenStudies();
1619 for (unsigned int ind = 0; ind < List->length();ind++) {
1620 if (theStudyName == QString(List[ind])) {
1621 studyname = theStudyName;
1625 if (studyname == "") {
1628 bool appFound = false;
1629 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() ) {
1631 QAD_Study* openStudy = app->loadStudy( studyname );
1633 // if (myActiveApp == 0)
1634 //myActiveApp = app;
1644 Opens the existing study.
1645 Displays select file dialog and calls corresponding function of
1647 (application is defined according to extension of selected file).
1649 void QAD_Desktop::onOpenStudy()
1653 /* Select a file to open */
1654 name = selectFileName ( true );
1655 if ( name.isNull() || name.isEmpty() )
1658 // Workaround for non-existent files
1660 if (!fi.exists() || !fi.isFile()) {
1661 QAD_MessageBox::error1 ( this, tr("ERR_ERROR"),
1662 tr("ERR_DOC_CANTOPEN") +": " + name,
1667 CORBA::Object_var obj = myNameService->Resolve("/myStudyManager");
1668 SALOMEDS::StudyManager_var myStudyMgr = SALOMEDS::StudyManager::_narrow(obj);
1669 ASSERT(! CORBA::is_nil(myStudyMgr));
1670 SALOMEDS::ListOfOpenStudies_var List = myStudyMgr->GetOpenStudies();
1671 for (unsigned int ind = 0; ind < List->length();ind++) {
1672 QString NameExistingStudy(List[ind]);
1673 QString NameOpeningStudy = QAD_Tools::getFileNameFromPath( name, true );
1674 if ( NameExistingStudy.compare( NameOpeningStudy ) == 0 ) {
1675 if ( QAD_MessageBox::warn2 ( this, tr("WRN_WARNING"),
1676 tr("QUE_DOC_ALREADYEXIST").arg( name ),
1677 tr ("BUT_YES"), tr ("BUT_NO"), QAD_YES, QAD_NO,
1678 QAD_NO ) == QAD_NO )
1680 putInfo ( tr("INF_READY") );
1692 Try to associate an application to the opened study.
1693 Assumed that the association study<->application is unique.
1695 bool appFound = false;
1696 putInfo ( tr("INF_DOC_OPENING") + " " + name );
1697 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() )
1699 QString ext = QAD_Tools::getFileExtensionFromPath ( name );
1700 if ( app->getStudyExtension() == ext )
1702 /* application found */
1703 if ( app->isStudyOpened( name ) )
1705 /* already opened: prompt for reopen */
1706 if ( QAD_MessageBox::warn2 ( this, tr("WRN_WARNING"),
1707 tr("QUE_DOC_ALREADYOPEN").arg( name ),
1708 tr ("BUT_YES"), tr ("BUT_NO"), QAD_YES, QAD_NO,
1709 QAD_NO ) == QAD_NO )
1711 putInfo ( tr("INF_READY") );
1714 /* now the study is closed to be re-opened */
1715 //don't ask user to remove study permanently
1716 if (app->getStudyByName ( name ) != NULL)
1717 onCloseStudy ( app->getStudyByName ( name ), false );
1718 else if (app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, true )) != NULL)
1719 onCloseStudy ( app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, true )), false );
1723 /* open the study */
1724 QAD_Study* openStudy = app->openStudy( name );
1726 QAD_MessageBox::error1( this,
1728 tr("ERR_DOC_CANTOPEN") + "\n" + name,
1737 QAD_MessageBox::error1( this,
1739 tr("ERR_DOC_UNKNOWNTYPE"),
1742 putInfo ( tr("INF_READY") );
1745 bool QAD_Desktop::loadComponentData( const QString& compName )
1749 if ( compName.isEmpty() ) {
1750 MESSAGE("loadComponentData(): empty component name passed!")
1754 // Open component's data in active study if any
1755 MESSAGE("loadComponentData(): Opening " << compName << " component data ")
1756 if (!myActiveStudy) {
1757 MESSAGE("loadComponentData(): No active study exists")
1761 Engines::Component_var comp ;
1762 if ( compName.compare("SUPERV") == 0 ) {
1763 comp = getEngine( "SuperVisionContainer", compName) ;
1766 /* comp = ( compName.compare("Data1") != 0 ) ? getEngine( "FactoryServer", compName) :
1767 getEngine( "FactoryServerPy", compName);
1769 comp = getEngine( "FactoryServer", compName);
1770 if ( comp->_is_nil() )
1771 comp = getEngine( "FactoryServerPy", compName);
1774 if ( CORBA::is_nil( comp ) ) {
1775 MESSAGE("loadComponentData(): Engine is null");
1779 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
1780 SALOMEDS::SComponent_var SCO = SALOMEDS::SComponent::_narrow(aStudy->FindObject( getComponentUserName(compName) ));
1782 if (!SCO->_is_nil()) {
1783 SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp);
1784 if (!CORBA::is_nil(driver)) {
1785 SALOMEDS::StudyBuilder_var B = aStudy->NewBuilder();
1786 if (!CORBA::is_nil(B)) {
1788 B->LoadWith(SCO,driver);
1790 catch( const SALOME::SALOME_Exception& ) {
1791 // Oops, something went wrong while loading -> return an error
1796 MESSAGE("loadComponentData(): Driver is null");
1797 // Incorrect! All components should inherit SALOMEDS::Driver
1801 MESSAGE("loadComponentData(): SComponent is null");
1802 // Don't return false here, for there might be no data
1803 // for a given component in the study yet
1810 Saves the active study
1812 bool QAD_Desktop::onSaveStudy()
1814 return onSaveStudy ( myActiveStudy );
1818 Saves the given study
1820 bool QAD_Desktop::onSaveStudy( QAD_Study* study )
1822 if ( !study ) return true;
1824 if ( !study->isSaved() )
1825 return onSaveAsStudy ( study );
1827 /* saving study... */
1828 QAD_Application* app = study->getApp();
1829 QAD_ASSERT_DEBUG_ONLY ( app );
1830 putInfo ( tr("INF_DOC_SAVING") + study->getTitle() );
1831 if ( !app->saveStudy( study ) )
1833 putInfo( tr("INF_CANCELLED") );
1838 putInfo ( tr("INF_DOC_SAVED").arg( "" ) );
1843 Saves the active study under a new name
1845 bool QAD_Desktop::onSaveAsStudy()
1847 return onSaveAsStudy( myActiveStudy );
1851 Saves the given study under a new name
1853 bool QAD_Desktop::onSaveAsStudy( QAD_Study* study )
1855 if ( !study ) return true;
1857 /* Save study in a format supported by its application
1859 QAD_Application* app = study->getApp();
1860 QAD_ASSERT_DEBUG_ONLY ( app );
1862 /* Select a file where to save
1864 QString name = selectFileName ( false );
1865 if ( name.isNull() || name.isEmpty() )
1867 putInfo( tr("INF_CANCELLED") );
1873 putInfo ( tr("INF_DOC_SAVING") + name );
1874 if ( !app->saveAsStudy( study, name ) ) {
1875 /* can't save the file */
1876 QAD_MessageBox::error1( this,
1878 tr("ERR_DOC_CANTWRITE") + "\n" + name,
1881 return false; /* cannot save */
1883 putInfo ( tr("INF_DOC_SAVED").arg( name ) );
1884 return true; /* saved ok */
1888 Closes the active study
1890 bool QAD_Desktop::onCloseStudy()
1892 bool close = this->onCloseStudy ( getActiveStudy(), true );
1897 Closes the given study and ask user to remove study
1898 from the study manager permanently
1900 bool QAD_Desktop::onCloseStudy( QAD_Study* study )
1902 return onCloseStudy( study, true );
1906 Closes the given study and ask user to remove study
1907 from the study manager permanently if ask is equal true
1909 bool QAD_Desktop::onCloseStudy( QAD_Study* study, bool ask )
1911 bool removePerm = false;
1915 SALOMEGUI_CloseDlg aDlg( this );
1916 int res = aDlg.exec();
1921 //if ( study->isModified() )
1922 if ( !onSaveStudy( study ) ) {
1923 putInfo( tr("INF_CANCELLED") );
1936 putInfo( tr("INF_CANCELLED") );
1940 /* close active component */
1941 if (!myXmlHandler->myIdList.IsEmpty())
1943 deactivateComponent();
1946 myCombo->setCurrentItem (0);
1947 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() )
1948 aButton->setOn(false);
1949 qApp->processEvents();
1951 /* close the study */
1952 return study->getApp()->closeStudy( study, removePerm );
1955 // Displays study properties dialog box
1956 void QAD_Desktop::onStudyProperties()
1958 if (myActiveStudy) {
1960 QAD_Operation* op = new QAD_Operation( myActiveStudy );
1963 SALOMEGUI_StudyPropertiesDlg aDlg(this);
1964 int res = aDlg.exec();
1966 if ( res == QDialog::Accepted && aDlg.isChanged() )
1971 // T2.12 - add the word "locked" to study frame captions if <myActiveStudy> study is locked
1972 myActiveStudy->updateCaptions();
1978 locate all windows in cascade mode
1981 void QAD_Desktop::onCascade()
1983 myWorkspace->cascade();
1984 int w = myWorkspace->width();
1985 int h = myWorkspace->height();
1986 QWidgetList wList = myWorkspace->windowList();
1987 QWidgetListIt it(wList);
1989 for(;it.current(); ++it)
1990 it.current()->resize((int)(0.8*w), (int)(0.8*h));
1994 // called when help window closed
1996 // void QAD_Desktop::onHelpWindowClosed()
1998 // myHelpWindow = 0;
2002 Called when 'view status bar' option
2005 void QAD_Desktop::onViewStatusBar()
2007 bool show = myStdActions.at( ViewStatusBarId )->isOn();
2008 if ( show == myStatusBar->isVisible() )
2011 myStatusBar->show();
2013 myStatusBar->hide();
2017 Called when View/Toolbars popup menu is about to show
2019 void QAD_Desktop::onToolBarPopupAboutToShow()
2021 myToolBarAction.clear();
2022 myToolBarsPopup.clear();
2023 QPtrList<QDockWindow> wlist = dockWindows();
2024 for ( QDockWindow* w = wlist.first(); w; w = wlist.next() ) {
2025 if ( w->inherits( "QToolBar" ) ) {
2026 QToolBar* tb = ( QToolBar* )w;
2027 if ( appropriate( tb ) ) {
2028 ToggleAction* a = new ToggleAction( tb->label(), tb->label(), 0, this, 0, true );
2029 a->setStatusTip ( tr("PRP_DESK_VIEW_TOOLBAR") );
2030 a->setOn( tb->isVisible() );
2031 QAD_ASSERT( connect( a, SIGNAL( toggledOn() ), tb, SLOT( show() ) ) );
2032 QAD_ASSERT( connect( a, SIGNAL( toggledOff() ), tb, SLOT( hide() ) ) );
2033 a->addTo( &myToolBarsPopup );
2034 myToolBarAction.append( a );
2041 Called on 'View\Selection Mode'
2043 void QAD_Desktop::onSelectionMode()
2045 const QActionP* obj = (QActionP*) sender();
2047 Selection_Mode SelectionMode = ActorSelection;
2049 if ( obj == myStdActions.at(SelectionActorId) ) {
2050 SelectionMode = ActorSelection;
2051 if ( obj->isOn() ) {
2052 myStdActions.at(SelectionCellId)->setOn(false);
2053 myStdActions.at(SelectionEdgeId)->setOn(false);
2054 myStdActions.at(SelectionPointId)->setOn(false);
2056 myStdActions.at(SelectionActorId)->setOn(true);
2058 } else if ( obj == myStdActions.at(SelectionCellId) ) {
2059 SelectionMode = CellSelection;
2060 if ( obj->isOn() ) {
2061 myStdActions.at(SelectionActorId)->setOn(false);
2062 myStdActions.at(SelectionEdgeId)->setOn(false);
2063 myStdActions.at(SelectionPointId)->setOn(false);
2065 myStdActions.at(SelectionActorId)->setOn(true);
2067 } else if ( obj == myStdActions.at(SelectionEdgeId) ) {
2068 SelectionMode = EdgeOfCellSelection;
2069 if ( obj->isOn() ) {
2070 myStdActions.at(SelectionActorId)->setOn(false);
2071 myStdActions.at(SelectionCellId)->setOn(false);
2072 myStdActions.at(SelectionPointId)->setOn(false);
2074 myStdActions.at(SelectionActorId)->setOn(true);
2076 } else if ( obj == myStdActions.at(SelectionPointId) ) {
2077 SelectionMode = NodeSelection;
2078 if ( obj->isOn() ) {
2079 myStdActions.at(SelectionEdgeId)->setOn(false);
2080 myStdActions.at(SelectionCellId)->setOn(false);
2081 myStdActions.at(SelectionActorId)->setOn(false);
2083 myStdActions.at(SelectionActorId)->setOn(true);
2086 QAD_StudyFrame* sf = myActiveApp->getActiveStudy()->getActiveStudyFrame();
2087 sf->getRightFrame()->getViewFrame()->SetSelectionMode( SelectionMode );
2089 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveApp->getActiveStudy()->getSelection() );
2090 Sel->SetSelectionMode( SelectionMode );
2094 Called on 'View\Selection Mode'
2096 void QAD_Desktop::SetSelectionMode(Selection_Mode mode, bool activeCompOnly)
2101 myStdActions.at(SelectionEdgeId)->setOn(false);
2102 myStdActions.at(SelectionCellId)->setOn(false);
2103 myStdActions.at(SelectionActorId)->setOn(false);
2104 myStdActions.at(SelectionPointId)->setOn(true);
2107 case EdgeOfCellSelection:
2109 myStdActions.at(SelectionActorId)->setOn(false);
2110 myStdActions.at(SelectionCellId)->setOn(false);
2111 myStdActions.at(SelectionPointId)->setOn(false);
2112 myStdActions.at(SelectionEdgeId)->setOn(true);
2118 case VolumeSelection:
2120 myStdActions.at(SelectionActorId)->setOn(false);
2121 myStdActions.at(SelectionEdgeId)->setOn(false);
2122 myStdActions.at(SelectionPointId)->setOn(false);
2123 myStdActions.at(SelectionCellId)->setOn(true);
2126 case ActorSelection:
2128 myStdActions.at(SelectionCellId)->setOn(false);
2129 myStdActions.at(SelectionEdgeId)->setOn(false);
2130 myStdActions.at(SelectionPointId)->setOn(false);
2131 myStdActions.at(SelectionActorId)->setOn(true);
2136 QAD_StudyFrame* sf = myActiveApp->getActiveStudy()->getActiveStudyFrame();
2137 if ( sf->getTypeView() == VIEW_VTK ) {
2138 sf->getRightFrame()->getViewFrame()->SetSelectionMode( mode );
2139 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveApp->getActiveStudy()->getSelection() );
2140 Sel->SetSelectionMode( mode, activeCompOnly );
2146 Called on 'Window\NewWindow3d'
2148 void QAD_Desktop::onNewWindow3d()
2152 //VRV: T2.5 - add default viewer
2153 QApplication::restoreOverrideCursor();
2154 SALOMEGUI_ViewChoiceDlg *choice = new SALOMEGUI_ViewChoiceDlg(this, "", TRUE);
2155 int r = choice->exec();
2158 myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(choice->getSelectedViewer()));
2160 //VRV: T2.5 - add default viewer
2162 const QActionP* obj = (QActionP*) sender();
2163 if ( obj == myStdActions.at(ViewOCCId) ) {
2164 myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(0));
2165 } else if ( obj == myStdActions.at(ViewVTKId) ) {
2166 myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(1));
2167 } else if ( obj == myStdActions.at(ViewPlot2dId) ) {
2168 myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(3));
2173 // Helps to execute command
2174 class RunBrowser: public QThread {
2177 RunBrowser(QString theApp, QString theParams, QString theHelpFile, QString theContext=NULL):
2178 myApp(theApp), myParams(theParams), myHelpFile("file:" + theHelpFile + theContext), myStatus(0) {};
2184 if ( !myApp.isEmpty())
2186 aCommand.sprintf("%s %s %s",myApp.latin1(),myParams.latin1(),myHelpFile.latin1());
2187 myStatus = system(aCommand);
2190 QCustomEvent* ce2000 = new QCustomEvent (2000);
2191 postEvent (qApp, ce2000);
2195 if( myStatus != 0 || myApp.isEmpty())
2198 aCommand.sprintf("%s %s %s", QString(DEFAULT_BROWSER).latin1(),myParams.latin1(), myHelpFile.latin1());
2199 myStatus = system(aCommand);
2202 QCustomEvent* ce2001 = new QCustomEvent (2001);
2203 postEvent (qApp, ce2001);
2216 // Provide status tip for GUI help menu item
2218 void QAD_Desktop::onHelpModulePopupStatusText(int id)
2220 int Id = myHelpPopup.idAt( 0 ); // HelpContentsModuleId
2221 // MESSAGE ( "myHelpContentsModulePopup : " << id << "-" << Id)
2223 putInfo("Shows the help contents of each module");
2227 Called on 'help\contents'
2229 void QAD_Desktop::onHelpContents()
2230 { if (myActiveComp == "")
2231 myActiveComp = getComponentUserName( "KERNEL" ); //NRI "Salome";
2236 if (dir = getenv( getComponentName( myActiveComp ) + "_ROOT_DIR")) {
2237 root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share") + QAD_Tools::addSlash("salome") + QAD_Tools::addSlash("doc") + "html" );
2238 if ( QFileInfo( root + "index.html" ).exists() ) {
2241 QMessageBox::warning( this, tr("WRN_WARNING"),
2242 QString( "%1index.html doesn't exist." ).arg(root), tr ("BUT_OK") );
2247 QString helpFile = QFileInfo( homeDir + "index.html" ).absFilePath();
2248 QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
2249 QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
2251 RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile);
2256 Called on 'Module Help Reference'
2258 void QAD_Desktop::onHelpContentsModule()
2260 const QActionP* obj = (QActionP*) sender();
2262 QString aComponentName = obj->name();
2263 QString aFileName = aComponentName + "_index.html";
2268 if (dir = getenv( aComponentName + "_ROOT_DIR")) {
2269 root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("doc") + QAD_Tools::addSlash("salome") );
2270 if ( QFileInfo( root + aFileName ).exists() ) {
2273 QMessageBox::warning( this, tr("WRN_WARNING"),
2274 QString( "%1"+ aFileName + " doesn't exist." ).arg(root), tr ("BUT_OK") );
2279 QString helpFile = QFileInfo( homeDir + aFileName ).absFilePath();
2280 QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
2281 QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
2283 RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile);
2288 Called on 'help\TUI Reference'
2292 void QAD_Desktop::onHelpContentsTUI()
2294 if (myActiveComp == "")
2295 myActiveComp = getComponentUserName( "KERNEL" ); //NRI "Salome";
2300 if (dir = getenv( getComponentName( myActiveComp ) + "_ROOT_DIR")) {
2301 root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("doc") + "html" );
2302 if ( QFileInfo( root + "index.html" ).exists() ) {
2304 } else if (QFileInfo( root + "html/index.html" ).exists())
2305 homeDir = root + QAD_Tools::addSlash("html");
2307 QMessageBox::warning( this, tr("WRN_WARNING"),
2308 QString( "%1index.html doesn't exist." ).arg(root), tr ("BUT_OK") );
2313 QString helpFile = QFileInfo( homeDir + "index.html" ).absFilePath();
2315 QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
2316 QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
2318 RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile);
2325 // Called on 'help\search'
2327 // void QAD_Desktop::onHelpSearch()
2330 // myActiveApp->helpSearch();
2336 Called on 'help\about'
2338 void QAD_Desktop::onHelpAbout()
2341 myActiveApp->helpAbout();
2348 Activates the application and its active study
2350 void QAD_Desktop::onActivateApp( QAD_Application* activeApp )
2352 bool appChanged = ( activeApp != myActiveApp );
2355 updateDesktop( DeactivateApp );
2359 myActiveApp = activeApp;
2360 myActiveStudy = myActiveApp->getActiveStudy();
2370 updateDesktop( ActivateApp );
2371 updateCaption( (activeApp != NULL) ? ActivateApp : DeactivateApp );
2377 Called when the last study is removed from
2378 the application 'app'.
2380 void QAD_Desktop::onDeactivateApp(QAD_Application* app)
2382 if ( app && app == myActiveApp )
2387 Enables/disables standard actions
2389 void QAD_Desktop::updateActions()
2391 myStdActions.at( FileCloseId )->setEnabled ( myActiveStudy != NULL );
2392 myStdActions.at( FileSaveId )->setEnabled ( myActiveStudy != NULL );
2393 myStdActions.at( FileSaveAsId )->setEnabled ( myActiveStudy != NULL );
2394 myStdActions.at( FilePropsId )->setEnabled( myActiveStudy != NULL );
2395 // myStdActions.at( HelpContentsId )->setEnabled ( myActiveApp != NULL );
2396 // myStdActions.at( HelpSearchId )->setEnabled ( myActiveApp != NULL );
2397 // myStdActions.at( HelpWhatsThisId )->setEnabled ( myActiveApp != NULL );
2398 // myStdActions.at( HelpAboutId )->setEnabled ( myActiveApp != NULL );
2400 // myToolsPopup.setEnabled ( myActiveStudy != NULL );
2401 // myPrefPopup.setEnabled ( myActiveStudy != NULL );
2403 mySelectionModePopup.setEnabled ( myActiveStudy != NULL );
2406 myStdActions.at( ViewOCCId )->setEnabled( myActiveStudy != NULL );
2407 myStdActions.at( ViewVTKId )->setEnabled( myActiveStudy != NULL );
2408 myStdActions.at( ViewPlot2dId )->setEnabled( myActiveStudy != NULL );
2413 Called when 'Window' popup is about to show
2415 void QAD_Desktop::onWindowPopupAboutToShow()
2417 /* add cascade/tile items */
2418 myWindowPopup.clear();
2421 //myStdActions.at( WindowNew3dId )->addTo( &myWindowPopup );
2422 myWindowPopup.insertItem( tr("MEN_DESK_WINDOW_NEW3D"), &myNewViewPopup, WindowNew3dId );
2423 //myStdActions.at( WindowNew3dId )->setEnabled( true );
2424 myWindowPopup.setItemEnabled( WindowNew3dId, true );
2426 myStdActions.at( WindowCascadeId )->addTo( &myWindowPopup );
2427 myStdActions.at( WindowCascadeId )->setEnabled( true );
2428 myStdActions.at( WindowTileId )->addTo( &myWindowPopup );
2429 myStdActions.at( WindowTileId )->setEnabled( true );
2431 /* add names of opened studies */
2432 QWidgetList windows = myWorkspace->windowList();
2433 if ( windows.isEmpty() )
2435 //NRI : SAL2214 myStdActions.at( WindowNew3dId )->setEnabled( false );
2436 myWindowPopup.setItemEnabled( WindowNew3dId, false );
2438 myStdActions.at( WindowCascadeId )->setEnabled( false );
2439 myStdActions.at( WindowTileId )->setEnabled( false );
2443 myWindowPopup.insertSeparator();
2444 for ( int i = 0; i < int(windows.count()); ++i )
2446 int id = myWindowPopup.insertItem( windows.at(i)->caption(),
2447 this, SLOT( onWindowsPopupActivated( int ) ) );
2448 myWindowPopup.setItemParameter( id, i );
2449 myWindowPopup.setItemChecked( id, myWorkspace->activeWindow() == windows.at(i) );
2451 QAD_ASSERT( connect( &myWindowPopup, SIGNAL(highlighted( int )), this,
2452 SLOT(onWindowsPopupStatusText( int )) ));
2457 Called when the item with 'id' of 'Windows' popup
2460 void QAD_Desktop::onWindowsPopupStatusText( int id )
2462 int cascadeId = myWindowPopup.idAt( 1 );
2463 int tileId = myWindowPopup.idAt( 2 );
2464 if ( id == cascadeId || id == tileId )
2466 putInfo( tr("PRP_DESK_WINDOW_ACTIVATE") );
2470 Called when user wants to activate a child window with 'wid'
2473 void QAD_Desktop::onWindowsPopupActivated( int wid )
2475 QWidget* w = myWorkspace->windowList().at( wid );
2476 if ( w ) w->setFocus();
2480 Selects a file name when opening or saving files.
2481 The basic implementation just uses the standard
2483 Please redefine if another behaviour is required.
2485 QString QAD_Desktop::selectFileName ( bool open )
2487 QAD_FileDlg* fd = new QAD_FileDlg( this, open, true, true );
2491 QStringList filters;
2494 // All the file types of the supported applications
2496 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() )
2498 filters += app->getStudyDescription() + " " + tr("DESK_FILES") + " " +
2499 "(*." + app->getStudyExtension() + ")";
2503 QAD_ASSERT_DEBUG_ONLY ( myActiveStudy );
2504 if (myActiveStudy) {
2505 // get file name of active study
2506 name = QAD_Tools::getFileNameFromPath ( myActiveStudy->getTitle() );
2507 // get path to the active study file
2508 dir = QAD_Tools::getDirFromPath ( myActiveStudy->getPath(), false );
2510 QAD_ASSERT_DEBUG_ONLY ( !name.isNull() );
2511 // the file types supported by the active application
2512 filters += myActiveApp->getStudyDescription() + " " + tr("DESK_FILES") + " " +
2513 "(*." + myActiveApp->getStudyExtension() + ")" ;
2515 if (!dir.isEmpty()) {
2516 // when saving document ("Save As" command) - to get dir from active study filename
2517 // for new documents - to use last opened directory
2520 fd->setSelection( name );
2521 fd->setFilters( filters );
2524 QString filename = fd->selectedFile();
2526 qApp->processEvents();
2531 Closes all the studies of 'app'. Returns
2532 'true' if thay are closed OK, 'false' at least
2533 one can't be closed or user cancel the closure.
2535 bool QAD_Desktop::closeAllStudies( QAD_Application* app )
2537 QList<QAD_Study>& studies = app->getStudies();
2538 while ( !studies.isEmpty() )
2540 //don't ask user to remove study permanently
2541 if ( !onCloseStudy( studies.at(0), false ) )
2542 return false; /* user cancelled closing */
2548 Called on Popup item when SComponent representation in Object Browser is selected.
2550 void QAD_Desktop::onOpenWith()
2552 Engines::Component_var comp;
2553 QString ComponentSelected;
2555 SALOMEDS::SObject_var SO;
2556 SALOMEDS::SComponent_var SCO;
2557 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
2558 SALOMEDS::GenericAttribute_var anAttr;
2559 SALOMEDS::AttributeName_var aName;
2561 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2562 if ( Sel->IObjectCount() == 1 ) {
2563 Handle(SALOME_InteractiveObject) IO = Sel->firstIObject();
2564 SO = aStudy->FindObjectID( IO->getEntry() );
2565 SCO = SO->GetFatherComponent();
2567 if (SCO->FindAttribute(anAttr, "AttributeName")) {
2568 aName = SALOMEDS::AttributeName::_narrow(anAttr);
2569 name = aName->Value();
2570 if ( getComponentName( name ).isEmpty() )
2572 SALOME_ModuleCatalog::Acomponent_var Comp = myCatalogue->GetComponent( getComponentName(name) );
2573 if ( !Comp->_is_nil() ) {
2575 SALOME_ModuleCatalog::ListOfComponents_var list_type_composants =
2576 myCatalogue->GetTypedComponentList( Comp->component_type() );
2578 if ( list_type_composants->length() == 1 ) {
2579 ComponentSelected = name;
2580 } else if ( list_type_composants->length() > 1 ) {
2581 SALOMEGUI_OpenWith* aDlg = new SALOMEGUI_OpenWith( this );
2582 for (unsigned int ind = 0; ind < list_type_composants->length();ind++) {
2583 QString compusername = getComponentUserName( (char*)list_type_composants[ind] );
2584 if ( !compusername.isEmpty() )
2585 aDlg->addComponent( compusername );
2588 int retVal = aDlg->exec();
2589 ComponentSelected = aDlg->getComponent();
2591 if ( retVal == QDialog::Rejected || ComponentSelected.isEmpty()) {
2595 MESSAGE( "No component with type : " << Comp->component_type() << " exists" );
2600 MESSAGE( "This component not exists in the catalog" );
2604 QApplication::setOverrideCursor( Qt::waitCursor );
2605 Sel->ClearIObjects();
2607 // if (loadComponentData(ComponentSelected)) {
2608 onComboActiveComponent(ComponentSelected);
2609 // int nbItem = myCombo->count();
2611 // for (int i = 0; i < nbItem; i++) {
2612 // if (myCombo->text(i).compare(ComponentSelected)==0) {
2617 // myCombo->setCurrentItem(Index);
2618 // myActiveStudy->updateObjBrowser(true);
2622 QApplication::restoreOverrideCursor();
2627 Called to define settings of component.
2629 void QAD_Desktop::setSettings()
2631 SALOMEGUI* anActiveGUI = getActiveGUI();
2632 if ( anActiveGUI ) {
2633 QString Component = mapComponentName[myActiveComp];
2634 anActiveGUI->SetSettings( this, (char*)Component.latin1() );
2639 Called to load Component : xml resources and GUI librairy.
2641 bool QAD_Desktop::loadComponent(QString Component)
2643 if ( Component.isEmpty() ) {
2644 MESSAGE("loadComponent(): empty component name passed!")
2649 QString resDir("/"); //NRI : Pb under Windows
2651 QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager();
2654 if (!resMgr->loadResources( Component, msg ))
2656 //NRI QCString errMsg;
2657 // errMsg.sprintf( "Do not load all resources for module %sGUI.\n" ,
2658 // Component.latin1() );
2660 QMessageBox::warning( this, tr("WRN_WARNING"), msg, tr ("BUT_OK") );
2665 /* Parse xml file */
2666 myXmlHandler = new QAD_XmlHandler();
2667 myXmlHandler->setMainWindow(this);
2668 if (!myXmlHandler->setComponent(resMgr->resources( Component ))) return false;
2670 QString language = resMgr->language( Component );
2672 QString ComponentXml = Component + "_" + language + ".xml";
2673 //ComponentXml = resMgr->resources(Component + "GUI") ;
2674 //ComponentXml = QAD_Tools::addSlash(ComponentXml) ;
2675 ComponentXml = QAD_Tools::addSlash( resMgr->findFile( ComponentXml, Component ) ) + ComponentXml;
2676 QFile file( ComponentXml );
2678 if ( !file.exists() || !file.open( IO_ReadOnly ) ) {
2680 errMsg.sprintf( "Cannot open xml file: %s\n.",
2681 (file.name()).latin1() );
2683 QMessageBox::critical( this, tr("ERR_ERROR"), errMsg, tr ("BUT_OK") );
2688 QXmlInputSource source( file );
2689 QXmlSimpleReader reader;
2690 reader.setContentHandler( myXmlHandler );
2691 reader.setErrorHandler( myXmlHandler );
2693 bool IsMaxActStudy = myActiveStudy->getActiveStudyFrame()->isMaximized();
2694 if (IsMaxActStudy) {
2695 QString aSourceData = source.data();
2696 aSourceData = changeXmlInputSourceData( aSourceData, Component );
2697 source.setData(aSourceData);
2700 bool ok = reader.parse( source );
2704 QMessageBox::critical( this,
2705 tr( "INF_PARSE_ERROR" ),
2706 tr( myXmlHandler->errorProtocol() ) );
2710 myMenusList=myXmlHandler->myMenusList;
2711 myActiveMenus=myMenusList.at(0);
2712 myOperatorMenus->showMenuBar(0);
2713 myActiveMenus->showAllToolBars();
2715 /* Components toolbars */
2718 nbToolbars = myActiveMenus->getToolBarList().count();
2720 /* COMPONENT INTERFACE */
2721 SALOME_ModuleCatalog::Acomponent_ptr aComponent =
2722 myCatalogue->GetComponent(Component.latin1());
2724 if (CORBA::is_nil (aComponent)) {
2725 MESSAGE( "Catalog Error : Component not found in the catalog" )
2729 myActiveStudy->setMessage(QString("Component : ") +
2730 aComponent->componentusername() + " created " );
2731 myActiveStudy->setMessage(QString("Type : ") +
2732 QString::number(aComponent->component_type()));
2733 myActiveStudy->setMessage(QString("Constraint : ") +
2734 aComponent->constraint() );
2736 /* obtain interfaces list of the component */
2737 SALOME_ModuleCatalog::ListOfInterfaces_var _list =
2738 new SALOME_ModuleCatalog::ListOfInterfaces;
2739 _list = aComponent->GetInterfaceList();
2741 if (_list->length() != 0 ) {
2743 for (unsigned int ind = 0; ind < _list->length();ind++)
2744 myActiveStudy->setMessage( QString("Interface name : ") +
2748 /* obtain services list of the component */
2749 SALOME_ModuleCatalog::ListOfServices_var list_services_component =
2750 new SALOME_ModuleCatalog::ListOfServices;
2751 list_services_component = aComponent->GetServiceList(_list[0]);
2753 if (list_services_component->length() != 0 ) {
2755 for (unsigned int ind = 0; ind < list_services_component->length();ind++)
2756 myActiveStudy->setMessage( QString("Service name : ") +
2757 list_services_component[ind] );
2759 // Get a service of the component
2760 SALOME_ModuleCatalog::Service_var service = new SALOME_ModuleCatalog::Service;
2761 service = aComponent->GetService(_list[0],list_services_component[0]) ;
2762 myActiveStudy->setMessage( QString("Service name: ") + service->ServiceName);
2763 for (unsigned int ind1 = 0; ind1 <service->ServiceinParameter.length();ind1++) {
2764 myActiveStudy->setMessage( QString("Type of the in Parameter of this service : ") +
2765 (const char *) service->ServiceinParameter[ind1].Parametertype);
2766 myActiveStudy->setMessage( QString("Name of the in Parameter of this service : ") +
2767 (const char *) service->ServiceinParameter[ind1].Parametername);
2769 for (unsigned int ind1 = 0; ind1 <service->ServiceoutParameter.length();ind1++) {
2770 myActiveStudy->setMessage( QString("Type of the out Parameter of this service : ") +
2771 (const char *) service->ServiceoutParameter[ind1].Parametertype);
2772 myActiveStudy->setMessage( QString("Name of the out Parameter of this service : ") +
2773 (const char *) service->ServiceoutParameter[ind1].Parametername);
2780 QString QAD_Desktop::changeXmlInputSourceData(QString theData, QString theComponent)
2782 // MESSAGE ( " changeXmlInputSourceData : " << theComponent.latin1() )
2783 if ( theComponent=="SUPERV" ) {
2784 //Supervision main menu item
2787 QString aStrOld = createString( aItemId, aPosId );
2788 QString aStrNew = createString( aItemId, aPosId+1 );
2789 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2792 if ( theComponent == "VISU" ) {
2793 //Visualization main menu item
2796 QString aStrOld = createString( aItemId, aPosId );
2797 QString aStrNew = createString( aItemId, aPosId+1 );
2798 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2800 //Selection main menu item
2803 aStrOld = createString( aItemId, aPosId );
2804 aStrNew = createString( aItemId, aPosId+1 );
2805 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2807 //Representation main menu item
2810 aStrOld = createString( aItemId, aPosId );
2811 aStrNew = createString( aItemId, aPosId+1 );
2812 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2815 if ( theComponent == "SMESH" ) {
2816 //Hypotheses main menu item
2819 QString aStrOld = createString( aItemId, aPosId );
2820 QString aStrNew = createString( aItemId, aPosId+1 );
2821 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2823 //Mesh main menu item
2826 aStrOld = createString( aItemId, aPosId );
2827 aStrNew = createString( aItemId, aPosId+1 );
2828 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2830 //Controls main menu item
2833 aStrOld = createString( aItemId, aPosId );
2834 aStrNew = createString( aItemId, aPosId+1 );
2835 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2837 //Modification main menu item
2840 aStrOld = createString( aItemId, aPosId );
2841 aStrNew = createString( aItemId, aPosId+1 );
2842 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2844 //Numbering main menu item
2847 // aStrOld = createString( aItemId, aPosId );
2848 // aStrNew = createString( aItemId, aPosId+1 );
2849 // theData = theData.replace( QRegExp(aStrOld), aStrNew );
2852 if ( theComponent == "GEOM" ) {
2853 //New Entity main menu item
2856 QString aStrOld = createString( aItemId, aPosId );
2857 QString aStrNew = createString( aItemId, aPosId+1 );
2858 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2860 //Operations main menu item
2863 aStrOld = createString( aItemId, aPosId );
2864 aStrNew = createString( aItemId, aPosId+1 );
2865 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2867 //Repair main menu item
2870 aStrOld = createString( aItemId, aPosId );
2871 aStrNew = createString( aItemId, aPosId+1 );
2872 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2874 //Measures main menu item
2877 aStrOld = createString( aItemId, aPosId );
2878 aStrNew = createString( aItemId, aPosId+1 );
2879 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2882 if ( theComponent == "MED" ) {
2883 //MED main menu item
2886 QString aStrOld = createString( aItemId, aPosId );
2887 QString aStrNew = createString( aItemId, aPosId+1 );
2888 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2894 typedef bool OneDim(int, QAD_Desktop*);
2895 typedef void (*PTR_FACTORY_FUNCTION)( CORBA::ORB_var &orb, QWidget *parent, const char *name ) ;
2899 void QAD_Desktop::onDispatch()
2901 const QObject* obj = sender();
2903 QList<QAD_ListMenuIdAction> MenuList = myActiveMenus->getMenuList();
2904 QAD_ListMenuIdAction* aMenu;
2906 for(aMenu=MenuList.first();aMenu!=NULL;aMenu=MenuList.next()) {
2907 if (aMenu->getAction()==obj) {
2908 id = aMenu->getId();
2917 void QAD_Desktop::onDispatchTools(int id)
2919 /* Open Shared Library */
2920 OSD_SharedLibrary ToolsLibrary = OSD_SharedLibrary();
2924 QFileInfo fileInfo ;
2927 bool libToolsGUI = true;
2928 if( QAD_XmlHandler::_bibmap[ id ].isEmpty() )
2930 if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
2931 dir = QAD_Tools::addSlash(dir) ;
2933 dir = QAD_Tools::addSlash(dir) ;
2934 dir = dir + "salome" ;
2935 dir = QAD_Tools::addSlash(dir) ;
2937 dir = dir + "libToolsGUI.dll" ;
2939 dir = dir + "libToolsGUI.so" ;
2941 MESSAGE ( " GUI library = " << dir );
2942 fileInfo.setFile(dir) ;
2943 if (fileInfo.exists()) {
2944 ToolsLib = fileInfo.fileName() ;
2950 libToolsGUI = false;
2951 SCRUTE( QAD_XmlHandler::_bibmap[ id ] ) ;
2952 if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
2953 dir = QAD_Tools::addSlash(dir) ;
2955 dir = QAD_Tools::addSlash(dir) ;
2956 dir = dir + "salome" ;
2957 dir = QAD_Tools::addSlash(dir) ;
2958 dir = dir + QAD_XmlHandler::_bibmap[ id ].latin1() ;
2959 MESSAGE ( " GUI library = " << dir );
2960 fileInfo.setFile(dir) ;
2961 if (fileInfo.exists()) {
2962 ToolsLib = fileInfo.fileName() ;
2968 ToolsLibrary.SetName(TCollection_AsciiString((char*)ToolsLib.latin1()).ToCString());
2969 bool ok = ToolsLibrary.DlOpen(OSD_RTLD_LAZY);
2971 if ( libToolsGUI ) {
2972 OSD_Function osdF = ToolsLibrary.DlSymb("OnGUIEvent");
2973 OneDim (*f1) = NULL;
2974 f1 = (bool (*) (int, QAD_Desktop*)) osdF;
2977 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
2978 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
2979 CORBA::ORB_var &orb = init(0 , 0 ) ;
2980 OSD_Function osdF = ToolsLibrary.DlSymb("OnGUIEvent");
2981 PTR_FACTORY_FUNCTION f1 = NULL;
2982 f1 = (PTR_FACTORY_FUNCTION) osdF;
2983 f1(orb,0,"Registry");
2986 QMessageBox::critical( this,
2988 tr( ToolsLibrary.DlError() ) );
2994 void QAD_Desktop::onDispatch(int id)
2996 SALOMEGUI* anActiveGUI = getActiveGUI();
2998 anActiveGUI->OnGUIEvent(id,this);
3002 Returns the component's catalogue
3004 SALOME_ModuleCatalog::ModuleCatalog_var QAD_Desktop::getCatalogue()
3011 void QAD_Desktop::onComboActiveComponent( const QString & component ){
3012 onComboActiveComponent(component,true);
3014 void QAD_Desktop::onComboActiveComponent( const QString & component, bool isLoadData)
3016 if (myActiveStudy != 0) {
3017 if (myActiveComp.compare(component)!=0) {
3018 // deactivate previous component
3019 deactivateComponent();
3021 if (!myXmlHandler->myIdList.IsEmpty()) clearMenus();
3022 if ( myCombo->currentText() != component )
3023 myCombo->setCurrentText( component );
3024 //NRI if (component.compare(QString("Salome"))!= 0) {
3025 if (component.compare( getComponentUserName( "KERNEL" ) )!= 0) {
3026 // QApplication::setOverrideCursor( Qt::waitCursor );
3027 bool isOk = ( !isLoadData || loadComponentData( getComponentName(component) ) );
3029 QAD_MessageBox::error1( this,
3031 tr("ERR_COMP_DATA_NOT_LOADED").arg( component ),
3035 if ( !isOk || !loadComponent( getComponentName(component) ) ) {
3036 myCombo->setCurrentItem (0);
3037 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3038 aButton->setOn(false);
3044 myActiveComp = component;
3046 SALOME_Selection* oldSel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
3048 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3049 if ( aButton->textLabel().compare(component)==0)
3050 aButton->setOn(true);
3052 aButton->setOn(false);
3055 myActiveStudy->Selection( component );
3057 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
3058 SALOME_ListIteratorOfListIO It( oldSel->StoredIObjects() );
3059 for(;It.More();It.Next()) {
3060 int res = Sel->AddIObject( It.Value() );
3063 myActiveStudy->highlight( It.Value(), false );
3065 myActiveStudy->highlight( It.Value(), true );
3072 // IMPORTANT: SetSettings() should be called AFTER SALOME_Selection
3073 // has been created for a newly activated component
3074 getComponentGUI(component)->SetSettings( this, (char*)getComponentName(component).latin1() );
3076 myActiveStudy->updateObjBrowser(true);
3078 // QApplication::restoreOverrideCursor();
3080 } else { // component == "Salome"
3082 //NRI myActiveStudy->Selection( "Salome" );
3083 myActiveStudy->Selection( getComponentUserName( "KERNEL" ) );
3084 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
3085 Sel->ClearIObjects();
3086 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3087 aButton->setOn(false);
3091 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3092 if ( aButton->textLabel().compare(component)==0)
3093 aButton->setOn(true);
3096 } else if (component.compare(QString("Salome"))!= 0) {
3099 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3100 if ( aButton->textLabel().compare( component ) == 0 )
3101 pm = aButton->iconSet().pixmap();
3103 SALOMEGUI_ActivateComponentDlg aDlg( this, component, pm );
3104 int res = aDlg.exec();
3110 onComboActiveComponent(component,true);
3114 onComboActiveComponent(component,true);
3118 onComboActiveComponent(component,true);;
3122 putInfo( tr("INF_CANCELLED") );
3123 myCombo->setCurrentItem (0);
3124 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3125 aButton->setOn(false);
3134 void QAD_Desktop::activateComponent(const QString& theName, bool isLoadData){
3136 int nbItem = myCombo->count();
3139 for (int i = 0; i < nbItem; i++) {
3140 if (myCombo->text(i).compare(theName)==0) {
3145 myCombo->setCurrentItem (Index);
3146 onComboActiveComponent(theName,isLoadData);
3149 void QAD_Desktop::onButtonActiveComponent( )
3151 QToolButton* obj = (QToolButton*)sender();
3152 activateComponent(obj->textLabel());
3156 Clears All Resources of current component
3158 void QAD_Desktop::clearMenus()
3160 // san - commented as presumably obsolete
3161 // onActiveStudyChanged();
3164 myMenusList.clear();
3166 int length = myXmlHandler->myIdList.Length();
3167 for (int k=length; k>0; k--) {
3169 if ( menuBar()->findItem(myXmlHandler->myIdList.Value(k), &parent) )
3170 parent->removeItem( myXmlHandler->myIdList.Value(k) );
3175 if (myActiveMenus) {
3176 int nbtoolbars = myActiveMenus->getToolBarList().count();
3177 for (int k=0; k<nbtoolbars; k++) {
3178 myActiveMenus->getToolBarList().at(k)->hide();
3179 myActiveMenus->getToolBarList().at(k)->clear();
3181 myActiveMenus->clearToolBar();
3184 QList<QAD_ListPopupMenu> PopupList = myActiveMenus->getPopupMenuList();
3185 QAD_ListPopupMenu* aPopup;
3186 for(aPopup=PopupList.first();aPopup!=NULL;aPopup=PopupList.next()){
3187 aPopup->getPopup()->clear();
3190 myActiveMenus->clearPopupMenu();
3196 typedef bool TwoDim1(QKeyEvent* pe, QAD_Desktop*, QAD_StudyFrame*);
3198 Exports Key Events in active component ( GUI Librairy )
3200 void QAD_Desktop::onKeyPress( QKeyEvent* pe )
3202 // MESSAGE ( "QAD_Desktop::onKeyPress" )
3203 SALOMEGUI* anActiveGUI = getActiveGUI();
3205 anActiveGUI->OnKeyPress(pe,this,myActiveStudy->getActiveStudyFrame());
3208 typedef bool TwoDim(QMouseEvent* pe, QAD_Desktop*, QAD_StudyFrame*);
3210 Exports Mouse Press Events in active component ( GUI Librairy )
3212 bool QAD_Desktop::onMousePress( QMouseEvent* pe )
3214 // MESSAGE ( "QAD_Desktop::onMousePress" )
3215 SALOMEGUI* anActiveGUI = getActiveGUI();
3217 return anActiveGUI->OnMousePress(pe,this,myActiveStudy->getActiveStudyFrame());
3222 Exports Mouse Move Events in active component ( GUI Librairy )
3224 void QAD_Desktop::onMouseMove( QMouseEvent* pe )
3226 SALOMEGUI* anActiveGUI = getActiveGUI();
3228 anActiveGUI->OnMouseMove(pe,this,myActiveStudy->getActiveStudyFrame());
3232 Returns name of active component
3234 const QString& QAD_Desktop::getActiveComponent() const
3236 return myActiveComp;
3239 SALOMEGUI* QAD_Desktop::getActiveGUI()
3241 SALOMEGUI* anActiveGUI = 0;
3242 if ( myComponents.find( myActiveComp ) != myComponents.end() )
3243 anActiveGUI = myComponents[myActiveComp];
3247 typedef SALOMEGUI* (*ComponentGUI)();
3249 SALOMEGUI* QAD_Desktop::getComponentGUI( const QString& component )
3251 SALOMEGUI* aCompGUI = 0;
3252 if ( component.isEmpty() || getComponentName( component ).isEmpty() )
3255 // Load component GUI if requested for the first time
3256 if ( myComponents.find( component ) == myComponents.end() ) {
3257 OSD_SharedLibrary aSharedLibrary;
3258 QString ComponentLib;
3260 QFileInfo fileInfo ;
3261 QString fileString ;
3268 if ( libs = getenv("LD_LIBRARY_PATH")) {
3269 // MESSAGE ( " LD_LIBRARY_PATH : " << libs );
3270 QStringList dirList = QStringList::split( SEPARATOR, libs, false ); // skip empty entries
3271 for ( int i = dirList.count()-1; i >= 0; i-- ) {
3274 fileString = QAD_Tools::addSlash( dir ) + "lib" + getComponentName( component ) + "GUI.dll" ;
3276 fileString = QAD_Tools::addSlash( dir ) + "lib" + getComponentName( component ) + "GUI.so" ;
3279 fileInfo.setFile(fileString) ;
3280 if (fileInfo.exists()) {
3281 // MESSAGE( " GUI library = " << fileString.latin1() );
3282 ComponentLib = fileInfo.fileName() ;
3289 if (!_islibso) // component GUI could be in PyQt, use generic library
3291 MESSAGE("GUI library not found, trying generic library for PyQt GUI");
3293 if (dir = getenv("KERNEL_ROOT_DIR"))
3295 dir = QAD_Tools::addSlash(dir) ;
3297 dir = QAD_Tools::addSlash(dir) ;
3298 dir = dir + "salome" ;
3299 dir = QAD_Tools::addSlash(dir) ;
3301 dir = dir + "libSalomePyQtcmodule.dll" ;
3303 dir = dir + "libSalomePyQtcmodule.so" ;
3305 MESSAGE ( " GUI library = " << dir );
3306 fileInfo.setFile(dir) ;
3307 if (fileInfo.exists())
3309 ComponentLib = fileInfo.fileName() ;
3315 QMessageBox::critical( this,
3317 tr("ERR_LIBGUI" ).arg(component) );
3322 aSharedLibrary.SetName(TCollection_AsciiString((char*)ComponentLib.latin1()).ToCString());
3323 bool ok = aSharedLibrary.DlOpen(OSD_RTLD_LAZY);
3326 QMessageBox::critical( this,
3328 tr( aSharedLibrary.DlError() ) );
3332 OSD_Function osdF = aSharedLibrary.DlSymb("GetComponentGUI");
3333 if ( osdF != NULL ) {
3334 ComponentGUI f1 = (SALOMEGUI* (*) ()) osdF;
3335 SALOMEGUI* aCompGUI = (*f1)();
3337 myComponents.insert( component, aCompGUI );
3340 QMessageBox::critical( this,
3342 tr("ERR_GET_GUI_FAILED" ).arg(component) );
3348 QMessageBox::critical( this,
3350 tr("ERR_GET_GUI_NOT_FOUND" ).arg(ComponentLib) );
3354 aCompGUI = myComponents[component];
3360 Returns name of active component
3362 QString QAD_Desktop::getComponentDataType() const
3364 using namespace SALOMEDS;
3365 Study_var aStudy = getActiveStudy()->getStudyDocument();
3366 SObject_var aSObject = aStudy->FindObject(myActiveComp.latin1());
3367 SComponent_var aComponent = SComponent::_narrow(aSObject);
3368 if(!aComponent->_is_nil()){
3369 CORBA::String_var aString = aComponent->ComponentDataType();
3370 return aString.in();
3375 void QAD_Desktop::definePopup(QString & theContext,
3376 QString & theParent,
3377 QString & theObject )
3379 SALOMEGUI* anActiveGUI = getActiveGUI();
3381 anActiveGUI->DefinePopup(theContext, theParent, theObject);
3386 Copy popup menu [ static ]
3388 static void makePopup( QPopupMenu* popup, QPopupMenu* fromPopup, QAD_Desktop* receiver )
3391 if ( !popup || !fromPopup )
3393 // iterator through all popup items
3394 for ( int i = fromPopup->count()-1; i >= 0; i-- ) {
3395 int cmdId = fromPopup->idAt( i );
3396 QMenuItem* item = fromPopup->findItem( cmdId );
3398 // if item is a separator
3399 if ( item->isSeparator() ) {
3400 popup->insertSeparator( 0 );
3403 QIconSet* iconSet = item->iconSet();
3404 QKeySequence accel = fromPopup->accel( cmdId );
3406 QPopupMenu* popupChild = item->popup();
3407 // if item is a popup
3408 if ( popupChild && popupChild != fromPopup ) {
3409 QPopupMenu* newPopup = new QPopupMenu( popup );
3411 popup->insertItem( *iconSet, item->text(), newPopup, cmdId, 0 );
3413 popup->insertItem( item->text(), newPopup, cmdId, 0 );
3414 makePopup( newPopup, popupChild, receiver );
3416 // if item is a command
3419 popup->insertItem( *iconSet, item->text(), cmdId, 0 );
3421 popup->insertItem( item->text(), cmdId, 0 );
3422 popup->connectItem( cmdId, receiver, SLOT( onDispatch( int ) ) );
3424 popup->setAccel( accel, cmdId );
3433 void QAD_Desktop::createPopup(QPopupMenu* popup, const QString & theContext,
3434 const QString & theParent, const QString & theObject )
3436 if ( !myActiveComp.isEmpty() &&
3437 getOperatorMenus()->createPopupMenu(theContext,theParent,theObject) != NULL ) {
3438 makePopup( popup, getOperatorMenus()->createPopupMenu(theContext,theParent,theObject)->getPopup(), this );
3441 // Should be moved to SALOMEGUI_Application::onCreatePopup()...
3442 if ( myActiveComp.isEmpty() ) {
3443 popup->removeItem(QAD_Display_Popup_ID);
3444 popup->removeItem(QAD_DisplayOnly_Popup_ID);
3445 popup->removeItem(QAD_Erase_Popup_ID);
3446 int id = popup->idAt(popup->count()-1); // last item
3447 if (id < 0 && id != -1) popup->removeItem(id); // separator
3449 if ( popup && theParent.compare("ObjectBrowser")==0 ) {
3450 if ( popup->count()>0 ) {
3451 popup->insertItem (tr ("MEN_OPENWITH"), this, SLOT(onOpenWith()), 0, -1, 2);
3452 popup->insertSeparator (3);
3455 popup->insertItem (tr ("MEN_OPENWITH"), this, SLOT(onOpenWith()) );
3462 void QAD_Desktop::onActiveStudyChanged()
3464 // Avoid recursive calls caused by QAD_MessageBox
3465 static bool isRecursion = false;
3466 if ( isRecursion || myAboutToClose )
3469 if (myActiveComp != "") {
3470 // Try to load active component's data in the activated study
3471 if ( !loadComponentData(mapComponentName[myActiveComp]) ) {
3473 QAD_MessageBox::error1( this,
3475 tr("ERR_COMP_DATA_NOT_LOADED").arg( myActiveComp ),
3477 // Error while loading component's data -> deactivate it
3478 deactivateComponent();
3479 if (!myXmlHandler->myIdList.IsEmpty()) clearMenus();
3480 myCombo->setCurrentItem (0);
3481 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3482 aButton->setOn(false);
3485 isRecursion = false;
3489 myActiveStudy->updateObjBrowser(true);
3492 SALOMEGUI* anActiveGUI = getActiveGUI();
3494 anActiveGUI->ActiveStudyChanged(this);
3497 void QAD_Desktop::deactivateComponent()
3499 SALOMEGUI* anActiveGUI = getActiveGUI();
3501 anActiveGUI->Deactivate();
3505 Custom popup ( GUI Library )
3507 void QAD_Desktop::customPopup(QPopupMenu* popup, const QString & theContext,
3508 const QString & theParent, const QString & theObject)
3510 SALOMEGUI* anActiveGUI = getActiveGUI();
3512 anActiveGUI->CustomPopup(this, popup, theContext, theParent, theObject);
3515 void QAD_Desktop::onObjectBrowser()
3517 bool checkDiff = false;
3519 bool state = QAD_CONFIG->getSetting("ObjectBrowser:AddColumn").compare("true") == 0;
3521 if ( myStdActions.at( PrefObjectBrowserEntryId )->isOn() != state )
3525 if ( myStdActions.at( PrefObjectBrowserEntryId )->isOn() ) {
3527 QAD_CONFIG->addSetting( "ObjectBrowser:AddColumn", "true");
3530 QAD_CONFIG->addSetting( "ObjectBrowser:AddColumn", "false");
3534 if ( myStdActions.at( PrefObjectBrowserValueId )->isOn() ) {
3536 QAD_CONFIG->addSetting( "ObjectBrowser:ValueColumn", "true");
3539 QAD_CONFIG->addSetting( "ObjectBrowser:ValueColumn", "false");
3543 if ( myStdActions.at( PrefObjectBrowserIAPPId )->isOn() ) {
3545 QAD_CONFIG->addSetting( "ObjectBrowser:IAPP", "true");
3548 QAD_CONFIG->addSetting( "ObjectBrowser:IAPP", "false");
3551 /* To sort created object in chrono order or reverse chrono order */
3552 bool showCHRONO_SORT ;
3553 if ( myStdActions.at( PrefObjectBrowserCHRONO_SORTId )->isOn() ) {
3554 showCHRONO_SORT = true;
3555 QAD_CONFIG->addSetting( "ObjectBrowser:ChronologicalSort", "true");
3557 showCHRONO_SORT = false;
3558 QAD_CONFIG->addSetting( "ObjectBrowser:ChronologicalSort", "false");
3561 /* To show or not to show UseCase browser */
3563 if ( myStdActions.at( PrefObjectBrowserShowUseCaseId )->isOn() ) {
3565 QAD_CONFIG->addSetting( "ObjectBrowser:ShowUseCaseBrowser", "true");
3567 showUseCase = false;
3568 QAD_CONFIG->addSetting( "ObjectBrowser:ShowUseCaseBrowser", "false");
3571 /* Resize or don't resize columns automatically */
3573 if ( myStdActions.at( PrefObjectBrowserNoAutoSizeColumnsId )->isOn() ) {
3575 QAD_CONFIG->addSetting( "ObjectBrowser:NoAutoSizeColumns", "true");
3578 QAD_CONFIG->addSetting( "ObjectBrowser:NoAutoSizeColumns", "false");
3581 if ( myActiveApp ) {
3582 QList<QAD_Study>& studies = myActiveApp->getStudies();
3583 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3584 int nbSf = study->getStudyFramesCount();
3585 for ( int i = 0; i < nbSf; i++ ) {
3586 QAD_StudyFrame* sf = study->getStudyFrame(i);
3587 sf->getLeftFrame()->getObjectBrowser()->setShowInfoColumns( showEntry );
3588 sf->getLeftFrame()->getObjectBrowser()->setShowValueColumn( showValue );
3589 sf->getLeftFrame()->getObjectBrowser()->setEnableChronoSort( showCHRONO_SORT );
3590 // sf->getLeftFrame()->getObjectBrowser()->setShowIAPP( showIAPP ); // this is done by below updateObjBrowser() call
3591 sf->getLeftFrame()->getObjectBrowser()->showUseCaseBrowser( showUseCase );
3592 sf->getLeftFrame()->getObjectBrowser()->autoSizeColumns( autoSize );
3594 study->updateObjBrowser(true);
3599 void QAD_Desktop::onViewerTrihedron()
3601 QString Size = QAD_CONFIG->getSetting("Viewer:TrihedronSize");
3604 SALOMEGUI_TrihedronSizeDlg *Dlg = new SALOMEGUI_TrihedronSizeDlg(this);
3605 if (!Size.isEmpty())
3606 Dlg->setTrihedronSize(Size.toInt());
3607 int r = Dlg->exec();
3608 dim = Dlg->getTrihedronSize();
3611 if (r == QDialog::Accepted) {
3612 QAD_CONFIG->addSetting("Viewer:TrihedronSize", dim);
3615 QList<QAD_Study>& studies = myActiveApp->getStudies();
3616 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3617 int nbSf = study->getStudyFramesCount();
3618 for ( int i = 0; i < nbSf; i++ ) {
3619 study->getStudyFrame(i)->getRightFrame()->getViewFrame()->onAdjustTrihedron();
3626 void QAD_Desktop::onExternalBrowser()
3629 QString theApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
3630 QString theParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
3632 SALOMEGUI_ExternalBrowserDlg *Dlg = new SALOMEGUI_ExternalBrowserDlg(this);
3634 if (!theApp.isEmpty())
3636 QString theParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
3637 Dlg->setSettings(theApp, theParams);
3639 int r = Dlg->exec();
3640 QString theAppFromDialog = Dlg->getApp();
3641 QString theParamsFromDialog = Dlg->getParams();
3644 if (r == QDialog::Accepted)
3646 QAD_CONFIG->addSetting("ExternalBrowser:Application", theAppFromDialog );
3647 QAD_CONFIG->addSetting("ExternalBrowser:Parameters", theParamsFromDialog );
3653 void QAD_Desktop::onDirList()
3655 // getting dir list from settings
3656 QStringList dirList = QStringList::split(';', QAD_CONFIG->getSetting("FileDlg:QuickDirList"), false);
3657 QAD_DirListDlg* dlg = new QAD_DirListDlg(this);
3658 dlg->setPathList(dirList);
3659 if ( dlg->exec() == QDialog::Accepted) {
3660 dlg->getPathList(dirList);
3661 QAD_CONFIG->addSetting("FileDlg:QuickDirList", dirList.join(";"));
3666 void QAD_Desktop::onConsoleFontAction()
3668 // getting font from settings
3669 QString fntSet = QAD_CONFIG->getSetting("Viewer:ConsoleFont");
3670 QFont font = QAD_Tools::stringToFont( fntSet );
3672 font = QFontDialog::getFont( &bOk, font, this );
3674 fntSet = QAD_Tools::fontToString( font );
3675 QAD_CONFIG->addSetting("Viewer:ConsoleFont", fntSet );
3678 QList<QAD_Study>& studies = myActiveApp->getStudies();
3679 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3680 int nbSf = study->getStudyFramesCount();
3681 for ( int i = 0; i < nbSf; i++ ) {
3682 study->getStudyFrame(i)->getRightFrame()->getPyEditor()->setFont( font );
3683 study->getStudyFrame(i)->getRightFrame()->getMessage()->setFont( font );
3690 void QAD_Desktop::onSavePref()
3692 QAD_CONFIG->createConfigFile(true);
3695 //VRV: T2.5 - add default viewer
3696 void QAD_Desktop::onDefaultViewer(QActionP * theAction)
3698 int type = VIEW_TYPE_MAX;
3701 if (myStdActions.at(DefaultViewerOCCId) == theAction)
3703 else if (myStdActions.at(DefaultViewerVTKId) == theAction)
3705 else if (myStdActions.at(DefaultGraphSupervisorId) == theAction)
3706 type = VIEW_GRAPHSUPERV;
3707 else if (myStdActions.at(DefaultPlot2dId) == theAction)
3709 if ( type != VIEW_TYPE_MAX )
3710 QAD_CONFIG->addSetting( "Viewer:DefaultViewer", QString::number( type ) );
3712 //VRV: T2.5 - add default viewer
3714 void QAD_Desktop::onViewerOCC()
3716 QString BackgroundColorRed = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorRed");
3717 QString BackgroundColorGreen = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorGreen");
3718 QString BackgroundColorBlue = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorBlue");
3721 if( !BackgroundColorRed.isEmpty() && !BackgroundColorGreen.isEmpty() && !BackgroundColorBlue.isEmpty() )
3722 color = QColor(BackgroundColorRed.toInt(),
3723 BackgroundColorGreen.toInt(),
3724 BackgroundColorBlue.toInt());
3726 color = QColor(35, 136, 145);
3728 QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3731 /* VSR : PAL5420 ---------------------------------------------------
3732 if ( myActiveApp ) {
3733 QList<QAD_Study>& studies = myActiveApp->getStudies();
3734 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3735 int nbSf = study->getStudyFramesCount();
3736 for ( int i = 0; i < nbSf; i++ ) {
3737 QAD_StudyFrame* sf = study->getStudyFrame(i);
3738 if ( sf->getTypeView() == VIEW_OCC ) {
3739 sf->getRightFrame()->getViewFrame()->setBackgroundColor( c );
3744 VSR : PAL5420 --------------------------------------------------- */
3745 QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorRed", c.red() );
3746 QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorGreen", c.green() );
3747 QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorBlue", c.blue() );
3751 void QAD_Desktop::onGraphSupervisor()
3753 QString BackgroundColorRed = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorRed");
3754 QString BackgroundColorGreen = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorGreen");
3755 QString BackgroundColorBlue = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorBlue");
3758 if( !BackgroundColorRed.isEmpty() && !BackgroundColorGreen.isEmpty() && !BackgroundColorBlue.isEmpty() )
3759 color = QColor(BackgroundColorRed.toInt(),
3760 BackgroundColorGreen.toInt(),
3761 BackgroundColorBlue.toInt());
3763 color = QColor(35, 136, 145);
3765 QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3768 /* VSR : PAL5420 ---------------------------------------------------
3769 if ( myActiveApp ) {
3770 QList<QAD_Study>& studies = myActiveApp->getStudies();
3771 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3772 int nbSf = study->getStudyFramesCount();
3773 for ( int i = 0; i < nbSf; i++ ) {
3774 QAD_StudyFrame* sf = study->getStudyFrame(i);
3775 if ( sf->getTypeView() == VIEW_GRAPHSUPERV ) {
3776 sf->getRightFrame()->getViewFrame()->setBackgroundColor( c );
3781 VSR : PAL5420 --------------------------------------------------- */
3782 QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorRed", c.red() );
3783 QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorGreen", c.green() );
3784 QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorBlue", c.blue() );
3788 void QAD_Desktop::onViewerVTK()
3790 QString BackgroundColorRed = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorRed");
3791 QString BackgroundColorGreen = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorGreen");
3792 QString BackgroundColorBlue = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorBlue");
3795 if( !BackgroundColorRed.isEmpty() && !BackgroundColorGreen.isEmpty() && !BackgroundColorBlue.isEmpty() )
3796 color = QColor(BackgroundColorRed.toInt(),
3797 BackgroundColorGreen.toInt(),
3798 BackgroundColorBlue.toInt());
3800 color = QColor(0, 0, 0);
3802 QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3805 /* VSR : PAL5420 ---------------------------------------------------
3806 if ( myActiveApp ) {
3807 QList<QAD_Study>& studies = myActiveApp->getStudies();
3808 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3809 int nbSf = study->getStudyFramesCount();
3810 for ( int i = 0; i < nbSf; i++ ) {
3811 QAD_StudyFrame* sf = study->getStudyFrame(i);
3812 if ( sf->getTypeView() == VIEW_VTK ) {
3813 sf->getRightFrame()->getViewFrame()->setBackgroundColor( c );
3818 VSR : PAL5420 --------------------------------------------------- */
3819 QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorRed", c.red() );
3820 QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorGreen", c.green() );
3821 QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorBlue", c.blue() );
3825 void QAD_Desktop::onPlot2d()
3828 if ( QAD_CONFIG->hasSetting( "Plot2d:Background" ) ) {
3829 QString bgString = QAD_CONFIG->getSetting( "Plot2d:Background" );
3830 QStringList bgData = QStringList::split( ":", bgString, true );
3831 int bgRed = 0, bgGreen = 0, bgBlue = 0;
3832 if ( bgData.count() > 0 ) bgRed = bgData[ 0 ].toInt();
3833 if ( bgData.count() > 1 ) bgGreen = bgData[ 1 ].toInt();
3834 if ( bgData.count() > 2 ) bgBlue = bgData[ 2 ].toInt();
3835 color = QColor( bgRed, bgGreen, bgBlue );
3838 color = QColor(255, 255, 255);
3841 color = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3843 if ( color.isValid() ) {
3844 /* VSR : PAL5420 ---------------------------------------------------
3845 if ( myActiveApp ) {
3846 QList<QAD_Study>& studies = myActiveApp->getStudies();
3847 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3848 int nbSf = study->getStudyFramesCount();
3849 for ( int i = 0; i < nbSf; i++ ) {
3850 QAD_StudyFrame* sf = study->getStudyFrame(i);
3851 if ( sf->getTypeView() == VIEW_PLOT2D ) {
3852 sf->getRightFrame()->getViewFrame()->setBackgroundColor( color );
3857 VSR : PAL5420 --------------------------------------------------- */
3859 bgData.append( QString::number( color.red() ) );
3860 bgData.append( QString::number( color.green() ) );
3861 bgData.append( QString::number( color.blue() ) );
3862 QAD_CONFIG->addSetting( "Plot2d:Background", bgData.join( ":" ) );
3867 void QAD_Desktop::helpAbout()
3869 SALOMEGUI_AboutDlg* About = new SALOMEGUI_AboutDlg( QAD_Application::getDesktop(), tr("MEN_ABOUT"));
3874 // /* Help Search */
3875 // void QAD_Desktop::helpSearch()
3879 // /* Help Contents */
3880 // void QAD_Desktop::helpContents()
3882 // if (myActiveComp == "")
3883 // myActiveComp = getComponentUserName( "KERNEL" ); //NRI "Salome";
3887 // if (dir = getenv( getComponentName( myActiveComp ) + "_ROOT_DIR")) {
3888 // root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share") + QAD_Tools::addSlash("salome") + "doc" );
3889 // if ( QFileInfo( root + "index.html" ).exists() ) {
3890 // helpContext( root + "index.html", "" );
3893 // root = QAD_Tools::addSlash( root + "html" );
3894 // if ( QFileInfo( root + "index.html" ).exists() ) {
3895 // helpContext( root + "index.html", "" );
3898 // root = QAD_Tools::addSlash( root + "html" );
3899 // if ( QFileInfo( root + "index.html" ).exists() ) {
3900 // helpContext( root + "index.html", "" );
3906 // // //NRI getHelpWindow()->contents();
3907 // // getHelpWindow()->show();
3908 // // getHelpWindow()->raise();
3909 // // getHelpWindow()->setActiveWindow();
3913 //void QAD_Desktop::helpContext(const QString& source, const QString& context)
3915 // //getHelpWindow()->context(source, context); //implemented in QAD_HelpWindow::context( const QString& _source, const QString& _context)
3916 // //getHelpWindow()->show(); //from QMainWindow class
3917 // //getHelpWindow()->raise(); //from QMainWindow class
3918 // //getHelpWindow()->setActiveWindow(); //from QMainWindow class
3920 // QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
3921 // QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
3923 // RunBrowser* rs = new RunBrowser(anApp, aParams, source, context);
3927 /* Preferences/MultiFile Save */
3928 void QAD_Desktop::onMultiFileSave()
3930 if ( myStdActions.at( PrefMultiFileSave )->isOn() )
3931 QAD_CONFIG->addSetting( "Desktop:MultiFileSave", "true");
3933 QAD_CONFIG->addSetting( "Desktop:MultiFileSave", "false");
3936 /* Preferences/ASCII Save */
3937 void QAD_Desktop::onASCIISave()
3939 if ( myStdActions.at( PrefASCIISave )->isOn() )
3940 QAD_CONFIG->addSetting( "Desktop:ASCIISave", "true");
3942 QAD_CONFIG->addSetting( "Desktop:ASCIISave", "false");
3945 /* Preferences / Undo Level */
3946 void QAD_Desktop::onUndoLevel()
3948 static int MAX_UNDO_LEVEL = 1000;
3949 bool isAccepted = false;
3950 static QString aLabel = QString("Level value (%1 ... %2) : ").
3951 arg(1).arg(MAX_UNDO_LEVEL);
3953 SALOMEGUI_SetValueDlg::getInteger("Undo Level",aLabel,
3954 1,MAX_UNDO_LEVEL,getUndoLevel(),
3956 if(!isAccepted) return;
3957 QAD_CONFIG->addSetting("Desktop:UndoLevel", anUndoLevel);
3958 if(!myActiveApp) return;
3959 QList<QAD_Study>& studies = myActiveApp->getStudies();
3960 int aWasWarning = 0;
3961 for(QAD_Study* study = studies.first(); study; study = studies.next()){
3962 SALOMEDS::Study_var aStudyDoc = study->getStudyDocument();
3963 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudyDoc->NewBuilder();
3964 if (!aStudyDoc->GetProperties()->IsLocked()) {
3965 aStudyBuilder->UndoLimit(anUndoLevel);
3968 QAD_MessageBox::warn1 ((QWidget*)QAD_Application::getDesktop(),
3969 QObject::tr("WRN_WARNING"),
3970 QObject::tr("WRN_STUDY_LOCKED"),
3971 QObject::tr("BUT_OK"));
3978 /* Update status bar for File menu items */
3979 void QAD_Desktop::onFilePopupStatusText( int id )
3981 QString component = getActiveComponent();
3983 if (component != "") {
3984 //one of the modules is active now
3985 int importId = myFilePopup.idAt(8);
3986 int exportId = myFilePopup.idAt(9);
3987 int importTableId = myFilePopup.idAt(10);
3989 if (component == getComponentUserName("SMESH") || component == getComponentUserName("GEOM")) {
3991 putInfo( tr("PRP_DESK_FILE_IMPORT") );
3993 putInfo( tr("PRP_DESK_FILE_EXPORT") );
3995 if (component == getComponentUserName("VISU")) {
3997 putInfo( tr("PRP_DESK_FILE_IMPORTMED") );
3998 if (id == importTableId)
3999 putInfo( tr("PRP_DESK_FILE_IMPORTTABLE") );
4001 putInfo( tr("PRP_DESK_FILE_EXPLOREMEDFILE") );
4003 if (component == getComponentUserName("SUPERV")) {
4005 putInfo( tr("PRP_DESK_FILE_IMPORTDF") );
4007 putInfo( tr("PRP_DESK_FILE_EXPORTDF") );
4012 /* Update status bar for Edit menu items */
4013 void QAD_Desktop::onEditPopupStatusText( int id )
4015 QString component = getActiveComponent();
4017 if (component != "") {
4018 //one of the modules is active now
4020 if (component == getComponentUserName("SMESH") || component == getComponentUserName("GEOM") ) {
4021 int deleteId = myEditPopup.idAt(5);
4023 putInfo( tr("PRP_DESK_EDIT_DELETE") );
4025 if (component == getComponentUserName("SUPERV") ) {
4026 int newDFId = myEditPopup.idAt(5);
4027 int modifyDFId = myEditPopup.idAt(6);
4029 putInfo( tr("PRP_DESK_EDIT_NEWDF") );
4030 if (id == modifyDFId)
4031 putInfo( tr("PRP_DESK_EDIT_MODIFYDF") );
4036 /* Update status bar for View menu items */
4037 void QAD_Desktop::onViewPopupStatusText( int id )
4039 QString component = getActiveComponent();
4041 if (component != "") {
4042 //one of the modules is active now
4043 int DispModeId = myViewPopup.idAt(2);
4045 if (component == getComponentUserName("GEOM")) {
4046 if (id == DispModeId)
4047 putInfo( tr("PRP_DESK_VIEW_DISPLAYMODE") );
4049 if (component == getComponentUserName("SMESH")) {
4050 int updateId = myViewPopup.idAt(3);
4052 if (id == DispModeId)
4053 putInfo( tr("PRP_DESK_VIEW_DISPLAYMODE") );
4055 putInfo( tr("PRP_DESK_VIEW_UPDATE") );
4060 /*********************************************************************
4061 ** Class: AppSelectionDlg
4062 ** Descr: Dialog for the selection of the application when several
4063 ** applications exist in the desktop and new study creation
4064 ** is activated by user.
4066 **********************************************************************/
4068 \class Desktop_AppSelectionDlg QAD_Desktop.h
4069 \brief Dialog for the selection of the application when several
4070 applications exist in the desktop and new study creation
4071 is activated by user.
4076 Desktop_AppSelectionDlg::Desktop_AppSelectionDlg( QAD_Desktop* desktop,
4077 QList<QAD_Application>& apps ) :
4078 QDialog( desktop, 0, true ),
4082 QAD_ASSERT_DEBUG_ONLY ( desktop );
4083 setCaption( tr("INF_DESK_DOC_CREATE") );
4084 if ( desktop->icon() )
4085 setIcon( *desktop->icon() );
4087 QBoxLayout* mainLayout = new QVBoxLayout( this, 5 );
4089 /* Create selection buttons */
4090 QVButtonGroup* buttonGrp = new QVButtonGroup ( this );
4091 buttonGrp->setExclusive ( true );
4092 QBoxLayout* vLayout = new QVBoxLayout( mainLayout, 5 );
4093 vLayout->addWidget ( buttonGrp );
4095 /* Create selection button for available app */
4097 for ( QAD_Application* app = myApps.first(); app; app = myApps.next(), id++ )
4099 /* add radio button for application */
4100 buttonGrp->insert( new QRadioButton( app->getStudyDescription() +
4101 " (*." + app->getStudyExtension() + ")", buttonGrp ), id );
4104 /* make the first application selected */
4105 buttonGrp->setButton( 0 );
4107 /* listen to the selection */
4108 QAD_ASSERT ( connect ( buttonGrp, SIGNAL(clicked(int)), this, SLOT(onAppSelected(int)) ));
4110 /* Create OK/Cancel buttons
4112 QBoxLayout* hLayout = new QHBoxLayout( mainLayout, 5 );
4113 QPushButton* buttonOK = new QPushButton( tr("BUT_OK"), this );
4114 QPushButton* buttonCancel = new QPushButton( tr("BUT_CANCEL"), this );
4115 QPushButton* buttonHelp = new QPushButton( tr("BUT_HELP"), this );
4116 buttonOK->setDefault( true );
4118 hLayout->addStretch();
4119 hLayout->addWidget( buttonOK );
4120 hLayout->addWidget( buttonCancel );
4121 hLayout->addWidget( buttonHelp );
4123 /* connect buttons */
4124 QAD_ASSERT ( connect( buttonOK, SIGNAL(clicked()), this, SLOT(accept())) );
4125 QAD_ASSERT ( connect( buttonCancel, SIGNAL(clicked()), this, SLOT(reject())) );
4126 QAD_ASSERT ( connect( buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp())) );
4128 /* disable resizing */
4129 setFixedSize( 0, 0 );
4130 setSizePolicy( QSizePolicy ( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
4133 Desktop_AppSelectionDlg::~Desktop_AppSelectionDlg()
4137 QAD_Application* Desktop_AppSelectionDlg::selectedApp() const
4139 return myApps.at( myAppId );
4142 void Desktop_AppSelectionDlg::resizeEvent( QResizeEvent* e )
4144 QAD_Tools::centerWidget( this, parentWidget() );
4150 void Desktop_AppSelectionDlg::onAppSelected( int id )
4155 void Desktop_AppSelectionDlg::onHelp()