From 938287095f3c2705b97df881feba30924733f291 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 17 Dec 2018 10:47:14 +0100 Subject: [PATCH] Use connection type instead of um_network_key to see if a printer has a network connection CURA-6011 --- cura/Settings/MachineManager.py | 9 ++++++++- .../qml/Menus/ConfigurationMenu/ConfigurationMenu.qml | 2 +- resources/qml/MonitorSidebar.qml | 4 ++-- resources/qml/PrinterSelector/MachineSelector.qml | 2 +- resources/qml/PrinterSelector/MachineSelectorList.qml | 1 + 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index c375ce01d1..342f53aac6 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -23,7 +23,7 @@ from UM.Settings.SettingFunction import SettingFunction from UM.Signal import postponeSignals, CompressTechnique from cura.Machines.QualityManager import getMachineDefinitionIDForQualitySearch -from cura.PrinterOutputDevice import PrinterOutputDevice +from cura.PrinterOutputDevice import PrinterOutputDevice, ConnectionType from cura.PrinterOutput.ConfigurationModel import ConfigurationModel from cura.PrinterOutput.ExtruderConfigurationModel import ExtruderConfigurationModel from cura.PrinterOutput.MaterialOutputModel import MaterialOutputModel @@ -521,6 +521,13 @@ class MachineManager(QObject): def printerConnected(self): return bool(self._printer_output_devices) + @pyqtProperty(bool, notify=printerConnectedStatusChanged) + def activeMachineHasRemoteConnection(self) -> bool: + if self._global_container_stack: + connection_type = self._global_container_stack.getMetaDataEntry("connection_type") + return connection_type in [ConnectionType.NetworkConnection, ConnectionType.CloudConnection] + return False + @pyqtProperty(str, notify = printerConnectedStatusChanged) def activeMachineNetworkKey(self) -> str: if self._global_container_stack: diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml index 33a317b42b..8e9c276c0d 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml @@ -134,7 +134,7 @@ Cura.ExpandablePopup property bool is_connected: false //If current machine is connected to a printer. Only evaluated upon making popup visible. onVisibleChanged: { - is_connected = Cura.MachineManager.activeMachineNetworkKey !== "" && Cura.MachineManager.printerConnected //Re-evaluate. + is_connected = Cura.MachineManager.activeMachineHasRemoteConnection && Cura.MachineManager.printerConnected //Re-evaluate. } property int configuration_method: is_connected ? ConfigurationMenu.ConfigurationMethod.Auto : ConfigurationMenu.ConfigurationMethod.Custom //Auto if connected to a printer at start-up, or Custom if not. diff --git a/resources/qml/MonitorSidebar.qml b/resources/qml/MonitorSidebar.qml index 669bdbfb8f..70ee60377d 100644 --- a/resources/qml/MonitorSidebar.qml +++ b/resources/qml/MonitorSidebar.qml @@ -21,7 +21,7 @@ Rectangle property bool hideView: Cura.MachineManager.activeMachineName == "" // Is there an output device for this printer? - property bool isNetworkPrinter: Cura.MachineManager.activeMachineNetworkKey != "" + property bool isNetworkPrinter: Cura.MachineManager.activeMachineHasRemoteConnection property bool printerConnected: Cura.MachineManager.printerConnected property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands property var connectedPrinter: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null @@ -205,7 +205,7 @@ Rectangle target: Cura.MachineManager onGlobalContainerChanged: { - base.isNetworkPrinter = Cura.MachineManager.activeMachineNetworkKey != "" + base.isNetworkPrinter = Cura.MachineManager.activeMachineHasRemoteConnection base.printerConnected = Cura.MachineManager.printerOutputDevices.length != 0 } } diff --git a/resources/qml/PrinterSelector/MachineSelector.qml b/resources/qml/PrinterSelector/MachineSelector.qml index 6e120e89c7..8a7b87f409 100644 --- a/resources/qml/PrinterSelector/MachineSelector.qml +++ b/resources/qml/PrinterSelector/MachineSelector.qml @@ -11,7 +11,7 @@ Cura.ExpandablePopup { id: machineSelector - property bool isNetworkPrinter: Cura.MachineManager.activeMachineNetworkKey != "" + property bool isNetworkPrinter: Cura.MachineManager.activeMachineHasRemoteConnection property bool isPrinterConnected: Cura.MachineManager.printerConnected property var outputDevice: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null diff --git a/resources/qml/PrinterSelector/MachineSelectorList.qml b/resources/qml/PrinterSelector/MachineSelectorList.qml index b157f9a4f6..e0dc6f5e44 100644 --- a/resources/qml/PrinterSelector/MachineSelectorList.qml +++ b/resources/qml/PrinterSelector/MachineSelectorList.qml @@ -30,6 +30,7 @@ ListView { text: model.name width: listView.width + outputDevice: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null } } /*