From: vsr Date: Tue, 24 Nov 2020 08:31:42 +0000 (+0300) Subject: Emit a signal and propagate it to the active module when panel is shown X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fvuzlov%2F20215;p=modules%2Fgui.git Emit a signal and propagate it to the active module when panel is shown --- diff --git a/doc/salome/gui/input/using_help_panel.rst b/doc/salome/gui/input/using_help_panel.rst index 20f8d1a9b..9321a3d20 100644 --- a/doc/salome/gui/input/using_help_panel.rst +++ b/doc/salome/gui/input/using_help_panel.rst @@ -165,3 +165,12 @@ For Python modules, *Help panel* can be accessed via the ``SalomePyQt`` Python m # Clear Help panel sg.infoClear() + +.. _hp_update_panel + +Notifications +============= + +Each time when *Help panel* is shown, currently active module is informed via +the virtual method ``updateInfoPanel()``. This method can be used to properly +update the contents of the *Help panel*, depending on the current context. diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 72b13bda9..1f57055cf 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1388,6 +1388,7 @@ void LightApp_Application::insertDockWindow( const int id, QWidget* wid ) // 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 ); @@ -5079,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. diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index 8f15d63b0..da8ffc266 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -270,6 +270,8 @@ protected slots: virtual void onDesktopMessage( const QString& ); + virtual void onInfoPanelShown(); + private slots: void onSelection(); void onRefresh(); diff --git a/src/LightApp/LightApp_Module.cxx b/src/LightApp/LightApp_Module.cxx index da1d8a70c..9373ae2ee 100644 --- a/src/LightApp/LightApp_Module.cxx +++ b/src/LightApp/LightApp_Module.cxx @@ -315,6 +315,11 @@ void LightApp_Module::MenuItem() { } +/*!NOT IMPLEMENTED*/ +void LightApp_Module::updateInfoPanel() +{ +} + /*!NOT IMPLEMENTED*/ void LightApp_Module::createPreferences() { diff --git a/src/LightApp/LightApp_Module.h b/src/LightApp/LightApp_Module.h index 31222c615..94fd9396f 100644 --- a/src/LightApp/LightApp_Module.h +++ b/src/LightApp/LightApp_Module.h @@ -117,6 +117,8 @@ public slots: void MenuItem(); + virtual void updateInfoPanel(); + protected slots: virtual void onModelSaved(); virtual void onModelOpened(); diff --git a/src/Qtx/QtxDockWidget.cxx b/src/Qtx/QtxDockWidget.cxx index fc9827654..4bb125b31 100644 --- a/src/Qtx/QtxDockWidget.cxx +++ b/src/Qtx/QtxDockWidget.cxx @@ -376,13 +376,7 @@ QtxDockWidget::~QtxDockWidget() */ QSize QtxDockWidget::sizeHint() const { - QSize sz = QDockWidget::sizeHint(); - - // printf( "----------------> QtxDockWidget::sizeHint()\n" ); - return QSize( 500, 100 ); - - return sz; } /*! @@ -391,9 +385,7 @@ QSize QtxDockWidget::sizeHint() const */ QSize QtxDockWidget::minimumSizeHint() const { - QSize sz = QDockWidget::minimumSizeHint(); - - return sz; + return QDockWidget::minimumSizeHint(); } /*! @@ -415,6 +407,9 @@ void QtxDockWidget::setVisible( bool on ) else myWatcher->hidden( this ); } + + if ( on ) + emit( aboutToShow() ); } /*! diff --git a/src/Qtx/QtxDockWidget.h b/src/Qtx/QtxDockWidget.h index 53ecbb61f..048a9e64d 100644 --- a/src/Qtx/QtxDockWidget.h +++ b/src/Qtx/QtxDockWidget.h @@ -49,6 +49,7 @@ public: signals: void orientationChanged( Qt::Orientation ); + void aboutToShow(); public slots: virtual void setVisible( bool );