mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-19 04:37:51 -06:00
Also rename setting in list of visible settings
Yeah, that's why the preferences file had a setting version number... Contributes to issue CURA-6311.
This commit is contained in:
parent
a38984dcec
commit
5fcb59d9fc
3 changed files with 31 additions and 1 deletions
|
@ -34,6 +34,8 @@ class VersionUpgrade41to42(VersionUpgrade):
|
|||
|
||||
## Upgrades instance containers to have the new version
|
||||
# number.
|
||||
#
|
||||
# This renames the renamed settings in the containers.
|
||||
def upgradeInstanceContainer(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]:
|
||||
parser = configparser.ConfigParser(interpolation = None)
|
||||
parser.read_string(serialized)
|
||||
|
@ -52,6 +54,29 @@ class VersionUpgrade41to42(VersionUpgrade):
|
|||
parser.write(result)
|
||||
return [filename], [result.getvalue()]
|
||||
|
||||
## Upgrades Preferences to have the new version number.
|
||||
#
|
||||
# This renames the renamed settings in the list of visible settings.
|
||||
def upgradePreferences(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]:
|
||||
parser = configparser.ConfigParser(interpolation = None)
|
||||
parser.read_string(serialized)
|
||||
|
||||
#Update version number.
|
||||
parser["metadata"]["setting_version"] = "8"
|
||||
|
||||
#Renamed settings.
|
||||
if "visible_settings" in parser["general"]:
|
||||
visible_settings = parser["general"]["visible_settings"]
|
||||
visible_settings = set(visible_settings.split(";"))
|
||||
for old_name, new_name in _renamed_settings.items():
|
||||
if old_name in visible_settings:
|
||||
visible_settings.remove(old_name)
|
||||
visible_settings.add(new_name)
|
||||
|
||||
result = io.StringIO()
|
||||
parser.write(result)
|
||||
return [filename], [result.getvalue()]
|
||||
|
||||
## Upgrades stacks to have the new version number.
|
||||
def upgradeStack(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]:
|
||||
parser = configparser.ConfigParser(interpolation = None)
|
||||
|
|
|
@ -14,6 +14,7 @@ def getMetaData() -> Dict[str, Any]:
|
|||
return {
|
||||
"version_upgrade": {
|
||||
# From To Upgrade function
|
||||
("preferences", 6000007): ("preferences", 6000008, upgrade.upgradePreferences),
|
||||
("machine_stack", 4000007): ("machine_stack", 4000008, upgrade.upgradeStack),
|
||||
("extruder_train", 4000007): ("extruder_train", 4000008, upgrade.upgradeStack),
|
||||
("definition_changes", 4000007): ("definition_changes", 4000008, upgrade.upgradeInstanceContainer),
|
||||
|
@ -22,6 +23,10 @@ def getMetaData() -> Dict[str, Any]:
|
|||
("user", 4000007): ("user", 4000008, upgrade.upgradeInstanceContainer),
|
||||
},
|
||||
"sources": {
|
||||
"preferences": {
|
||||
"get_version": upgrade.getCfgVersion,
|
||||
"location": {"."}
|
||||
},
|
||||
"machine_stack": {
|
||||
"get_version": upgrade.getCfgVersion,
|
||||
"location": {"./machine_instances"}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue