From: stv Date: Mon, 17 Dec 2007 11:54:45 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: snapshot_171207 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fbf07bee6b004cf622b096d9e0adeec4c0aa089f;p=modules%2Fgui.git *** empty log message *** --- diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index bef1e5759..bfbf063c9 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1,17 +1,17 @@ // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D -// +// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either +// License as published by the Free Software Foundation; either // version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com @@ -64,10 +64,12 @@ #include #include -#include -#include #include #include +#include +#include +#include +#include #include @@ -147,6 +149,9 @@ #include #endif +#define ToolBarMarker 0 +#define DockWidgetMarker 1 + static const char* imageEmptyIcon[] = { "20 20 1 1", ". c None", @@ -263,14 +268,14 @@ LightApp_Application::LightApp_Application() // Set existing font for the python console in resources if( !aResMgr->hasValue( "PyConsole", "font" ) ) return; - + QFont f = aResMgr->fontValue( "PyConsole", "font" ); QFontDatabase fdb; QStringList famdb = fdb.families(); - + if ( famdb.contains(f.family()) || !aResMgr->hasValue( "PyConsole", "additional_families" ) ) return; - + QStringList anAddFamilies = aResMgr->stringValue( "PyConsole", "additional_families" ).split( ";", QString::SkipEmptyParts ); QString aFamily; for ( QStringList::Iterator it = anAddFamilies.begin(); it != anAddFamilies.end(); ++it ) @@ -299,15 +304,9 @@ LightApp_Application::~LightApp_Application() /*!Start application.*/ void LightApp_Application::start() { - if ( desktop() ) { + if ( desktop() ) desktop()->retrieveGeometry( resourceMgr()->stringValue( "desktop", "geometry", "(800%)x(800%) (+400%) (+400%) :(full)" ) ); - //desktop()->retrieveGeometry( SUIT_Session::session()->resourceMgr()->stringValue( "desktop", "state", "normal" )); - //desktop()->retrieveGeometry( SUIT_Session::session()->resourceMgr()->stringValue( "desktop", "pos_x", "center" )); - //desktop()->retrieveGeometry( SUIT_Session::session()->resourceMgr()->stringValue( "desktop", "pos_y", "center" )); - //desktop()->retrieveGeometry( SUIT_Session::session()->resourceMgr()->stringValue( "desktop", "widht", "800" )); - //desktop()->retrieveGeometry( SUIT_Session::session()->resourceMgr()->stringValue( "desktop", "height", "800" )); - } - + CAM_Application::start(); updateWindows(); @@ -362,7 +361,7 @@ QString LightApp_Application::applicationVersion() const } } } - return _app_version; + return _app_version; } /*!Load module by \a name.*/ @@ -390,15 +389,15 @@ bool LightApp_Application::activateModule( const QString& modName ) if ( actName == modName ) return true; - putInfo( tr( "ACTIVATING_MODULE" ).arg( modName ) ); + putInfo( tr( "ACTIVATING_MODULE" ).arg( modName ) ); - saveWindowsGeometry(); + saveDockWindowsState(); bool status = CAM_Application::activateModule( modName ); updateModuleActions(); - putInfo( "" ); + putInfo( "" ); if ( !status ) return false; @@ -460,7 +459,7 @@ void LightApp_Application::createActions() root = Qtx::addSlash( Qtx::addSlash(dir) + Qtx::addSlash("share") + Qtx::addSlash("doc") + Qtx::addSlash("salome") + Qtx::addSlash("gui") + Qtx::addSlash("GUI") ); if ( QFileInfo( root + aFileName ).exists() ) { - a = createAction( id, tr( QString("GUI Help").toLatin1().constData() ), + a = createAction( id, tr( QString("GUI Help").toLatin1().constData() ), resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ), tr( QString("GUI Help").toLatin1().constData() ), tr( QString("GUI Help").toLatin1().constData() ), @@ -473,10 +472,10 @@ void LightApp_Application::createActions() dir = getenv("KERNEL_ROOT_DIR"); if ( !dir.isEmpty() ) { QString aFN = "index.html"; - root = Qtx::addSlash( Qtx::addSlash(dir) + Qtx::addSlash("share") + Qtx::addSlash("doc") + + root = Qtx::addSlash( Qtx::addSlash(dir) + Qtx::addSlash("share") + Qtx::addSlash("doc") + Qtx::addSlash("salome") ); if ( QFileInfo( root + aFN ).exists() ) { - a = createAction( id, tr( QString("KERNEL Help").toLatin1().constData() ), + a = createAction( id, tr( QString("KERNEL Help").toLatin1().constData() ), resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ), tr( QString("KERNEL Help").toLatin1().constData() ), tr( QString("KERNEL Help").toLatin1().constData() ), @@ -494,10 +493,10 @@ void LightApp_Application::createActions() continue; QString modName = moduleName( *it ); - + dir = getenv( (modName + "_ROOT_DIR").toLatin1().constData() ); if ( !dir.isEmpty() ) { - root = Qtx::addSlash( Qtx::addSlash(dir) + Qtx::addSlash("share") + Qtx::addSlash("doc") + + root = Qtx::addSlash( Qtx::addSlash(dir) + Qtx::addSlash("share") + Qtx::addSlash("doc") + Qtx::addSlash("salome") + Qtx::addSlash("gui") + Qtx::addSlash(modName) ); if ( QFileInfo( root + aFileName ).exists() ) { @@ -531,11 +530,9 @@ void LightApp_Application::createActions() QStringList modList; modules( modList, false ); - if( modList.count() > 1 ) + if ( modList.count() > 1 ) { - QtxToolBar* modTBar = new QtxToolBar( true, tr( "INF_TOOLBAR_MODULES" ), desk ); - - LightApp_ModuleAction* moduleAction = + LightApp_ModuleAction* moduleAction = new LightApp_ModuleAction( tr( "APP_NAME" ), defIcon, desk ); QMap iconMap; @@ -547,7 +544,7 @@ void LightApp_Application::createActions() { if ( !isLibExists( *it ) ) continue; - + QString iconName; if ( iconMap.contains( *it ) ) iconName = iconMap[*it]; @@ -564,13 +561,12 @@ void LightApp_Application::createActions() } icon = Qtx::scaleIcon( icon, iconSize ); - + moduleAction->insertModule( *it, icon ); } connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ), this, SLOT( onModuleActivation( const QString& ) ) ); registerAction( ModulesListId, moduleAction ); - modTBar->addAction( moduleAction ); } // New window @@ -595,7 +591,6 @@ void LightApp_Application::createActions() createActionForViewer( NewQxGraphViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_C ); #endif - createAction( RenameId, tr( "TOT_RENAME" ), QIcon(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ), Qt::SHIFT+Qt::Key_R, desk, false, this, SLOT( onRenameWindow() ) ); createMenu( RenameId, windowMenu, -1 ); @@ -607,6 +602,9 @@ void LightApp_Application::createActions() createMenu( separator(), fileMenu, -1, 100, -1 ); createMenu( MRUId, fileMenu, 100, -1 ); createMenu( separator(), fileMenu, -1, 100, -1 ); + + int modTBar = createTool( tr( "INF_TOOLBAR_MODULES" ) ); + createTool( ModulesListId, modTBar ); } /*!On module activation action.*/ @@ -635,8 +633,8 @@ void LightApp_Application::onModuleActivation( const QString& modName ) else { // cancelled putInfo( tr("INF_CANCELLED") ); - - LightApp_ModuleAction* moduleAction = + + LightApp_ModuleAction* moduleAction = qobject_cast( action( ModulesListId ) ); if ( moduleAction ) moduleAction->setActiveModule( QString() ); @@ -707,7 +705,7 @@ void LightApp_Application::onNewDoc() { SUIT_Study* study = activeStudy(); - saveWindowsGeometry(); + saveDockWindowsState(); CAM_Application::onNewDoc(); @@ -724,7 +722,7 @@ void LightApp_Application::onNewDoc() void LightApp_Application::onOpenDoc() { SUIT_Study* study = activeStudy(); - saveWindowsGeometry(); + saveDockWindowsState(); CAM_Application::onOpenDoc(); @@ -835,8 +833,6 @@ void LightApp_Application::onSelection() void LightApp_Application::setActiveStudy( SUIT_Study* study ) { CAM_Application::setActiveStudy( study ); - - activateWindows(); } /*! @@ -885,15 +881,15 @@ void LightApp_Application::updateCommandsStatus() class RunBrowser: public QThread { public: - RunBrowser( LightApp_Application* app, - const QString& theApp, - const QString& theParams, - const QString& theHelpFile, + RunBrowser( LightApp_Application* app, + const QString& theApp, + const QString& theParams, + const QString& theHelpFile, const QString& theContext = QString() ) - : myApp( theApp ), - myParams( theParams ), + : myApp( theApp ), + myParams( theParams ), #ifdef WIN32 - myHelpFile( "file://" + theHelpFile ), + myHelpFile( "file://" + theHelpFile ), #else myHelpFile( "file:" + theHelpFile ), #endif @@ -912,7 +908,7 @@ public: QProcess* proc = new QProcess(); //myStatus = system(aCommand); - + //if(myStatus != 0) proc->start( aCommand ); if ( proc->waitForStarted() ) { @@ -945,10 +941,10 @@ void LightApp_Application::onHelpContentsModule() QString aFileNameKernel = "index.html"; QString dir = getenv( (aComponentName + "_ROOT_DIR").toLatin1().constData() ); - QString homeDir = !aComponentName.compare(QString("KERNEL")) ? - Qtx::addSlash( Qtx::addSlash(dir) + Qtx::addSlash("share") + Qtx::addSlash("doc") + Qtx::addSlash("salome") ) : + QString homeDir = !aComponentName.compare(QString("KERNEL")) ? + Qtx::addSlash( Qtx::addSlash(dir) + Qtx::addSlash("share") + Qtx::addSlash("doc") + Qtx::addSlash("salome") ) : Qtx::addSlash( Qtx::addSlash(dir) + Qtx::addSlash("share") + Qtx::addSlash("doc") + Qtx::addSlash("salome") + Qtx::addSlash("gui") + Qtx::addSlash(aComponentName) ); - + QString helpFile = QFileInfo( homeDir + (!aComponentName.compare(QString("KERNEL")) ? aFileNameKernel : aFileName) ).absoluteFilePath(); SUIT_ResourceMgr* resMgr = resourceMgr(); QString platform; @@ -959,9 +955,9 @@ void LightApp_Application::onHelpContentsModule() #endif QString anApp = resMgr->stringValue("ExternalBrowser", platform); #ifdef WIN32 - QString quote("\""); - anApp.prepend( quote ); - anApp.append( quote ); + QString quote("\""); + anApp.prepend( quote ); + anApp.append( quote ); #endif QString aParams = resMgr->stringValue("ExternalBrowser", "parameters"); @@ -981,18 +977,18 @@ void LightApp_Application::onHelpContentsModule() /*! SLOT: Displays help contents for choosen dialog */ -void LightApp_Application::onHelpContextModule( const QString& theComponentName, - const QString& theFileName, +void LightApp_Application::onHelpContextModule( const QString& theComponentName, + const QString& theFileName, const QString& theContext ) { QString homeDir = ""; if ( !theComponentName.isEmpty() ) { QString dir = getenv( ( theComponentName + "_ROOT_DIR" ).toLatin1().constData() ); if ( !dir.isEmpty() ) - homeDir = Qtx::addSlash( Qtx::addSlash( dir ) + - Qtx::addSlash( "share" ) + - Qtx::addSlash( "doc" ) + - Qtx::addSlash( "salome" ) + + homeDir = Qtx::addSlash( Qtx::addSlash( dir ) + + Qtx::addSlash( "share" ) + + Qtx::addSlash( "doc" ) + + Qtx::addSlash( "salome" ) + Qtx::addSlash( "gui" ) + Qtx::addSlash( theComponentName ) ); } @@ -1007,9 +1003,9 @@ void LightApp_Application::onHelpContextModule( const QString& theComponentName, #endif QString anApp = resMgr->stringValue("ExternalBrowser", platform); #ifdef WIN32 - QString quote("\""); - anApp.prepend( quote ); - anApp.append( quote ); + QString quote("\""); + anApp.prepend( quote ); + anApp.append( quote ); #endif QString aParams = resMgr->stringValue("ExternalBrowser", "parameters"); @@ -1033,30 +1029,6 @@ void LightApp_Application::onSelectionChanged() { } -/*! - \return window by key - \param flag - key for window - \param studyId - study id - Flag used how identificator of window in windows list. -*/ -QWidget* LightApp_Application::window( const int flag, const int studyId ) const -{ - QWidget* wid = 0; - - int sId = studyId; - if ( sId < 0 ) { - if ( !activeStudy() ) - return 0; - else - sId = activeStudy()->id(); - } - - if ( myWindows.contains( flag ) ) - wid = myWindows[flag]->widget( sId ); - - return wid; -} - /*! Adds window to application. \param wid - QWidget @@ -1064,6 +1036,7 @@ QWidget* LightApp_Application::window( const int flag, const int studyId ) const \param studyId - study id Flag used how identificator of window in windows list. */ +/* void LightApp_Application::addWindow( QWidget* wid, const int flag, const int studyId ) { if ( !wid ) @@ -1085,7 +1058,7 @@ void LightApp_Application::addWindow( QWidget* wid, const int flag, const int st LightApp_WidgetContainer* newWC = new LightApp_WidgetContainer( flag, desktop() ); connect( newWC, SIGNAL( destroyed ( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) ); - // asv: connecting a slot for storing visibility flag of a window + // asv: connecting a slot for storing visibility flag of a window connect( newWC, SIGNAL( visibilityChanged ( bool ) ), SLOT( onVisibilityChanged( bool ) ) ); myWindows.insert( flag, newWC ); if ( winMap.contains( flag ) ) { @@ -1122,85 +1095,93 @@ void LightApp_Application::addWindow( QWidget* wid, const int flag, const int st setWindowShown( flag, !myWindows[flag]->isEmpty() ); } - -/*! - Removes window from application. - \param flag - key for window - \param studyId - study id - Flag used how identificator of window in windows list. */ -void LightApp_Application::removeWindow( const int flag, const int studyId ) + +QWidget* LightApp_Application::dockWindow( const int id ) const { - if ( !myWindows.contains( flag ) ) - return; + QWidget* wid = 0; + if ( myWin.contains( id ) ) + wid = myWin[id]; + return wid; +} - int sId = studyId; - if ( sId < 0 ) +QDockWidget* LightApp_Application::windowDock( QWidget* wid ) const +{ + if ( !wid ) + return 0; + + QDockWidget* dock = 0; + QWidget* w = wid->parentWidget(); + while ( w && !dock ) { - if ( !activeStudy() ) - return; - else - sId = activeStudy()->id(); + dock = ::qobject_cast( w ); + w = w->parentWidget(); } + return dock; +} - bool anIsEmpty = !myWindows[flag]->isEmpty(); - QWidget* wid = myWindows[flag]->widget( sId ); - myWindows[flag]->remove( sId ); +void LightApp_Application::insertDockWindow( const int id, QWidget* wid ) +{ + if ( !wid ) + return; + + if ( wid != dockWindow( id ) ) + removeDockWindow( id ); + + myWin.insert( id, wid ); + + QtxDockWidget* dock = new QtxDockWidget( true, desktop() ); + connect( dock, SIGNAL( destroyed( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) ); - //setWindowShown( flag, !myWindows[flag]->isEmpty() ); - setWindowShown( flag, anIsEmpty ); + dock->setFeatures( QDockWidget::AllDockWidgetFeatures ); + dock->setObjectName( QString( "window_%1" ).arg( id ) ); + dock->setWidget( wid ); + dock->show(); } -/*! - Gets window. - \param flag - key for window - \param studyId - study id - Flag used how identificator of window in windows list. -*/ -QWidget* LightApp_Application::getWindow( const int flag, const int studyId ) +void LightApp_Application::removeDockWindow( const int id ) { - QWidget* wid = window( flag, studyId ); + QWidget* wid = dockWindow( id ); if ( !wid ) - addWindow( wid = createWindow( flag ), flag, studyId ); + return; - return wid; + myWin.remove( id ); + + QDockWidget* dock = windowDock( wid ); + if ( !dock ) + return; + + dock->setWidget( 0 ); + wid->setParent( 0 ); + wid->setVisible( false ); + delete dock; } -/*! - \return is window visible - \param type - flag of window -*/ -bool LightApp_Application::isWindowVisible( const int type ) const +void LightApp_Application::placeDockWindow( const int id, Qt::DockWidgetArea place ) { - bool res = false; - if ( myWindows.contains( type ) ) - { - //SUIT_Desktop* desk = ((LightApp_Application*)this)->desktop(); - //res = desk && desk->appropriate( myWindows[type] ); - res = myWindows[type]->isVisible(); - } - return res; + QDockWidget* dock = windowDock( dockWindow( id ) ); + if ( dock && desktop() ) + desktop()->addDockWidget( place, dock ); } /*! - Sets window show or hide. - \param type - window identificator. - \param on - true/false (window show/hide) + Gets window. + \param flag - key for window + \param studyId - study id + Flag used how identificator of window in windows list. */ -void LightApp_Application::setWindowShown( const int type, const bool on ) +QWidget* LightApp_Application::getWindow( const int flag, const int ) { - if ( !desktop() || !myWindows.contains( type ) ) - return; + QWidget* wid = dockWindow( flag ); + if ( !wid ) + insertDockWindow( flag, wid = createWindow( flag ) ); - QDockWidget* dw = myWindows[type]; - //desktop()->setAppropriate( dw, on ); - if( on ) - dw->show(); - else if( dw->isVisible() ) - { - dw->hide(); - myWindowsVisible[ type ] = true; - } + QMap winMap; + currentWindows( winMap ); + if ( winMap.contains( flag ) ) + placeDockWindow( flag, (Qt::DockWidgetArea)winMap[flag] ); + + return wid; } /*! @@ -1208,7 +1189,7 @@ void LightApp_Application::setWindowShown( const int type, const bool on ) */ LightApp_Browser* LightApp_Application::objectBrowser() { - return qobject_cast( window( WT_ObjectBrowser ) ); + return qobject_cast( dockWindow( WT_ObjectBrowser ) ); } /*! @@ -1216,7 +1197,7 @@ LightApp_Browser* LightApp_Application::objectBrowser() */ LogWindow* LightApp_Application::logWindow() { - return qobject_cast( window( WT_LogWindow ) ); + return qobject_cast( dockWindow( WT_LogWindow ) ); } #ifndef DISABLE_PYCONSOLE @@ -1225,7 +1206,7 @@ LogWindow* LightApp_Application::logWindow() */ PyConsole_Console* LightApp_Application::pythonConsole() { - return qobject_cast( window( WT_PyConsole ) ); + return qobject_cast( dockWindow( WT_PyConsole ) ); } #endif @@ -1236,7 +1217,7 @@ PyConsole_Console* LightApp_Application::pythonConsole() void LightApp_Application::updateObjectBrowser( const bool updateModels ) { // update existing data models - if ( updateModels ) + if ( updateModels ) { const bool isAutoUpdate = objectBrowser() ? objectBrowser()->autoUpdate() : true; if ( objectBrowser() ) @@ -1324,7 +1305,7 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType #else vm = new Plot2d_Viewer(); #endif - viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface + viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface Plot2d_ViewWindow* wnd = dynamic_cast( viewMgr->getActiveView() ); if( wnd ) { @@ -1427,6 +1408,8 @@ void LightApp_Application::onStudyCreated( SUIT_Study* theStudy ) getWindow( WT_ObjectBrowser ); + loadDockWindowsState(); + if ( objectBrowser() ) objectBrowser()->setRoot( aRoot ); @@ -1434,8 +1417,6 @@ void LightApp_Application::onStudyCreated( SUIT_Study* theStudy ) if ( objectBrowser() ) objectBrowser()->openLevels(); - - activateWindows(); } /*! @@ -1453,6 +1434,8 @@ void LightApp_Application::onStudyOpened( SUIT_Study* theStudy ) getWindow( WT_ObjectBrowser ); + loadDockWindowsState(); + if ( objectBrowser() ) objectBrowser()->setRoot( aRoot ); @@ -1461,8 +1444,6 @@ void LightApp_Application::onStudyOpened( SUIT_Study* theStudy ) if ( objectBrowser() ) objectBrowser()->openLevels(); - activateWindows(); - emit studyOpened(); } @@ -1482,9 +1463,6 @@ void LightApp_Application::onStudyClosed( SUIT_Study* s ) emit studyClosed(); activateModule( "" ); - - for ( WindowMap::ConstIterator itr = myWindows.begin(); s && itr != myWindows.end(); ++itr ) - removeWindow( itr.key(), s->id() ); } /*!Protected SLOT.On desktop activated.*/ @@ -1509,7 +1487,7 @@ QString LightApp_Application::getFileFilter() const /*! Shows file dialog and return user selected file name */ -QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters, +QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters, const QString& caption, QWidget* parent ) { if ( !parent ) @@ -1527,7 +1505,7 @@ QString LightApp_Application::getDirectory( const QString& initial, const QStrin } /*! Get open file names*/ -QStringList LightApp_Application::getOpenFileNames( const QString& initial, const QString& filters, +QStringList LightApp_Application::getOpenFileNames( const QString& initial, const QString& filters, const QString& caption, QWidget* parent ) { if ( !parent ) @@ -1671,7 +1649,7 @@ QWidget* LightApp_Application::createWindow( const int flag ) Adds to map \a aMap. */ void LightApp_Application::defaultWindows( QMap& aMap ) const -{ +{ aMap.insert( WT_ObjectBrowser, Qt::LeftDockWidgetArea ); #ifndef DISABLE_PYCONSOLE aMap.insert( WT_PyConsole, Qt::BottomDockWidgetArea ); @@ -1717,7 +1695,7 @@ LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const QStringList modNameList; app->modules( modNameList, false ); - for ( QStringList::const_iterator it = modNameList.begin(); + for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it ) _prefs_->addPreference( *it ); @@ -1764,10 +1742,10 @@ void LightApp_Application::moduleAdded( CAM_Module* mod ) if ( myPrefs && lightMod && !myPrefs->hasModule( lightMod->moduleName() )) { - int modCat = myPrefs->addPreference( mod->moduleName() ); + myPrefs->addPreference( mod->moduleName() ); lightMod->createPreferences(); QtxPreferenceItem* item = myPrefs->findItem( mod->moduleName(), true ); - if ( item && item->isEmpty() ) + if ( item && item->isEmpty() ) delete item; } } @@ -1881,7 +1859,7 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) anIndexesList.append(0); anIndexesList.append(1); anIndexesList.append(2); - + pref->setItemProperty( "strings", aCurveTypesList, curveType ); pref->setItemProperty( "indexes", anIndexesList, curveType ); @@ -1890,11 +1868,11 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) pref->setItemProperty( "min", 0, markerSize ); pref->setItemProperty( "max", 100, markerSize ); - + QStringList aScaleModesList; aScaleModesList.append( tr("PREF_LINEAR") ); aScaleModesList.append( tr("PREF_LOGARITHMIC") ); - + anIndexesList.clear(); anIndexesList.append(0); anIndexesList.append(1); @@ -2094,7 +2072,7 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString } if( sec=="Study" ) - { + { if( param=="store_positions" ) updateWindows(); } @@ -2122,19 +2100,59 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString } } +/*! + Loads preferences +*/ +void LightApp_Application::loadPreferences() +{ + CAM_Application::loadPreferences(); + + SUIT_ResourceMgr* aResMgr = resourceMgr(); + + if ( !aResMgr ) + return; + + myWinGeom.clear(); + QStringList mods = aResMgr->parameters( "windows_geometry" ); + for ( QStringList::const_iterator it = mods.begin(); it != mods.end(); ++it ) + { + QByteArray arr; + if ( aResMgr->value( "windows_geometry", *it, arr ) ) + myWinGeom.insert( *it, arr ); + } + + myWinVis.clear(); + mods = aResMgr->parameters( "windows_visibility" ); + for ( QStringList::const_iterator itr = mods.begin(); itr != mods.end(); ++itr ) + { + QByteArray arr; + if ( aResMgr->value( "windows_visibility", *itr, arr ) ) + myWinVis.insert( *itr, arr ); + } +} + /*! Saves preferences */ void LightApp_Application::savePreferences() { - saveWindowsGeometry(); - - if ( resourceMgr() ) - { - if ( desktop() ) - resourceMgr()->setValue( "desktop", "geometry", desktop()->storeGeometry() ); - resourceMgr()->save(); - } + CAM_Application::savePreferences(); + + saveDockWindowsState(); + + if ( !resourceMgr() ) + return; + + for ( WinGeom::const_iterator it = myWinGeom.begin(); it != myWinGeom.end(); ++it ) + resourceMgr()->setValue( "windows_geometry", it.key(), it.value() ); + + for ( WinVis::const_iterator itr = myWinVis.begin(); itr != myWinVis.end(); ++itr ) + resourceMgr()->setValue( "windows_visibility", itr.key(), itr.value() ); + + if ( desktop() ) + resourceMgr()->setValue( "desktop", "geometry", desktop()->storeGeometry() ); + + resourceMgr()->save(); } /*! @@ -2155,12 +2173,12 @@ void LightApp_Application::updateDesktopTitle() { } /*! - \brief Get map of the operations which can be performed + \brief Get map of the operations which can be performed on the module activation. - + The method should return the map of the kind \c {:} where \c is an integer identifier of the operation and - \c is a title for the button to be added to the + \c is a title for the button to be added to the dialog box. After user selects the required operation by the clicking the corresponding button in the dialog box, its identifier is passed to the moduleActionSelected() method to process @@ -2182,7 +2200,7 @@ QMap LightApp_Application::activateModuleActions() const from "Activate module" dialog box. Performs the required operation according to the user choice. - + \param id operation identifier \sa activateModuleActions() */ @@ -2218,8 +2236,8 @@ void LightApp_Application::updateModuleActions() QString modName; if ( activeModule() ) modName = activeModule()->moduleName(); - - LightApp_ModuleAction* moduleAction = + + LightApp_ModuleAction* moduleAction = qobject_cast( action( ModulesListId ) ); if ( moduleAction ) moduleAction->setActiveModule( modName ); @@ -2265,35 +2283,22 @@ void LightApp_Application::updateWindows() QMap winMap; currentWindows( winMap ); - if ( activeStudy() ) { - for ( QMap::ConstIterator it = winMap.begin(); it != winMap.end(); ++it ) { - getWindow( it.key() ); - - if ( !myWindows.contains( it.key() ) ) - continue; - Qt::DockWidgetArea dock = desktop()->dockWidgetArea( myWindows[it.key()] ); - if ( dock != Qt::NoDockWidgetArea - && - dock != (Qt::DockWidgetArea)it.value() ) { - //desktop()->removeDockWidget( myWindows[it.key()] ); - desktop()->addDockWidget( (Qt::DockWidgetArea)it.value(), myWindows[it.key()] ); - } + if ( activeStudy() ) + { + for ( QMap::ConstIterator it = winMap.begin(); it != winMap.end(); ++it ) + { + if ( !dockWindow( it.key() ) ) + getWindow( it.key() ); } - - loadWindowsGeometry(); } - // setWindowShown should be done even if no study is active (open). in this case all open windows - // will be hidden, which is neccessary in this case. - for ( WindowMap::ConstIterator itr = myWindows.begin(); itr != myWindows.end(); ++itr ) { - - if ( myWindowsVisible.contains( itr.key() ) && - !myWindowsVisible[ itr.key() ] ) - continue; - - if ( itr.value() ) - setWindowShown( itr.key(), !itr.value()->isEmpty() && winMap.contains( itr.key() ) ); + for ( WinMap::ConstIterator it = myWin.begin(); it != myWin.end(); ++it ) + { + QWidget* wid = it.value(); + wid->setVisible( activeStudy() && winMap.contains( it.key() ) ); } + + loadDockWindowsState(); } /*! @@ -2311,7 +2316,7 @@ void LightApp_Application::updateViewManagers() /*! Loads windows geometry */ -void LightApp_Application::loadWindowsGeometry() +void LightApp_Application::loadDockWindowsState() { bool store = resourceMgr()->booleanValue( "Study", "store_positions", true ); if( !store ) @@ -2321,13 +2326,36 @@ void LightApp_Application::loadWindowsGeometry() if ( activeModule() ) modName = activeModule()->name(); - desktop()->restoreState( resourceMgr()->stringValue( "windows_geometry", modName ).toLatin1() ); + if ( myWinGeom.contains( modName ) ) + desktop()->restoreState( myWinGeom[modName] ); + + if ( !myWinVis.contains( modName ) ) + return; + + QMap tbMap, dwMap; + dockWindowsState( myWinVis[modName], tbMap, dwMap ); + + QList tbList = qFindChildren( desktop() ); + for ( QList::iterator tit = tbList.begin(); tit != tbList.end(); ++tit ) + { + QToolBar* tb = *tit; + if ( tbMap.contains( tb->objectName() ) ) + tb->setVisible( tbMap[tb->objectName()] ); + } + + QList dwList = qFindChildren( desktop() ); + for ( QList::iterator dit = dwList.begin(); dit != dwList.end(); ++dit ) + { + QDockWidget* dw = *dit; + if ( dwMap.contains( dw->objectName() ) ) + dw->setVisible( dwMap[dw->objectName()] ); + } } /*! Saves windows geometry */ -void LightApp_Application::saveWindowsGeometry() +void LightApp_Application::saveDockWindowsState() { bool store = resourceMgr()->booleanValue( "Study", "store_positions", true ); if( !store ) @@ -2337,18 +2365,94 @@ void LightApp_Application::saveWindowsGeometry() if ( activeModule() ) modName = activeModule()->name(); - resourceMgr()->setValue( "windows_geometry", modName, desktop()->saveState() ); + myWinGeom.insert( modName, desktop()->saveState() ); + + QByteArray visArr; + if ( myWinVis.contains( modName ) ) + visArr = myWinVis[modName]; + + QMap tbMap, dwMap; + dockWindowsState( visArr, tbMap, dwMap ); + + QList tbList = qFindChildren( desktop() ); + for ( QList::iterator it = tbList.begin(); it != tbList.end(); ++it ) + { + QToolBar* tb = *it; + tbMap.insert( tb->objectName(), tb->toggleViewAction()->isChecked() ); + } + + QList dwList = qFindChildren( desktop() ); + for ( QList::iterator it = dwList.begin(); it != dwList.end(); ++it ) + { + QDockWidget* wid = *it; + dwMap.insert( wid->objectName(), wid->toggleViewAction()->isChecked() ); + } + + visArr = dockWindowsState( tbMap, dwMap ); + + myWinVis.insert( modName, visArr ); } -/*! - Activates windows -*/ -void LightApp_Application::activateWindows() +QByteArray LightApp_Application::dockWindowsState( const QMap& tb, const QMap& dw ) const { - if ( activeStudy() ) + QByteArray visArr; + QDataStream stream( &visArr, QIODevice::WriteOnly ); + + stream << (uchar)ToolBarMarker; + stream << tb.size(); + for ( QMap::const_iterator tit = tb.begin(); tit != tb.end(); ++tit ) + { + stream << tit.key(); + stream << (uchar)( tit.value() ? 1 : 0 ); + } + + stream << (uchar)DockWidgetMarker; + stream << dw.size(); + for ( QMap::const_iterator wit = dw.begin(); wit != dw.end(); ++wit ) { - for ( WindowMap::Iterator itr = myWindows.begin(); itr != myWindows.end(); ++itr ) - itr.value()->activate( activeStudy()->id() ); + stream << wit.key(); + stream << (uchar)( wit.value() ? 1 : 0 ); + } + + return visArr; +} + +void LightApp_Application::dockWindowsState( const QByteArray& arr, QMap& tb, QMap& dw ) const +{ + tb.clear(); + dw.clear(); + + QByteArray visArr = arr; + QDataStream stream( &visArr, QIODevice::ReadOnly ); + + uchar marker; + stream >> marker; + if ( marker != ToolBarMarker ) + return; + + int lines; + stream >> lines; + for ( int i = 0; i < lines; ++i ) + { + QString objectName; + stream >> objectName; + uchar shown; + stream >> shown; + tb.insert( objectName, shown ); + } + + stream >> marker; + if ( marker != DockWidgetMarker ) + return; + + stream >> lines; + for ( int j = 0; j < lines; ++j ) + { + QString objectName; + stream >> objectName; + uchar shown; + stream >> shown; + dw.insert( objectName, shown ); } } @@ -2437,13 +2541,13 @@ SUIT_Accel* LightApp_Application::accel() const void LightApp_Application::onWCDestroyed( QObject* ob ) { // remove destroyed widget container from windows map - for ( WindowMap::ConstIterator itr = myWindows.begin(); itr != myWindows.end(); ++itr ) + for ( WinMap::ConstIterator itr = myWin.begin(); itr != myWin.end(); ++itr ) { if ( itr.value() != ob ) continue; int key = itr.key(); - myWindows.remove( key ); + myWin.remove( key ); break; } } @@ -2497,7 +2601,7 @@ bool LightApp_Application::isLibExists( const QString& moduleTitle ) const return false; QString lib = moduleLibrary( moduleTitle ); - + //abd: changed libSalomePyQtGUI to SalomePyQtGUI for WIN32 bool isPythonModule = lib.contains("SalomePyQtGUI"); @@ -2513,14 +2617,14 @@ bool LightApp_Application::isLibExists( const QString& moduleTitle ) const for( ; anIt!=aLast; anIt++ ) { QFileInfo inf( Qtx::addSlash( *anIt ) + lib ); - + if( inf.exists() ) { isLibFound = true; break; } } - + if ( !isLibFound ) { printf( "****************************************************************\n" ); @@ -2548,17 +2652,17 @@ bool LightApp_Application::isLibExists( const QString& moduleTitle ) const { QFileInfo inf( Qtx::addSlash( *anIt ) + pylib ); QFileInfo infgui( Qtx::addSlash( *anIt ) + pylibgui ); - + if( !isPyLib && inf.exists() ) isPyLib = true; - + if( !isPyGuiLib && infgui.exists() ) isPyGuiLib = true; - + if ( isPyLib && isPyGuiLib && isLibFound) return true; } - + printf( "****************************************************************\n" ); printf( "* Warning: python library for %s cannot be found:\n", moduleTitle.toLatin1().constData() ); if (!isPyLib) @@ -2588,19 +2692,6 @@ void LightApp_Application::setDefaultStudyName( const QString& theName ) } } -/*! slot, called on show/hide of a dock window */ -void LightApp_Application::onVisibilityChanged( bool visible ) -{ - const QObject* win = sender(); - - for ( WindowMap::ConstIterator itr = myWindows.begin(); itr != myWindows.end(); ++itr ) - if ( itr.value() == win ) - { - myWindowsVisible[ itr.key() ] = visible; - return; - } -} - /*! Custom event handler */ @@ -2627,8 +2718,8 @@ bool LightApp_Application::checkDataObject(LightApp_DataObject* theObj) { if (theObj) { - bool isSuitable = !theObj->entry().isEmpty() && - !theObj->componentDataType().isEmpty() && + bool isSuitable = !theObj->entry().isEmpty() && + !theObj->componentDataType().isEmpty() && !theObj->name().isEmpty(); return isSuitable; } diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index a4b0462fe..6e21b3ce3 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -1,17 +1,17 @@ // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D -// +// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either +// License as published by the Free Software Foundation; either // version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com @@ -31,10 +31,12 @@ #include "LightApp.h" #include +#include + class LogWindow; class LightApp_Browser; #ifndef DISABLE_PYCONSOLE - class PyConsole_Console; +class PyConsole_Console; #endif class LightApp_WidgetContainer; class LightApp_Preferences; @@ -47,6 +49,7 @@ class CAM_Module; class QString; class QWidget; class QStringList; +class QDockWidget; #ifdef WIN32 #pragma warning( disable:4251 ) @@ -61,7 +64,7 @@ class LIGHTAPP_EXPORT LightApp_Application : public CAM_Application Q_OBJECT public: - typedef enum { WT_ObjectBrowser, + typedef enum { WT_ObjectBrowser, #ifndef DISABLE_PYCONSOLE WT_PyConsole, #endif @@ -110,11 +113,11 @@ public: virtual bool activateModule( const QString& ); LightApp_SelectionMgr* selectionMgr() const; - + LogWindow* logWindow(); LightApp_Browser* objectBrowser(); #ifndef DISABLE_PYCONSOLE - PyConsole_Console* pythonConsole(); + PyConsole_Console* pythonConsole(); #endif virtual void updateObjectBrowser( const bool = true ); @@ -123,10 +126,10 @@ public: virtual QString getFileFilter() const; - virtual QString getFileName( bool open, const QString& initial, const QString& filters, + virtual QString getFileName( bool open, const QString& initial, const QString& filters, const QString& caption, QWidget* parent ); virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent ); - virtual QStringList getOpenFileNames( const QString& initial, const QString& filters, + virtual QStringList getOpenFileNames( const QString& initial, const QString& filters, const QString& caption, QWidget* parent ); void updateActions(); @@ -137,12 +140,10 @@ public: virtual SUIT_ViewManager* createViewManager( const QString& vmType ); QWidget* getWindow( const int, const int = -1 ); - QWidget* window( const int, const int = -1 ) const; - void addWindow( QWidget*, const int, const int = -1 ); - void removeWindow( const int, const int = -1 ); - - bool isWindowVisible( const int ) const; - void setWindowShown( const int, const bool ); + QWidget* dockWindow( const int ) const; + void removeDockWindow( const int ); + void insertDockWindow( const int, QWidget* ); + void placeDockWindow( const int, Qt::DockWidgetArea ); virtual void start(); @@ -157,7 +158,7 @@ public: static int studyId(); virtual bool event( QEvent* ); - + virtual bool checkDataObject( LightApp_DataObject* theObj ); signals: @@ -197,7 +198,10 @@ protected: LightApp_Preferences* preferences( const bool ) const; virtual void createPreferences( LightApp_Preferences* ); virtual void preferencesChanged( const QString&, const QString& ); + + virtual void loadPreferences(); virtual void savePreferences(); + virtual void updateDesktopTitle(); virtual QMap activateModuleActions() const; @@ -224,15 +228,14 @@ private slots: void onMRUActivated( QString ); void onPreferenceChanged( QString&, QString&, QString& ); void onRenameWindow(); - void onVisibilityChanged( bool ); protected: void updateWindows(); void updateViewManagers(); void updateModuleActions(); - void loadWindowsGeometry(); - void saveWindowsGeometry(); + void loadDockWindowsState(); + void saveDockWindowsState(); void updatePreference( const QString&, const QString&, const QString& ); @@ -241,18 +244,25 @@ protected: void currentViewManagers( QStringList& ) const; void moduleIconNames( QMap& ) const; - void activateWindows(); bool isLibExists( const QString& ) const; + QDockWidget* windowDock( QWidget* ) const; + QByteArray dockWindowsState( const QMap&, const QMap& ) const; + void dockWindowsState( const QByteArray&, QMap&, QMap& ) const; + protected: - typedef QMap WindowMap; - typedef QMap WindowVisibilityMap; + typedef QPointer WinPtr; + typedef QMap WinMap; + typedef QMap WinVis; + typedef QMap WinGeom; protected: LightApp_Preferences* myPrefs; LightApp_SelectionMgr* mySelMgr; - WindowMap myWindows; - WindowVisibilityMap myWindowsVisible; + + WinMap myWin; + WinVis myWinVis; + WinGeom myWinGeom; SUIT_Accel* myAccel; diff --git a/src/LightApp/LightApp_ModuleAction.cxx b/src/LightApp/LightApp_ModuleAction.cxx index ef1723e67..c7ecc1bd1 100755 --- a/src/LightApp/LightApp_ModuleAction.cxx +++ b/src/LightApp/LightApp_ModuleAction.cxx @@ -167,6 +167,7 @@ QWidget* LightApp_ModuleAction::ComboAction::createWidget( QWidget* parent ) cb->setSizeAdjustPolicy( QComboBox::AdjustToContents ); cb->setFocusPolicy( Qt::NoFocus ); l->addWidget( cb ); + l->addSpacing( 3 ); connect( cb, SIGNAL( activatedId( int ) ), this, SIGNAL( activatedId( int ) ) ); diff --git a/src/Qtx/QtxAction.cxx b/src/Qtx/QtxAction.cxx index 1e46ce16d..e4da75af7 100755 --- a/src/Qtx/QtxAction.cxx +++ b/src/Qtx/QtxAction.cxx @@ -22,6 +22,7 @@ #include "QtxAction.h" #include +#include #include #include @@ -37,12 +38,12 @@ public: ActionNotify( bool add, QWidget* wid ) : QEvent( QEvent::User ), myAdd( add ), myWidget( wid ) {}; ~ActionNotify() {}; - bool isAdded() const { return myAdd; } - QWidget* widget() const { return myWidget; } + bool isAdded() const { return myAdd; } + QWidget* widget() const { return myWidget; } private: - bool myAdd; - QWidget* myWidget; + bool myAdd; + QPointer myWidget; }; /*! @@ -195,6 +196,9 @@ void QtxAction::removedFrom( QWidget* /*w*/ ) void QtxAction::customEvent( QEvent* e ) { ActionNotify* ae = (ActionNotify*)e; + if ( !ae->widget() ) + return; + if ( ae->isAdded() ) addedTo( ae->widget() ); else diff --git a/src/Qtx/QtxActionMenuMgr.cxx b/src/Qtx/QtxActionMenuMgr.cxx index f3b42a46d..2540721e3 100644 --- a/src/Qtx/QtxActionMenuMgr.cxx +++ b/src/Qtx/QtxActionMenuMgr.cxx @@ -1027,9 +1027,9 @@ bool QtxActionMenuMgr::load( const QString& fname, QtxActionMgr::Reader& r ) \param pid parent menu item ID \return \c true if parent menu item contains such child item */ -bool QtxActionMenuMgr::containsMenu( const QString& title, const int pid ) const +bool QtxActionMenuMgr::containsMenu( const QString& title, const int pid, const bool rec ) const { - return (bool)find( title, pid, false ); + return (bool)find( title, pid, rec ); } /*! @@ -1038,9 +1038,9 @@ bool QtxActionMenuMgr::containsMenu( const QString& title, const int pid ) const \param pid parent menu item ID \return \c true if parent menu item contains such child item */ -bool QtxActionMenuMgr::containsMenu( const int id, const int pid ) const +bool QtxActionMenuMgr::containsMenu( const int id, const int pid, const bool rec ) const { - return (bool)find( id, pid, false ); + return (bool)find( id, pid, rec ); } /*! diff --git a/src/Qtx/QtxActionMenuMgr.h b/src/Qtx/QtxActionMenuMgr.h index 96d15b51b..1f5079161 100644 --- a/src/Qtx/QtxActionMenuMgr.h +++ b/src/Qtx/QtxActionMenuMgr.h @@ -90,8 +90,8 @@ public: virtual bool load( const QString&, QtxActionMgr::Reader& ); - bool containsMenu( const QString&, const int ) const; - bool containsMenu( const int, const int ) const; + bool containsMenu( const QString&, const int, const bool = false ) const; + bool containsMenu( const int, const int, const bool = false ) const; QMenu* findMenu( const int ) const; diff --git a/src/Qtx/QtxActionMgr.cxx b/src/Qtx/QtxActionMgr.cxx index d8c52a09f..a1aa362b5 100644 --- a/src/Qtx/QtxActionMgr.cxx +++ b/src/Qtx/QtxActionMgr.cxx @@ -40,7 +40,10 @@ static qtx_actionlist qtx_separator_actions; void qtxSeparatorActionCleanup() { for ( qtx_actionlist::iterator it = qtx_separator_actions.begin(); it != qtx_separator_actions.end(); ++it ) - delete (QAction*)(*it); + { + QAction* a = *it; + delete a; + } } /*! diff --git a/src/Qtx/QtxActionToolMgr.cxx b/src/Qtx/QtxActionToolMgr.cxx index a13c60e3c..47b339edd 100644 --- a/src/Qtx/QtxActionToolMgr.cxx +++ b/src/Qtx/QtxActionToolMgr.cxx @@ -594,8 +594,8 @@ bool QtxActionToolMgr::isVisible( const int id, const int tid ) const return false; bool vis = false; - const NodeList& lst = myToolBars[tid].nodes; - for ( NodeList::const_iterator it = lst.begin(); it != lst.end() && !vis; ++it ) + const ToolBarInfo& inf = myToolBars[tid]; + for ( NodeList::const_iterator it = inf.nodes.begin(); it != inf.nodes.end() && !vis; ++it ) { const ToolNode& node = *it; if ( node.id == id ) diff --git a/src/Qtx/QtxDockWidget.cxx b/src/Qtx/QtxDockWidget.cxx index fd6f00371..2984e7164 100644 --- a/src/Qtx/QtxDockWidget.cxx +++ b/src/Qtx/QtxDockWidget.cxx @@ -43,6 +43,9 @@ public: virtual bool eventFilter( QObject*, QEvent* ); + bool isEmpty() const; + bool isVisible() const; + protected: virtual void customEvent( QEvent* ); @@ -56,11 +59,13 @@ private: void updateCaption(); void updateVisibility(); + void setEmpty( const bool ); + void setVisible( const bool ); + private: QtxDockWidget* myCont; bool myState; bool myEmpty; - bool myVisible; }; /*! @@ -73,7 +78,6 @@ QtxDockWidget::Watcher::Watcher( QtxDockWidget* cont ) myEmpty( false ) { myCont->installEventFilter( this ); - myVisible = myCont->isVisibleTo( myCont->parentWidget() ); installFilters(); } @@ -125,7 +129,7 @@ void QtxDockWidget::Watcher::shown( QtxDockWidget* dw ) if ( dw != myCont ) return; - myVisible = true; + setVisible( true ); } /*! @@ -137,7 +141,36 @@ void QtxDockWidget::Watcher::hidden( QtxDockWidget* dw ) if ( dw != myCont ) return; - myVisible = false; + setVisible( false ); +} + +bool QtxDockWidget::Watcher::isEmpty() const +{ + return myEmpty; +} + +bool QtxDockWidget::Watcher::isVisible() const +{ + bool vis = false; + if ( myCont && myCont->toggleViewAction() ) + vis = myCont->toggleViewAction()->isChecked(); + return vis; +} + +void QtxDockWidget::Watcher::setEmpty( const bool on ) +{ + myEmpty = on; +} + +void QtxDockWidget::Watcher::setVisible( const bool on ) +{ + if ( !myCont || !myCont->toggleViewAction() ) + return; + + bool block = myCont->toggleViewAction()->signalsBlocked(); + myCont->toggleViewAction()->blockSignals( true ); + myCont->toggleViewAction()->setChecked( on ); + myCont->toggleViewAction()->blockSignals( block ); } /*! @@ -148,10 +181,14 @@ void QtxDockWidget::Watcher::showContainer() if ( !myCont ) return; + bool vis = isVisible(); + QtxDockWidget* cont = myCont; myCont = 0; cont->show(); myCont = cont; + + setVisible( vis ); } /*! @@ -162,10 +199,14 @@ void QtxDockWidget::Watcher::hideContainer() if ( !myCont ) return; + bool vis = isVisible(); + QtxDockWidget* cont = myCont; myCont = 0; cont->hide(); myCont = cont; + + setVisible( vis ); } /*! @@ -216,10 +257,12 @@ void QtxDockWidget::Watcher::updateVisibility() for ( int i = 0; i < (int)l->count() && !vis; i++ ) vis = l->itemAt( i ) && l->itemAt( i )->widget() && l->itemAt( i )->widget()->isVisibleTo( myCont ); - if ( myEmpty == vis ) + bool empty = isEmpty(); + if ( empty == vis ) { - myEmpty = !vis; - if ( !myEmpty ) + empty = !vis; + setEmpty( empty ); + if ( !empty ) myCont->toggleViewAction()->setVisible( myState ); else { @@ -228,7 +271,7 @@ void QtxDockWidget::Watcher::updateVisibility() } } - vis = !myEmpty && myVisible; + vis = !empty && isVisible(); if ( vis != myCont->isVisibleTo( myCont->parentWidget() ) ) vis ? showContainer() : hideContainer(); } @@ -357,6 +400,12 @@ QSize QtxDockWidget::minimumSizeHint() const */ void QtxDockWidget::setVisible( bool on ) { + updateGeometry(); + if ( widget() ) + widget()->updateGeometry(); + + QDockWidget::setVisible( on && ( myWatcher ? !myWatcher->isEmpty() : true ) ); + if ( myWatcher ) { if ( on ) @@ -364,12 +413,6 @@ void QtxDockWidget::setVisible( bool on ) else myWatcher->hidden( this ); } - - updateGeometry(); - if ( widget() ) - widget()->updateGeometry(); - - QDockWidget::setVisible( on ); } /*! diff --git a/src/Qtx/QtxPreferenceMgr.cxx b/src/Qtx/QtxPreferenceMgr.cxx index ee4397694..1b12db5e6 100644 --- a/src/Qtx/QtxPreferenceMgr.cxx +++ b/src/Qtx/QtxPreferenceMgr.cxx @@ -130,7 +130,8 @@ void QtxPreferenceItem::Updater::customEvent( QEvent* /*e*/ ) \param parent parent preference item */ QtxPreferenceItem::QtxPreferenceItem( QtxPreferenceItem* parent ) -: myParent( 0 ) +: myParent( 0 ), +myEval( true ) { myId = generateId(); @@ -425,6 +426,16 @@ void QtxPreferenceItem::setOption( const QString& name, const QVariant& val ) sendItemChanges(); } +bool QtxPreferenceItem::isEvaluateValues() const +{ + return myEval; +} + +void QtxPreferenceItem::setEvaluateValues( const bool on ) +{ + myEval = on; +} + /*! \fn void QtxPreferenceItem::store(); \brief Save preference item (for example, to the resource file). @@ -588,8 +599,11 @@ bool QtxPreferenceItem::getBoolean( const bool val ) const */ QString QtxPreferenceItem::getString( const QString& val ) const { + QString res = val; QtxResourceMgr* resMgr = resourceMgr(); - return resMgr ? resMgr->stringValue( mySection, myParameter, val ) : val; + if ( resMgr ) + resMgr->value( mySection, myParameter, res, isEvaluateValues() ); + return res; } /*! @@ -748,9 +762,12 @@ void QtxPreferenceItem::triggerUpdate() \return property value or null QVariant if option is not set \sa setOptionValue() */ -QVariant QtxPreferenceItem::optionValue( const QString& /*name*/ ) const +QVariant QtxPreferenceItem::optionValue( const QString& name ) const { - return QVariant(); + QVariant val; + if ( name == "eval" || name == "evaluation" || name == "subst" || name == "substitution" ) + val = isEvaluateValues(); + return val; } /*! @@ -763,8 +780,13 @@ QVariant QtxPreferenceItem::optionValue( const QString& /*name*/ ) const \param val new property value \sa optionValue() */ -void QtxPreferenceItem::setOptionValue( const QString& /*name*/, const QVariant& /*val*/ ) +void QtxPreferenceItem::setOptionValue( const QString& name, const QVariant& val ) { + if ( name == "eval" || name == "evaluation" || name == "subst" || name == "substitution" ) + { + if ( val.canConvert( QVariant::Bool ) ) + setEvaluateValues( val.toBool() ); + } } /*! diff --git a/src/Qtx/QtxPreferenceMgr.h b/src/Qtx/QtxPreferenceMgr.h index cc3b2d913..7022351f9 100644 --- a/src/Qtx/QtxPreferenceMgr.h +++ b/src/Qtx/QtxPreferenceMgr.h @@ -73,6 +73,9 @@ public: QVariant option( const QString& ) const; void setOption( const QString&, const QVariant& ); + bool isEvaluateValues() const; + void setEvaluateValues( const bool ); + virtual void store() = 0; virtual void retrieve() = 0; @@ -125,6 +128,7 @@ private: QtxPreferenceItem* myParent; ItemList myChildren; + bool myEval; QIcon myIcon; QString myTitle; QString mySection; diff --git a/src/Qtx/QtxToolBar.cxx b/src/Qtx/QtxToolBar.cxx index f450db201..3651ca387 100644 --- a/src/Qtx/QtxToolBar.cxx +++ b/src/Qtx/QtxToolBar.cxx @@ -41,6 +41,9 @@ public: virtual bool eventFilter( QObject*, QEvent* ); + bool isEmpty() const; + bool isVisible() const; + protected: virtual void customEvent( QEvent* ); @@ -55,11 +58,13 @@ private: void updateVisibility(); + void setEmpty( const bool ); + void setVisible( const bool ); + private: QtxToolBar* myCont; bool myState; bool myEmpty; - bool myVisible; }; /*! @@ -73,7 +78,6 @@ QtxToolBar::Watcher::Watcher( QtxToolBar* cont ) myEmpty( false ) { myCont->installEventFilter( this ); - myVisible = myCont->isVisibleTo( myCont->parentWidget() ); installFilters(); } @@ -116,7 +120,7 @@ void QtxToolBar::Watcher::shown( QtxToolBar* tb ) if ( tb != myCont ) return; - myVisible = true; + setVisible( true ); } /*! @@ -128,7 +132,36 @@ void QtxToolBar::Watcher::hidden( QtxToolBar* tb ) if ( tb != myCont ) return; - myVisible = false; + setVisible( false ); +} + +bool QtxToolBar::Watcher::isEmpty() const +{ + return myEmpty; +} + +bool QtxToolBar::Watcher::isVisible() const +{ + bool vis = false; + if ( myCont && myCont->toggleViewAction() ) + vis = myCont->toggleViewAction()->isChecked(); + return vis; +} + +void QtxToolBar::Watcher::setEmpty( const bool on ) +{ + myEmpty = on; +} + +void QtxToolBar::Watcher::setVisible( const bool on ) +{ + if ( !myCont || !myCont->toggleViewAction() ) + return; + + bool block = myCont->toggleViewAction()->signalsBlocked(); + myCont->toggleViewAction()->blockSignals( true ); + myCont->toggleViewAction()->setChecked( on ); + myCont->toggleViewAction()->blockSignals( block ); } /*! @@ -139,10 +172,14 @@ void QtxToolBar::Watcher::showContainer() if ( !myCont ) return; + bool vis = isVisible(); + QtxToolBar* cont = myCont; myCont = 0; cont->show(); myCont = cont; + + setVisible( vis ); } /*! @@ -153,10 +190,14 @@ void QtxToolBar::Watcher::hideContainer() if ( !myCont ) return; + bool vis = isVisible(); + QtxToolBar* cont = myCont; myCont = 0; cont->hide(); myCont = cont; + + setVisible( vis ); } /*! @@ -205,9 +246,7 @@ void QtxToolBar::Watcher::updateVisibility() return; bool vis = false; - QList actList = myCont->actions(); - for ( QList::const_iterator it = actList.begin(); it != actList.end() && !vis; ++it ) { if ( (*it)->isSeparator() ) @@ -217,10 +256,12 @@ void QtxToolBar::Watcher::updateVisibility() } QMainWindow* mw = myCont->mainWindow(); - if ( mw && myEmpty == vis ) + bool empty = isEmpty(); + if ( mw && empty == vis ) { - myEmpty = !vis; - if ( !myEmpty ) + empty = !vis; + setEmpty( empty ); + if ( !empty ) myCont->toggleViewAction()->setVisible( myState ); else { @@ -229,7 +270,7 @@ void QtxToolBar::Watcher::updateVisibility() } } - vis = !myEmpty && myVisible; + vis = !empty && isVisible(); if ( vis != myCont->isVisibleTo( myCont->parentWidget() ) ) vis ? showContainer() : hideContainer(); } diff --git a/src/Qtx/QtxWorkstack.cxx b/src/Qtx/QtxWorkstack.cxx index 0927f0745..4796645d1 100644 --- a/src/Qtx/QtxWorkstack.cxx +++ b/src/Qtx/QtxWorkstack.cxx @@ -1195,10 +1195,10 @@ bool QtxWorkstackChild::eventFilter( QObject* o, QEvent* e ) if ( e->type() == QEvent::WindowTitleChange || e->type() == QEvent::WindowIconChange ) emit captionChanged( this ); - if ( !e->spontaneous() && ( e->type() == QEvent::Show || e->type() == QEvent::ShowToParent ) ) + if ( !e->spontaneous() && e->type() == QEvent::ShowToParent ) emit shown( this ); - if ( !e->spontaneous() && ( e->type() == QEvent::Hide || e->type() == QEvent::HideToParent ) ) + if ( !e->spontaneous() && e->type() == QEvent::HideToParent ) emit hidden( this ); if ( e->type() == QEvent::FocusIn ) diff --git a/src/SUIT/SUIT_Application.cxx b/src/SUIT/SUIT_Application.cxx index d841f3e63..f8e0d9e9c 100755 --- a/src/SUIT/SUIT_Application.cxx +++ b/src/SUIT/SUIT_Application.cxx @@ -67,7 +67,7 @@ SUIT_Desktop* SUIT_Application::desktop() \return FALSE if application can not be closed (because of non saved data for example). This method called by SUIT_Session whin closing of application was requested. */ -bool SUIT_Application::isPossibleToClose( bool& closePermanently ) +bool SUIT_Application::isPossibleToClose( bool& ) { return true; } @@ -548,6 +548,16 @@ int SUIT_Application::actionId( const QAction* a ) const return id; } +QList SUIT_Application::actions() const +{ + return myActionMap.values(); +} + +QList SUIT_Application::actionIds() const +{ + return myActionMap.keys(); +} + /*! Creates action and registers it both in menu manager and tool manager \return new instance of action diff --git a/src/SUIT/SUIT_Application.h b/src/SUIT/SUIT_Application.h index dd84cd031..7d7827076 100755 --- a/src/SUIT/SUIT_Application.h +++ b/src/SUIT/SUIT_Application.h @@ -149,6 +149,10 @@ protected: static QAction* separator(); QAction* action( const int ) const; int actionId( const QAction* ) const; + + QList actions() const; + QList actionIds() const; + int registerAction( const int, QAction* ); QAction* createAction( const int, const QString&, const QIcon&, const QString&, const QString&, const int, QObject* = 0,