diff options
author | Konstantinos Karmas <konskarm@gmail.com> | 2021-09-23 17:21:46 +0300 |
---|---|---|
committer | Konstantinos Karmas <konskarm@gmail.com> | 2021-09-23 17:21:46 +0300 |
commit | b322edfa53ee1d6dfafd9fefe9164ac92df352f2 (patch) | |
tree | e9cb83b4fd5d8139c68b04564adffb0431a4e541 /plugins/VersionUpgrade/VersionUpgrade411to412 | |
parent | 3e143a012a755bedf9a5b82775afaab555dce054 (diff) |
Update the flsun quality_changes profiles during version upgrade
So that they are also mapped from the global qualities to the flsun_sr-specific ones. This way they will be able to still be used in the newer Cura versions.
CURA-8510
Diffstat (limited to 'plugins/VersionUpgrade/VersionUpgrade411to412')
-rw-r--r-- | plugins/VersionUpgrade/VersionUpgrade411to412/VersionUpgrade411to412.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/plugins/VersionUpgrade/VersionUpgrade411to412/VersionUpgrade411to412.py b/plugins/VersionUpgrade/VersionUpgrade411to412/VersionUpgrade411to412.py index 510675c113..bc00c3fad8 100644 --- a/plugins/VersionUpgrade/VersionUpgrade411to412/VersionUpgrade411to412.py +++ b/plugins/VersionUpgrade/VersionUpgrade411to412/VersionUpgrade411to412.py @@ -3,6 +3,7 @@ import configparser import io +import os.path from typing import List, Tuple from UM.VersionUpgrade import VersionUpgrade @@ -24,6 +25,16 @@ class VersionUpgrade411to412(VersionUpgrade): "high": "flsun_sr_fine" } + _flsun_quality_type_mapping = { + "extra coarse": "normal", + "coarse" : "normal", + "verydraft" : "normal", + "draft" : "normal", + "fast" : "normal", + "normal" : "normal", + "high" : "fine" + } + def upgradePreferences(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]: """ Upgrades preferences to have the new version number. @@ -59,6 +70,15 @@ class VersionUpgrade411to412(VersionUpgrade): parser["metadata"] = {} parser["metadata"]["setting_version"] = "19" + # Update user-made quality profiles of flsun_sr printers to use the flsun_sr-specific qualities instead of the + # global ones as their base + file_base_name = os.path.basename(filename) # Remove any path-related characters from the filename + old_definition = parser["general"]["definition"] + old_quality_type = parser["metadata"]["quality_type"] + if file_base_name.startswith("flsun_sr") and old_definition == "fdmprinter" and parser["metadata"]["type"] == "quality_changes": + parser["general"]["definition"] = "flsun_sr" + parser["metadata"]["quality_type"] = self._flsun_quality_type_mapping.get(old_quality_type, "normal") + result = io.StringIO() parser.write(result) return [filename], [result.getvalue()] |