mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-24 23:23:57 -06:00
Allow the machine manager to set an empty active machine
Gracefully handle the case where the machine manager is requested to delete the last machine in Cura. In this case, instead of deleting everything of this machine and still keep it as an active machine, the machine manager will set the active machine to None. The QML files which depend on the active machine were changed to properly handle themselves when there is no active machine. CURA-7454
This commit is contained in:
parent
669dcc62dd
commit
5c898b8c57
7 changed files with 23 additions and 11 deletions
|
@ -290,9 +290,15 @@ class MachineManager(QObject):
|
|||
self.activeStackValueChanged.emit()
|
||||
|
||||
@pyqtSlot(str)
|
||||
def setActiveMachine(self, stack_id: str) -> None:
|
||||
def setActiveMachine(self, stack_id: Optional[str]) -> None:
|
||||
self.blurSettings.emit() # Ensure no-one has focus.
|
||||
|
||||
if not stack_id:
|
||||
self._application.setGlobalContainerStack(None)
|
||||
self.globalContainerChanged.emit()
|
||||
self._application.showAddPrintersUncancellableDialog.emit()
|
||||
return
|
||||
|
||||
container_registry = CuraContainerRegistry.getInstance()
|
||||
containers = container_registry.findContainerStacks(id = stack_id)
|
||||
if not containers:
|
||||
|
@ -717,6 +723,8 @@ class MachineManager(QObject):
|
|||
other_machine_stacks = [s for s in machine_stacks if s["id"] != machine_id]
|
||||
if other_machine_stacks:
|
||||
self.setActiveMachine(other_machine_stacks[0]["id"])
|
||||
else:
|
||||
self.setActiveMachine(None)
|
||||
|
||||
metadatas = CuraContainerRegistry.getInstance().findContainerStacksMetadata(id = machine_id)
|
||||
if not metadatas:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue