From 0e913044dee301f64ed9bcfab687506c764091cd Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Mon, 11 Feb 2019 10:21:54 +0100 Subject: [PATCH 01/10] Ensure pop-up is not shown if cloud connection is already configured Contributes to CL-1222 --- plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py index a4d5bedb1f..93bf72eac4 100644 --- a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py @@ -412,10 +412,15 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): active_machine = self._application.getMachineManager().activeMachine # type: Optional["GlobalStack"] if active_machine: - # Check 1: Printer isn't already configured for cloud + # Check 1A: Printer isn't already configured for cloud if ConnectionType.CloudConnection.value in active_machine.configuredConnectionTypes: Logger.log("d", "Active machine was already configured for cloud.") return + + # Check 1B: Printer isn't already configured for cloud + if active_machine.getMetaDataEntry("cloud_flow_complete", "value") is True: + Logger.log("d", "Active machine was already configured for cloud.") + return # Check 2: User did not already say "Don't ask me again" if active_machine.getMetaDataEntry("show_cloud_message", "value") is False: From aa454ea357b8a64405601b37e1a0ec5f230a34c5 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Tue, 12 Feb 2019 12:18:29 +0100 Subject: [PATCH 02/10] Use parseBool instead of "is True" and "is False" Contributes to CL-1222 --- plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py index 93bf72eac4..947f2fc402 100644 --- a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py @@ -19,6 +19,7 @@ from UM.Signal import Signal, signalemitter from UM.Version import Version from UM.Message import Message from UM.i18n import i18nCatalog +from UM.Util import parseBool from . import ClusterUM3OutputDevice, LegacyUM3OutputDevice from .Cloud.CloudOutputDeviceManager import CloudOutputDeviceManager @@ -418,12 +419,12 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): return # Check 1B: Printer isn't already configured for cloud - if active_machine.getMetaDataEntry("cloud_flow_complete", "value") is True: + if parseBool(active_machine.getMetaDataEntry("cloud_flow_complete", "value")): Logger.log("d", "Active machine was already configured for cloud.") return # Check 2: User did not already say "Don't ask me again" - if active_machine.getMetaDataEntry("show_cloud_message", "value") is False: + if not parseBool(active_machine.getMetaDataEntry("show_cloud_message", "value")): Logger.log("d", "Active machine shouldn't ask about cloud anymore.") return From 70fc363048116fe2af92a4f91fef6664553321db Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 13 Feb 2019 10:49:53 +0100 Subject: [PATCH 03/10] Fix cloud pop up paths Contributes to CL-1222 --- plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py index 947f2fc402..8418e01028 100644 --- a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py @@ -4,6 +4,7 @@ import json from queue import Queue from threading import Event, Thread from time import time +import os from zeroconf import Zeroconf, ServiceBrowser, ServiceStateChange, ServiceInfo from PyQt5.QtNetwork import QNetworkRequest, QNetworkAccessManager @@ -454,7 +455,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): if not self._start_cloud_flow_message: self._start_cloud_flow_message = Message( text = i18n_catalog.i18nc("@info:status", "Send and monitor print jobs from anywhere using your Ultimaker account."), - image_source = "../../../../../Cura/plugins/UM3NetworkPrinting/resources/svg/cloud-flow-start.svg", + image_source = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../resources/svg/cloud-flow-start.svg", image_caption = i18n_catalog.i18nc("@info:status", "Connect to Ultimaker Cloud"), option_text = i18n_catalog.i18nc("@action", "Don't ask me again for this printer."), option_state = False @@ -475,7 +476,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): self._cloud_flow_complete_message = Message( text = i18n_catalog.i18nc("@info:status", "You can now send and monitor print jobs from anywhere using your Ultimaker account."), lifetime = 30, - image_source = "../../../../../Cura/plugins/UM3NetworkPrinting/resources/svg/cloud-flow-completed.svg", + image_source = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../resources/svg/cloud-flow-completed.svg"), image_caption = i18n_catalog.i18nc("@info:status", "Connected!") ) self._cloud_flow_complete_message.addAction("", i18n_catalog.i18nc("@action", "Review your connection"), "", "", 1) # TODO: Icon From aa2acac2447d4ba378d3b8a2438f03f1a78c35ed Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 13 Feb 2019 10:52:37 +0100 Subject: [PATCH 04/10] Fix typo Contributes to CL-1222 --- 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 8418e01028..c3d1f3794a 100644 --- a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py @@ -455,7 +455,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): if not self._start_cloud_flow_message: self._start_cloud_flow_message = Message( text = i18n_catalog.i18nc("@info:status", "Send and monitor print jobs from anywhere using your Ultimaker account."), - image_source = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../resources/svg/cloud-flow-start.svg", + image_source = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../resources/svg/cloud-flow-start.svg"), image_caption = i18n_catalog.i18nc("@info:status", "Connect to Ultimaker Cloud"), option_text = i18n_catalog.i18nc("@action", "Don't ask me again for this printer."), option_state = False From c15e49876a17efe275af09d918d9b9c85e6bb262 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 13 Feb 2019 11:00:11 +0100 Subject: [PATCH 05/10] Revert "Use parseBool instead of "is True" and "is False"" This reverts commit aa454ea357b8a64405601b37e1a0ec5f230a34c5. --- plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py index c3d1f3794a..aea8de8155 100644 --- a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py @@ -20,7 +20,6 @@ from UM.Signal import Signal, signalemitter from UM.Version import Version from UM.Message import Message from UM.i18n import i18nCatalog -from UM.Util import parseBool from . import ClusterUM3OutputDevice, LegacyUM3OutputDevice from .Cloud.CloudOutputDeviceManager import CloudOutputDeviceManager @@ -420,12 +419,12 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): return # Check 1B: Printer isn't already configured for cloud - if parseBool(active_machine.getMetaDataEntry("cloud_flow_complete", "value")): + if active_machine.getMetaDataEntry("cloud_flow_complete", "value") is True: Logger.log("d", "Active machine was already configured for cloud.") return # Check 2: User did not already say "Don't ask me again" - if not parseBool(active_machine.getMetaDataEntry("show_cloud_message", "value")): + if active_machine.getMetaDataEntry("show_cloud_message", "value") is False: Logger.log("d", "Active machine shouldn't ask about cloud anymore.") return From 8fecf7fb394ea9b3152fd2f5c63801bd667149e4 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 13 Feb 2019 11:04:51 +0100 Subject: [PATCH 06/10] Don't crash when clicking don't show again Contributes to CL-1222 --- 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 aea8de8155..c5121ecb5e 100644 --- a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py @@ -488,7 +488,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): active_machine.setMetaDataEntry("cloud_flow_complete", True) return - def _onDontAskMeAgain(self, messageId: str, checked: bool) -> None: + def _onDontAskMeAgain(self, messageId: str) -> None: active_machine = self._application.getMachineManager().activeMachine # type: Optional["GlobalStack"] if active_machine: active_machine.setMetaDataEntry("show_cloud_message", False) From d74f4f36bd42bd2134c671d24f82991bf61a51c2 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 13 Feb 2019 11:30:31 +0100 Subject: [PATCH 07/10] Improve cloud flow checks Contributes to CL-1222 --- plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py index c5121ecb5e..1c9d1e2938 100644 --- a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py @@ -419,12 +419,12 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): return # Check 1B: Printer isn't already configured for cloud - if active_machine.getMetaDataEntry("cloud_flow_complete", "value") is True: + if active_machine.getMetaDataEntry("cloud_flow_complete", False): Logger.log("d", "Active machine was already configured for cloud.") return # Check 2: User did not already say "Don't ask me again" - if active_machine.getMetaDataEntry("show_cloud_message", "value") is False: + if not active_machine.getMetaDataEntry("show_cloud_message", True): Logger.log("d", "Active machine shouldn't ask about cloud anymore.") return From cf4bcf81e7d69ab4de861e7e6bafa2f221ea4171 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 13 Feb 2019 11:49:53 +0100 Subject: [PATCH 08/10] Make pop up permanent Contributes to CL-1222 --- plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py index 1c9d1e2938..26ad49ce57 100644 --- a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py @@ -454,6 +454,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): if not self._start_cloud_flow_message: self._start_cloud_flow_message = Message( text = i18n_catalog.i18nc("@info:status", "Send and monitor print jobs from anywhere using your Ultimaker account."), + lifetime = 0, image_source = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../resources/svg/cloud-flow-start.svg"), image_caption = i18n_catalog.i18nc("@info:status", "Connect to Ultimaker Cloud"), option_text = i18n_catalog.i18nc("@action", "Don't ask me again for this printer."), From d08b8d813db760d0156cb9a4e99671a0f2494320 Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Wed, 13 Feb 2019 12:23:41 +0100 Subject: [PATCH 09/10] Generate the correct path for the svg on Windows. CL-1222 --- plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py index 26ad49ce57..782663061e 100644 --- a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py @@ -455,7 +455,8 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): self._start_cloud_flow_message = Message( text = i18n_catalog.i18nc("@info:status", "Send and monitor print jobs from anywhere using your Ultimaker account."), lifetime = 0, - image_source = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../resources/svg/cloud-flow-start.svg"), + image_source = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "resources", "svg", + "cloud-flow-start.svg"), image_caption = i18n_catalog.i18nc("@info:status", "Connect to Ultimaker Cloud"), option_text = i18n_catalog.i18nc("@action", "Don't ask me again for this printer."), option_state = False @@ -476,7 +477,8 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): self._cloud_flow_complete_message = Message( text = i18n_catalog.i18nc("@info:status", "You can now send and monitor print jobs from anywhere using your Ultimaker account."), lifetime = 30, - image_source = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../resources/svg/cloud-flow-completed.svg"), + image_source = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "resources", "svg", + "cloud-flow-completed.svg"), image_caption = i18n_catalog.i18nc("@info:status", "Connected!") ) self._cloud_flow_complete_message.addAction("", i18n_catalog.i18nc("@action", "Review your connection"), "", "", 1) # TODO: Icon From 25cfd4f496bca16385faf3e443a0a82ac9b9ff55 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 13 Feb 2019 14:21:23 +0100 Subject: [PATCH 10/10] Avoid double negatives in cloud flow metadata Contributes to CL-1222 --- plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py index 782663061e..c454bf7846 100644 --- a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py @@ -424,7 +424,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): return # Check 2: User did not already say "Don't ask me again" - if not active_machine.getMetaDataEntry("show_cloud_message", True): + if active_machine.getMetaDataEntry("do_not_show_cloud_message", False): Logger.log("d", "Active machine shouldn't ask about cloud anymore.") return @@ -488,13 +488,13 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): # Set the machine's cloud flow as complete so we don't ask the user again and again for cloud connected printers active_machine = self._application.getMachineManager().activeMachine if active_machine: - active_machine.setMetaDataEntry("cloud_flow_complete", True) + active_machine.setMetaDataEntry("do_not_show_cloud_message", True) return def _onDontAskMeAgain(self, messageId: str) -> None: active_machine = self._application.getMachineManager().activeMachine # type: Optional["GlobalStack"] if active_machine: - active_machine.setMetaDataEntry("show_cloud_message", False) + active_machine.setMetaDataEntry("do_not_show_cloud_message", True) Logger.log("d", "Will not ask the user again to cloud connect for current printer.") return