From 70115208459f606337beeed59c54c068fbfd0682 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Tue, 9 Aug 2016 15:54:20 +0200 Subject: [PATCH] Select the UM3 that we are connected to if it is in the list CURA-2035 --- DiscoverUM3Action.py | 10 ++++++++++ DiscoverUM3Action.qml | 13 +++++++++++++ 2 files changed, 23 insertions(+) diff --git a/DiscoverUM3Action.py b/DiscoverUM3Action.py index fc895a78ff..4ca500dc48 100644 --- a/DiscoverUM3Action.py +++ b/DiscoverUM3Action.py @@ -55,3 +55,13 @@ class DiscoverUM3Action(MachineAction): if self._network_plugin: # Ensure that the connection states are refreshed. self._network_plugin.reCheckConnections() + + @pyqtSlot(result = str) + def getStoredKey(self): + global_container_stack = Application.getInstance().getGlobalContainerStack() + if global_container_stack: + meta_data = global_container_stack.getMetaData() + if "um_network_key" in meta_data: + return global_container_stack.getMetaDataEntry("um_network_key") + + return "" \ No newline at end of file diff --git a/DiscoverUM3Action.qml b/DiscoverUM3Action.qml index 2a70457f7c..4dcb5e074d 100644 --- a/DiscoverUM3Action.qml +++ b/DiscoverUM3Action.qml @@ -97,6 +97,18 @@ Cura.MachineAction { id: listview model: manager.foundDevices + onModelChanged: + { + var selectedKey = manager.getStoredKey(); + for(var i = 0; i < model.length; i++) { + if(model[i].getKey() == selectedKey) + { + currentIndex = i; + return + } + } + currentIndex = -1; + } width: parent.width currentIndex: -1 onCurrentIndexChanged: base.selectedPrinter = listview.model[currentIndex] @@ -134,6 +146,7 @@ Cura.MachineAction { width: parent.width * 0.5 visible: base.selectedPrinter + spacing: UM.Theme.getSize("default_margin").height Label { width: parent.width