diff --git a/cura/PrintInformation.py b/cura/PrintInformation.py index 05b740637d..6d73489448 100644 --- a/cura/PrintInformation.py +++ b/cura/PrintInformation.py @@ -309,16 +309,13 @@ class PrintInformation(QObject): self.jobNameChanged.emit() - @pyqtProperty(str) - def baseName(self): - return self._base_name - @pyqtSlot(str) def setProjectName(self, name): self.setBaseName(name, is_project_file = True) - @pyqtSlot(str) - def setBaseName(self, base_name, is_project_file = False): + baseNameChanged = pyqtSignal() + + def setBaseName(self, base_name: str, is_project_file: bool = False): # Ensure that we don't use entire path but only filename name = os.path.basename(base_name) @@ -336,6 +333,9 @@ class PrintInformation(QObject): self._base_name = name self._updateJobName() + @pyqtProperty(str, fset = setBaseName, notify = baseNameChanged) + def baseName(self): + return self._base_name ## Created an acronymn-like abbreviated machine name from the currently active machine name # Called each time the global stack is switched @@ -395,7 +395,6 @@ class PrintInformation(QObject): ## Listen to scene changes to check if we need to reset the print information def _onSceneChanged(self, scene_node): - # Ignore any changes that are not related to sliceable objects if not isinstance(scene_node, SceneNode)\ or not scene_node.callDecoration("isSliceable")\ diff --git a/cura/Settings/ExtruderStack.py b/cura/Settings/ExtruderStack.py index 1b12814ab0..8dcaaf302e 100644 --- a/cura/Settings/ExtruderStack.py +++ b/cura/Settings/ExtruderStack.py @@ -136,6 +136,8 @@ class ExtruderStack(CuraContainerStack): @override(CuraContainerStack) def deserialize(self, contents: str, file_name: Optional[str] = None) -> None: super().deserialize(contents, file_name) + if "enabled" not in self.getMetaData(): + self.addMetaDataEntry("enabled", "True") stacks = ContainerRegistry.getInstance().findContainerStacks(id=self.getMetaDataEntry("machine", "")) if stacks: self.setNextStack(stacks[0]) diff --git a/plugins/3MFReader/ThreeMFWorkspaceReader.py b/plugins/3MFReader/ThreeMFWorkspaceReader.py index 214623c92d..5c312e7c5a 100755 --- a/plugins/3MFReader/ThreeMFWorkspaceReader.py +++ b/plugins/3MFReader/ThreeMFWorkspaceReader.py @@ -99,6 +99,7 @@ class MachineInfo: class ExtruderInfo: def __init__(self): self.position = None + self.enabled = True self.variant_info = None self.root_material_id = None @@ -425,6 +426,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader): extruder_info = ExtruderInfo() extruder_info.position = position + if parser.has_option("metadata", "enabled"): + extruder_info.enabled = parser["metadata"]["enabled"] if variant_id not in ("empty", "empty_variant"): extruder_info.variant_info = instance_container_info_dict[variant_id] if material_id not in ("empty", "empty_material"): @@ -946,6 +949,15 @@ class ThreeMFWorkspaceReader(WorkspaceReader): else: self._quality_type_to_apply = self._machine_info.quality_type + # Set enabled/disabled for extruders + for position, extruder_stack in extruder_stack_dict.items(): + extruder_info = self._machine_info.extruder_info_dict.get(position) + if not extruder_info: + continue + if "enabled" not in extruder_stack.getMetaData(): + extruder_stack.addMetaDataEntry("enabled", "True") + extruder_stack.setMetaDataEntry("enabled", str(extruder_info.enabled)) + def _updateActiveMachine(self, global_stack): # Actually change the active machine. machine_manager = Application.getInstance().getMachineManager() diff --git a/resources/qml/JobSpecs.qml b/resources/qml/JobSpecs.qml index 04e8ec397f..742e8d6765 100644 --- a/resources/qml/JobSpecs.qml +++ b/resources/qml/JobSpecs.qml @@ -13,7 +13,7 @@ Item { id: base property bool activity: CuraApplication.platformActivity - property string fileBaseName: "" + property string fileBaseName: PrintInformation.baseName UM.I18nCatalog { id: catalog; name:"cura"} @@ -24,26 +24,17 @@ Item { target: backgroundItem onHasMesh: { - if (base.fileBaseName == "") + if (PrintInformation.baseName == "") { - base.fileBaseName = name; + PrintInformation.baseName = name; } } } onActivityChanged: { - if (activity == true && base.fileBaseName == ''){ - //this only runs when you open a file from the terminal (or something that works the same way; for example when you drag a file on the icon in MacOS or use 'open with' on Windows) - base.fileBaseName = PrintInformation.baseName; //get the fileBaseName from PrintInformation.py because this saves the filebase when the file is opened using the terminal (or something alike) - PrintInformation.setBaseName(base.fileBaseName); - } - if (activity == true && base.fileBaseName != ''){ - //this runs in all other cases where there is a mesh on the buildplate (activity == true). It uses the fileBaseName from the hasMesh signal - PrintInformation.setBaseName(base.fileBaseName); - } - if (activity == false){ + if (activity == false) { //When there is no mesh in the buildplate; the printJobTextField is set to an empty string so it doesn't set an empty string as a jobName (which is later used for saving the file) - PrintInformation.setBaseName('') + PrintInformation.baseName = '' } }