Merge pull request #5478 from Ultimaker/CL-1267_selective_cloud_flow_metadata

CL-1267 Don't hide Cloud flow message for wrong printer
This commit is contained in:
Simon Edwards 2019-04-03 17:09:57 +02:00 committed by GitHub
commit f933f2f271
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 6 deletions

View file

@ -32,8 +32,8 @@ class CloudOutputDeviceManager:
# The translation catalog for this device. # The translation catalog for this device.
I18N_CATALOG = i18nCatalog("cura") I18N_CATALOG = i18nCatalog("cura")
addedCloudCluster = Signal() addedCloudCluster = Signal(CloudOutputDevice)
removedCloudCluster = Signal() removedCloudCluster = Signal(CloudOutputDevice)
def __init__(self) -> None: def __init__(self) -> None:
# Persistent dict containing the remote clusters for the authenticated user. # Persistent dict containing the remote clusters for the authenticated user.
@ -86,7 +86,7 @@ class CloudOutputDeviceManager:
removed_cluster.disconnect() removed_cluster.disconnect()
removed_cluster.close() removed_cluster.close()
self._output_device_manager.removeOutputDevice(removed_cluster.key) self._output_device_manager.removeOutputDevice(removed_cluster.key)
self.removedCloudCluster.emit() self.removedCloudCluster.emit(removed_cluster)
del self._remote_clusters[removed_cluster.key] del self._remote_clusters[removed_cluster.key]
# Add an output device for each new remote cluster. # Add an output device for each new remote cluster.
@ -94,7 +94,7 @@ class CloudOutputDeviceManager:
for added_cluster in added_clusters: for added_cluster in added_clusters:
device = CloudOutputDevice(self._api, added_cluster) device = CloudOutputDevice(self._api, added_cluster)
self._remote_clusters[added_cluster.cluster_id] = device self._remote_clusters[added_cluster.cluster_id] = device
self.addedCloudCluster.emit() self.addedCloudCluster.emit(added_cluster)
for device, cluster in updates: for device, cluster in updates:
device.clusterData = cluster device.clusterData = cluster

View file

@ -458,7 +458,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
if self._start_cloud_flow_message and not self._start_cloud_flow_message.visible: if self._start_cloud_flow_message and not self._start_cloud_flow_message.visible:
self._start_cloud_flow_message.show() self._start_cloud_flow_message.show()
def _onCloudPrintingConfigured(self) -> None: def _onCloudPrintingConfigured(self, device) -> None:
# Hide the cloud flow start message if it was hanging around already # Hide the cloud flow start message if it was hanging around already
# For example: if the user already had the browser openen and made the association themselves # For example: if the user already had the browser openen and made the association themselves
if self._start_cloud_flow_message and self._start_cloud_flow_message.visible: if self._start_cloud_flow_message and self._start_cloud_flow_message.visible:
@ -473,7 +473,16 @@ 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 # 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 active_machine = self._application.getMachineManager().activeMachine
if active_machine: if active_machine:
# The active machine _might_ not be the machine that was in the added cloud cluster and
# then this will hide the cloud message for the wrong machine. So we only set it if the
# host names match between the active machine and the newly added cluster
saved_host_name = active_machine.getMetaDataEntry("um_network_key", "").split('.')[0]
added_host_name = device.toDict()["host_name"]
if added_host_name == saved_host_name:
active_machine.setMetaDataEntry("do_not_show_cloud_message", True) active_machine.setMetaDataEntry("do_not_show_cloud_message", True)
return return
def _onDontAskMeAgain(self, checked: bool) -> None: def _onDontAskMeAgain(self, checked: bool) -> None: