Browse Source

Ensure that intent gets updated when changing quality / material

CURA-6775
Jaime van Kessel 5 years ago
parent
commit
3730ea247d
1 changed files with 17 additions and 0 deletions
  1. 17 0
      cura/Settings/MachineManager.py

+ 17 - 0
cura/Settings/MachineManager.py

@@ -1109,6 +1109,7 @@ class MachineManager(QObject):
 
 
         self.activeQualityGroupChanged.emit()
         self.activeQualityGroupChanged.emit()
         self.activeQualityChangesGroupChanged.emit()
         self.activeQualityChangesGroupChanged.emit()
+        self._updateIntentWithQuality()
 
 
     def _setQualityGroup(self, quality_group: Optional["QualityGroup"], empty_quality_changes: bool = True) -> None:
     def _setQualityGroup(self, quality_group: Optional["QualityGroup"], empty_quality_changes: bool = True) -> None:
         if self._global_container_stack is None:
         if self._global_container_stack is None:
@@ -1136,6 +1137,7 @@ class MachineManager(QObject):
 
 
         self.activeQualityGroupChanged.emit()
         self.activeQualityGroupChanged.emit()
         self.activeQualityChangesGroupChanged.emit()
         self.activeQualityChangesGroupChanged.emit()
+        self._updateIntentWithQuality()
 
 
     def _fixQualityChangesGroupToNotSupported(self, quality_changes_group: "QualityChangesGroup") -> None:
     def _fixQualityChangesGroupToNotSupported(self, quality_changes_group: "QualityChangesGroup") -> None:
         metadatas = [quality_changes_group.metadata_for_global] + list(quality_changes_group.metadata_per_extruder.values())
         metadatas = [quality_changes_group.metadata_for_global] + list(quality_changes_group.metadata_per_extruder.values())
@@ -1277,6 +1279,21 @@ class MachineManager(QObject):
                    current_quality_type, quality_type)
                    current_quality_type, quality_type)
         self._setQualityGroup(candidate_quality_groups[quality_type], empty_quality_changes = True)
         self._setQualityGroup(candidate_quality_groups[quality_type], empty_quality_changes = True)
 
 
+    ## Update the current intent after the quality changed
+    def _updateIntentWithQuality(self):
+        global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()
+        if global_stack is None:
+            return
+        Logger.log("d", "Updating intent due to quality change")
+
+        category = "default"
+
+        for extruder in global_stack.extruderList:
+            current_category = extruder.intent.getMetaDataEntry("intent_category", "default")
+            if current_category != "default" and current_category != category:
+                category = current_category
+        self.setIntentByCategory(category)
+
     ##  Update the material profile in the current stacks when the variant is
     ##  Update the material profile in the current stacks when the variant is
     #   changed.
     #   changed.
     #   \param position The extruder stack to update. If provided with None, all
     #   \param position The extruder stack to update. If provided with None, all