// It should be set on the app start
auto extRootDir = getenv(salomeAppDir);
- ASSERT(extRootDir)
if (!extRootDir)
{
- MESSAGE("Cannot get SALOME_APPLICATION_DIR env variable! Cancel adding selected extensions.");
+ SUIT_MessageBox::warning(desktop(), tr("WRN_WARNING"), tr("WRN_SALOME_APPLICATION_DIR"));
return;
}
SCRUTE(extRootDir);
QString extName = extFileInfo.baseName();
moduleAction->insertExtension(extName);
}
-
- // read description file (.salomex) and check it's OK
- // QtxResourceMgr resMgr;
- // if ( !resMgr.addResource( path ) )
- // {
- // SUIT_MessageBox::warning( desktop(), tr( "WRN_WARNING" ), tr( "WRN_MODULE_BAD_SALOMEX_FILE" ).arg( path ) );
- // continue;
- // }
- // // retrieve module name
- // QString name = resMgr.stringValue( "General", "name" ).trimmed();
- // if ( name.isEmpty() )
- // {
- // SUIT_MessageBox::warning( desktop(), tr( "WRN_WARNING" ), tr( "WRN_MODULE_EMPTY_NAME" ).arg( path ) );
- // continue;
- // }
- // // retrieve root directory
- // QString root = resMgr.stringValue( "General", "root" ).trimmed();
- // if ( root.isEmpty() )
- // {
- // SUIT_MessageBox::warning( desktop(), tr( "WRN_WARNING" ), tr( "WRN_MODULE_EMPTY_ROOT" ).arg( path ) );
- // continue;
- // }
-
- //addUserModule( name, root, true );
}
}
return true;
}
+/*!Remove user module from UI.*/
+void LightApp_Application::removeUserModule(const QString& moduleInnerName, LightApp_ModuleAction* moduleAction)
+{
+ MESSAGE("Remove a module from UI...");
+ 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
+ // 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(moduleUserName);
+ }
+
+ // Remove Help menu items
+ removeHelpItems(moduleUserName);
+
+ // Remove Preferences
+ LightApp_Preferences* prefs = preferences();
+ if (prefs)
+ prefs->removeModule(moduleUserName);
+
+ // Remove settings
+ // Here we use an inner module name!
+ QStringList customModules = resourceMgr()->stringValue("launch", "user_modules").split(";", QString::SkipEmptyParts);
+ customModules.removeAll(moduleInnerName);
+ resourceMgr()->setValue("launch", "user_modules", customModules.join(";"));
+ removeModuleInfo(moduleInnerName);
+}
+
/*!On module removing action.*/
void LightApp_Application::onExtRemoving(const QString& title)
{
std::string extName = title.toStdString();
SCRUTE(extName);
+ // Ask user if he's ready to completely remove an extension and all its modules.
+ int answer = SUIT_MessageBox::question(
+ desktop(),
+ tr("TLT_REMOVE_EXTENSION"),
+ tr("QUE_REMOVE_EXTENSION").arg(title),
+ SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
+ SUIT_MessageBox::Ok
+ );
+
+ if (answer == SUIT_MessageBox::Cancel)
+ {
+ MESSAGE("Removing of an extension was cancelled");
+ return; // cancelled
+ }
+
+ if (activeStudy() && activeStudy()->isModified() && !onSaveDoc())
+ {
+ // doc is not saved, or saving cancelled
+ SUIT_MessageBox::warning(
+ desktop(),
+ tr("WRN_WARNING"), tr("WRN_CANCEL_REMOVE_EXTENSION_UNSAVE").arg(title)
+ );
+
+ return;
+ }
+
// It should be set on the app start
auto extRootDir = getenv(salomeAppDir);
- ASSERT(extRootDir)
if (!extRootDir)
{
- MESSAGE("Cannot get SALOME_APPLICATION_DIR env variable! Cancel adding selected extensions.");
+ SUIT_MessageBox::warning(desktop(), tr("WRN_WARNING"), tr("WRN_SALOME_APPLICATION_DIR"));
return;
}
SCRUTE(extRootDir);
extensionRemover, (char*)"remove_salomex", (char*)"ss", extRootDir, extName.c_str());
if (!removedModules || removedModules == Py_None)
{
- SUIT_MessageBox::warning(desktop(), tr("WRN_WARNING"), tr("WRN_FAILED_REMOVE_EXTENSION").arg(title) );
+ SUIT_MessageBox::warning(desktop(), tr("WRN_WARNING"), tr("WRN_FAILED_REMOVE_EXTENSION").arg(title));
return;
}
// We need it to remove ext and modules from UI
LightApp_ModuleAction* moduleAction = qobject_cast<LightApp_ModuleAction*>(action(ModulesListId));
- ASSERT(moduleAction);
+ if (!moduleAction)
+ {
+ MESSAGE("Cannot get a pointer to LightApp_ModuleAction! Removing from menue and toolbars will skipped.");
+ }
// Module's content was already removed on python remove_salomex call,
// then all we do next - just remove UI items.
{
// Get the current module's name
auto moduleNameItem = PyList_GetItem(removedModules, pos);
- 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
- // 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(moduleUserName);
- }
-
- // Remove Help menu items
- removeHelpItems(moduleUserName);
-
- // Remove Preferences
- LightApp_Preferences* prefs = preferences();
- if (prefs)
- prefs->removeModule(moduleUserName);
+ const QString moduleInnerName(PyUnicode_AsUTF8(moduleNameItem));
- // Remove settings
- // Here we use an inner module name!
- QStringList customModules = resourceMgr()->stringValue("launch", "user_modules").split(";", QString::SkipEmptyParts);
- customModules.removeAll(moduleInnerName);
- resourceMgr()->setValue("launch", "user_modules", customModules.join(";"));
- removeModuleInfo(moduleInnerName);
+ removeUserModule(moduleInnerName, moduleAction);
}
// Remove an ext from UI