]> SALOME platform Git repositories - modules/gui.git/blobdiff - src/LightApp/LightApp_Application.cxx
Salome HOME
bos #20215 Help panels into SALOME for new users
[modules/gui.git] / src / LightApp / LightApp_Application.cxx
index 1aa01cf53bf075d186cc28c3843646a311ebe0a4..d9379a40acc3b64d9c470d541c307e98ac8985e4 100644 (file)
@@ -88,6 +88,7 @@
 #include <QtxFontEdit.h>
 #include <QtxToolBar.h>
 #include <QtxTreeView.h>
+#include <QtxInfoPanel.h>
 #include <QtxMRUAction.h>
 #include <QtxDockAction.h>
 #include <QtxDockWidget.h>
@@ -526,6 +527,9 @@ bool LightApp_Application::activateModule( const QString& modName )
 
   saveDockWindowsState();
 
+  if ( infoPanel() )
+    infoPanel()->clear();
+
   bool status = CAM_Application::activateModule( modName );
 
   updateModuleActions();
@@ -601,26 +605,24 @@ void LightApp_Application::createActions()
   QString url = resMgr->stringValue("GUI", "site_url");
   if ( !url.isEmpty() ) {
     QString title = tr ( "SALOME_SITE" );
-    QAction* as = createAction( id, title,
+    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 );
-    id++;
   }
 
   // b) Link to Forum
   url = resMgr->stringValue("GUI", "forum_url");
   if ( !url.isEmpty() ) {
     QString title = tr ( "SALOME_FORUM" );
-    QAction* af = createAction( helpMenu, title,
+    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 );
-    id++;
   }
 
   // c) Link to YouTube channel
@@ -628,16 +630,28 @@ void LightApp_Application::createActions()
   if ( !url.isEmpty() ) {
     createMenu( separator(), helpMenu, -1, 0 );
     QString title = tr ( "SALOME_VIDEO_TUTORIALS" );
-    QAction* av = createAction( helpMenu, title,
+    QAction* av = createAction( VideosId, title,
                                resMgr->loadPixmap( "LightApp", tr( "ICON_LIFE_RIGN" ), false ),
-                               title, title,
+                               title, tr( "PRP_SALOME_VIDEO_TUTORIALS" ),
                                0, desk, false, this, SLOT( onHelpContentsModule() ) );
     av->setData( url );
     createMenu( av, helpMenu, -1, 0 );
-    id++;
   }
 
-  // d) Help for modules
+  // 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 );
+  }
+
+  // e) Help for modules
 
   // - First create top-level menus to preserve correct order
   QString userGuide = "User's Guide";
@@ -1369,9 +1383,18 @@ void LightApp_Application::insertDockWindow( const int id, QWidget* wid )
   myWin.insert( id, wid );
 
   QtxDockWidget* dock = new QtxDockWidget( true, desktop() );
+  if ( id == WT_InfoPanel ) {
+    // Info panel's position is strongly limited to the right area;
+    // It is not movable and not floatable.
+    dock->setAllowedAreas( Qt::RightDockWidgetArea );
+    dock->setFeatures( QDockWidget::DockWidgetClosable );
+    connect( dock, SIGNAL( aboutToShow()), this, SLOT( onInfoPanelShown() ) );
+  }
+  else {
+    dock->setFeatures( QDockWidget::AllDockWidgetFeatures );
+  }
   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->setWidget( wid );
@@ -1441,6 +1464,11 @@ SUIT_DataBrowser* LightApp_Application::objectBrowser()
   return qobject_cast<SUIT_DataBrowser*>( dockWindow( WT_ObjectBrowser ) );
 }
 
+QtxInfoPanel* LightApp_Application::infoPanel()
+{
+  return qobject_cast<QtxInfoPanel *>( dockWindow( WT_InfoPanel ));
+}
+
 /*!
   \return Log Window
 */
@@ -1793,6 +1821,7 @@ void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
   }
 
   getWindow( WT_ObjectBrowser );
+  getWindow( WT_InfoPanel );
 
   loadDockWindowsState();
 
@@ -1824,6 +1853,7 @@ void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
   }
 
   getWindow( WT_ObjectBrowser );
+  getWindow( WT_InfoPanel );
 
   loadDockWindowsState();
 
@@ -2129,6 +2159,13 @@ QWidget* LightApp_Application::createWindow( const int flag )
     wid = ob;
     ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
   }
+  else if ( flag == WT_InfoPanel)
+  {
+    QtxInfoPanel* ipanel = new QtxInfoPanel( desktop() );
+    ipanel->setObjectName( "infoPanel" );
+    ipanel->setWindowTitle( tr( "INFO_PANEL" ) );
+    wid = ipanel;
+  }
 #ifndef DISABLE_PYCONSOLE
   else  if ( flag == WT_PyConsole )
   {
@@ -2166,6 +2203,7 @@ void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
 #endif
   if ( activeStudy() ) {
     aMap.insert( WT_ObjectBrowser, Qt::LeftDockWidgetArea );
+    aMap.insert( WT_InfoPanel, Qt::RightDockWidgetArea );
     //  aMap.insert( WT_LogWindow, Qt::DockBottom );
   }
 }
@@ -4126,6 +4164,34 @@ void LightApp_Application::updateWindows()
   }
 
   loadDockWindowsState();
+
+  if ( !activeModule() && infoPanel() )
+  {
+    infoPanel()->clear();
+    infoPanel()->setTitle( tr( "INFO_WELCOME_TO_SALOME" ) );
+
+    int grp = infoPanel()->addGroup( tr( "INFO_GETTING_STARTED" ) );
+    infoPanel()->addAction( action( FileNewId ), grp );
+    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 );
+    infoPanel()->addAction( action( VideosId ), grp );
+    infoPanel()->addLabel( action( VideosId )->statusTip(), grp );
+
+    LightApp_ModuleAction* ma = qobject_cast<LightApp_ModuleAction*>(action(ModulesListId));
+    if ( ma && ma->count() > 0 )
+    {
+      grp = infoPanel()->addGroup( tr( "INFO_AVAILABLE_MODULES" ) );
+      foreach ( QString mname, ma->modules() )
+      {
+        infoPanel()->addAction( ma->moduleAction( mname ), grp );
+        if ( !moduleDescription( mname ).isEmpty() )
+          infoPanel()->addLabel( moduleDescription( mname ), grp );
+      }
+    }
+  }
 }
 
 /*!
@@ -5014,6 +5080,12 @@ void LightApp_Application::onDesktopMessage( const QString& message )
   }
 }
 
+void LightApp_Application::onInfoPanelShown()
+{
+  if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
+    ((LightApp_Module*)activeModule())->updateInfoPanel();
+}
+
 /*!
   Internal method. 
   Returns all top level toolbars.