diff --git a/cura/QualityManager.py b/cura/QualityManager.py index fc3b9b4f53..4849e8d67d 100644 --- a/cura/QualityManager.py +++ b/cura/QualityManager.py @@ -44,9 +44,6 @@ class QualityManager: criteria = {"type": "quality_changes", "name": quality_changes_name} result = self._getFilteredContainersForStack(machine_definition, [], **criteria) - criteria = {"type": "quality_changes", "global_profile": quality_changes_name} - result.extend(self._getFilteredContainersForStack(machine_definition, [], **criteria)) - return result ## Fetch the list of available quality types for this combination of machine definition and materials. diff --git a/cura/Settings/ContainerManager.py b/cura/Settings/ContainerManager.py index 70575cf5e7..a917718e61 100644 --- a/cura/Settings/ContainerManager.py +++ b/cura/Settings/ContainerManager.py @@ -467,8 +467,6 @@ class ContainerManager(QObject): base_name = active_quality_name unique_name = self._container_registry.uniqueName(base_name) - global_changes = None - # Go through the active stacks and create quality_changes containers from the user containers. for stack in cura.Settings.ExtruderManager.getInstance().getActiveGlobalAndExtruderStacks(): user_container = stack.getTop() @@ -484,11 +482,6 @@ class ContainerManager(QObject): extruder_id) self._performMerge(new_changes, user_container) - if stack is global_stack: - global_changes = new_changes - else: - new_changes.setMetaDataEntry("global_profile", global_changes.getId()) - self._container_registry.addContainer(new_changes) stack.replaceContainer(stack.getContainerIndex(quality_changes_container), new_changes) @@ -570,16 +563,10 @@ class ContainerManager(QObject): container_registry = self._container_registry containers_to_rename = self._container_registry.findInstanceContainers(type = "quality_changes", name = quality_name) - containers_to_rename.extend(self._container_registry.findInstanceContainers(type = "quality_changes", global_profile = quality_name)) - global_changes_id = "" for container in containers_to_rename: stack_id = container.getMetaDataEntry("extruder", global_stack.getId()) container_registry.renameContainer(container.getId(), new_name, self._createUniqueId(stack_id, new_name)) - if "global_profile" not in container.getMetaData(): - global_changes_id = container.getId() - else: - container.setMetaDataEntry("global_profile", global_changes_id) if not containers_to_rename: UM.Logger.log("e", "Unable to rename %s, because we could not find the profile", quality_name) @@ -649,10 +636,9 @@ class ContainerManager(QObject): # Handle the extruders if present. extruders = machine_definition.getMetaDataEntry("machine_extruder_trains") if extruders: - for key in extruders: - value = extruders[key] - new_changes = self._createQualityChanges(quality_container, new_name, machine_definition, value) - new_changes.addMetaDataEntry("global_profile", global_changes.getId()) + for extruder_id in extruders: + extruder = extruders[extruder_id] + new_changes = self._createQualityChanges(quality_container, new_name, machine_definition, extruder) new_change_instances.append(new_changes) self._container_registry.addContainer(new_changes) @@ -661,19 +647,12 @@ class ContainerManager(QObject): # Duplicate a quality changes container def _duplicateQualityChangesForMachineType(self, quality_changes_name, base_name, machine_definition): new_change_instances = [] - profile_index = -1 - global_changes_id = "" for container in QualityManager.getInstance().findQualityChangesByName(quality_changes_name, machine_definition): new_unique_id = self._createUniqueId(container.getId(), base_name) new_container = container.duplicate(new_unique_id, base_name) - if profile_index >= 0: - new_container.setMetaDataEntry("global_profile", global_changes_id) - else: - global_changes_id = new_unique_id new_change_instances.append(new_container) self._container_registry.addContainer(new_container) - profile_index += 1 return new_change_instances diff --git a/cura/Settings/CuraContainerRegistry.py b/cura/Settings/CuraContainerRegistry.py index f5b6568c4a..271d395307 100644 --- a/cura/Settings/CuraContainerRegistry.py +++ b/cura/Settings/CuraContainerRegistry.py @@ -161,21 +161,19 @@ class CuraContainerRegistry(ContainerRegistry): profile_index = -1 global_profile = None + new_name = self.uniqueName(name_seed) + for profile in profile_or_list: if profile_index >= 0: if len(machine_extruders) > profile_index: extruder_id = machine_extruders[profile_index].getBottom().getId() - profile_name = "%s_%s" % (extruder_id, name_seed) # Ensure the extruder profiles get non-conflicting names # NB: these are not user-facing if "extruder" in profile.getMetaData(): profile.setMetaDataEntry("extruder", extruder_id) else: profile.addMetaDataEntry("extruder", extruder_id) - if "global_profile" in profile.getMetaData(): - profile.setMetaDataEntry("global_profile", global_profile.getId()) - else: - profile.addMetaDataEntry("global_profile", global_profile.getId()) + profile_id = (extruder_id + "_" + name_seed).lower().replace(" ", "_") elif profile_index == 0: # Importing a multiextrusion profile into a single extrusion machine; merge 1st extruder profile into global profile profile._id = self.uniqueName("temporary_profile") @@ -188,16 +186,9 @@ class CuraContainerRegistry(ContainerRegistry): break else: global_profile = profile - profile_name = name_seed - new_name = self.uniqueName(profile_name) + profile_id = (global_container_stack.getBottom().getId() + "_" + name_seed).lower().replace(" ", "_") - profile.setDirty(True) # Ensure the profiles are correctly saved - if "type" in profile.getMetaData(): - profile.setMetaDataEntry("type", "quality_changes") - else: - profile.addMetaDataEntry("type", "quality_changes") - self._configureProfile(profile, profile_name) - profile.setName(new_name) + self._configureProfile(profile, profile_id, new_name) profile_index += 1 @@ -206,11 +197,18 @@ class CuraContainerRegistry(ContainerRegistry): # If it hasn't returned by now, none of the plugins loaded the profile successfully. return {"status": "error", "message": catalog.i18nc("@info:status", "Profile {0} has an unknown file type.", file_name)} - def _configureProfile(self, profile, id_seed): + def _configureProfile(self, profile, id_seed, new_name): profile.setReadOnly(False) + profile.setDirty(True) # Ensure the profiles are correctly saved new_id = self.createUniqueName("quality_changes", "", id_seed, catalog.i18nc("@label", "Custom profile")) profile._id = new_id + profile.setName(new_name) + + if "type" in profile.getMetaData(): + profile.setMetaDataEntry("type", "quality_changes") + else: + profile.addMetaDataEntry("type", "quality_changes") if self._machineHasOwnQualities(): profile.setDefinition(self._activeQualityDefinition()) diff --git a/cura/Settings/QualitySettingsModel.py b/cura/Settings/QualitySettingsModel.py index d0ba7f4e11..09d6a3c821 100644 --- a/cura/Settings/QualitySettingsModel.py +++ b/cura/Settings/QualitySettingsModel.py @@ -154,7 +154,7 @@ class QualitySettingsModel(UM.Qt.ListModel.ListModel): criteria = {"type": "quality_changes", "quality_type": quality_type, "definition": definition_id, "name": quality_changes_container.getName()} if self._extruder_definition_id != "": criteria["extruder"] = self._extruder_definition_id - criteria["name"] = "%s_%s" % (self._extruder_definition_id, quality_changes_container.getName()) + criteria["name"] = quality_changes_container.getName() else: criteria["extruder"] = None