Merge remote-tracking branch 'origin/master' into feature_intent

This commit is contained in:
Lipu Fei 2019-10-01 09:41:05 +02:00
commit 96a9bcccbb
55 changed files with 551 additions and 205 deletions

View file

@ -96,6 +96,14 @@ class LocalClusterOutputDeviceManager:
if not active_machine:
return
self._connectToOutputDevice(device, active_machine)
self._connectToActiveMachine()
# Pre-select the correct machine type of the group host.
# We first need to find the correct definition because the machine manager only takes name as input, not ID.
definitions = CuraApplication.getInstance().getContainerRegistry().findContainers(id = device.printerType)
if not definitions:
return
CuraApplication.getInstance().getMachineManager().switchPrinterType(definitions[0].getName())
## Callback for when the active machine was changed by the user or a new remote cluster was found.
def _connectToActiveMachine(self) -> None:
@ -111,7 +119,7 @@ class LocalClusterOutputDeviceManager:
self._connectToOutputDevice(device, active_machine)
elif device.key in output_device_manager.getOutputDeviceIds():
# Remove device if it is not meant for the active machine.
CuraApplication.getInstance().getOutputDeviceManager().removeOutputDevice(device.key)
output_device_manager.removeOutputDevice(device.key)
## Callback for when a manual device check request was responded to.
def _onCheckManualDeviceResponse(self, address: str, status: PrinterSystemStatus,
@ -201,7 +209,7 @@ class LocalClusterOutputDeviceManager:
if not active_machine:
return
self._connectToOutputDevice(device, active_machine)
CloudFlowMessage(device.ipAddress).show() # Nudge the user to start using Ultimaker Cloud.
self._showCloudFlowMessage(device)
## Add an address to the stored preferences.
def _storeManualAddress(self, address: str) -> None:
@ -248,3 +256,14 @@ class LocalClusterOutputDeviceManager:
output_device_manager = CuraApplication.getInstance().getOutputDeviceManager()
if device.key not in output_device_manager.getOutputDeviceIds():
output_device_manager.addOutputDevice(device)
## Nudge the user to start using Ultimaker Cloud.
@staticmethod
def _showCloudFlowMessage(device: LocalClusterOutputDevice) -> None:
if CuraApplication.getInstance().getMachineManager().activeMachineIsUsingCloudConnection:
# This printer is already cloud connected, so we do not bother the user anymore.
return
if not CuraApplication.getInstance().getCuraAPI().account.isLoggedIn:
# Do not show the message if the user is not signed in.
return
CloudFlowMessage(device.ipAddress).show()

View file

@ -60,9 +60,13 @@ class UltimakerNetworkedPrinterOutputDevice(NetworkedPrinterOutputDevice):
self._time_of_last_response = time()
self._time_of_last_request = time()
# Set the display name from the properties
# Set the display name from the properties.
self.setName(self.getProperty("name"))
# Set the display name of the printer type.
definitions = CuraApplication.getInstance().getContainerRegistry().findContainers(id = self.printerType)
self._printer_type_name = definitions[0].getName() if definitions else ""
# Keeps track of all printers in the cluster.
self._printers = [] # type: List[PrinterOutputModel]
self._has_received_printers = False
@ -87,6 +91,11 @@ class UltimakerNetworkedPrinterOutputDevice(NetworkedPrinterOutputDevice):
def address(self) -> str:
return self._address
## The display name of the printer.
@pyqtProperty(str, constant=True)
def printerTypeName(self) -> str:
return self._printer_type_name
# Get all print jobs for this cluster.
@pyqtProperty("QVariantList", notify=printJobsChanged)
def printJobs(self) -> List[UM3PrintJobOutputModel]: