Keep global settings on sync to diff printer type

In addition to the per-extruder user changes, copy the global user
changes to the new_machine.

CURA-6127
This commit is contained in:
Kostas Karmas 2019-12-13 15:00:22 +01:00
parent 2b6b7a1f81
commit 409dc98299

View file

@ -1257,16 +1257,19 @@ class MachineManager(QObject):
new_machine.setMetaDataEntry("hidden", False) new_machine.setMetaDataEntry("hidden", False)
self._global_container_stack.setMetaDataEntry("hidden", True) self._global_container_stack.setMetaDataEntry("hidden", True)
# The new_machine only has the global user changes and not the per-extruder user changes (since it has an empty # The new_machine does not contain user changes (global or per-extruder user changes).
# extruderList before it becomes active). Keep a temporary copy of the per-extruder user changes and transfer # Keep a temporary copy of the global and per-extruder user changes and transfer them to the user changes
# it to the user changes of the new machine after the new_machine becomes active. # of the new machine after the new_machine becomes active.
global_user_changes = self._global_container_stack.userChanges
per_extruder_user_changes = {} per_extruder_user_changes = {}
for extruder_name, extruder_stack in self._global_container_stack.extruders.items(): for extruder_name, extruder_stack in self._global_container_stack.extruders.items():
per_extruder_user_changes[extruder_name] = extruder_stack.userChanges per_extruder_user_changes[extruder_name] = extruder_stack.userChanges
self.setActiveMachine(new_machine.getId()) self.setActiveMachine(new_machine.getId())
# Apply the per-extruder userChanges to the new_machine (which is of different type than the previous one). # Apply the global and per-extruder userChanges to the new_machine (which is of different type than the
# previous one).
self._global_container_stack.setUserChanges(global_user_changes)
for extruder_name in self._global_container_stack.extruders.keys(): for extruder_name in self._global_container_stack.extruders.keys():
self._global_container_stack.extruders[extruder_name].setUserChanges(per_extruder_user_changes[extruder_name]) self._global_container_stack.extruders[extruder_name].setUserChanges(per_extruder_user_changes[extruder_name])