diff options
author | Nino van Hooff <ninovanhooff@gmail.com> | 2020-07-07 17:11:03 +0300 |
---|---|---|
committer | Nino van Hooff <ninovanhooff@gmail.com> | 2020-07-07 17:11:03 +0300 |
commit | 816aaafc1972d43d93913b9976a1ca7735037914 (patch) | |
tree | c3b036c046b38e35cbce91ea2428bf956a8b94f4 | |
parent | 141ad8ff1dcadeb98a530a858374ca7a63cb4c13 (diff) |
Revert changes for CURA-5479
It was decided that functionality present in existing plugins is
sufficient. No need to replicate it in our own codebase and
take on the burden of maintenance
CURA-5479
-rwxr-xr-x | cura/CuraApplication.py | 2 | ||||
-rw-r--r-- | cura/UI/PrintInformation.py | 43 | ||||
-rw-r--r-- | plugins/VersionUpgrade/VersionUpgrade462to47/VersionUpgrade462to47.py | 9 | ||||
-rw-r--r-- | resources/qml/Preferences/GeneralPage.qml | 31 | ||||
-rw-r--r-- | resources/texts/change_log.txt | 2 | ||||
-rw-r--r-- | tests/TestPrintInformation.py | 9 |
6 files changed, 24 insertions, 72 deletions
diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 82797cd231..bae212917a 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -533,7 +533,7 @@ class CuraApplication(QtApplication): preferences.addPreference("cura/active_mode", "simple") preferences.addPreference("cura/categories_expanded", "") - preferences.addPreference("cura/job_name_template", "{machine_name_short}_{project_name}") + preferences.addPreference("cura/jobname_prefix", True) preferences.addPreference("cura/select_models_on_load", False) preferences.addPreference("view/center_on_select", False) preferences.addPreference("mesh/scale_to_fit", False) diff --git a/cura/UI/PrintInformation.py b/cura/UI/PrintInformation.py index 95aceb67e1..ae4aab0407 100644 --- a/cura/UI/PrintInformation.py +++ b/cura/UI/PrintInformation.py @@ -252,11 +252,11 @@ class PrintInformation(QObject): self.materialNamesChanged.emit() def _onPreferencesChanged(self, preference: str) -> None: - if preference == "cura/job_name_template": - self._updateJobName() - elif preference == "cura/material_settings": - for build_plate_number in range(self._multi_build_plate_model.maxBuildPlate + 1): - self._calculateInformation(build_plate_number) + if preference != "cura/material_settings": + return + + 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,8 +305,12 @@ class PrintInformation(QObject): # Only update the job name when it's not user-specified. if not self._is_user_specified_job_name: - if not self._pre_sliced: - self._job_name = self.parseTemplate() + 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 else: self._job_name = base_name @@ -436,28 +440,3 @@ 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() - active_machine_type_name = global_container_stack.definition.getName() \ - if global_container_stack \ - else "no_machine" - - 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 diff --git a/plugins/VersionUpgrade/VersionUpgrade462to47/VersionUpgrade462to47.py b/plugins/VersionUpgrade/VersionUpgrade462to47/VersionUpgrade462to47.py index ae7e421ab8..a167c9917e 100644 --- a/plugins/VersionUpgrade/VersionUpgrade462to47/VersionUpgrade462to47.py +++ b/plugins/VersionUpgrade/VersionUpgrade462to47/VersionUpgrade462to47.py @@ -4,8 +4,6 @@ import configparser from typing import Tuple, List, Dict, Set import io - -from UM.Util import parseBool from UM.VersionUpgrade import VersionUpgrade @@ -44,13 +42,6 @@ class VersionUpgrade462to47(VersionUpgrade): parser["general"]["visible_settings"] = ";".join( set(parser["general"]["visible_settings"].split(";")).difference(_removed_settings)) - if "cura" in parser and "jobname_prefix" in parser["cura"]: - if not parseBool(parser["cura"]["jobname_prefix"]): - parser["cura"]["job_name_template"] = "{project_name}" - del parser["cura"]["jobname_prefix"] - # else: When the jobname_prefix preference is True or not set, - # the default value for job_name_template ("{machine_name_short}_{project_name}") will be used - result = io.StringIO() parser.write(result) return [filename], [result.getvalue()] diff --git a/resources/qml/Preferences/GeneralPage.qml b/resources/qml/Preferences/GeneralPage.qml index 0d3f6ea586..62768556e4 100644 --- a/resources/qml/Preferences/GeneralPage.qml +++ b/resources/qml/Preferences/GeneralPage.qml @@ -85,8 +85,8 @@ UM.PreferencesPage scaleTinyCheckbox.checked = boolCheck(UM.Preferences.getValue("mesh/scale_tiny_meshes")) UM.Preferences.resetPreference("cura/select_models_on_load") selectModelsOnLoadCheckbox.checked = boolCheck(UM.Preferences.getValue("cura/select_models_on_load")) - UM.Preferences.resetPreference("cura/job_name_template") - jobnameTemplateTextField.text = UM.Preferences.getValue("cura/job_name_template") + UM.Preferences.resetPreference("cura/jobname_prefix") + prefixJobNameCheckbox.checked = boolCheck(UM.Preferences.getValue("cura/jobname_prefix")) UM.Preferences.resetPreference("view/show_overhang"); showOverhangCheckbox.checked = boolCheck(UM.Preferences.getValue("view/show_overhang")) UM.Preferences.resetPreference("view/show_xray_warning"); @@ -627,25 +627,14 @@ UM.PreferencesPage { width: childrenRect.width height: childrenRect.height - text: catalog.i18nc("@info:tooltip. Note variable names themselves (ie. machine_name_short, project_name) should not be translated", "Variables: machine_name_short, machine_name, project_name") + text: catalog.i18nc("@info:tooltip", "Should a prefix based on the printer name be added to the print job name automatically?") - Column + CheckBox { - spacing: 4 * screenScaleFactor - - Label - { - id: jobNameTemplateLabel - text: catalog.i18nc("@label","Print job template:") - } - - TextField - { - id: jobNameTemplateTextField - width: 250 * screenScaleFactor - text: UM.Preferences.getValue("cura/job_name_template") - onTextChanged: UM.Preferences.setValue("cura/job_name_template", text) - } + id: prefixJobNameCheckbox + text: catalog.i18nc("@option:check", "Add machine prefix to job name") + checked: boolCheck(UM.Preferences.getValue("cura/jobname_prefix")) + onCheckedChanged: UM.Preferences.setValue("cura/jobname_prefix", checked) } } @@ -681,7 +670,7 @@ UM.PreferencesPage ComboBox { id: choiceOnOpenProjectDropDownButton - width: 250 * screenScaleFactor + width: 200 * screenScaleFactor model: ListModel { @@ -747,7 +736,7 @@ UM.PreferencesPage ComboBox { id: choiceOnProfileOverrideDropDownButton - width: 250 * screenScaleFactor + width: 200 * screenScaleFactor model: ListModel { diff --git a/resources/texts/change_log.txt b/resources/texts/change_log.txt index 7621f6f713..8ce125d932 100644 --- a/resources/texts/change_log.txt +++ b/resources/texts/change_log.txt @@ -140,7 +140,7 @@ A new performance enhancement that limits re-rendering of the application interf Previous versions used different ways of handling HTTP requests. This version uses a unified method, for better performance. * Job names less sensitive to being touched. -A contribution from fieldOfview has fixed an issue where the job name in the bottom-left of the scene is no longer made static by clicking on it. If you load a model and change to another printer, the prefix is now correctly updated. +A contribution from fieldOfview has fixed an issue where the jobname in the bottom-left of the scene is no longer made static by clicking on it. If you load a model and change to another printer, the prefix is now correctly updated. * Property checks on instance containers. A new speed optimization for reading setting values from profiles. diff --git a/tests/TestPrintInformation.py b/tests/TestPrintInformation.py index 577827f326..5133dfcafb 100644 --- a/tests/TestPrintInformation.py +++ b/tests/TestPrintInformation.py @@ -8,13 +8,6 @@ from unittest.mock import MagicMock, patch from UM.MimeTypeDatabase import MimeTypeDatabase, MimeType -def preferencesGetValue(key: str): - if key == "cura/job_name_template": - return "{machine_name_short}_{project_name}" - - return '{"omgzomg": {"spool_weight": 10, "spool_cost": 9}}' - - def getPrintInformation(printer_name) -> PrintInformation: mock_application = MagicMock(name = "mock_application") @@ -26,7 +19,7 @@ def getPrintInformation(printer_name) -> PrintInformation: mocked_extruder_stack.material = mocked_material mock_application.getInstance = MagicMock(return_value = mock_application) - mocked_preferences.getValue = MagicMock(side_effect = preferencesGetValue) + mocked_preferences.getValue = MagicMock(return_value = '{"omgzomg": {"spool_weight": 10, "spool_cost": 9}}') global_container_stack = MagicMock() global_container_stack.definition.getName = MagicMock(return_value = printer_name) |