From 861f255a24ab1aa44b9132cd915e37d58ee4600e Mon Sep 17 00:00:00 2001 From: vsr Date: Wed, 18 Nov 2020 18:38:58 +0300 Subject: [PATCH] InfoPanel introduction v3. --- src/CAM/CAM_Application.cxx | 29 +++++++++++++++++++---- src/CAM/CAM_Application.h | 3 ++- src/LightApp/LightApp_Application.cxx | 15 ++++++++++-- src/LightApp/LightApp_ModuleAction.cxx | 18 ++++++++++++++ src/LightApp/LightApp_ModuleAction.h | 3 +++ src/LightApp/resources/LightApp_msg_en.ts | 8 +++++++ src/LightApp/resources/LightApp_msg_fr.ts | 8 +++++++ src/LightApp/resources/LightApp_msg_ja.ts | 8 +++++++ 8 files changed, 84 insertions(+), 8 deletions(-) diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index ae731cee5..f7052bb20 100644 --- a/src/CAM/CAM_Application.cxx +++ b/src/CAM/CAM_Application.cxx @@ -640,7 +640,7 @@ QString CAM_Application::moduleTitle( const QString& name ) /*! \brief Get module icon name. - \param name module name + \param name module name or title \return module icon or null QString if module is not found */ QString CAM_Application::moduleIcon( const QString& name ) @@ -648,24 +648,40 @@ QString CAM_Application::moduleIcon( const QString& name ) QString res; for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isNull(); ++it ) { - if ( (*it).name == name ) + if ( (*it).name == name || (*it).title == name ) res = (*it).icon; } return res; } +/*! + \brief Get module description. + \param name module name or title + \return module description or null QString if description is not provided in config file. +*/ +QString CAM_Application::moduleDescription( const QString& name ) +{ + QString res; + for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isNull(); ++it ) + { + if ( (*it).name == name || (*it).title == name ) + res = (*it).description; + } + return res; +} + /*! \brief Get module library name by its title (user name). - \param title module title (user name) + \param title module name or title \param full if \c true, return full library name, otherwise return its internal name \return module library name or null QString if module is not found */ -QString CAM_Application::moduleLibrary( const QString& title, const bool full ) +QString CAM_Application::moduleLibrary( const QString& name, const bool full ) { QString res; for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isEmpty(); ++it ) { - if ( (*it).title == title ) + if ( (*it).name == name || (*it).title == name ) res = (*it).library; } if ( !res.isEmpty() && full ) @@ -771,6 +787,8 @@ void CAM_Application::readModuleList() QString modIcon = resMgr->stringValue( *it, "icon", QString() ); + QString modDescription = resMgr->stringValue( *it, "description", QString() ); + QString modLibrary = resMgr->stringValue( *it, "library", QString() ).trimmed(); if ( !modLibrary.isEmpty() ) { @@ -801,6 +819,7 @@ void CAM_Application::readModuleList() inf.status = hasGui ? stUnknown : stNoGui; if ( hasGui ) inf.library = modLibrary; inf.icon = modIcon; + inf.description = modDescription; inf.version = version; myInfoList.append( inf ); } diff --git a/src/CAM/CAM_Application.h b/src/CAM/CAM_Application.h index b0b69d3f6..a11669897 100644 --- a/src/CAM/CAM_Application.h +++ b/src/CAM/CAM_Application.h @@ -74,6 +74,7 @@ public: static QString moduleName( const QString& ); static QString moduleTitle( const QString& ); static QString moduleIcon( const QString& ); + static QString moduleDescription( const QString& ); static QString moduleLibrary( const QString&, const bool = true ); virtual void createEmptyStudy(); @@ -100,7 +101,7 @@ private: private: enum { stUnknown = 0, stNoGui, stInaccessible, stReady }; typedef struct { - QString name, title, icon, library, version; + QString name, title, icon, library, version, description; int status; } ModuleInfo; typedef QList ModuleInfoList; diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 67b111213..bb80f17f6 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -4154,9 +4154,20 @@ void LightApp_Application::updateWindows() loadDockWindowsState(); - if (!activeModule() && infoPanel() ) { + if (!activeModule() && infoPanel() ) + { infoPanel()->clear(); - infoPanel()->addAction( action(ModulesListId) ); + LightApp_ModuleAction* ma = qobject_cast(action(ModulesListId)); + if ( ma && ma->count() > 0 ) + { + int 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 ); + } + } } } diff --git a/src/LightApp/LightApp_ModuleAction.cxx b/src/LightApp/LightApp_ModuleAction.cxx index fa9a8c695..9431ec346 100644 --- a/src/LightApp/LightApp_ModuleAction.cxx +++ b/src/LightApp/LightApp_ModuleAction.cxx @@ -271,6 +271,15 @@ LightApp_ModuleAction::~LightApp_ModuleAction() { } +/*! + \brief Get number of registered modules. + \return modules count +*/ +int LightApp_ModuleAction::count() const +{ + return modules().count(); +} + /*! \brief Get list of modules. \return modules names list @@ -314,6 +323,15 @@ void LightApp_ModuleAction::setModuleIcon( const QString& name, const QIcon& ico update(); } +/*! + \brief Get module action. + \param name module name +*/ +QAction* LightApp_ModuleAction::moduleAction( const QString& name ) const +{ + return mySet->moduleAction( name ); +} + /*! \brief Add module into the list. \param name module name diff --git a/src/LightApp/LightApp_ModuleAction.h b/src/LightApp/LightApp_ModuleAction.h index c5e6da61c..1048e8b4c 100644 --- a/src/LightApp/LightApp_ModuleAction.h +++ b/src/LightApp/LightApp_ModuleAction.h @@ -50,11 +50,14 @@ public: LightApp_ModuleAction( const QString&, const QIcon&, QObject* = 0 ); virtual ~LightApp_ModuleAction(); + int count() const; QStringList modules() const; QIcon moduleIcon( const QString& ) const; void setModuleIcon( const QString&, const QIcon& ); + QAction* moduleAction( const QString& ) const; + void insertModule( const QString&, const QIcon&, const int = -1 ); void removeModule( const QString& ); diff --git a/src/LightApp/resources/LightApp_msg_en.ts b/src/LightApp/resources/LightApp_msg_en.ts index c19044846..afee886f9 100644 --- a/src/LightApp/resources/LightApp_msg_en.ts +++ b/src/LightApp/resources/LightApp_msg_en.ts @@ -1125,6 +1125,14 @@ File does not exist PREF_PY_NUM_COLUMNS Number of columns: + + INFO_GETTING_STARTED + Getting started + + + INFO_AVAILABLE_MODULES + Available modules + LightApp_Module diff --git a/src/LightApp/resources/LightApp_msg_fr.ts b/src/LightApp/resources/LightApp_msg_fr.ts index 9bc156218..899f3bd49 100644 --- a/src/LightApp/resources/LightApp_msg_fr.ts +++ b/src/LightApp/resources/LightApp_msg_fr.ts @@ -1125,6 +1125,14 @@ Le fichier n'existe pas PREF_PY_NUM_COLUMNS Nombre de colonnes: + + INFO_GETTING_STARTED + Getting started + + + INFO_AVAILABLE_MODULES + Available modules + LightApp_Module diff --git a/src/LightApp/resources/LightApp_msg_ja.ts b/src/LightApp/resources/LightApp_msg_ja.ts index fc99440c0..06eadeb99 100644 --- a/src/LightApp/resources/LightApp_msg_ja.ts +++ b/src/LightApp/resources/LightApp_msg_ja.ts @@ -1123,6 +1123,14 @@ Pythonファイルは、文字、数字、アンダースコアが含まれて PREF_PY_NUM_COLUMNS 列数 + + INFO_GETTING_STARTED + Getting started + + + INFO_AVAILABLE_MODULES + Available modules + LightApp_Module -- 2.39.2