mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 15:07:28 -06:00
Loading workspace now activates the machine and notifies everyone that it was changed
CURA-1263
This commit is contained in:
parent
d5229992df
commit
8ae0cfd848
2 changed files with 20 additions and 2 deletions
|
@ -277,7 +277,7 @@ class MachineManager(QObject):
|
||||||
|
|
||||||
def _onInstanceContainersChanged(self, container):
|
def _onInstanceContainersChanged(self, container):
|
||||||
container_type = container.getMetaDataEntry("type")
|
container_type = container.getMetaDataEntry("type")
|
||||||
|
|
||||||
if container_type == "material":
|
if container_type == "material":
|
||||||
self.activeMaterialChanged.emit()
|
self.activeMaterialChanged.emit()
|
||||||
elif container_type == "variant":
|
elif container_type == "variant":
|
||||||
|
|
|
@ -147,6 +147,9 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
else:
|
else:
|
||||||
if self._resolve_strategy == "override":
|
if self._resolve_strategy == "override":
|
||||||
user_containers[0].deserialize(archive.open(instance_container_file).read().decode("utf-8"))
|
user_containers[0].deserialize(archive.open(instance_container_file).read().decode("utf-8"))
|
||||||
|
else:
|
||||||
|
# TODO: Handle other resolve strategies
|
||||||
|
pass
|
||||||
user_instance_containers.append(instance_container)
|
user_instance_containers.append(instance_container)
|
||||||
elif container_type == "quality_changes":
|
elif container_type == "quality_changes":
|
||||||
# Check if quality changes already exists.
|
# Check if quality changes already exists.
|
||||||
|
@ -168,22 +171,37 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
for container_stack_file in container_stack_files:
|
for container_stack_file in container_stack_files:
|
||||||
container_id = self._stripFileToId(container_stack_file)
|
container_id = self._stripFileToId(container_stack_file)
|
||||||
|
|
||||||
stack = ContainerStack(container_id)
|
|
||||||
# Check if a stack by this ID already exists;
|
# Check if a stack by this ID already exists;
|
||||||
container_stacks = self._container_registry.findContainerStacks(id=container_id)
|
container_stacks = self._container_registry.findContainerStacks(id=container_id)
|
||||||
if container_stacks:
|
if container_stacks:
|
||||||
|
stack = container_stacks[0]
|
||||||
if self._resolve_strategy == "override":
|
if self._resolve_strategy == "override":
|
||||||
container_stacks[0].deserialize(archive.open(container_stack_file).read().decode("utf-8"))
|
container_stacks[0].deserialize(archive.open(container_stack_file).read().decode("utf-8"))
|
||||||
|
else:
|
||||||
|
# TODO: Handle other resolve strategies
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
|
stack = ContainerStack(container_id)
|
||||||
# Deserialize stack by converting read data from bytes to string
|
# Deserialize stack by converting read data from bytes to string
|
||||||
stack.deserialize(archive.open(container_stack_file).read().decode("utf-8"))
|
stack.deserialize(archive.open(container_stack_file).read().decode("utf-8"))
|
||||||
|
|
||||||
self._container_registry.addContainer(stack)
|
self._container_registry.addContainer(stack)
|
||||||
|
|
||||||
if stack.getMetaDataEntry("type") == "extruder_train":
|
if stack.getMetaDataEntry("type") == "extruder_train":
|
||||||
extruder_stacks.append(stack)
|
extruder_stacks.append(stack)
|
||||||
else:
|
else:
|
||||||
global_stack = stack
|
global_stack = stack
|
||||||
|
# Notify everything/one that is to notify about changes.
|
||||||
|
for container in global_stack.getContainers():
|
||||||
|
global_stack.containersChanged.emit(container)
|
||||||
|
|
||||||
|
for stack in extruder_stacks:
|
||||||
|
for container in stack.getContainers():
|
||||||
|
stack.containersChanged.emit(container)
|
||||||
|
|
||||||
|
# Actually change the active machine.
|
||||||
|
Application.getInstance().setGlobalContainerStack(global_stack)
|
||||||
return nodes
|
return nodes
|
||||||
|
|
||||||
def _stripFileToId(self, file):
|
def _stripFileToId(self, file):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue