Retain active quality-changes when changing material

This wasn't updated yet for the new quality-changes functionality.

Contributes to issue CURA-2006.
This commit is contained in:
Ghostkeeper 2016-08-23 17:24:44 +02:00
parent 9ba9e90a8f
commit f9e0e457ea
No known key found for this signature in database
GPG key ID: 701948C5954A7385

View file

@ -489,6 +489,7 @@ class MachineManager(QObject):
old_variant = self._active_container_stack.findContainer({"type": "variant"}) old_variant = self._active_container_stack.findContainer({"type": "variant"})
old_material = self._active_container_stack.findContainer({"type": "material"}) old_material = self._active_container_stack.findContainer({"type": "material"})
old_quality = self._active_container_stack.findContainer({"type": "quality"}) old_quality = self._active_container_stack.findContainer({"type": "quality"})
old_quality_changes = self._active_container_stack.findContainer({"type": "quality_changes"})
if not old_material: if not old_material:
Logger.log("w", "While trying to set the active material, no material was found to replace it.") Logger.log("w", "While trying to set the active material, no material was found to replace it.")
return return
@ -500,11 +501,15 @@ class MachineManager(QObject):
containers[0].nameChanged.connect(self._onMaterialNameChanged) containers[0].nameChanged.connect(self._onMaterialNameChanged)
preferred_quality_name = None
if old_quality: if old_quality:
preferred_quality_name = old_quality.getName() if old_quality_changes:
new_quality = self._updateQualityChangesContainer(old_quality.getMetaDataEntry("quality_type"), old_quality_changes.getMetaDataEntry("name"))
else:
new_quality = self._updateQualityContainer(self._global_container_stack.getBottom(), old_variant, containers[0], old_quality.getName())
else:
new_quality = self._updateQualityContainer(self._global_container_stack.getBottom(), old_variant, containers[0])
self.setActiveQuality(self._updateQualityContainer(self._global_container_stack.getBottom(), old_variant, containers[0], preferred_quality_name).id) self.setActiveQuality(new_quality.getId())
@pyqtSlot(str) @pyqtSlot(str)
def setActiveVariant(self, variant_id): def setActiveVariant(self, variant_id):