Salome HOME
Fix broken documentation links
authorvsr <vsr@opencascade.com>
Thu, 17 Feb 2022 10:40:56 +0000 (13:40 +0300)
committervsr <vsr@opencascade.com>
Thu, 17 Feb 2022 10:40:56 +0000 (13:40 +0300)
src/LightApp/LightApp_Application.cxx
src/LightApp/resources/LightApp.xml

index 88750b9f545df325769efd66facead085bef716f..e687135f6a656301e7679061818e350dba879162 100644 (file)
 #include <utilities.h>
 
 #define FIRST_HELP_ID 1000000
+#define HAS_WWW_URL true
+#define HAS_FORUM_URL true
+#define HAS_YOUTUBE_URL true
+#define HAS_TUTORIAL_URL false
 
 #ifndef DISABLE_SALOMEOBJECT
   #include <SALOME_InteractiveObject.hxx>
@@ -301,6 +305,24 @@ namespace
       result = QLocale( lang ).nativeLanguageName();
     return result;
   }
+
+  QString getHelpItem( const QString& section, const QString& parameter, const QString& root = QString() )
+  {
+    SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+    foreach( QString item, resMgr->stringValue( section, parameter ).split( ";;", QString::SkipEmptyParts ) )
+    {
+      if ( item.startsWith( "http", Qt::CaseInsensitive ) )
+        return item;
+      QString path = item;
+      path.remove( QRegExp( "#.*$" ) );
+      QFileInfo fi( path );
+      if ( fi.isRelative() && !root.isEmpty() )
+        path = Qtx::addSlash( root ) + path;
+      if ( QFile::exists( path ) )
+        return item;
+    }
+    return QString();
+  }
 }
 
 /*!Create new instance of LightApp_Application.*/
@@ -601,54 +623,63 @@ void LightApp_Application::createActions()
 
   int id = LightApp_Application::UserID + FIRST_HELP_ID;
 
+  QString url;
+
   // a) Link to web site
-  QString url = resMgr->stringValue("GUI", "site_url");
-  if ( !url.isEmpty() ) {
-    QString title = tr ( "SALOME_SITE" );
-    QAction* as = createAction( WebSiteId, title,
-                               resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
-                               title, title,
-                               0, desk, false, this, SLOT( onHelpContentsModule() ) );
-    as->setData( url );
-    createMenu( as, helpMenu, -1, 0 );
+  if ( HAS_WWW_URL ) {
+    url = resMgr->stringValue("GUI", "site_url");
+    if ( !url.isEmpty() ) {
+      QString title = tr ( "SALOME_SITE" );
+      QAction* as = createAction( WebSiteId, title,
+                                  resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
+                                  title, title,
+                                  0, desk, false, this, SLOT( onHelpContentsModule() ) );
+      as->setData( url );
+      createMenu( as, helpMenu, -1, 0 );
+    }
   }
 
   // b) Link to Forum
-  url = resMgr->stringValue("GUI", "forum_url");
-  if ( !url.isEmpty() ) {
-    QString title = tr ( "SALOME_FORUM" );
-    QAction* af = createAction( ForumId, title,
-                               resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
-                               title, title,
-                               0, desk, false, this, SLOT( onHelpContentsModule() ) );
-    af->setData( url );
-    createMenu( af, helpMenu, -1, 0 );
+  if ( HAS_FORUM_URL ) {
+    url = resMgr->stringValue("GUI", "forum_url");
+    if ( !url.isEmpty() ) {
+      QString title = tr ( "SALOME_FORUM" );
+      QAction* af = createAction( ForumId, title,
+                                  resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
+                                  title, title,
+                                  0, desk, false, this, SLOT( onHelpContentsModule() ) );
+      af->setData( url );
+      createMenu( af, helpMenu, -1, 0 );
+    }
   }
 
   // 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( VideosId, title,
-                               resMgr->loadPixmap( "LightApp", tr( "ICON_LIFE_RIGN" ), false ),
-                               title, tr( "PRP_SALOME_VIDEO_TUTORIALS" ),
-                               0, desk, false, this, SLOT( onHelpContentsModule() ) );
-    av->setData( url );
-    createMenu( av, helpMenu, -1, 0 );
+  if ( HAS_YOUTUBE_URL ) {
+    url = resMgr->stringValue("GUI", "channel_url");
+    if ( !url.isEmpty() ) {
+      createMenu( separator(), helpMenu, -1, 0 );
+      QString title = tr ( "SALOME_VIDEO_TUTORIALS" );
+      QAction* av = createAction( VideosId, title,
+                                  resMgr->loadPixmap( "LightApp", tr( "ICON_LIFE_RIGN" ), false ),
+                                  title, tr( "PRP_SALOME_VIDEO_TUTORIALS" ),
+                                  0, desk, false, this, SLOT( onHelpContentsModule() ) );
+      av->setData( url );
+      createMenu( av, helpMenu, -1, 0 );
+    }
   }
 
   // d) Link to Tutorials
-
-  url = resMgr->stringValue("GUI", "tutorials_url");
-  if ( !url.isEmpty() ) {
-    QString title = tr ( "SALOME_TUTORIALS" );
-    QAction* as = createAction( TutorialsId, title,
-                               resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
-                               title, tr( "PRP_SALOME_TUTORIALS" ),
-                               0, desk, false, this, SLOT( onHelpContentsModule() ) );
-    as->setData( url );
-    createMenu( as, helpMenu, -1, 0 );
+  if ( HAS_TUTORIAL_URL ) {
+    url = resMgr->stringValue("GUI", "tutorials_url");
+    if ( !url.isEmpty() ) {
+      QString title = tr ( "SALOME_TUTORIALS" );
+      QAction* as = createAction( TutorialsId, title,
+                                  resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
+                                  title, tr( "PRP_SALOME_TUTORIALS" ),
+                                  0, desk, false, this, SLOT( onHelpContentsModule() ) );
+      as->setData( url );
+      createMenu( as, helpMenu, -1, 0 );
+    }
   }
 
   // e) Help for modules
@@ -673,7 +704,7 @@ void LightApp_Application::createActions()
     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 env variable
-    QString modDir  = Qtx::getenv( rootDir.toUtf8().constData() );        // module root dir path
+    QString modDir  = Qtx::getenv( rootDir.toUtf8().constData() );   // module root dir path
     QString docSection;
     if (resMgr->hasValue( modName, "documentation" ) )
       docSection = resMgr->stringValue(modName, "documentation");
@@ -683,29 +714,11 @@ void LightApp_Application::createActions()
       helpSubMenu = resMgr->stringValue( docSection, "sub_menu", "" );
       if ( helpSubMenu.contains( "%1" ) )
         helpSubMenu = helpSubMenu.arg( aModule );
-      QStringList listOfParam = resMgr->parameters( docSection );
-      foreach( QString paramName, listOfParam ) {
-        QString valueStr = resMgr->stringValue( docSection, paramName );
-        if ( !valueStr.isEmpty() ) {
-          QStringList valueItems = valueStr.split( ";;", QString::SkipEmptyParts );
-          foreach( QString item, valueItems ) {
-            if ( item.startsWith( "http", Qt::CaseInsensitive ) ) {
-              QString key = paramName.contains( "%1" ) ? paramName.arg( aModule ) : paramName;
-              helpData.insert( key, item );
-              break;
-            }
-            else {
-              QFileInfo fi( item );
-              if ( fi.isRelative() && !modDir.isEmpty() )
-                item = Qtx::addSlash( modDir ) + item;
-              if ( QFile::exists( item ) ) {
-                QString key = paramName.contains( "%1" ) ? paramName.arg( aModule ) : paramName;
-                helpData.insert( key, item );
-                break;
-              }
-            }
-          }
-        }
+      foreach( QString paramName, resMgr->parameters( docSection ) ) {
+        QString key = paramName.contains( "%1" ) ? paramName.arg( aModule ) : paramName;
+        QString helpItem = getHelpItem( docSection, paramName );
+        if ( !helpItem.isEmpty() )
+          helpData.insert( key, helpItem );
       }
     }
 
@@ -756,20 +769,15 @@ void LightApp_Application::createActions()
 
   QStringList addHelpItems = resMgr->parameters( "add_help" );
   foreach ( QString paramName, addHelpItems ) {
-    QString valueStr = resMgr->stringValue( "add_help", paramName );
-    if ( !valueStr.isEmpty() ) {
-      QStringList valueItems = valueStr.split( ";;", QString::SkipEmptyParts );
-      foreach( QString item, valueItems ) {
-        if ( item.startsWith( "http", Qt::CaseInsensitive ) || QFile::exists( item ) ) {
-          QPixmap helpIcon = item.startsWith( "http", Qt::CaseInsensitive ) ?
-            resMgr->loadPixmap( "STD", tr( "ICON_WWW" ), false ) : resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false );
-          QAction* a = createAction( id++, paramName, helpIcon, paramName, paramName,
-                                     0, desk, false, this, SLOT( onHelpContentsModule() ) );
-          a->setData( item );
-          createMenu( a, helpMenu, -1, 10 );
-          break;
-        }
-      }
+    QString helpItem = getHelpItem( "add_help", paramName );
+    if ( !helpItem.isEmpty() )
+    {
+      QPixmap helpIcon = helpItem.startsWith( "http", Qt::CaseInsensitive ) ?
+        resMgr->loadPixmap( "STD", tr( "ICON_WWW" ), false ) : resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false );
+      QAction* a = createAction( id++, paramName, helpIcon, paramName, paramName,
+                                 0, desk, false, this, SLOT( onHelpContentsModule() ) );
+      a->setData( helpItem );
+      createMenu( a, helpMenu, -1, 10 );
     }
   }
 
@@ -4180,8 +4188,10 @@ void LightApp_Application::updateWindows()
     infoPanel()->addLabel( action( FileNewId )->statusTip(), grp );
     infoPanel()->addAction( action( FileOpenId ), grp );
     infoPanel()->addLabel( action( FileOpenId )->statusTip(), grp );
-    infoPanel()->addAction( action( TutorialsId ), grp );
-    infoPanel()->addLabel( action( TutorialsId )->statusTip(), grp );
+    if ( HAS_TUTORIAL_URL ) {
+      infoPanel()->addAction( action( TutorialsId ), grp );
+      infoPanel()->addLabel( action( TutorialsId )->statusTip(), grp );
+    }
     infoPanel()->addAction( action( VideosId ), grp );
     infoPanel()->addLabel( action( VideosId )->statusTip(), grp );
 
index aec839256351bd850779291b8ccabf527deca6ec..4643e5859a556f6d254705cba1c02e0bb993fd78 100644 (file)
   </section>
   <section name="GUI" >
     <parameter name="documentation"     value="gui_help"/>
-    <parameter name="site_url"          value="http://www.salome-platform.org"/>
-    <parameter name="tutorials_url"     value="https://www.salome-platform.org/user-section/salome-tutorials"/>
-    <parameter name="forum_url"         value="http://www.salome-platform.org/forum"/>
+    <parameter name="site_url"          value="https://www.salome-platform.org"/>
+    <parameter name="tutorials_url"     value="https://old.salome-platform.org/user-section/salome-tutorials"/>
+    <parameter name="forum_url"         value="https://discourse.salome-platform.org"/>
     <parameter name="channel_url"       value="https://www.youtube.com/playlist?list=PLgvBxFyGVRbZZz4wVvP36xXQL-S81RZsc&amp;disable_polymer=true"/>
   </section>
   <section name="KERNEL" >
     <parameter name="documentation"     value="kernel_help"/>
   </section>
   <section name="gui_help" >
-    <parameter name="User's Guide/GUI module"      value="${GUI_ROOT_DIR}/share/doc/salome/gui/GUI/index.html;;http://docs.salome-platform.org/latest/gui/GUI/index.html"/>
-    <parameter name="Developer's Guide/GUI module" value="${GUI_ROOT_DIR}/share/doc/salome/tui/GUI/index.html;;http://docs.salome-platform.org/latest/tui/GUI/index.html"/>
+    <parameter name="User's Guide/GUI module"      value="${GUI_ROOT_DIR}/share/doc/salome/gui/GUI/index.html;;https://docs.salome-platform.org/latest/gui/GUI/index.html"/>
+    <parameter name="Developer's Guide/GUI module" value="${GUI_ROOT_DIR}/share/doc/salome/tui/GUI/index.html;;https://docs.salome-platform.org/latest/tui/GUI/index.html"/>
   </section>
   <section name="kernel_help" >
-    <parameter name="Developer's Guide/KERNEL module" value="${KERNEL_ROOT_DIR}/share/doc/salome/tui/KERNEL/index.html;;http://docs.salome-platform.org/latest/tui/KERNEL/index.html"/>
+    <parameter name="Developer's Guide/KERNEL module" value="${KERNEL_ROOT_DIR}/share/doc/salome/tui/KERNEL/index.html;;https://docs.salome-platform.org/latest/tui/KERNEL/index.html"/>
   </section>
   <section name="notification" >
     <parameter name="timeout" value="10"/>
   </section>
   <section name="add_help">
     <!-- Additional help resources -->
-    <parameter name="Developer resources"  value="${DOCUMENTATION_ROOT_DIR}/share/doc/salome/main/index.html;;${DOCUMENTATION_ROOT_DIR}/index.html;;http://docs.salome-platform.org/latest/index.html" />
+    <parameter name="Developer resources"  value="${DOCUMENTATION_ROOT_DIR}/share/doc/salome/main/tui.html#guides;;${DOCUMENTATION_ROOT_DIR}/index.html;;https://docs.salome-platform.org/latest/main/tui.html#guides" />
   </section>
  <section name="windows_geometry">
   <parameter name="nomodule" value="#00 #00 #00 #FF #00 #00 #00 #00 #FD #00 #00 #00 #03 #00 #00 #00 #00 #00 #00 #01 #00 #00 #00 #02 #62 #FC #02 #00 #00 #00 #01 #FB #00 #00 #00 #22 #00 #6F #00 #62 #00 #6A #00 #65 #00 #63 #00 #74 #00 #42 #00 #72 #00 #6F #00 #77 #00 #73 #00 #65 #00 #72 #00 #44 #00 #6F #00 #63 #00 #6B #01 #00 #00 #00 #3B #00 #00 #02 #62 #00 #00 #00 #59 #00 #FF #FF #FF #00 #00 #00 #01 #00 #00 #00 #DC #00 #00 #02 #62 #FC #02 #00 #00 #00 #01 #FB #00 #00 #00 #1A #00 #69 #00 #6E #00 #66 #00 #6F #00 #50 #00 #61 #00 #6E #00 #65 #00 #6C #00 #44 #00 #6F #00 #63 #00 #6B #01 #00 #00 #00 #3B #00 #00 #02 #62 #00 #00 #02 #62 #00 #FF #FF #FF #00 #00 #00 #03 #00 #00 #04 #C3 #00 #00 #00 #59 #FC #01 #00 #00 #00 #01 #FB #00 #00 #00 #22 #00 #70 #00 #79 #00 #74 #00 #68 #00 #6F #00 #6E #00 #43 #00 #6F #00 #6E #00 #73 #00 #6F #00 #6C #00 #65 #00 #44 #00 #6F #00 #63 #00 #6B #01 #00 #00 #00 #00 #00 #00 #04 #C3 #00 #00 #00 #46 #00 #FF #FF #FF #00 #00 #02 #DB #00 #00 #02 #62 #00 #00 #00 #04 #00 #00 #00 #04 #00 #00 #00 #08 #00 #00 #00 #08 #FC #00 #00 #00 #01 #00 #00 #00 #02 #00 #00 #00 #03 #00 #00 #00 #1C #00 #53 #00 #61 #00 #6C #00 #6F #00 #6D #00 #65 #00 #53 #00 #74 #00 #61 #00 #6E #00 #64 #00 #61 #00 #72 #00 #64 #01 #00 #00 #00 #00 #FF #FF #FF #FF #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #1A #00 #53 #00 #61 #00 #6C #00 #6F #00 #6D #00 #65 #00 #4D #00 #6F #00 #64 #00 #75 #00 #6C #00 #65 #00 #73 #01 #00 #00 #00 #BC #FF #FF #FF #FF #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #00 #0E #00 #50 #00 #6C #00 #75 #00 #67 #00 #69 #00 #6E #00 #73 #00 #00 #00 #00 #22 #FF #FF #FF #FF #00 #00 #00 #00 #00 #00 #00 #00"/>