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
This commit is contained in:
Konstantinos Karmas 2021-09-23 16:21:46 +02:00
parent 3e143a012a
commit b322edfa53

View file

@ -3,6 +3,7 @@
import configparser import configparser
import io import io
import os.path
from typing import List, Tuple from typing import List, Tuple
from UM.VersionUpgrade import VersionUpgrade from UM.VersionUpgrade import VersionUpgrade
@ -24,6 +25,16 @@ class VersionUpgrade411to412(VersionUpgrade):
"high": "flsun_sr_fine" "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]]: def upgradePreferences(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]:
""" """
Upgrades preferences to have the new version number. Upgrades preferences to have the new version number.
@ -59,6 +70,15 @@ class VersionUpgrade411to412(VersionUpgrade):
parser["metadata"] = {} parser["metadata"] = {}
parser["metadata"]["setting_version"] = "19" 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() result = io.StringIO()
parser.write(result) parser.write(result)
return [filename], [result.getvalue()] return [filename], [result.getvalue()]