From e363f1af948b013d5a15005847986826638ac78d Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 3 May 2019 14:10:21 +0200 Subject: [PATCH] Remove hardcoded references to Ultimaker machines in QML We shouldn't hardocode machines in QML in any case. It also created issues for other monitor / connection flows. --- cura/Settings/GlobalStack.py | 4 ++ plugins/MonitorStage/MonitorMain.qml | 43 +++++++-------------- resources/definitions/fdmprinter.def.json | 3 +- resources/definitions/ultimaker3.def.json | 1 + resources/definitions/ultimaker_s5.def.json | 1 + 5 files changed, 22 insertions(+), 30 deletions(-) diff --git a/cura/Settings/GlobalStack.py b/cura/Settings/GlobalStack.py index 15c95c9394..f6c739a08e 100755 --- a/cura/Settings/GlobalStack.py +++ b/cura/Settings/GlobalStack.py @@ -76,6 +76,10 @@ class GlobalStack(CuraContainerStack): def maxExtruderCount(self): return len(self.getMetaDataEntry("machine_extruder_trains")) + @pyqtProperty(bool, notify=configuredConnectionTypesChanged) + def supportsNetworkConnection(self): + return self.getMetaDataEntry("supports_network_connection", False) + @classmethod def getLoadingPriority(cls) -> int: return 2 diff --git a/plugins/MonitorStage/MonitorMain.qml b/plugins/MonitorStage/MonitorMain.qml index 88193737bb..9e719ddb43 100644 --- a/plugins/MonitorStage/MonitorMain.qml +++ b/plugins/MonitorStage/MonitorMain.qml @@ -12,7 +12,15 @@ Rectangle id: viewportOverlay property bool isConnected: Cura.MachineManager.activeMachineHasNetworkConnection || Cura.MachineManager.activeMachineHasCloudConnection - property bool isNetworkConfigurable: ["Ultimaker 3", "Ultimaker 3 Extended", "Ultimaker S5"].indexOf(Cura.MachineManager.activeMachineDefinitionName) > -1 + property bool isNetworkConfigurable: + { + if(Cura.MachineManager.activeMachine === null) + { + return false + } + return Cura.MachineManager.activeMachine.supportsNetworkConnection + } + property bool isNetworkConfigured: { // Readability: @@ -98,7 +106,6 @@ Rectangle width: contentWidth } - // CASE 3: CAN NOT MONITOR Label { id: noNetworkLabel @@ -106,24 +113,8 @@ Rectangle { horizontalCenter: parent.horizontalCenter } - visible: !isNetworkConfigured - text: catalog.i18nc("@info", "Please select a network connected printer to monitor.") - font: UM.Theme.getFont("medium") - color: UM.Theme.getColor("monitor_text_primary") - wrapMode: Text.WordWrap - width: contentWidth - lineHeight: UM.Theme.getSize("monitor_text_line_large").height - lineHeightMode: Text.FixedHeight - } - Label - { - id: noNetworkUltimakerLabel - anchors - { - horizontalCenter: parent.horizontalCenter - } visible: !isNetworkConfigured && isNetworkConfigurable - text: catalog.i18nc("@info", "Please connect your Ultimaker printer to your local network.") + text: catalog.i18nc("@info", "Please connect your printer to the network.") font: UM.Theme.getFont("medium") color: UM.Theme.getColor("monitor_text_primary") wrapMode: Text.WordWrap @@ -135,7 +126,7 @@ Rectangle { anchors { - left: noNetworkUltimakerLabel.left + left: noNetworkLabel.left } visible: !isNetworkConfigured && isNetworkConfigurable height: UM.Theme.getSize("monitor_text_line").height @@ -160,7 +151,7 @@ Rectangle verticalCenter: externalLinkIcon.verticalCenter } color: UM.Theme.getColor("monitor_text_link") - font: UM.Theme.getFont("medium") // 14pt, regular + font: UM.Theme.getFont("medium") linkColor: UM.Theme.getColor("monitor_text_link") text: catalog.i18nc("@label link to technical assistance", "View user manuals online") renderType: Text.NativeRendering @@ -170,14 +161,8 @@ Rectangle anchors.fill: parent hoverEnabled: true onClicked: Qt.openUrlExternally("https://ultimaker.com/en/resources/manuals/ultimaker-3d-printers") - onEntered: - { - manageQueueText.font.underline = true - } - onExited: - { - manageQueueText.font.underline = false - } + onEntered: manageQueueText.font.underline = true + onExited: manageQueueText.font.underline = false } } } diff --git a/resources/definitions/fdmprinter.def.json b/resources/definitions/fdmprinter.def.json index 636a918579..230f5e5082 100644 --- a/resources/definitions/fdmprinter.def.json +++ b/resources/definitions/fdmprinter.def.json @@ -17,7 +17,8 @@ { "0": "fdmextruder" }, - "supports_usb_connection": true + "supports_usb_connection": true, + "supports_network_connection": false }, "settings": { diff --git a/resources/definitions/ultimaker3.def.json b/resources/definitions/ultimaker3.def.json index 368a41e0a9..3535661245 100644 --- a/resources/definitions/ultimaker3.def.json +++ b/resources/definitions/ultimaker3.def.json @@ -26,6 +26,7 @@ "first_start_actions": [ "DiscoverUM3Action" ], "supported_actions": [ "DiscoverUM3Action" ], "supports_usb_connection": false, + "supports_network_connection": true, "firmware_update_info": { "id": 9066, "check_urls": diff --git a/resources/definitions/ultimaker_s5.def.json b/resources/definitions/ultimaker_s5.def.json index f76ce77619..41808c134f 100644 --- a/resources/definitions/ultimaker_s5.def.json +++ b/resources/definitions/ultimaker_s5.def.json @@ -30,6 +30,7 @@ "first_start_actions": [ "DiscoverUM3Action" ], "supported_actions": [ "DiscoverUM3Action" ], "supports_usb_connection": false, + "supports_network_connection": true, "weight": -1, "firmware_update_info": { "id": 9051,