Rename setKey() and add docs

CURA-6011
This commit is contained in:
Lipu Fei 2018-12-14 10:55:34 +01:00
parent 99cee1dfe7
commit aba3b6dd8e
2 changed files with 8 additions and 4 deletions

View file

@ -28,7 +28,7 @@ Cura.MachineAction
// Check if there is another instance with the same key // Check if there is another instance with the same key
if (!manager.existsKey(printerKey)) if (!manager.existsKey(printerKey))
{ {
manager.setKey(base.selectedDevice) manager.associateActiveMachineWithPrinterDevice(base.selectedDevice)
manager.setGroupName(printerName) // TODO To change when the groups have a name manager.setGroupName(printerName) // TODO To change when the groups have a name
completed() completed()
} }

View file

@ -3,7 +3,7 @@
import os.path import os.path
import time import time
from typing import Optional from typing import Optional, TYPE_CHECKING
from PyQt5.QtCore import pyqtSignal, pyqtProperty, pyqtSlot, QObject from PyQt5.QtCore import pyqtSignal, pyqtProperty, pyqtSlot, QObject
@ -13,10 +13,12 @@ from UM.i18n import i18nCatalog
from cura.CuraApplication import CuraApplication from cura.CuraApplication import CuraApplication
from cura.MachineAction import MachineAction from cura.MachineAction import MachineAction
from cura.PrinterOutputDevice import PrinterOutputDevice
from .UM3OutputDevicePlugin import UM3OutputDevicePlugin from .UM3OutputDevicePlugin import UM3OutputDevicePlugin
if TYPE_CHECKING:
from cura.PrinterOutputDevice import PrinterOutputDevice
catalog = i18nCatalog("cura") catalog = i18nCatalog("cura")
@ -117,8 +119,10 @@ class DiscoverUM3Action(MachineAction):
# Ensure that the connection states are refreshed. # Ensure that the connection states are refreshed.
self._network_plugin.reCheckConnections() self._network_plugin.reCheckConnections()
# Associates the currently active machine with the given printer device. The network connection information will be
# stored into the metadata of the currently active machine.
@pyqtSlot(QObject) @pyqtSlot(QObject)
def setKey(self, printer_device: Optional[PrinterOutputDevice]) -> None: def associateActiveMachineWithPrinterDevice(self, printer_device: Optional["PrinterOutputDevice"]) -> None:
Logger.log("d", "Attempting to set the network key of the active machine to %s", printer_device.key) Logger.log("d", "Attempting to set the network key of the active machine to %s", printer_device.key)
global_container_stack = CuraApplication.getInstance().getGlobalContainerStack() global_container_stack = CuraApplication.getInstance().getGlobalContainerStack()
if global_container_stack: if global_container_stack: