Salome HOME
0023551: [EDF] Help menu : option to set links
authorvsr <vsr@opencascade.com>
Fri, 27 Apr 2018 09:02:10 +0000 (12:02 +0300)
committervsr <vsr@opencascade.com>
Fri, 27 Apr 2018 09:23:15 +0000 (12:23 +0300)
src/LightApp/LightApp_Application.cxx
src/LightApp/resources/LightApp.xml
src/STD/resources/about.png [changed mode: 0755->0644]

index 351397e107c26582630d112b4ee77a3bcdd41325..128df3e64ff5fde858c1a40663fb0ef3e3f8b286 100644 (file)
 #include <QTreeView>
 #include <QMimeData>
 #include <QShortcut>
+#include <QRegExp>
 
 #include <utilities.h>
 
@@ -597,47 +598,59 @@ void LightApp_Application::createActions()
                 tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
                 Qt::CTRL+Qt::Key_P, desk, false, this, SLOT( onPreferences() ) );
 
-  // Help menu:
-
-  // - Help for modules
+  // Help menu
 
   int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
-  createMenu( separator(), helpMenu, -1, 10 );
   
-  // Site && forum
   int id = LightApp_Application::UserID + FIRST_HELP_ID;
 
-  QString site = tr ( "SALOME_SITE" );
-  QAction* as = createAction( id, site,
-                             resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
-                             site, site,
-                             0, desk, false, this, SLOT( onHelpOnline() ) );
-  as->setData( "salome-platform.org" );
-  createMenu( as, helpMenu, -1, 0 );
-  id++;
-
-  QString forum = tr ( "SALOME_FORUM" );
-
-  QAction* af = createAction( helpMenu, forum,
-                             resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
-                             forum, forum,
-                             0, desk, false, this, SLOT( onHelpOnline() ) );
-  af->setData( "salome-platform.org/forum" );
-  createMenu( af, helpMenu, -1, 0 );
-  id++;
-
-  createMenu( separator(), helpMenu, -1, 0 );
-
-  // YouTube channel
-  QString video = tr ( "SALOME_VIDEO_TUTORIALS" );
-  QAction* av = createAction( helpMenu, video,
-                             resMgr->loadPixmap( "LightApp", tr( "ICON_LIFE_RIGN" ), false ),
-                             video, video,
-                             0, desk, false, this, SLOT( onHelpOnline() ) );
-  av->setData( "www.youtube.com/playlist?list=PLgvBxFyGVRbZZz4wVvP36xXQL-S81RZsc&disable_polymer=true" );
-  createMenu( av, helpMenu, -1, 0 );
-  id++;
-
+  // a) Link to web site
+  QString url = resMgr->stringValue("GUI", "site_url");
+  if ( !url.isEmpty() ) {
+    QString title = tr ( "SALOME_SITE" );
+    QAction* as = createAction( id, title,
+                               resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
+                               title, title,
+                               0, desk, false, this, SLOT( onHelpOnline() ) );
+    as->setData( url );
+    createMenu( as, helpMenu, -1, 0 );
+    id++;
+  }
+
+  // b) Link to Forum
+  url = resMgr->stringValue("GUI", "forum_url");
+  if ( !url.isEmpty() ) {
+    QString title = tr ( "SALOME_FORUM" );
+    QAction* af = createAction( helpMenu, title,
+                               resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
+                               title, title,
+                               0, desk, false, this, SLOT( onHelpOnline() ) );
+    af->setData( url );
+    createMenu( af, helpMenu, -1, 0 );
+    id++;
+  }
+
+  // c) Link to YouTube channel
+  url = resMgr->stringValue("GUI", "channel_url");
+  if ( !url.isEmpty() ) {
+    createMenu( separator(), helpMenu, -1, 0 );
+    QString title = tr ( "SALOME_VIDEO_TUTORIALS" );
+    QAction* av = createAction( helpMenu, title,
+                               resMgr->loadPixmap( "LightApp", tr( "ICON_LIFE_RIGN" ), false ),
+                               title, title,
+                               0, desk, false, this, SLOT( onHelpOnline() ) );
+    av->setData( url );
+    createMenu( av, helpMenu, -1, 0 );
+    id++;
+  }
+
+  // d) Help for modules
+
+  // - First create top-level menus to preserve correct order
+  QString userGuide = "User's Guide";
+  QString devGuide = "Developer's Guide";
+  createMenu( userGuide, helpMenu, -1, 5 );
+  createMenu( devGuide, helpMenu, -1, 5 );
 
   QStringList aModuleList;
   modules( aModuleList, false );
@@ -652,8 +665,8 @@ void LightApp_Application::createActions()
     QString helpSubMenu;                                             // help submenu name (empty if not needed)
     QString modName = moduleName( aModule );                         // module name
     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 rootDir = QString( "%1_ROOT_DIR" ).arg( modName );       // module root dir env variable
+    QString modDir  = getenv( rootDir.toLatin1().constData() );      // module root dir path
     QString docSection;
     if (resMgr->hasValue( modName, "documentation" ) )
       docSection = resMgr->stringValue(modName, "documentation");
@@ -689,8 +702,15 @@ void LightApp_Application::createActions()
         helpFileName.replace( "//", "" );
       // obtain submenus hierarchy if given
       QStringList smenus = helpFileName.split( "/" );
-      helpFileName = smenus.last();
-      smenus.removeLast();
+      helpFileName = smenus.takeLast();
+      // workaround for User's Guide and Developer's Guide to avoid having single item in module's submenu.
+      if ( helpFileName == userGuide || helpFileName == devGuide ) {
+       QString menuPath = smenus.join( "/" );
+       QStringList allKeys = helpData.keys();
+       QStringList total = allKeys.filter( QRegExp( QString( "^%1" ).arg( menuPath ) ) );
+       if ( total.count() == 1 && smenus.count() > 0 )
+         helpFileName = smenus.takeLast();
+      }
       QAction* a = createAction( id, helpFileName,
                                  resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
                                  helpFileName, helpFileName,
@@ -701,17 +721,16 @@ void LightApp_Application::createActions()
       }
       // create sub-menus hierarchy
       int menuId = helpMenu;
-      foreach ( QString subMenu, smenus ) {
-        menuId = createMenu( subMenu, menuId, -1, 0 );
-      }
-      createMenu( a, menuId, -1, 0 );
+      foreach ( QString subMenu, smenus )
+        menuId = createMenu( subMenu, menuId, -1, 5 );
+      createMenu( a, menuId, -1, ( menuId != helpMenu && (helpFileName == userGuide || helpFileName == devGuide) ) ? 0 : 5 );
       id++;
     }
   }
 
   // - Additional help items
 
-  createMenu( separator(), helpMenu, -1, 5 );
+  createMenu( separator(), helpMenu, -1, 10 );
 
   QStringList addHelpItems = resMgr->parameters( "add_help" );
   foreach ( QString addHelpItem, addHelpItems ) {
@@ -722,7 +741,7 @@ void LightApp_Application::createActions()
                                  addHelpItem, addHelpItem,
                                  0, desk, false, this, SLOT( onHelpContentsModule() ) );
       a->setData( valueStr );
-      createMenu( a, helpMenu, -1, 5 );
+      createMenu( a, helpMenu, -1, 10 );
       id++;
     }
   }
index 5e9e844abafec0ff994bbf62ded687d8d85656f9..9004e7b2ae8d9f207b1a16d1310085268c3a944e 100644 (file)
   </section>
   <section name="GUI" >
     <parameter name="documentation"     value="gui_help"/>
+    <parameter name="site_url"          value="www.salome-platform.org"/>
+    <parameter name="forum_url"         value="www.salome-platform.org/forum"/>
+    <parameter name="channel_url"       value="www.youtube.com/playlist?list=PLgvBxFyGVRbZZz4wVvP36xXQL-S81RZsc&amp;disable_polymer=true"/>
   </section>
   <section name="KERNEL" >
     <parameter name="documentation"     value="kernel_help"/>
old mode 100755 (executable)
new mode 100644 (file)
index 25dbd81..747c453
Binary files a/src/STD/resources/about.png and b/src/STD/resources/about.png differ