From a5c16fe617c3338094a7a5c0d13590334931910f Mon Sep 17 00:00:00 2001 From: adv Date: Mon, 8 Feb 2010 08:30:34 +0000 Subject: [PATCH] Improve Help menu management --- src/LightApp/LightApp_Application.cxx | 39 ++++++++++++++++++--------- src/LightApp/resources/LightApp.xml | 16 +++++++++++ src/SalomeApp/resources/SalomeApp.xml | 17 ++++++++++++ 3 files changed, 60 insertions(+), 12 deletions(-) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 3a6d053b2..8257b5f33 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -451,6 +451,12 @@ void LightApp_Application::createActionForViewer( const int id, } /*!Create actions:*/ + +typedef struct { + QString filePath; + QString subMenu; +} helpInfoStruct; + void LightApp_Application::createActions() { STD_Application::createActions(); @@ -465,9 +471,8 @@ void LightApp_Application::createActions() //! Help for modules int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 ); - int helpModuleMenu = createMenu( tr( "MEN_DESK_MODULE_HELP" ), helpMenu, -1, 0 ); createMenu( separator(), helpMenu, -1, 1 ); - + helpInfoStruct helpData; QStringList aModuleList; modules( aModuleList, false ); aModuleList.prepend( "GUI" ); @@ -476,22 +481,23 @@ void LightApp_Application::createActions() int id = LightApp_Application::UserID + FIRST_HELP_ID; // help for other existing modules + QString aModule; foreach( aModule, aModuleList ) { if ( aModule.isEmpty() ) // module title (user name) continue; QString modName = moduleName( aModule ); // module name - IMap paramValue; + IMap paramValue; if ( modName.isEmpty() ) modName = aModule; // for KERNEL and GUI QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir variable QString modDir = getenv( rootDir.toLatin1().constData() ); // module root dir - QString docSection; if (resMgr->hasValue( modName, "documentation" ) ) docSection = resMgr->stringValue(modName, "documentation"); else if ( resMgr->hasSection( modName + "_documentation" ) ) docSection = modName + "_documentation"; if ( !docSection.isEmpty() ) { + helpData.subMenu = resMgr->stringValue( docSection, "sub_menu", "" ).arg( modName ); QStringList listOfParam = resMgr->parameters( docSection ); foreach( QString paramName, listOfParam ){ QString valueStr = resMgr->stringValue( docSection, paramName ); @@ -499,8 +505,10 @@ void LightApp_Application::createActions() QFileInfo fi( valueStr ); if ( fi.isRelative() && !modDir.isEmpty() ) valueStr = Qtx::addSlash( modDir ) + valueStr; - if ( QFile::exists( valueStr ) ) - paramValue.insert( paramName, valueStr ); + if ( QFile::exists( valueStr ) ){ + helpData.filePath = valueStr; + paramValue.insert( paramName, helpData ); + } } } } @@ -508,20 +516,27 @@ void LightApp_Application::createActions() if ( paramValue.isEmpty() && !modDir.isEmpty() ) { QStringList idxLst = QStringList() << modDir << "share" << "doc" << "salome" << "gui" << modName << "index.html"; QString indexFile = idxLst.join( QDir::separator() ); // index file - if ( QFile::exists( indexFile ) ) - paramValue.insert( tr( "%1 Help" ).arg( aModule ), indexFile ); + if ( QFile::exists( indexFile ) ){ + helpData.filePath = indexFile; + paramValue.insert( tr( "%1 Help" ).arg( aModule ), helpData ); + } } - IMapConstIterator fileIt; + IMapConstIterator fileIt; for ( fileIt = paramValue.begin(); fileIt != paramValue.end(); fileIt++ ) { QString helpFileName = fileIt.key(); - QString helpFilePath = fileIt.value(); + helpData = fileIt.value(); QAction* a = createAction( id, helpFileName, resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ), helpFileName, helpFileName, 0, desk, false, this, SLOT( onHelpContentsModule() ) ); - a->setData( helpFilePath ); - createMenu( a, helpModuleMenu, -1 ); + a->setData( helpData.filePath ); + if ( !helpData.subMenu.isEmpty() ){ + int helpSubMenu = createMenu( helpData.subMenu, helpMenu, -1, 0 ); + createMenu( a, helpSubMenu, -1 ); + } + else + createMenu( a, helpMenu, -1, 0 ); id++; } } diff --git a/src/LightApp/resources/LightApp.xml b/src/LightApp/resources/LightApp.xml index 348795f7a..42ea7105b 100644 --- a/src/LightApp/resources/LightApp.xml +++ b/src/LightApp/resources/LightApp.xml @@ -157,4 +157,20 @@ +
+ +
+
+ +
+
+ + + +
+
+ + + +
diff --git a/src/SalomeApp/resources/SalomeApp.xml b/src/SalomeApp/resources/SalomeApp.xml index 956a3a13c..38ab2e1a1 100644 --- a/src/SalomeApp/resources/SalomeApp.xml +++ b/src/SalomeApp/resources/SalomeApp.xml @@ -205,4 +205,21 @@ +
+ +
+
+ +
+
+ + + +
+
+ + + +
+ -- 2.39.2