From f3b904056168484a76d3d922e96df23f098d5bae Mon Sep 17 00:00:00 2001 From: joeydelarago Date: Mon, 29 Aug 2022 14:03:23 +0200 Subject: [PATCH] Add sanity check for printers that are online. They must have an online connection type. This can pop up when adding a printer from a 3mf since we do not store the connection_type but we do store is_online=True. CURA-9277 --- cura/Machines/Models/MachineListModel.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cura/Machines/Models/MachineListModel.py b/cura/Machines/Models/MachineListModel.py index a758060384..6814600307 100644 --- a/cura/Machines/Models/MachineListModel.py +++ b/cura/Machines/Models/MachineListModel.py @@ -11,6 +11,7 @@ from UM.Qt.ListModel import ListModel from UM.Settings.ContainerStack import ContainerStack from UM.i18n import i18nCatalog from UM.Util import parseBool +from cura.PrinterOutput.PrinterOutputDevice import ConnectionType from cura.Settings.CuraContainerRegistry import CuraContainerRegistry from cura.Settings.GlobalStack import GlobalStack @@ -90,10 +91,17 @@ class MachineListModel(ListModel): if parseBool(container_stack.getMetaDataEntry("hidden", False)): return + # This is required because machines loaded from projects have the is_online="True" but no connection type. + # We want to display them the same way as unconnected printers in this case. + has_connection = False + has_connection |= parseBool(container_stack.getMetaDataEntry("is_abstract_machine", False)) + for connection_type in [ConnectionType.NetworkConnection.value, ConnectionType.CloudConnection.value]: + has_connection |= connection_type in container_stack.configuredConnectionTypes + self.appendItem({"name": container_stack.getName(), "id": container_stack.getId(), "metadata": container_stack.getMetaData().copy(), - "isOnline": parseBool(container_stack.getMetaDataEntry("is_online", False)), + "isOnline": parseBool(container_stack.getMetaDataEntry("is_online", False)) and has_connection, "isAbstractMachine": parseBool(container_stack.getMetaDataEntry("is_abstract_machine", False)), "machineCount": machine_count, })