From 5074cf69ddde8337e42e0ef59b1c91525d25f65d Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 5 Apr 2019 09:42:21 +0200 Subject: [PATCH 1/7] Fix typing CURA-6435 --- plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py index 4fc4c1f795..a6bc13f3c2 100644 --- a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py @@ -356,7 +356,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): properties = device.getProperties().copy() if b"incomplete" in properties: del properties[b"incomplete"] - properties[b"cluster_size"] = len(cluster_printers_list) + properties[b"cluster_size"] = str(len(cluster_printers_list)).encode("utf-8") self._onRemoveDevice(instance_name) self._onAddDevice(instance_name, address, properties) From f2234cffa4a9ffb5811ffbcd2409b698cdc04935 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 5 Apr 2019 10:43:09 +0200 Subject: [PATCH 2/7] Fix extruder enable/disable problem in color scheme --- plugins/SimulationView/SimulationViewMenuComponent.qml | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/SimulationView/SimulationViewMenuComponent.qml b/plugins/SimulationView/SimulationViewMenuComponent.qml index 957d8170cf..6a035cc624 100644 --- a/plugins/SimulationView/SimulationViewMenuComponent.qml +++ b/plugins/SimulationView/SimulationViewMenuComponent.qml @@ -177,7 +177,6 @@ Cura.ExpandableComponent height: UM.Theme.getSize("layerview_row").height + UM.Theme.getSize("default_lining").height width: parent.width visible: !UM.SimulationView.compatibilityMode - enabled: index < 4 onClicked: { From 6892307be306c4304551461bbd17011d4f4d857e Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 5 Apr 2019 10:49:36 +0200 Subject: [PATCH 3/7] Fix typo --- plugins/3MFReader/WorkspaceDialog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/3MFReader/WorkspaceDialog.py b/plugins/3MFReader/WorkspaceDialog.py index 09fcff9758..332c57ceb1 100644 --- a/plugins/3MFReader/WorkspaceDialog.py +++ b/plugins/3MFReader/WorkspaceDialog.py @@ -155,7 +155,7 @@ class WorkspaceDialog(QObject): def setNumSettingsOverriddenByQualityChanges(self, num_settings_overridden_by_quality_changes): self._num_settings_overridden_by_quality_changes = num_settings_overridden_by_quality_changes - self.numSettingsOverriddenByQualityChangesChanged.emit() + self.numSettingsOverridenByQualityChangesChanged.emit() @pyqtProperty(str, notify=qualityNameChanged) def qualityName(self): From 495b24b87ba6c9f0a0308b02236b744664cad629 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 5 Apr 2019 16:41:22 +0200 Subject: [PATCH 4/7] Factor out the scene proxy --- resources/qml/Actions.qml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/qml/Actions.qml b/resources/qml/Actions.qml index c35e845993..81c14aa01a 100644 --- a/resources/qml/Actions.qml +++ b/resources/qml/Actions.qml @@ -282,7 +282,7 @@ Item { id: groupObjectsAction text: catalog.i18nc("@action:inmenu menubar:edit","&Group Models"); - enabled: UM.Scene.numObjectsSelected > 1 ? true: false + enabled: UM.Selection.selectionCount > 1 ? true: false iconName: "object-group" shortcut: "Ctrl+G"; onTriggered: CuraApplication.groupSelected(); @@ -302,7 +302,7 @@ Item { id: unGroupObjectsAction text: catalog.i18nc("@action:inmenu menubar:edit","Ungroup Models"); - enabled: UM.Scene.isGroupSelected + enabled: UM.Selection.isGroupSelected iconName: "object-ungroup" shortcut: "Ctrl+Shift+G"; onTriggered: CuraApplication.ungroupSelected(); @@ -312,7 +312,7 @@ Item { id: mergeObjectsAction text: catalog.i18nc("@action:inmenu menubar:edit","&Merge Models"); - enabled: UM.Scene.numObjectsSelected > 1 ? true: false + enabled: UM.Selection.selectionCount > 1 ? true: false iconName: "merge"; shortcut: "Ctrl+Alt+G"; onTriggered: CuraApplication.mergeSelected(); From ed503cb6ecc714a23b4de3590ec82fc5eadb81e9 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 5 Apr 2019 17:07:12 +0200 Subject: [PATCH 5/7] Removed platform check that always had the same result The UM.Application.platform property has been removed by someone for quite some time. I don't know why the check was in there, but it doesn't seem needed at all as the property was always undefined --- .../resources/qml/ToolboxConfirmUninstallResetDialog.qml | 2 +- resources/qml/Cura.qml | 2 +- resources/qml/Dialogs/AskOpenAsProjectOrModelsDialog.qml | 2 +- resources/qml/Dialogs/OpenFilesIncludingProjectsDialog.qml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxConfirmUninstallResetDialog.qml b/plugins/Toolbox/resources/qml/ToolboxConfirmUninstallResetDialog.qml index e238132680..81649fdfef 100644 --- a/plugins/Toolbox/resources/qml/ToolboxConfirmUninstallResetDialog.qml +++ b/plugins/Toolbox/resources/qml/ToolboxConfirmUninstallResetDialog.qml @@ -26,7 +26,7 @@ UM.Dialog minimumWidth: 450 * screenScaleFactor minimumHeight: 150 * screenScaleFactor - modality: UM.Application.platform == "linux" ? Qt.NonModal : Qt.WindowModal + modality: Qt.WindowModal Column { diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index dd985fe5c3..982f371a7b 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -563,7 +563,7 @@ UM.MainWindow //: File open dialog title title: catalog.i18nc("@title:window","Open file(s)") - modality: UM.Application.platform == "linux" ? Qt.NonModal : Qt.WindowModal; + modality: Qt.WindowModal selectMultiple: true nameFilters: UM.MeshFileHandler.supportedReadFileTypes; folder: CuraApplication.getDefaultPath("dialog_load_path") diff --git a/resources/qml/Dialogs/AskOpenAsProjectOrModelsDialog.qml b/resources/qml/Dialogs/AskOpenAsProjectOrModelsDialog.qml index 6b1856723b..f6436f62c5 100644 --- a/resources/qml/Dialogs/AskOpenAsProjectOrModelsDialog.qml +++ b/resources/qml/Dialogs/AskOpenAsProjectOrModelsDialog.qml @@ -26,7 +26,7 @@ UM.Dialog minimumHeight: maximumHeight minimumWidth: maximumWidth - modality: UM.Application.platform == "linux" ? Qt.NonModal : Qt.WindowModal + modality: Qt.WindowModal property var fileUrl diff --git a/resources/qml/Dialogs/OpenFilesIncludingProjectsDialog.qml b/resources/qml/Dialogs/OpenFilesIncludingProjectsDialog.qml index 3dcd4b6236..0df914805a 100644 --- a/resources/qml/Dialogs/OpenFilesIncludingProjectsDialog.qml +++ b/resources/qml/Dialogs/OpenFilesIncludingProjectsDialog.qml @@ -25,7 +25,7 @@ UM.Dialog minimumHeight: height minimumWidth: width - modality: UM.Application.platform == "linux" ? Qt.NonModal : Qt.WindowModal; + modality: Qt.WindowModal property var fileUrls: [] property int spacerHeight: 10 * screenScaleFactor From 5b818d203ad9905f70ed7d6e1770d89027523ebe Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 5 Apr 2019 17:45:19 +0200 Subject: [PATCH 6/7] Move a bunch of network only functions out of machine manager Machine manager is way to big as is, so we need to move more code out of it to locations where the code is actually used. --- .../NetworkedPrinterOutputDevice.py | 19 +++++++++++++- cura/Settings/MachineManager.py | 26 ------------------- .../src/DiscoverUM3Action.py | 9 ++++++- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/cura/PrinterOutput/NetworkedPrinterOutputDevice.py b/cura/PrinterOutput/NetworkedPrinterOutputDevice.py index b846d98299..86da9bf57f 100644 --- a/cura/PrinterOutput/NetworkedPrinterOutputDevice.py +++ b/cura/PrinterOutput/NetworkedPrinterOutputDevice.py @@ -18,6 +18,8 @@ from enum import IntEnum import os # To get the username import gzip +from cura.Settings.CuraContainerRegistry import CuraContainerRegistry + class AuthState(IntEnum): NotAuthenticated = 1 @@ -319,12 +321,27 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice): self._manager.authenticationRequired.connect(self._onAuthenticationRequired) if self._properties.get(b"temporary", b"false") != b"true": - CuraApplication.getInstance().getMachineManager().checkCorrectGroupName(self.getId(), self.name) + self._checkCorrectGroupName(self.getId(), self.name) def _registerOnFinishedCallback(self, reply: QNetworkReply, on_finished: Optional[Callable[[QNetworkReply], None]]) -> None: if on_finished is not None: self._onFinishedCallbacks[reply.url().toString() + str(reply.operation())] = on_finished + ## This method checks if the name of the group stored in the definition container is correct. + # After updating from 3.2 to 3.3 some group names may be temporary. If there is a mismatch in the name of the group + # then all the container stacks are updated, both the current and the hidden ones. + def _checkCorrectGroupName(self, device_id: str, group_name: str) -> None: + global_container_stack = CuraApplication.getInstance().getGlobalContainerStack() + active_machine_network_name = CuraApplication.getInstance().getMachineManager().activeMachineNetworkKey() + if global_container_stack and device_id == active_machine_network_name: + # Check if the group_name is correct. If not, update all the containers connected to the same printer + if CuraApplication.getInstance().getMachineManager().activeMachineNetworkGroupName != group_name: + metadata_filter = {"um_network_key": active_machine_network_name} + containers = CuraContainerRegistry.getInstance().findContainerStacks(type="machine", + **metadata_filter) + for container in containers: + container.setMetaDataEntry("group_name", group_name) + def _handleOnFinished(self, reply: QNetworkReply) -> None: # Due to garbage collection, we need to cache certain bits of post operations. # As we don't want to keep them around forever, delete them if we get a reply. diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index 3cee636d1d..267baf085f 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -683,11 +683,6 @@ class MachineManager(QObject): return False return True - ## Check if a container is read_only - @pyqtSlot(str, result = bool) - def isReadOnly(self, container_id: str) -> bool: - return CuraContainerRegistry.getInstance().isReadOnly(container_id) - ## Copy the value of the setting of the current extruder to all other extruders as well as the global container. @pyqtSlot(str) def copyValueToExtruders(self, key: str) -> None: @@ -1065,9 +1060,6 @@ class MachineManager(QObject): def _onMaterialNameChanged(self) -> None: self.activeMaterialChanged.emit() - def _onQualityNameChanged(self) -> None: - self.activeQualityChanged.emit() - def _getContainerChangedSignals(self) -> List[Signal]: if self._global_container_stack is None: return [] @@ -1463,24 +1455,6 @@ class MachineManager(QObject): if self.hasUserSettings and self._application.getPreferences().getValue("cura/active_mode") == 1: self._application.discardOrKeepProfileChanges() - ## Find all container stacks that has the pair 'key = value' in its metadata and replaces the value with 'new_value' - def replaceContainersMetadata(self, key: str, value: str, new_value: str) -> None: - machines = CuraContainerRegistry.getInstance().findContainerStacks(type = "machine") - for machine in machines: - if machine.getMetaDataEntry(key) == value: - machine.setMetaDataEntry(key, new_value) - - ## This method checks if the name of the group stored in the definition container is correct. - # After updating from 3.2 to 3.3 some group names may be temporary. If there is a mismatch in the name of the group - # then all the container stacks are updated, both the current and the hidden ones. - def checkCorrectGroupName(self, device_id: str, group_name: str) -> None: - if self._global_container_stack and device_id == self.activeMachineNetworkKey(): - # Check if the group_name is correct. If not, update all the containers connected to the same printer - if self.activeMachineNetworkGroupName != group_name: - metadata_filter = {"um_network_key": self.activeMachineNetworkKey()} - containers = CuraContainerRegistry.getInstance().findContainerStacks(type = "machine", **metadata_filter) - for container in containers: - container.setMetaDataEntry("group_name", group_name) ## This method checks if there is an instance connected to the given network_key def existNetworkInstances(self, network_key: str) -> bool: diff --git a/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py b/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py index a2a319b46a..0f2106bc9c 100644 --- a/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py +++ b/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py @@ -115,7 +115,7 @@ class DiscoverUM3Action(MachineAction): previous_connect_group_name = meta_data["group_name"] global_container_stack.setMetaDataEntry("group_name", group_name) # Find all the places where there is the same group name and change it accordingly - CuraApplication.getInstance().getMachineManager().replaceContainersMetadata(key = "group_name", value = previous_connect_group_name, new_value = group_name) + self._replaceContainersMetadata(key = "group_name", value = previous_connect_group_name, new_value = group_name) else: global_container_stack.setMetaDataEntry("group_name", group_name) # Set the default value for "hidden", which is used when you have a group with multiple types of printers @@ -125,6 +125,13 @@ class DiscoverUM3Action(MachineAction): # Ensure that the connection states are refreshed. self._network_plugin.refreshConnections() + ## Find all container stacks that has the pair 'key = value' in its metadata and replaces the value with 'new_value' + def _replaceContainersMetadata(self, key: str, value: str, new_value: str) -> None: + machines = CuraContainerRegistry.getInstance().findContainerStacks(type="machine") + for machine in machines: + if machine.getMetaDataEntry(key) == value: + machine.setMetaDataEntry(key, new_value) + # Associates the currently active machine with the given printer device. The network connection information will be # stored into the metadata of the currently active machine. @pyqtSlot(QObject) From fe1402462015421f82011ce6ac6735fb522268d6 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 5 Apr 2019 17:49:29 +0200 Subject: [PATCH 7/7] Move existNetworkInstances into discover action --- cura/Settings/MachineManager.py | 7 ------- plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py | 4 +++- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index 267baf085f..736cb06d49 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -1455,13 +1455,6 @@ class MachineManager(QObject): if self.hasUserSettings and self._application.getPreferences().getValue("cura/active_mode") == 1: self._application.discardOrKeepProfileChanges() - - ## This method checks if there is an instance connected to the given network_key - def existNetworkInstances(self, network_key: str) -> bool: - metadata_filter = {"um_network_key": network_key} - containers = CuraContainerRegistry.getInstance().findContainerStacks(type = "machine", **metadata_filter) - return bool(containers) - @pyqtSlot("QVariant") def setGlobalVariant(self, container_node: "ContainerNode") -> None: self.blurSettings.emit() diff --git a/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py b/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py index 0f2106bc9c..28e7b60a0e 100644 --- a/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py +++ b/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py @@ -157,7 +157,9 @@ class DiscoverUM3Action(MachineAction): @pyqtSlot(str, result = bool) def existsKey(self, key: str) -> bool: - return CuraApplication.getInstance().getMachineManager().existNetworkInstances(network_key = key) + metadata_filter = {"um_network_key": key} + containers = CuraContainerRegistry.getInstance().findContainerStacks(type="machine", **metadata_filter) + return bool(containers) @pyqtSlot() def loadConfigurationFromPrinter(self) -> None: