From 4e2eb94e89f8c396867e3b4e28ecc982b7b77024 Mon Sep 17 00:00:00 2001 From: vsr Date: Wed, 1 Jun 2022 13:10:53 +0300 Subject: [PATCH] Clear info panel when module is deactivated + properly align actions not having icons in the Info panel --- src/CAM/CAM_Application.cxx | 20 +++++++++++++++++--- src/CAM/CAM_Application.h | 1 + src/LightApp/LightApp_Application.cxx | 6 ++++++ src/LightApp/LightApp_Application.h | 1 + src/Qtx/QtxInfoPanel.cxx | 20 ++++++++++++++++++++ 5 files changed, 45 insertions(+), 3 deletions(-) diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index 46d47ef2b..aa92a3a97 100644 --- a/src/CAM/CAM_Application.cxx +++ b/src/CAM/CAM_Application.cxx @@ -454,12 +454,14 @@ bool CAM_Application::activateModule( CAM_Module* mod ) { if ( !myModule->deactivateModule( activeStudy() ) ) { - // .... - } + // ??? + } + moduleDeactivated( myModule ); } myModule = mod; - if ( myModule ){ + if ( myModule ) + { // Connect the module to the active study myModule->connectToStudy( dynamic_cast( activeStudy() ) ); if ( !myModule->activateModule( activeStudy() ) ) @@ -607,6 +609,18 @@ void CAM_Application::moduleAdded( CAM_Module* /*mod*/ ) { } +/*! + \brief Callback function, called when the module is just deactivated. + + This virtual method can be re-implemented in the successors. Base implementation + does nothing. + + \param mod module just deactivated +*/ +void CAM_Application::moduleDeactivated( CAM_Module* /*mod*/ ) +{ +} + /*! \brief Get module name by its title (user name). \param title module title (user name) diff --git a/src/CAM/CAM_Application.h b/src/CAM/CAM_Application.h index 722e4387d..3dc79da71 100644 --- a/src/CAM/CAM_Application.h +++ b/src/CAM/CAM_Application.h @@ -88,6 +88,7 @@ protected: virtual bool checkModule( const QString& ); virtual void moduleAdded( CAM_Module* ); + virtual void moduleDeactivated( CAM_Module* ); virtual void beforeCloseDoc( SUIT_Study* ); virtual void afterCloseDoc(); virtual bool activateModule( CAM_Module* = 0 ); diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index e86a70914..9f042366b 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -2330,6 +2330,12 @@ void LightApp_Application::moduleAdded( CAM_Module* mod ) } } +void LightApp_Application::moduleDeactivated( CAM_Module* /*mod*/ ) +{ + if ( infoPanel() ) + infoPanel()->clear(); +} + void LightApp_Application::emptyPreferences( const QString& modName ) { QtxPreferenceItem* item = myPrefs->findItem( modName, true ); diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index 8a6132ef7..c6e43cf47 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -234,6 +234,7 @@ protected: virtual void beforeCloseDoc( SUIT_Study* ); virtual void afterCloseDoc(); virtual void moduleAdded( CAM_Module* ); + virtual void moduleDeactivated( CAM_Module* ); virtual bool activateModule( CAM_Module* = 0 ); LightApp_Preferences* preferences( const bool ) const; diff --git a/src/Qtx/QtxInfoPanel.cxx b/src/Qtx/QtxInfoPanel.cxx index 5920d6fea..f2a36af99 100644 --- a/src/Qtx/QtxInfoPanel.cxx +++ b/src/Qtx/QtxInfoPanel.cxx @@ -96,10 +96,30 @@ void QtxInfoPanel::Container::addLabel( const QString& text, Qt::Alignment align void QtxInfoPanel::Container::addAction( QAction* action, const int id ) { + static const char* empty_xpm[] = {"16 16 1 1", + " c None", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " "}; QToolButton* button = new QToolButton( this ); button->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); button->setAutoRaise( true ); + if ( action->icon().isNull() ) + action->setIcon( QPixmap(empty_xpm) ); button->setDefaultAction( action ); put( button ); ids[ id ] = button; -- 2.39.2