X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FLightApp%2FLightApp_Application.cxx;h=24c8f40ffd465c62eda29adc7b5da33f60e9c370;hb=6ea08066cb76ea0e557d89789037f3fd1a03e0fb;hp=c800af179314a353d9d6bd1ab280828bac13529e;hpb=7397622d22624ab84dd52c68a276e2cf50d262fb;p=modules%2Fgui.git diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index c800af179..24c8f40ff 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -35,8 +35,9 @@ #endif #ifndef DISABLE_PYCONSOLE - #include "LightApp_PyInterp.h" // WARNING! This include must be the first! - #include + #include "PyConsole_Interp.h" + #include "LightApp_PyEditor.h" + #include "PyConsole_Console.h" #endif #include "LightApp_Application.h" @@ -84,6 +85,7 @@ #include #include +#include #include #include #include @@ -244,24 +246,26 @@ int LightApp_Application::lastStudyId = 0; //since the 'toolbar marker' is not unique, find index of first occurrence of the //'toolbar marker' in the array and check that next string is name of the toolbar -int getToolbarMarkerIndex(QByteArray input, const QStringList& aFlags) { - int aResult = -1,tmp = 0; - int inputLen = input.length(); - QDataStream anInputData(&input, QIODevice::ReadOnly); - while(tmp < inputLen) { - tmp = input.indexOf(QToolBarMarker, tmp + 1); - if(tmp < 0 ) - break; - anInputData.device()->seek(tmp); +namespace +{ + int getToolbarMarkerIndex( QByteArray input, const QStringList& aFlags ) { + int aResult = -1,tmp = 0; + int inputLen = input.length(); + QDataStream anInputData( &input, QIODevice::ReadOnly ); + while ( tmp < inputLen ) { + tmp = input.indexOf( QToolBarMarker, tmp + 1 ); + if ( tmp < 0 ) + break; + anInputData.device()->seek( tmp ); uchar mark; - anInputData>>mark; + anInputData >> mark; int lines; anInputData >> lines; - if(lines == 0 && anInputData.atEnd()){ - //Case then array doesn't contain information about toolbars, - aResult = tmp; - break; + if ( lines == 0 && anInputData.atEnd() ) { + //Case then array doesn't contain information about toolbars, + aResult = tmp; + break; } int pos; @@ -269,13 +273,26 @@ int getToolbarMarkerIndex(QByteArray input, const QStringList& aFlags) { int cnt; anInputData >> cnt; QString str; - anInputData>>str; - if(aFlags.contains(str)) { - aResult = tmp; - break; + anInputData >> str; + if ( aFlags.contains( str ) ) { + aResult = tmp; + break; } - } - return aResult; + } + return aResult; + } + + QString langToName( const QString& lang ) + { + // special processing for English language to avoid such result as "American English" + // as Qt cannot just say "English" + QString result; + if ( lang == "en" ) + result = "English"; + else + result = QLocale( lang ).nativeLanguageName(); + return result; + } } /*! @@ -419,6 +436,7 @@ LightApp_Application::LightApp_Application() */ LightApp_Application::~LightApp_Application() { + savePreferences(); delete mySelMgr; delete myScreenHelper; } @@ -441,9 +459,10 @@ void LightApp_Application::start() /*!Closeapplication.*/ void LightApp_Application::closeApplication() { +#ifndef DISABLE_QTXWEBBROWSER QProcess::startDetached( "HelpBrowser", QStringList() << QString( "--remove=%1" ).arg( QApplication::instance()->applicationPid() ) ); - +#endif CAM_Application::closeApplication(); } @@ -798,7 +817,7 @@ void LightApp_Application::createActions() createMenu( FullScreenId, viewMenu, 20, -1 ); int modTBar = createTool( tr( "INF_TOOLBAR_MODULES" ), // title (language-dependant) - QString( "SalomeModules" ) ); // name (language-independant) + QString( "SalomeModules" ) ); // name (language-independant) createTool( ModulesListId, modTBar ); } @@ -988,6 +1007,7 @@ void LightApp_Application::onHelpAbout() */ void LightApp_Application::onSelection() { + //MESSAGE("onSelection") onSelectionChanged(); if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) ) @@ -1132,8 +1152,12 @@ void LightApp_Application::onHelpContentsModule() anApp.append( quote ); #endif QString aParams = resMgr->stringValue("ExternalBrowser", "parameters"); +#if DISABLE_QTXWEBBROWSER + bool useExtBrowser = true; +#else bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false ); - +#endif + if( useExtBrowser ) { if ( !anApp.isEmpty() ) { RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile ); @@ -1202,7 +1226,11 @@ void LightApp_Application::onHelpContextModule( const QString& theComponentName, anApp.append( quote ); #endif +#if DISABLE_QTXWEBBROWSER + bool useExtBrowser = true; +#else bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false ); +#endif if(useExtBrowser) { QString aParams = resMgr->stringValue("ExternalBrowser", "parameters"); @@ -1284,8 +1312,8 @@ void LightApp_Application::insertDockWindow( const int id, QWidget* wid ) connect( dock, SIGNAL( destroyed( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) ); dock->setFeatures( QDockWidget::AllDockWidgetFeatures ); - dock->setObjectName( wid->objectName().isEmpty() ? QString( "window_%1" ).arg( id ) : - QString( "%1Dock" ).arg( wid->objectName() ) ); + dock->setObjectName( wid->objectName().isEmpty() ? QString( "window_%1" ).arg( id ) : + QString( "%1Dock" ).arg( wid->objectName() ) ); dock->setWidget( wid ); dock->toggleViewAction()->setData( QVariant( wid->objectName() ) ); connect( dock->toggleViewAction(), SIGNAL( triggered( bool ) ), @@ -1434,19 +1462,31 @@ SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, c { SUIT_ViewManager* aVM = viewManager( vmType ); SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager(); - + MESSAGE("vmType: " << vmType.toStdString() << " aVM: " << aVM << " anActiveVM: " << anActiveVM ); if ( anActiveVM && anActiveVM->getType() == vmType ) - aVM = anActiveVM; + { + MESSAGE("aVM = anActiveVM"); + aVM = anActiveVM; + } - if ( aVM && create ) + if ( aVM && !aVM->getDetached() && create ) { if ( !aVM->getActiveView() ) - aVM->createView(); + { + MESSAGE("aVM->createView()"); + aVM->createView(); + } else - desktop()->setActiveWindow( aVM->getActiveView() ); + { + MESSAGE("desktop()->setActiveWindow: " << aVM->getActiveView()); + desktop()->setActiveWindow( aVM->getActiveView() ); + } } else if ( create ) - aVM = createViewManager( vmType ); + { + MESSAGE("aVM = createViewManager( vmType )"); + aVM = createViewManager( vmType ); + } return aVM; } @@ -1455,7 +1495,7 @@ SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, c Creates view manager of some type \param vmType - type of view manager */ -SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType ) +SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, bool detached ) { SUIT_ResourceMgr* resMgr = resourceMgr(); @@ -1507,7 +1547,7 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType #ifndef DISABLE_PVVIEWER if( vmType == PVViewer_Viewer::Type() ) { - if ( viewMgr = dynamic_cast( getViewManager( vmType, false ) ) ) { + if (( viewMgr = dynamic_cast( getViewManager( vmType, false )))) { viewMgr->getActiveView()->setFocus(); return 0; } else { @@ -1613,6 +1653,7 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType if ( !viewMgr ) return 0; + viewMgr->setDetached(detached); addViewManager( viewMgr ); SUIT_ViewWindow* viewWin = viewMgr->createViewWindow(); @@ -1748,7 +1789,7 @@ void LightApp_Application::onStudySaved( SUIT_Study* s ) { QtxMRUAction* mru = ::qobject_cast( action( MRUId ) ); if ( mru && s ) - mru->insert( s->studyName() ); + mru->insert( s->studyName() ); emit studySaved(); } @@ -1758,7 +1799,7 @@ void LightApp_Application::onStudyClosed( SUIT_Study* s ) { /* disconnect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ), - this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) ); + this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) ); */ // stop auto-save timer @@ -1809,12 +1850,10 @@ void LightApp_Application::studyCreated( SUIT_Study* s ) } /*!Gets file filter. - *\retval QString "(*.bin)" + *\retval QString "(*.hdf)" */ -QString LightApp_Application::getFileFilter() const +QString LightApp_Application::getFileFilter( bool /*open*/) const { - //return "(*.bin)"; - // HDF persistence return "(*.hdf)"; } @@ -2035,15 +2074,14 @@ QWidget* LightApp_Application::createWindow( const int flag ) #ifndef DISABLE_PYCONSOLE else if ( flag == WT_PyConsole ) { - PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(), getPyInterp() ); + PyConsole_Console* pyCons = new PyConsole_Console( desktop(), new LightApp_PyEditor( getPyInterp() ) ); pyCons->setObjectName( "pythonConsole" ); pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) ); - pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" )); - pyCons->setIsShowBanner(resourceMgr()->booleanValue( "PyConsole", "show_banner", true )); + pyCons->setFont( resMgr->fontValue( "PyConsole", "font" ) ); + pyCons->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) ); + pyCons->setAutoCompletion( resMgr->booleanValue( "PyConsole", "auto_completion", true ) ); pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) ); - wid = pyCons; - pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) ); } #endif else if ( flag == WT_LogWindow ) @@ -2219,10 +2257,15 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) LightApp_Preferences::Selector, "language", "language" ); QStringList aLangs = SUIT_Session::session()->resourceMgr()->stringValue( "language", "languages", "en" ).split( "," ); QList aIcons; + QList aNumbers; + QStringList aTitles; foreach ( QString aLang, aLangs ) { aIcons << QPixmap( QString( ":/images/%1" ).arg( aLang ) ); + aNumbers << aLang; + aTitles << langToName( aLang ); } - pref->setItemProperty( "strings", aLangs, curLang ); + pref->setItemProperty( "strings", aTitles, curLang ); + pref->setItemProperty( "ids", aNumbers, curLang ); pref->setItemProperty( "icons", aIcons, curLang ); pref->setItemProperty( "restart", true, curLang ); @@ -2250,6 +2293,7 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) // .... -> ascii save mode pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" ); // .... -> store windows geometry + pref->addPreference( tr( "PREF_LOAD_LIGHT" ), studyGroup, LightApp_Preferences::Bool, "Study", "autoload_light_modules" ); pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" ); pref->addPreference( "", studyGroup, LightApp_Preferences::Space ); pref->addPreference( tr( "PREF_STORE_TOOL_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_tool_positions" ); @@ -2262,7 +2306,12 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) // ... "Study properties" group <> // ... "Help browser" group <> +#ifndef DISABLE_QTXWEBBROWSER int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab, LightApp_Preferences::Auto, "ExternalBrowser", "use_external_browser"); +#else + int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab ); +#endif + #ifdef WIN32 QString platform = "winapplication"; #else @@ -2277,10 +2326,13 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) // ... "Python console properties" group <> int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab ); + pref->setItemProperty( "columns", 2, pythonConsoleGroup ); // .... -> font pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" ); // .... -> show banner pref->addPreference( tr( "PREF_SHOW_BANNER" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "show_banner" ); + // .... -> auto-completion + pref->addPreference( tr( "PREF_AUTO_COMPLETION" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "auto_completion" ); // ... "Python console properties" group <> // ... "MRU" preferences group <> @@ -2307,7 +2359,7 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) pref->setItemProperty( "columns", 2, fullScreenGroup ); // .... -> automatic hiding toolbars pref->addPreference( tr( "PREF_FULL_SCREEN_AUTO" ), fullScreenGroup, - LightApp_Preferences::Bool, "OCCViewer", "automatic_hiding" ); + LightApp_Preferences::Bool, "OCCViewer", "automatic_hiding" ); // ... "Full-screen" group <> // .. "General" preferences tab <> @@ -2426,13 +2478,13 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) // .... -> Reverse stereo pref->addPreference( tr( "PREF_REVERSE_STEREO" ), stereoGroup, - LightApp_Preferences::Bool, "OCCViewer", "reverse_stereo" ); + LightApp_Preferences::Bool, "OCCViewer", "reverse_stereo" ); // .... -> Enable V-Sync pref->addPreference( tr( "PREF_ENABLE_VSYNC" ), stereoGroup, - LightApp_Preferences::Bool, "OCCViewer", "enable_vsync" ); + LightApp_Preferences::Bool, "OCCViewer", "enable_vsync" ); // .... -> Enable quad-buffer support pref->addPreference( tr( "PREF_ENABLE_QUAD_BUFFER_SUPPORT" ), stereoGroup, - LightApp_Preferences::Bool, "OCCViewer", "enable_quad_buffer_support" ); + LightApp_Preferences::Bool, "OCCViewer", "enable_quad_buffer_support" ); #endif // ... "Background" group <> int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup ); @@ -2494,18 +2546,18 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) int occSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), occGroup ); pref->setItemProperty( "columns", 2, occSelectionGroup ); // .... -> enable preselection - pref->addPreference( tr( "PREF_ENABLE_PRESELECTION" ), occSelectionGroup, - LightApp_Preferences::Bool, "OCCViewer", "enable_preselection" ); + pref->addPreference( tr( "PREF_ENABLE_PRESELECTION" ), occSelectionGroup, + LightApp_Preferences::Bool, "OCCViewer", "enable_preselection" ); // .... -> enable selection - pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), occSelectionGroup, - LightApp_Preferences::Bool, "OCCViewer", "enable_selection" ); + pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), occSelectionGroup, + LightApp_Preferences::Bool, "OCCViewer", "enable_selection" ); // ... "Selection" group <> // ... "Clipping" group <> int occClippingGroup = pref->addPreference( tr( "PREF_GROUP_CLIPPING" ), occGroup ); // .... -> clipping color pref->addPreference( tr( "PREF_CLIPPING_COLOR" ), occClippingGroup, - LightApp_Preferences::Color, "OCCViewer", "clipping_color" ); + LightApp_Preferences::Color, "OCCViewer", "clipping_color" ); int texturePref = pref->addPreference( "", occClippingGroup, LightApp_Preferences::Frame ); pref->setItemProperty( "columns", 2, texturePref ); // .... -> use default texture @@ -2860,8 +2912,9 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) int pyeditTab = pref->addPreference( tr( "PREF_TAB_PYEDITOR" ), salomeCat ); // ... "Font settings" group <> int pyFontGroup = pref->addPreference( tr( "PREF_GROUP_PY_FONT" ), pyeditTab ); - pref->addPreference( tr( "PREF_PY_FONT" ), pyFontGroup, - LightApp_Preferences::Font, "PyEditor", "Font" ); + int pyFont = pref->addPreference( tr( "PREF_PY_FONT" ), pyFontGroup, + LightApp_Preferences::Font, "PyEditor", "Font" ); + pref->setItemProperty( "features", QtxFontEdit::Family | QtxFontEdit::Size | QtxFontEdit::UserSize, pyFont ); // ... "Font settings" group <> // ... "Display settings" group <> int pyDispGroup = pref->addPreference( tr( "PREF_GROUP_PY_DISPLAY" ), pyeditTab ); @@ -3583,6 +3636,9 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString else if ( param=="show_banner" ) { pythonConsole()->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) ); } + else if ( param=="auto_completion" ) { + pythonConsole()->setAutoCompletion( resMgr->booleanValue( "PyConsole", "auto_completion", true ) ); + } } #endif @@ -3616,10 +3672,15 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString } if ( sec == "desktop" && param == "opaque_resize" ) { bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false ); - QMainWindow::DockOptions dopts = desktop()->dockOptions(); - if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks; - else dopts &= ~QMainWindow::AnimatedDocks; - desktop()->setDockOptions( dopts ); + // RNV: This code has been commented, because clearing of the QMainWindow::AnimatedDocks option + // leads to strange behaviour of the dockable windows (at least at qt-5.6.1): + // any dockable window can't be docked to the another area, except initial area. + // It is possible to move window to another area, but it always returns to the initial area. + // + // QMainWindow::DockOptions dopts = desktop()->dockOptions(); + // if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks; + // else dopts &= ~QMainWindow::AnimatedDocks; + // desktop()->setDockOptions( dopts ); desktop()->setOpaqueResize( opaqueResize ); if ( dynamic_cast( desktop() ) ) dynamic_cast( desktop() )->workstack()->setOpaqueResize( opaqueResize ); @@ -3635,7 +3696,7 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString if ( !vm || !vm->inherits( "Plot2d_Viewer" ) ) continue; - Plot2d_Viewer* Plot2dVM = dynamic_cast( vm ); + //Plot2d_Viewer* Plot2dVM = dynamic_cast( vm ); viewMgr->setViewModel( vm ); Plot2d_ViewWindow* wnd = dynamic_cast( viewMgr->getActiveView() ); @@ -3645,39 +3706,6 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString } } #endif - -#ifndef DISABLE_PYVIEWER - if ( sec == QString( "PyViewer" ) && ( param == QString( "HighlightCurrentLine" ) || - param == QString( "LineNumberArea" ) || - param == QString( "TextWrapping" ) || - param == QString( "CenterCursorOnScroll" ) || - param == QString( "TabSpaceVisible" ) || - param == QString( "TabSize" ) || - param == QString( "VerticalEdge" ) || - param == QString( "NumberColumns" ) || - param == QString( "Font" ) ) ) - { - QList lst; - viewManagers( PyViewer_Viewer::Type(), lst ); - QListIterator itPy( lst ); - while ( itPy.hasNext() ) - { - SUIT_ViewManager* viewMgr = itPy.next(); - SUIT_ViewModel* vm = viewMgr->getViewModel(); - if ( !vm || !vm->inherits( "PyViewer_Viewer" ) ) - continue; - - PyViewer_Viewer* pyEditVM = dynamic_cast( vm ); - - viewMgr->setViewModel( vm ); - PyViewer_ViewWindow* pyView = dynamic_cast( viewMgr->getActiveView() ); - if( pyView ) - { - pyView->setPreferences(); - } - } - } -#endif } /*! @@ -3720,10 +3748,10 @@ void LightApp_Application::loadPreferences() if ( desktop() ) { desktop()->retrieveGeometry( aResMgr->stringValue( "desktop", "geometry" ) ); bool opaqueResize = aResMgr->booleanValue( "desktop", "opaque_resize", false ); - QMainWindow::DockOptions dopts = desktop()->dockOptions(); - if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks; - else dopts &= ~QMainWindow::AnimatedDocks; - desktop()->setDockOptions( dopts ); + // QMainWindow::DockOptions dopts = desktop()->dockOptions(); + // if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks; + // else dopts &= ~QMainWindow::AnimatedDocks; + // desktop()->setDockOptions( dopts ); desktop()->setOpaqueResize( opaqueResize ); if ( dynamic_cast( desktop() ) ) dynamic_cast( desktop() )->workstack()->setOpaqueResize( opaqueResize ); @@ -4013,26 +4041,26 @@ void LightApp_Application::loadDockWindowsState() if(tbMap) { QList tbList = findToolBars(); for ( QList::iterator tit = tbList.begin(); tit != tbList.end(); ++tit ) - { - QToolBar* tb = *tit; - if ( tbMap->contains( tb->objectName() ) ) { - tb->setVisible( (*tbMap)[tb->objectName()] ); - } + { + QToolBar* tb = *tit; + if ( tbMap->contains( tb->objectName() ) ) { + tb->setVisible( (*tbMap)[tb->objectName()] ); + } } } if(dwMap) { - QList dwList = qFindChildren( desktop() ); + QList dwList = desktop()->findChildren(); for ( QList::iterator dit = dwList.begin(); dit != dwList.end(); ++dit ) { - QDockWidget* dw = *dit; - - QObject* po = Qtx::findParent( dw, "QMainWindow" ); - if ( po != desktop() ) - continue; - - if ( dwMap->contains( dw->objectName() ) ) - dw->setVisible( (*dwMap)[dw->objectName()] ); + QDockWidget* dw = *dit; + + QObject* po = Qtx::findParent( dw, "QMainWindow" ); + if ( po != desktop() ) + continue; + + if ( dwMap->contains( dw->objectName() ) ) + dw->setVisible( (*dwMap)[dw->objectName()] ); } } */ @@ -4447,8 +4475,10 @@ bool LightApp_Application::isLibExists( const QString& moduleTitle ) const bool isPythonLightModule = lib.contains("SalomePyQtGUILight"); QStringList paths; -#ifdef WIN32 +#if defined(WIN32) paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts ); +#elif defined(__APPLE__) + paths = QString(::getenv( "DYLD_LIBRARY_PATH" )).split( ":", QString::SkipEmptyParts ); #else paths = QString(::getenv( "LD_LIBRARY_PATH" )).split( ":", QString::SkipEmptyParts ); #endif @@ -4873,10 +4903,10 @@ QList LightApp_Application::findToolBars( const QStringList& names ) QList aResult; QList tbList = desktop()->findChildren(); for ( QList::iterator tit = tbList.begin(); tit != tbList.end(); ++tit ) { - QToolBar* tb = *tit; + QToolBar* tb = *tit; QObject* po = Qtx::findParent( tb, "QMainWindow" ); if ( po != desktop() ) - continue; + continue; if ( names.isEmpty() || names.contains( tb->objectName() ) ) aResult.append(tb); } @@ -4885,12 +4915,12 @@ QList LightApp_Application::findToolBars( const QStringList& names ) /*! Internal method to parse toolbars and dockable windows state. - */ -QByteArray LightApp_Application::processState(QByteArray& input, - const bool processWin, - const bool processTb, - const bool isRestoring, - QByteArray defaultState) { +*/ +QByteArray LightApp_Application::processState(QByteArray& input, + const bool processWin, + const bool processTb, + const bool isRestoring, + QByteArray defaultState) { QByteArray aRes; bool hasDefaultState = !defaultState.isEmpty(); @@ -4905,7 +4935,7 @@ QByteArray LightApp_Application::processState(QByteArray& input, tmpInputData >> version; tmpInputData >> dockmarker; tmpInputData >> nbDocWin; - } + } if(processWin && processTb && !isRestoring) { aRes = input; } else if(!processWin && !processTb ) { @@ -4916,7 +4946,7 @@ QByteArray LightApp_Application::processState(QByteArray& input, QList aToolBars = findToolBars(); QStringList aNames; - for ( QList::iterator tit = aToolBars.begin(); tit != aToolBars.end(); ++tit ) { + for ( QList::iterator tit = aToolBars.begin(); tit != aToolBars.end(); ++tit ) { QToolBar* tb = *tit; aNames.append(tb->objectName()); } @@ -4930,7 +4960,7 @@ QByteArray LightApp_Application::processState(QByteArray& input, if(hasDefaultState) { toolBarMarkerIndexDef = getToolbarMarkerIndex(defaultState, aNames); if(toolBarMarkerIndexDef < 0) - return aRes; + return aRes; } QDataStream anInputDataDef(&defaultState, QIODevice::ReadOnly); @@ -4946,28 +4976,28 @@ QByteArray LightApp_Application::processState(QByteArray& input, } else { //Write date from default settings if(hasDefaultState) { - aTargetData = &anInputDataDef; - aTargetIndex = toolBarMarkerIndexDef; + aTargetData = &anInputDataDef; + aTargetIndex = toolBarMarkerIndexDef; } else { - //If no default state, write current snapshot of the dockable windows - if(isRestoring) { - aTargetData = &anInputDataCur; - int toolBarMarkerIndexCur = getToolbarMarkerIndex(currentArr, aNames); - aTargetIndex = toolBarMarkerIndexCur; - } + //If no default state, write current snapshot of the dockable windows + if(isRestoring) { + aTargetData = &anInputDataCur; + int toolBarMarkerIndexCur = getToolbarMarkerIndex(currentArr, aNames); + aTargetIndex = toolBarMarkerIndexCur; + } } } if(aTargetData && aTargetIndex >= 0 ) { aTargetData->device()->seek(0); while( aTargetData->device()->pos() < aTargetIndex ) { - uchar ch; - *aTargetData >> ch; - aData<> ch; + aData<= 0) { int index; if(!isDockWinWriten ) { - //Write version marker - int marker, version; - aTargetData->device()->seek(0); - *aTargetData >> marker; - *aTargetData >> version; - aData << marker; - aData << version; - aData << (uchar) QDockWidgetMarker; - aData << (int) 0; - int shift = 4*sizeof(int) + sizeof(QSize); - index = aTargetIndex - shift; + //Write version marker + int marker, version; + aTargetData->device()->seek(0); + *aTargetData >> marker; + *aTargetData >> version; + aData << marker; + aData << version; + aData << (uchar) QDockWidgetMarker; + aData << (int) 0; + int shift = 4*sizeof(int) + sizeof(QSize); + index = aTargetIndex - shift; } else { - index = aTargetIndex; + index = aTargetIndex; } - + aTargetData->device()->seek(index); while(!aTargetData->atEnd()) { - uchar ch; - *aTargetData >> ch; - aData << ch; + uchar ch; + *aTargetData >> ch; + aData << ch; } } else { // Not treat toolbars aData << (uchar) QToolBarMarker; @@ -5030,7 +5060,7 @@ void LightApp_Application::emitOperationFinished( const QString& theModuleName, Update visibility state of given objects */ void LightApp_Application::updateVisibilityState( DataObjectList& theList, - SUIT_ViewModel* theViewModel ) + SUIT_ViewModel* theViewModel ) { if ( !theViewModel || theList.isEmpty() ) return; @@ -5049,14 +5079,14 @@ void LightApp_Application::updateVisibilityState( DataObjectList& theList, if ( anObjModule ) { LightApp_Displayer* aDisplayer = anObjModule->displayer(); if ( aDisplayer ) { - Qtx::VisibilityState anObjState = Qtx::UnpresentableState; + Qtx::VisibilityState anObjState = Qtx::UnpresentableState; if ( aDisplayer->canBeDisplayed( obj->entry(), theViewModel->getType() ) ) { if ( aView && aDisplayer->IsDisplayed( obj->entry(), aView ) ) anObjState = Qtx::ShownState; else anObjState = Qtx::HiddenState; } - aStudy->setVisibilityState( obj->entry(), anObjState ); + aStudy->setVisibilityState( obj->entry(), anObjState ); } } } @@ -5103,23 +5133,23 @@ bool LightApp_Application::checkExistingDoc() { bool result = true; if( activeStudy() ) { - int answer = SUIT_MessageBox::question( desktop(), - tr( "APPCLOSE_CAPTION" ), - tr( "STUDYCLOSE_DESCRIPTION" ), - tr( "APPCLOSE_SAVE" ), - tr( "APPCLOSE_CLOSE" ), - tr( "APPCLOSE_CANCEL" ), 0 ); + int answer = SUIT_MessageBox::question( desktop(), + tr( "APPCLOSE_CAPTION" ), + tr( "STUDYCLOSE_DESCRIPTION" ), + tr( "APPCLOSE_SAVE" ), + tr( "APPCLOSE_CLOSE" ), + tr( "APPCLOSE_CANCEL" ), 0 ); if(answer == 0) { if ( activeStudy()->isSaved() ) { - onSaveDoc(); - closeDoc( false ); + onSaveDoc(); + closeDoc( false ); } else if ( onSaveAsDoc() ) { - if( !closeDoc( false ) ) { - result = false; - } + if( !closeDoc( false ) ) { + result = false; + } } else { - result = false; - } + result = false; + } } else if( answer == 1 ) { closeDoc( false ); @@ -5135,14 +5165,16 @@ bool LightApp_Application::checkExistingDoc() PyConsole_Interp* LightApp_Application::getPyInterp() { static PyConsole_Interp* myInterp = 0; - if ( !myInterp ) + if ( !myInterp ) { myInterp = createPyInterp(); + myInterp->initialize(); + } return myInterp; } PyConsole_Interp* LightApp_Application::createPyInterp() { - return new LightApp_PyInterp(); + return new PyConsole_Interp(); } #endif // DISABLE_PYCONSOLE