mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-22 06:03: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
|
@ -154,7 +154,7 @@ class BaseMaterialsModel(ListModel):
|
|||
|
||||
# Update the available materials (ContainerNode) for the current active machine and extruder setup.
|
||||
global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()
|
||||
if not global_stack.hasMaterials:
|
||||
if not global_stack or not global_stack.hasMaterials:
|
||||
return # There are no materials for this machine, so nothing to do.
|
||||
extruder_list = global_stack.extruderList
|
||||
if self._extruder_position > len(extruder_list):
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -143,7 +143,7 @@ UM.Dialog
|
|||
{
|
||||
width: parent.width
|
||||
height: childrenRect.height
|
||||
model: Cura.MachineManager.activeMachine.extruderList
|
||||
model: Cura.MachineManager.activeMachine ? Cura.MachineManager.activeMachine.extruderList : null
|
||||
delegate: Column
|
||||
{
|
||||
height: childrenRect.height
|
||||
|
|
|
@ -33,7 +33,7 @@ Cura.ExpandablePopup
|
|||
}
|
||||
|
||||
contentPadding: UM.Theme.getSize("default_lining").width
|
||||
enabled: Cura.MachineManager.activeMachine.hasMaterials || Cura.MachineManager.activeMachine.hasVariants || Cura.MachineManager.activeMachine.hasVariantBuildplates; //Only let it drop down if there is any configuration that you could change.
|
||||
enabled: Cura.MachineManager.activeMachine ? Cura.MachineManager.activeMachine.hasMaterials || Cura.MachineManager.activeMachine.hasVariants || Cura.MachineManager.activeMachine.hasVariantBuildplates : false; //Only let it drop down if there is any configuration that you could change.
|
||||
|
||||
headerItem: Item
|
||||
{
|
||||
|
@ -84,7 +84,7 @@ Cura.ExpandablePopup
|
|||
{
|
||||
id: variantLabel
|
||||
|
||||
visible: Cura.MachineManager.activeMachine.hasVariants
|
||||
visible: Cura.MachineManager.activeMachine ? Cura.MachineManager.activeMachine.hasVariants : false
|
||||
|
||||
text: model.variant
|
||||
elide: Text.ElideRight
|
||||
|
@ -114,7 +114,7 @@ Cura.ExpandablePopup
|
|||
color: UM.Theme.getColor("text")
|
||||
renderType: Text.NativeRendering
|
||||
|
||||
visible: !Cura.MachineManager.activeMachine.hasMaterials && (Cura.MachineManager.activeMachine.hasVariants || Cura.MachineManager.activeMachine.hasVariantBuildplates)
|
||||
visible: Cura.MachineManager.activeMachine ? !Cura.MachineManager.activeMachine.hasMaterials && (Cura.MachineManager.activeMachine.hasVariants || Cura.MachineManager.activeMachine.hasVariantBuildplates) : false
|
||||
|
||||
anchors
|
||||
{
|
||||
|
|
|
@ -244,7 +244,7 @@ Item
|
|||
Row
|
||||
{
|
||||
height: visible ? UM.Theme.getSize("print_setup_big_item").height : 0
|
||||
visible: Cura.MachineManager.activeMachine.hasMaterials
|
||||
visible: Cura.MachineManager.activeMachine ? Cura.MachineManager.activeMachine.hasMaterials : false
|
||||
|
||||
Label
|
||||
{
|
||||
|
@ -305,7 +305,7 @@ Item
|
|||
Row
|
||||
{
|
||||
height: visible ? UM.Theme.getSize("print_setup_big_item").height : 0
|
||||
visible: Cura.MachineManager.activeMachine.hasVariants
|
||||
visible: Cura.MachineManager.activeMachine ? Cura.MachineManager.activeMachine.hasVariants : false
|
||||
|
||||
Label
|
||||
{
|
||||
|
|
|
@ -130,7 +130,11 @@ Item
|
|||
target: extruderModel
|
||||
onModelChanged:
|
||||
{
|
||||
supportExtruderCombobox.color = supportExtruderCombobox.model.getItem(supportExtruderCombobox.currentIndex).color
|
||||
var maybeColor = supportExtruderCombobox.model.getItem(supportExtruderCombobox.currentIndex).color
|
||||
if (maybeColor)
|
||||
{
|
||||
supportExtruderCombobox.color = maybeColor
|
||||
}
|
||||
}
|
||||
}
|
||||
onCurrentIndexChanged:
|
||||
|
|
|
@ -28,11 +28,11 @@ ListView
|
|||
|
||||
delegate: MachineSelectorButton
|
||||
{
|
||||
text: model.name
|
||||
text: model.name ? model.name : ""
|
||||
width: listView.width
|
||||
outputDevice: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
|
||||
|
||||
checked: Cura.MachineManager.activeMachine.id == model.id
|
||||
checked: Cura.MachineManager.activeMachine ? Cura.MachineManager.activeMachine.id == model.id : false
|
||||
|
||||
onClicked:
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue