From 84de7d5944ec1d81a28dab24fe97fb51625e96b6 Mon Sep 17 00:00:00 2001 From: kosta Date: Fri, 20 Jan 2023 13:51:58 +0300 Subject: [PATCH] [bos #32523][EDF] SALOME on Demand GUI. Fixed using inner or user names in the modules removeing. Fixed early return after if statement. Removed commented code. --- src/LightApp/LightApp_Application.cxx | 28 ++++++++++++++-------- src/LightApp/LightApp_ModuleAction.cxx | 32 ++++---------------------- 2 files changed, 24 insertions(+), 36 deletions(-) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 00298a01f..6eb02e856 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1083,32 +1083,42 @@ void LightApp_Application::onExtRemoving(const QString& title) { // Get the current module's name auto moduleNameItem = PyList_GetItem(removedModules, pos); - QString name(PyUnicode_AsUTF8(moduleNameItem)); - SCRUTE(name.toStdString()); + QString moduleInnerName(PyUnicode_AsUTF8(moduleNameItem)); + SCRUTE(moduleInnerName.toStdString()); + + // There is a some confusion point, because now we have a module's 'inner' name + // from the extension's salomexd file. + // But, in the next GUI methods we need to use a module title (user name). + // For example, PYHELLO (inner name) and PyHello (user name to display in GUI). + // Then, from the inner module's name we need to get a user one. + QString moduleUserName = moduleTitle(moduleInnerName); + SCRUTE(moduleUserName.toStdString()); // Set current state in modules combo box - if (activeModule() && activeModule()->moduleName() == name) - activateModule( "" ); + // Don't confuse again, because activeModule()->moduleName() returns a module title, not an inner one! + if (activeModule() && activeModule()->moduleName() == moduleUserName) + activateModule(""); // Remove from "Modules" menu and toolbar if (moduleAction) { - moduleAction->removeModule(name); + moduleAction->removeModule(moduleUserName); } // Remove Help menu items - removeHelpItems(name); + removeHelpItems(moduleUserName); // Remove Preferences LightApp_Preferences* prefs = preferences(); if (prefs) - prefs->removeModule(name); + prefs->removeModule(moduleUserName); // Remove settings + // Here we use an inner module name! QStringList customModules = resourceMgr()->stringValue("launch", "user_modules").split(";", QString::SkipEmptyParts); - customModules.removeAll(moduleName(name)); + customModules.removeAll(moduleInnerName); resourceMgr()->setValue("launch", "user_modules", customModules.join(";")); - removeModuleInfo(moduleName(name)); + removeModuleInfo(moduleInnerName); } // Remove an ext from UI diff --git a/src/LightApp/LightApp_ModuleAction.cxx b/src/LightApp/LightApp_ModuleAction.cxx index 65c45c4f9..70ee48ce7 100644 --- a/src/LightApp/LightApp_ModuleAction.cxx +++ b/src/LightApp/LightApp_ModuleAction.cxx @@ -372,15 +372,6 @@ void LightApp_ModuleAction::insertModule( const QString& name, const QIcon& ico, a->setStatusTip( tr( "ACTIVATE_MODULE_TOP" ).arg( name ) ); a->setData( isCustom ); - // Commented because of using buttons for extension instead of modules - // if ( isCustom ) - // { - // myRemove->setEnabled( true ); - // QAction* inserted = myRemove->menu()->addAction( name ); - // connect( inserted, SIGNAL( triggered() ), myMapper, SLOT( map() ) ); - // myMapper->setMapping( inserted, name ); - // } - mySet->insertAction( a, -1, idx ); update(); } @@ -395,28 +386,15 @@ void LightApp_ModuleAction::removeModule( const QString& name ) MESSAGE("Start to remove module..."); int id = mySet->moduleId( name ); + SCRUTE(id); if ( id == -1 ) + { MESSAGE("Can't get a module's id! Return"); return; + } - QAction* a = moduleAction( name ); - bool isCustom = a->data().toBool(); - - SCRUTE(id); - mySet->removeAction( id ); - // Commented because of using buttons for extension instead of modules - // if ( isCustom ) - // { - // foreach ( QAction* ma, myRemove->menu()->actions() ) - // { - // if ( ma->text() == name ) - // { - // myRemove->menu()->removeAction( ma ); - // break; - // } - // } - // myRemove->setEnabled( !myRemove->menu()->actions().isEmpty() ); - // } + MESSAGE("Remove action by id..."); + mySet->removeAction(id); update(); -- 2.39.2