From 3d19e75c820a170a0a234bc7f20d8ede08a2cbd5 Mon Sep 17 00:00:00 2001 From: Nino van Hooff Date: Mon, 18 May 2020 14:44:35 +0200 Subject: [PATCH 1/6] Notify user of proper way to remove cloud printer CURA-7436 --- cura/Machines/Models/GlobalStacksModel.py | 4 ++++ resources/qml/Preferences/MachinesPage.qml | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/cura/Machines/Models/GlobalStacksModel.py b/cura/Machines/Models/GlobalStacksModel.py index 9db4ffe6db..38b92c00c9 100644 --- a/cura/Machines/Models/GlobalStacksModel.py +++ b/cura/Machines/Models/GlobalStacksModel.py @@ -19,6 +19,7 @@ class GlobalStacksModel(ListModel): ConnectionTypeRole = Qt.UserRole + 4 MetaDataRole = Qt.UserRole + 5 DiscoverySourceRole = Qt.UserRole + 6 # For separating local and remote printers in the machine management page + HasCloudConnectionRole = Qt.UserRole + 7 def __init__(self, parent = None) -> None: super().__init__(parent) @@ -57,10 +58,12 @@ class GlobalStacksModel(ListModel): container_stacks = CuraContainerRegistry.getInstance().findContainerStacks(type = "machine") for container_stack in container_stacks: has_remote_connection = False + has_cloud_connection = False for connection_type in container_stack.configuredConnectionTypes: has_remote_connection |= connection_type in [ConnectionType.NetworkConnection.value, ConnectionType.CloudConnection.value] + has_cloud_connection |= connection_type == ConnectionType.CloudConnection.value if parseBool(container_stack.getMetaDataEntry("hidden", False)): continue @@ -71,6 +74,7 @@ class GlobalStacksModel(ListModel): items.append({"name": container_stack.getMetaDataEntry("group_name", container_stack.getName()), "id": container_stack.getId(), "hasRemoteConnection": has_remote_connection, + "hasCloudConnection": has_cloud_connection, "metadata": container_stack.getMetaData().copy(), "discoverySource": section_name}) items.sort(key = lambda i: (not i["hasRemoteConnection"], i["name"])) diff --git a/resources/qml/Preferences/MachinesPage.qml b/resources/qml/Preferences/MachinesPage.qml index a3a8ec0e29..afd9ba264e 100644 --- a/resources/qml/Preferences/MachinesPage.qml +++ b/resources/qml/Preferences/MachinesPage.qml @@ -136,6 +136,11 @@ UM.ManagementPage { id: confirmDialog object: base.currentItem && base.currentItem.name ? base.currentItem.name : "" + text: base.currentItem && base.currentItem.hasCloudConnection? + catalog.i18nc("@label (%1 is object name)", "%1 will be removed but will be added again in the next sync. To remove the printer permanently, visit Ultimaker Digital Factory").arg(base.currentItem.name) + : + catalog.i18nc("@label (%1 is object name)", "Are you sure you wish to remove %1? This cannot be undone!").arg(base.currentItem.name) + ; onYes: { Cura.MachineManager.removeMachine(base.currentItem.id) From c61f5a162eb052994c009838db3495ed6c92d039 Mon Sep 17 00:00:00 2001 From: Nino van Hooff Date: Mon, 18 May 2020 14:48:41 +0200 Subject: [PATCH 2/6] Update remote and local printer labels in Machines page CURA-7436 --- cura/Machines/Models/GlobalStacksModel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cura/Machines/Models/GlobalStacksModel.py b/cura/Machines/Models/GlobalStacksModel.py index 38b92c00c9..bfc035be5d 100644 --- a/cura/Machines/Models/GlobalStacksModel.py +++ b/cura/Machines/Models/GlobalStacksModel.py @@ -68,7 +68,7 @@ class GlobalStacksModel(ListModel): if parseBool(container_stack.getMetaDataEntry("hidden", False)): continue - section_name = "Network enabled printers" if has_remote_connection else "Local printers" + section_name = "Connected printers" if has_remote_connection else "Preset printers" section_name = self._catalog.i18nc("@info:title", section_name) items.append({"name": container_stack.getMetaDataEntry("group_name", container_stack.getName()), From 252b993169fce8565edc04cac09633644dea33a6 Mon Sep 17 00:00:00 2001 From: Nino van Hooff Date: Mon, 18 May 2020 16:22:55 +0200 Subject: [PATCH 3/6] Refactor removal warning message to CloudOutputDeviceManager CURA-7436 --- cura/Machines/Models/GlobalStacksModel.py | 20 +++++++++++++------ .../src/Cloud/CloudOutputDeviceManager.py | 6 ++++++ resources/qml/Preferences/MachinesPage.qml | 6 +----- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/cura/Machines/Models/GlobalStacksModel.py b/cura/Machines/Models/GlobalStacksModel.py index bfc035be5d..f5007e7ce1 100644 --- a/cura/Machines/Models/GlobalStacksModel.py +++ b/cura/Machines/Models/GlobalStacksModel.py @@ -19,9 +19,9 @@ class GlobalStacksModel(ListModel): ConnectionTypeRole = Qt.UserRole + 4 MetaDataRole = Qt.UserRole + 5 DiscoverySourceRole = Qt.UserRole + 6 # For separating local and remote printers in the machine management page - HasCloudConnectionRole = Qt.UserRole + 7 + RemovalWarningRole = Qt.UserRole + 7 - def __init__(self, parent = None) -> None: + def __init__(self, parent=None) -> None: super().__init__(parent) self._catalog = i18nCatalog("cura") @@ -55,7 +55,7 @@ class GlobalStacksModel(ListModel): def _update(self) -> None: items = [] - container_stacks = CuraContainerRegistry.getInstance().findContainerStacks(type = "machine") + container_stacks = CuraContainerRegistry.getInstance().findContainerStacks(type="machine") for container_stack in container_stacks: has_remote_connection = False has_cloud_connection = False @@ -68,14 +68,22 @@ class GlobalStacksModel(ListModel): if parseBool(container_stack.getMetaDataEntry("hidden", False)): continue + device_name = container_stack.getMetaDataEntry("group_name", container_stack.getName()) section_name = "Connected printers" if has_remote_connection else "Preset printers" section_name = self._catalog.i18nc("@info:title", section_name) - items.append({"name": container_stack.getMetaDataEntry("group_name", container_stack.getName()), + default_removal_warning = self._catalog.i18nc( + "@label ({} is object name)", + "Are you sure you wish to remove {}? This cannot be undone!", device_name + ) + removal_warning = container_stack.getMetaDataEntry("removal_warning", default_removal_warning) + + items.append({"name": device_name, "id": container_stack.getId(), "hasRemoteConnection": has_remote_connection, "hasCloudConnection": has_cloud_connection, "metadata": container_stack.getMetaData().copy(), - "discoverySource": section_name}) - items.sort(key = lambda i: (not i["hasRemoteConnection"], i["name"])) + "discoverySource": section_name, + "removalWarning": removal_warning}) + items.sort(key=lambda i: (not i["hasRemoteConnection"], i["name"])) self.setItems(items) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py index f233e59fe5..71c1994bc1 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py @@ -265,6 +265,12 @@ class CloudOutputDeviceManager: machine.setName(device.name) machine.setMetaDataEntry(self.META_CLUSTER_ID, device.key) machine.setMetaDataEntry("group_name", device.name) + machine.setMetaDataEntry("removal_warning", self.I18N_CATALOG.i18nc( + "@label ({} is printer name)", + "{} will be removed but will be added again in the next sync. To remove the printer permanently, " + "visit Ultimaker Digital Factory", + device.name + )) machine.addConfiguredConnectionType(device.connectionType.value) def _connectToOutputDevice(self, device: CloudOutputDevice, machine: GlobalStack) -> None: diff --git a/resources/qml/Preferences/MachinesPage.qml b/resources/qml/Preferences/MachinesPage.qml index afd9ba264e..5341af65db 100644 --- a/resources/qml/Preferences/MachinesPage.qml +++ b/resources/qml/Preferences/MachinesPage.qml @@ -136,11 +136,7 @@ UM.ManagementPage { id: confirmDialog object: base.currentItem && base.currentItem.name ? base.currentItem.name : "" - text: base.currentItem && base.currentItem.hasCloudConnection? - catalog.i18nc("@label (%1 is object name)", "%1 will be removed but will be added again in the next sync. To remove the printer permanently, visit Ultimaker Digital Factory").arg(base.currentItem.name) - : - catalog.i18nc("@label (%1 is object name)", "Are you sure you wish to remove %1? This cannot be undone!").arg(base.currentItem.name) - ; + text: base.currentItem ? base.currentItem.removalWarning : ""; onYes: { Cura.MachineManager.removeMachine(base.currentItem.id) From 4e930b4d5262252593f011f9fbef5fc6afe8bc89 Mon Sep 17 00:00:00 2001 From: Kostas Karmas Date: Wed, 20 May 2020 15:08:05 +0200 Subject: [PATCH 4/6] Remove unused "has_cloud_connection" variable CURA-7436 --- cura/Machines/Models/GlobalStacksModel.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/cura/Machines/Models/GlobalStacksModel.py b/cura/Machines/Models/GlobalStacksModel.py index f5007e7ce1..c3ef7ab519 100644 --- a/cura/Machines/Models/GlobalStacksModel.py +++ b/cura/Machines/Models/GlobalStacksModel.py @@ -58,12 +58,10 @@ class GlobalStacksModel(ListModel): container_stacks = CuraContainerRegistry.getInstance().findContainerStacks(type="machine") for container_stack in container_stacks: has_remote_connection = False - has_cloud_connection = False for connection_type in container_stack.configuredConnectionTypes: has_remote_connection |= connection_type in [ConnectionType.NetworkConnection.value, ConnectionType.CloudConnection.value] - has_cloud_connection |= connection_type == ConnectionType.CloudConnection.value if parseBool(container_stack.getMetaDataEntry("hidden", False)): continue @@ -81,7 +79,6 @@ class GlobalStacksModel(ListModel): items.append({"name": device_name, "id": container_stack.getId(), "hasRemoteConnection": has_remote_connection, - "hasCloudConnection": has_cloud_connection, "metadata": container_stack.getMetaData().copy(), "discoverySource": section_name, "removalWarning": removal_warning}) From f677be14c2bb8c746b777ecf6699e2534dd15141 Mon Sep 17 00:00:00 2001 From: Kostas Karmas Date: Wed, 20 May 2020 15:10:04 +0200 Subject: [PATCH 5/6] Fix spacing CURA-7436 --- cura/Machines/Models/GlobalStacksModel.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cura/Machines/Models/GlobalStacksModel.py b/cura/Machines/Models/GlobalStacksModel.py index c3ef7ab519..201fbacd30 100644 --- a/cura/Machines/Models/GlobalStacksModel.py +++ b/cura/Machines/Models/GlobalStacksModel.py @@ -21,7 +21,7 @@ class GlobalStacksModel(ListModel): DiscoverySourceRole = Qt.UserRole + 6 # For separating local and remote printers in the machine management page RemovalWarningRole = Qt.UserRole + 7 - def __init__(self, parent=None) -> None: + def __init__(self, parent = None) -> None: super().__init__(parent) self._catalog = i18nCatalog("cura") @@ -55,7 +55,7 @@ class GlobalStacksModel(ListModel): def _update(self) -> None: items = [] - container_stacks = CuraContainerRegistry.getInstance().findContainerStacks(type="machine") + container_stacks = CuraContainerRegistry.getInstance().findContainerStacks(type = "machine") for container_stack in container_stacks: has_remote_connection = False From b5e971f9ecc2264f7f5a9d1f0261fb731af9cfc6 Mon Sep 17 00:00:00 2001 From: Kostas Karmas Date: Wed, 20 May 2020 15:21:57 +0200 Subject: [PATCH 6/6] Update remove cloud printer pop-up message CURA-7436 --- .../src/Cloud/CloudOutputDeviceManager.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py index 71c1994bc1..3322bbd639 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py @@ -267,9 +267,10 @@ class CloudOutputDeviceManager: machine.setMetaDataEntry("group_name", device.name) machine.setMetaDataEntry("removal_warning", self.I18N_CATALOG.i18nc( "@label ({} is printer name)", - "{} will be removed but will be added again in the next sync. To remove the printer permanently, " - "visit Ultimaker Digital Factory", - device.name + "{} will be removed until the next account sync.
To remove {} permanently, " + "visit Ultimaker Digital Factory. " + "

Are you sure you want to remove {} temporarily?", + device.name, device.name, device.name )) machine.addConfiguredConnectionType(device.connectionType.value)