mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 23:17:32 -06:00
Replace "cloudActive" property by generic "active"
CURA-12557
This commit is contained in:
parent
9cf75648ab
commit
ae2a189c14
6 changed files with 33 additions and 27 deletions
|
@ -33,8 +33,8 @@ class AuthState(IntEnum):
|
|||
class NetworkedPrinterOutputDevice(PrinterOutputDevice):
|
||||
authenticationStateChanged = pyqtSignal()
|
||||
|
||||
def __init__(self, device_id, address: str, properties: Dict[bytes, bytes], connection_type: ConnectionType = ConnectionType.NetworkConnection, parent: QObject = None) -> None:
|
||||
super().__init__(device_id = device_id, connection_type = connection_type, parent = parent)
|
||||
def __init__(self, device_id, address: str, properties: Dict[bytes, bytes], connection_type: ConnectionType = ConnectionType.NetworkConnection, parent: QObject = None, active: bool = True) -> None:
|
||||
super().__init__(device_id = device_id, connection_type = connection_type, parent = parent, active = active)
|
||||
self._manager = None # type: Optional[QNetworkAccessManager]
|
||||
self._timeout_time = 10 # After how many seconds of no response should a timeout occur?
|
||||
|
||||
|
|
|
@ -72,7 +72,10 @@ class PrinterOutputDevice(QObject, OutputDevice):
|
|||
# Signal to indicate that the configuration of one of the printers has changed.
|
||||
uniqueConfigurationsChanged = pyqtSignal()
|
||||
|
||||
def __init__(self, device_id: str, connection_type: "ConnectionType" = ConnectionType.NotConnected, parent: QObject = None) -> None:
|
||||
# Signal to indicate that the printer has become active or inactive
|
||||
activeChanged = pyqtSignal()
|
||||
|
||||
def __init__(self, device_id: str, connection_type: "ConnectionType" = ConnectionType.NotConnected, parent: QObject = None, active: bool = True) -> None:
|
||||
super().__init__(device_id = device_id, parent = parent) # type: ignore # MyPy complains with the multiple inheritance
|
||||
|
||||
self._printers = [] # type: List[PrinterOutputModel]
|
||||
|
@ -88,6 +91,8 @@ class PrinterOutputDevice(QObject, OutputDevice):
|
|||
|
||||
self._accepts_commands = False # type: bool
|
||||
|
||||
self._active: bool = active
|
||||
|
||||
self._update_timer = QTimer() # type: QTimer
|
||||
self._update_timer.setInterval(2000) # TODO; Add preference for update interval
|
||||
self._update_timer.setSingleShot(False)
|
||||
|
@ -295,3 +300,17 @@ class PrinterOutputDevice(QObject, OutputDevice):
|
|||
return
|
||||
|
||||
self._firmware_updater.updateFirmware(firmware_file)
|
||||
|
||||
@pyqtProperty(bool, notify = activeChanged)
|
||||
def active(self) -> bool:
|
||||
"""
|
||||
Indicates whether the printer is active, which is not the same as "being the active printer". In this case,
|
||||
active means that the printer can be used. An example of an inactive printer is one that cannot be used because
|
||||
the user doesn't have enough seats on Digital Factory.
|
||||
"""
|
||||
return self._active
|
||||
|
||||
def _setActive(self, active: bool) -> None:
|
||||
if active != self._active:
|
||||
self._active = active
|
||||
self.activeChanged.emit()
|
||||
|
|
|
@ -184,15 +184,13 @@ class MachineManager(QObject):
|
|||
|
||||
def _onOutputDevicesChanged(self) -> None:
|
||||
for printer_output_device in self._printer_output_devices:
|
||||
if hasattr(printer_output_device, "cloudActiveChanged"):
|
||||
printer_output_device.cloudActiveChanged.disconnect(self.printerConnectedStatusChanged)
|
||||
printer_output_device.activeChanged.disconnect(self.printerConnectedStatusChanged)
|
||||
|
||||
self._printer_output_devices = []
|
||||
for printer_output_device in self._application.getOutputDeviceManager().getOutputDevices():
|
||||
if isinstance(printer_output_device, PrinterOutputDevice):
|
||||
self._printer_output_devices.append(printer_output_device)
|
||||
if hasattr(printer_output_device, "cloudActiveChanged"):
|
||||
printer_output_device.cloudActiveChanged.connect(self.printerConnectedStatusChanged)
|
||||
printer_output_device.activeChanged.connect(self.printerConnectedStatusChanged)
|
||||
|
||||
self.outputDevicesChanged.emit()
|
||||
|
||||
|
@ -576,12 +574,11 @@ class MachineManager(QObject):
|
|||
return self.activeMachineHasCloudConnection and not self.activeMachineHasNetworkConnection
|
||||
|
||||
@pyqtProperty(bool, notify = printerConnectedStatusChanged)
|
||||
def activeMachineIsCloudActive(self) -> bool:
|
||||
def activeMachineIsActive(self) -> bool:
|
||||
if not self._printer_output_devices:
|
||||
return True
|
||||
|
||||
first_printer = self._printer_output_devices[0]
|
||||
return True if not hasattr(first_printer, 'cloudActive') else first_printer.cloudActive
|
||||
return self._printer_output_devices[0].active
|
||||
|
||||
def activeMachineNetworkKey(self) -> str:
|
||||
if self._global_container_stack:
|
||||
|
|
|
@ -65,8 +65,6 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||
# Therefore, we create a private signal used to trigger the printersChanged signal.
|
||||
_cloudClusterPrintersChanged = pyqtSignal()
|
||||
|
||||
cloudActiveChanged = pyqtSignal()
|
||||
|
||||
def __init__(self, api_client: CloudApiClient, cluster: CloudClusterResponse, parent: QObject = None) -> None:
|
||||
"""Creates a new cloud output device
|
||||
|
||||
|
@ -91,7 +89,8 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||
address="",
|
||||
connection_type=ConnectionType.CloudConnection,
|
||||
properties=properties,
|
||||
parent=parent
|
||||
parent=parent,
|
||||
active=cluster.display_status != "inactive"
|
||||
)
|
||||
|
||||
self._api = api_client
|
||||
|
@ -115,9 +114,6 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||
self._pre_upload_print_job = None # type: Optional[CloudPrintJobResponse]
|
||||
self._uploaded_print_job = None # type: Optional[CloudPrintJobResponse]
|
||||
|
||||
# Whether the printer is active, i.e. authorized for use i.r.t to workspace limitations
|
||||
self._active = cluster.display_status != "inactive"
|
||||
|
||||
CuraApplication.getInstance().getBackend().backendDone.connect(self._resetPrintJob)
|
||||
CuraApplication.getInstance().getController().getScene().sceneChanged.connect(self._onSceneChanged)
|
||||
|
||||
|
@ -197,9 +193,7 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||
self._received_print_jobs = status.print_jobs
|
||||
self._updatePrintJobs(status.print_jobs)
|
||||
|
||||
if status.active != self._active:
|
||||
self._active = status.active
|
||||
self.cloudActiveChanged.emit()
|
||||
self._setActive(status.active)
|
||||
|
||||
def requestWrite(self, nodes: List[SceneNode], file_name: Optional[str] = None, limit_mimetypes: bool = False,
|
||||
file_handler: Optional[FileHandler] = None, filter_by_machine: bool = False, **kwargs) -> None:
|
||||
|
@ -445,10 +439,6 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||
root_url_prefix = "-staging" if self._account.is_staging else ""
|
||||
return f"https://digitalfactory{root_url_prefix}.ultimaker.com/app/jobs/{self.clusterData.cluster_id}"
|
||||
|
||||
@pyqtProperty(bool, notify = cloudActiveChanged)
|
||||
def cloudActive(self) -> bool:
|
||||
return self._active
|
||||
|
||||
def __del__(self):
|
||||
CuraApplication.getInstance().getBackend().backendDone.disconnect(self._resetPrintJob)
|
||||
CuraApplication.getInstance().getController().getScene().sceneChanged.disconnect(self._onSceneChanged)
|
||||
|
|
|
@ -46,10 +46,10 @@ class UltimakerNetworkedPrinterOutputDevice(NetworkedPrinterOutputDevice):
|
|||
QUEUED_PRINT_JOBS_STATES = {"queued", "error"}
|
||||
|
||||
def __init__(self, device_id: str, address: str, properties: Dict[bytes, bytes], connection_type: ConnectionType,
|
||||
parent=None) -> None:
|
||||
parent=None, active: bool = True) -> None:
|
||||
|
||||
super().__init__(device_id=device_id, address=address, properties=properties, connection_type=connection_type,
|
||||
parent=parent)
|
||||
parent=parent, active=active)
|
||||
# Trigger the printersChanged signal when the private signal is triggered.
|
||||
self.printersChanged.connect(self._clusterPrintersChanged)
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ Cura.ExpandablePopup
|
|||
property bool isConnectedCloudPrinter: machineManager.activeMachineHasCloudConnection
|
||||
property bool isCloudRegistered: machineManager.activeMachineHasCloudRegistration
|
||||
property bool isGroup: machineManager.activeMachineIsGroup
|
||||
property bool isCloudActive: machineManager.activeMachineIsCloudActive
|
||||
property bool isActive: machineManager.activeMachineIsActive
|
||||
property string machineName: {
|
||||
if (isNetworkPrinter && machineManager.activeMachineNetworkGroupName != "")
|
||||
{
|
||||
|
@ -41,7 +41,7 @@ Cura.ExpandablePopup
|
|||
}
|
||||
else if (isConnectedCloudPrinter && Cura.API.connectionStatus.isInternetReachable)
|
||||
{
|
||||
if (isCloudActive)
|
||||
if (isActive)
|
||||
{
|
||||
return "printer_cloud_connected"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue