diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index fc7edb8714..e34bdc6908 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -125,6 +125,8 @@ class CuraApplication(QtApplication): # Cura will always show the Add Machine Dialog upon start. stacksValidationFinished = pyqtSignal() # Emitted whenever a validation is finished + projectFileLoaded = pyqtSignal(str) # Emitted whenever a project file is loaded + def __init__(self): # this list of dir names will be used by UM to detect an old cura directory for dir_name in ["extruders", "machine_instances", "materials", "plugins", "quality", "user", "variants"]: diff --git a/cura/PrintInformation.py b/cura/PrintInformation.py index 80abd0c356..86bcc2719e 100644 --- a/cura/PrintInformation.py +++ b/cura/PrintInformation.py @@ -66,10 +66,11 @@ class PrintInformation(QObject): self._base_name = "" self._abbr_machine = "" self._job_name = "" + self._project_name = "" Application.getInstance().globalContainerStackChanged.connect(self._updateJobName) Application.getInstance().fileLoaded.connect(self.setBaseName) - + Application.getInstance().projectFileLoaded.connect(self.setProjectName) Preferences.getInstance().preferenceChanged.connect(self._onPreferencesChanged) self._active_material_container = None @@ -78,7 +79,6 @@ class PrintInformation(QObject): self._material_amounts = [] - # Crate cura message translations and using translation keys initialize empty time Duration object for total time # and time for each feature def initializeCuraMessagePrintTimeProperties(self): @@ -241,6 +241,11 @@ class PrintInformation(QObject): self._job_name = name self.jobNameChanged.emit() + @pyqtSlot(str) + def setProjectName(self, name): + self._project_name = name + self.setJobName(name) + jobNameChanged = pyqtSignal() @pyqtProperty(str, notify = jobNameChanged) @@ -248,6 +253,11 @@ class PrintInformation(QObject): return self._job_name def _updateJobName(self): + # if the project name is set, we use the project name as the job name, so the job name should not get updated + # if a model file is loaded after that. + if self._project_name != "": + return + if self._base_name == "": self._job_name = "" self.jobNameChanged.emit() diff --git a/plugins/3MFReader/ThreeMFWorkspaceReader.py b/plugins/3MFReader/ThreeMFWorkspaceReader.py index 79e137e87f..5b1e084262 100755 --- a/plugins/3MFReader/ThreeMFWorkspaceReader.py +++ b/plugins/3MFReader/ThreeMFWorkspaceReader.py @@ -26,6 +26,7 @@ from configparser import ConfigParser import zipfile import io import configparser +import os i18n_catalog = i18nCatalog("cura") @@ -876,6 +877,11 @@ class ThreeMFWorkspaceReader(WorkspaceReader): nodes = self._3mf_mesh_reader.read(file_name) if nodes is None: nodes = [] + + base_file_name = os.path.basename(file_name) + if base_file_name.endswith(".curaproject.3mf"): + base_file_name = base_file_name[:base_file_name.rfind(".curaproject.3mf")] + Application.getInstance().projectFileLoaded.emit(base_file_name) return nodes ## HACK: Replaces the material container in the given stack with a newly created material container. diff --git a/resources/qml/OpenFilesIncludingProjectsDialog.qml b/resources/qml/OpenFilesIncludingProjectsDialog.qml index c8df7b69a2..af8fb9e05f 100644 --- a/resources/qml/OpenFilesIncludingProjectsDialog.qml +++ b/resources/qml/OpenFilesIncludingProjectsDialog.qml @@ -36,8 +36,6 @@ UM.Dialog var meshName = backgroundItem.getMeshName(projectFile.toString()); backgroundItem.hasMesh(decodeURIComponent(meshName)); - // always update the job name with the loaded project - PrintInformation.setBaseName(meshName); } function loadModelFiles(fileUrls)