mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 23:17:32 -06:00
CURA-5254 Keep track of the latest manual entry key, so it is then
selected in the list.
This commit is contained in:
parent
74a7452333
commit
eea9b7ab46
3 changed files with 25 additions and 2 deletions
|
@ -45,6 +45,8 @@ class DiscoverUM3Action(MachineAction):
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def reset(self):
|
def reset(self):
|
||||||
Logger.log("d", "Reset the list of found devices.")
|
Logger.log("d", "Reset the list of found devices.")
|
||||||
|
if self._network_plugin:
|
||||||
|
self._network_plugin.resetLastManualDevice()
|
||||||
self.discoveredDevicesChanged.emit()
|
self.discoveredDevicesChanged.emit()
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
|
@ -131,7 +133,7 @@ class DiscoverUM3Action(MachineAction):
|
||||||
self._network_plugin.reCheckConnections()
|
self._network_plugin.reCheckConnections()
|
||||||
|
|
||||||
@pyqtSlot(result = str)
|
@pyqtSlot(result = str)
|
||||||
def getStoredKey(self):
|
def getStoredKey(self) -> str:
|
||||||
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||||
if global_container_stack:
|
if global_container_stack:
|
||||||
meta_data = global_container_stack.getMetaData()
|
meta_data = global_container_stack.getMetaData()
|
||||||
|
@ -140,6 +142,12 @@ class DiscoverUM3Action(MachineAction):
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
@pyqtSlot(result = str)
|
||||||
|
def getLastManualEntryKey(self) -> str:
|
||||||
|
if self._network_plugin:
|
||||||
|
return self._network_plugin.getLastManualDevice()
|
||||||
|
return ""
|
||||||
|
|
||||||
@pyqtSlot(str, result = bool)
|
@pyqtSlot(str, result = bool)
|
||||||
def existsKey(self, key) -> bool:
|
def existsKey(self, key) -> bool:
|
||||||
return Application.getInstance().getMachineManager().existNetworkInstances(network_key = key)
|
return Application.getInstance().getMachineManager().existNetworkInstances(network_key = key)
|
||||||
|
|
|
@ -158,7 +158,10 @@ Cura.MachineAction
|
||||||
model: manager.foundDevices
|
model: manager.foundDevices
|
||||||
onModelChanged:
|
onModelChanged:
|
||||||
{
|
{
|
||||||
var selectedKey = manager.getStoredKey();
|
var selectedKey = manager.getLastManualEntryKey()
|
||||||
|
// If there is no last manual entry key, then we select the stored key (if any)
|
||||||
|
if (selectedKey == "")
|
||||||
|
selectedKey = manager.getStoredKey()
|
||||||
for(var i = 0; i < model.length; i++) {
|
for(var i = 0; i < model.length; i++) {
|
||||||
if(model[i].key == selectedKey)
|
if(model[i].key == selectedKey)
|
||||||
{
|
{
|
||||||
|
|
|
@ -60,6 +60,9 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
||||||
|
|
||||||
self._manual_instances = self._preferences.getValue("um3networkprinting/manual_instances").split(",")
|
self._manual_instances = self._preferences.getValue("um3networkprinting/manual_instances").split(",")
|
||||||
|
|
||||||
|
# Store the last manual entry key
|
||||||
|
self._last_manual_entry_key = "" # type: str
|
||||||
|
|
||||||
# The zero-conf service changed requests are handled in a separate thread, so we can re-schedule the requests
|
# The zero-conf service changed requests are handled in a separate thread, so we can re-schedule the requests
|
||||||
# which fail to get detailed service info.
|
# which fail to get detailed service info.
|
||||||
# Any new or re-scheduled requests will be appended to the request queue, and the handling thread will pick
|
# Any new or re-scheduled requests will be appended to the request queue, and the handling thread will pick
|
||||||
|
@ -72,6 +75,12 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
||||||
def getDiscoveredDevices(self):
|
def getDiscoveredDevices(self):
|
||||||
return self._discovered_devices
|
return self._discovered_devices
|
||||||
|
|
||||||
|
def getLastManualDevice(self) -> str:
|
||||||
|
return self._last_manual_entry_key
|
||||||
|
|
||||||
|
def resetLastManualDevice(self) -> None:
|
||||||
|
self._last_manual_entry_key = ""
|
||||||
|
|
||||||
## Start looking for devices on network.
|
## Start looking for devices on network.
|
||||||
def start(self):
|
def start(self):
|
||||||
self.startDiscovery()
|
self.startDiscovery()
|
||||||
|
@ -93,6 +102,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
||||||
for address in self._manual_instances:
|
for address in self._manual_instances:
|
||||||
if address:
|
if address:
|
||||||
self.addManualDevice(address)
|
self.addManualDevice(address)
|
||||||
|
self.resetLastManualDevice()
|
||||||
|
|
||||||
def reCheckConnections(self):
|
def reCheckConnections(self):
|
||||||
active_machine = Application.getInstance().getGlobalContainerStack()
|
active_machine = Application.getInstance().getGlobalContainerStack()
|
||||||
|
@ -136,6 +146,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
||||||
if not address:
|
if not address:
|
||||||
address = self._discovered_devices[key].ipAddress
|
address = self._discovered_devices[key].ipAddress
|
||||||
self._onRemoveDevice(key)
|
self._onRemoveDevice(key)
|
||||||
|
self.resetLastManualDevice()
|
||||||
|
|
||||||
if address in self._manual_instances:
|
if address in self._manual_instances:
|
||||||
self._manual_instances.remove(address)
|
self._manual_instances.remove(address)
|
||||||
|
@ -157,6 +168,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
||||||
if instance_name not in self._discovered_devices:
|
if instance_name not in self._discovered_devices:
|
||||||
# Add a preliminary printer instance
|
# Add a preliminary printer instance
|
||||||
self._onAddDevice(instance_name, address, properties)
|
self._onAddDevice(instance_name, address, properties)
|
||||||
|
self._last_manual_entry_key = instance_name
|
||||||
|
|
||||||
self._checkManualDevice(address)
|
self._checkManualDevice(address)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue