Merge pull request #7903 from Ultimaker/CURA-7493_prefer_online_cloud_printers

Sort new_devices on online status first, name second
This commit is contained in:
Remco Burema 2020-06-09 17:46:05 +02:00 committed by GitHub
commit ac36aeb831
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -163,7 +163,11 @@ class CloudOutputDeviceManager:
self._connectToActiveMachine()
return
new_devices.sort(key = lambda x: x.name.lower())
# Sort new_devices on online status first, alphabetical second.
# Since the first device might be activated in case there is no active printer yet,
# it would be nice to prioritize online devices
online_cluster_names = {c.friendly_name.lower() for c in clusters if c.is_online and not c.friendly_name is None}
new_devices.sort(key = lambda x: ("a{}" if x.name.lower() in online_cluster_names else "b{}").format(x.name.lower()))
image_path = os.path.join(
CuraApplication.getInstance().getPluginRegistry().getPluginPath("UM3NetworkPrinting") or "",