|
@@ -252,11 +252,12 @@ class PrintInformation(QObject):
|
|
|
self.materialNamesChanged.emit()
|
|
|
|
|
|
def _onPreferencesChanged(self, preference: str) -> None:
|
|
|
- if preference != "cura/material_settings":
|
|
|
- return
|
|
|
+ if preference == "cura/job_name_template":
|
|
|
+ self._updateJobName()
|
|
|
|
|
|
- for build_plate_number in range(self._multi_build_plate_model.maxBuildPlate + 1):
|
|
|
- self._calculateInformation(build_plate_number)
|
|
|
+ if preference == "cura/material_settings":
|
|
|
+ for build_plate_number in range(self._multi_build_plate_model.maxBuildPlate + 1):
|
|
|
+ self._calculateInformation(build_plate_number)
|
|
|
|
|
|
def _onActiveBuildPlateChanged(self) -> None:
|
|
|
new_active_build_plate = self._multi_build_plate_model.activeBuildPlate
|
|
@@ -305,12 +306,8 @@ class PrintInformation(QObject):
|
|
|
|
|
|
# Only update the job name when it's not user-specified.
|
|
|
if not self._is_user_specified_job_name:
|
|
|
- if self._application.getInstance().getPreferences().getValue("cura/jobname_prefix") and not self._pre_sliced:
|
|
|
- # Don't add abbreviation if it already has the exact same abbreviation.
|
|
|
- if base_name.startswith(self._abbr_machine + "_"):
|
|
|
- self._job_name = base_name
|
|
|
- else:
|
|
|
- self._job_name = self._abbr_machine + "_" + base_name
|
|
|
+ if not self._pre_sliced:
|
|
|
+ self._job_name = self.parseTemplate()
|
|
|
else:
|
|
|
self._job_name = base_name
|
|
|
|
|
@@ -440,3 +437,28 @@ class PrintInformation(QObject):
|
|
|
"""Listen to scene changes to check if we need to reset the print information"""
|
|
|
|
|
|
self.setToZeroPrintInformation(self._active_build_plate)
|
|
|
+
|
|
|
+ def parseTemplate(self) -> str:
|
|
|
+ """Generate a print job name from the job name template
|
|
|
+
|
|
|
+ The template is a user preference: "cura/job_name_template"
|
|
|
+ """
|
|
|
+ template = self._application.getInstance().getPreferences().getValue("cura/job_name_template")
|
|
|
+ output = template
|
|
|
+
|
|
|
+ output = output.replace("{machine_name_short}", self._abbr_machine)
|
|
|
+
|
|
|
+ if "{machine_name}" in template:
|
|
|
+ global_container_stack = self._application.getGlobalContainerStack()
|
|
|
+ if not global_container_stack:
|
|
|
+ self._abbr_machine = ""
|
|
|
+ return
|
|
|
+ active_machine_type_name = global_container_stack.definition.getName()
|
|
|
+ active_machine_type_name = active_machine_type_name.replace(" ", "_")
|
|
|
+ output = output.replace("{machine_name}", active_machine_type_name)
|
|
|
+
|
|
|
+ if "{project_name}" in template:
|
|
|
+ base_name = self._stripAccents(self._base_name)
|
|
|
+ output = output.replace("{project_name}", base_name)
|
|
|
+
|
|
|
+ return output
|