mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00
Move LegacyProfileReader-specific logic into the plug-in itself
This had the documentation that it should edit the profiles returned by LegacyProfileReader. Instead, just return correct profiles from the reader... Contributes to issue CURA-4715.
This commit is contained in:
parent
c6a2b1b9c9
commit
05e232b498
2 changed files with 14 additions and 21 deletions
|
@ -13,6 +13,7 @@ from UM.PluginRegistry import PluginRegistry # For getting the path to this plu
|
|||
from UM.Settings.ContainerRegistry import ContainerRegistry #To create unique profile IDs.
|
||||
from UM.Settings.InstanceContainer import InstanceContainer # The new profile to make.
|
||||
from cura.ProfileReader import ProfileReader # The plug-in type to implement.
|
||||
from cura.Settings.ExtruderManager import ExtruderManager #To get the current extruder definition.
|
||||
|
||||
|
||||
## A plugin that reads profile data from legacy Cura versions.
|
||||
|
@ -142,14 +143,13 @@ class LegacyProfileReader(ProfileReader):
|
|||
if len(profile.getAllKeys()) == 0:
|
||||
Logger.log("i", "A legacy profile was imported but everything evaluates to the defaults, creating an empty profile.")
|
||||
|
||||
# We need to downgrade the container to version 1 (in Cura 2.1) so the upgrade system can correctly upgrade
|
||||
# it to the latest version.
|
||||
profile.addMetaDataEntry("type", "profile")
|
||||
# don't know what quality_type it is based on, so use "normal" by default
|
||||
profile.addMetaDataEntry("quality_type", "normal")
|
||||
profile.setName("Imported Legacy Profile")
|
||||
profile.setDirty(True)
|
||||
|
||||
#Serialise and deserialise in order to perform the version upgrade.
|
||||
parser = configparser.ConfigParser(interpolation=None)
|
||||
data = profile.serialize()
|
||||
parser.read_string(data)
|
||||
|
@ -162,8 +162,20 @@ class LegacyProfileReader(ProfileReader):
|
|||
data = stream.getvalue()
|
||||
profile.deserialize(data)
|
||||
|
||||
#We need to return one extruder stack and one global stack.
|
||||
global_container_id = container_registry.uniqueName("Global Imported Legacy Profile")
|
||||
global_profile = profile.duplicate(new_id = global_container_id, new_name = "Imported Legacy Profile") #Needs to have the same name as the extruder profile.
|
||||
global_profile.setDirty(True)
|
||||
|
||||
#Only the extruder stack has an extruder metadata entry.
|
||||
profile.addMetaDataEntry("extruder", ExtruderManager.getInstance().getActiveExtruderStack().definition)
|
||||
|
||||
#Split all settings into per-extruder and global settings.
|
||||
for setting_key in profile.getAllKeys():
|
||||
settable_per_extruder = global_container_stack.getProperty(setting_key, "settable_per_extruder")
|
||||
if settable_per_extruder:
|
||||
global_profile.removeInstance(setting_key)
|
||||
else:
|
||||
profile.removeInstance(setting_key)
|
||||
|
||||
return [global_profile, profile]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue