mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-11 16:57:51 -06:00
Repaired the monitor icon not being updated
CL-541
This commit is contained in:
parent
a8695db1c8
commit
9ccd643f64
5 changed files with 76 additions and 27 deletions
|
@ -143,7 +143,7 @@ class PrinterOutputDevice(QObject, OutputDevice):
|
||||||
if self._accepts_commands != accepts_commands:
|
if self._accepts_commands != accepts_commands:
|
||||||
self._accepts_commands = accepts_commands
|
self._accepts_commands = accepts_commands
|
||||||
|
|
||||||
self.acceptsCommandsChanged.emit()
|
self.acceptsCommandsChanged.emit()
|
||||||
|
|
||||||
|
|
||||||
## The current processing state of the backend.
|
## The current processing state of the backend.
|
||||||
|
|
|
@ -137,8 +137,7 @@ class MachineManager(QObject):
|
||||||
printer_output_device.hotendIdChanged.disconnect(self._onHotendIdChanged)
|
printer_output_device.hotendIdChanged.disconnect(self._onHotendIdChanged)
|
||||||
printer_output_device.materialIdChanged.disconnect(self._onMaterialIdChanged)'''
|
printer_output_device.materialIdChanged.disconnect(self._onMaterialIdChanged)'''
|
||||||
|
|
||||||
self._printer_output_devices.clear()
|
self._printer_output_devices = []
|
||||||
|
|
||||||
for printer_output_device in Application.getInstance().getOutputDeviceManager().getOutputDevices():
|
for printer_output_device in Application.getInstance().getOutputDeviceManager().getOutputDevices():
|
||||||
if isinstance(printer_output_device, PrinterOutputDevice):
|
if isinstance(printer_output_device, PrinterOutputDevice):
|
||||||
self._printer_output_devices.append(printer_output_device)
|
self._printer_output_devices.append(printer_output_device)
|
||||||
|
|
|
@ -16,7 +16,6 @@ Item
|
||||||
color: UM.Theme.getColor("viewport_overlay")
|
color: UM.Theme.getColor("viewport_overlay")
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: parent.height
|
height: parent.height
|
||||||
visible: monitorViewComponent.sourceComponent == null ? 1 : 0
|
|
||||||
|
|
||||||
MouseArea
|
MouseArea
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,26 +14,79 @@ class MonitorStage(CuraStage):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
|
||||||
# Wait until QML engine is created, otherwise creating the new QML components will fail
|
# Wait until QML engine is created, otherwise creating the new QML components will fail
|
||||||
Application.getInstance().engineCreatedSignal.connect(self._setComponents)
|
Application.getInstance().engineCreatedSignal.connect(self._onEngineCreated)
|
||||||
|
self._printer_output_device = None
|
||||||
|
|
||||||
# Update the status icon when the output device is changed
|
self._active_print_job = None
|
||||||
Application.getInstance().getOutputDeviceManager().activeDeviceChanged.connect(self._setIconSource)
|
self._active_printer = None
|
||||||
|
|
||||||
def _setComponents(self):
|
def _setActivePrintJob(self, print_job):
|
||||||
self._setMainOverlay()
|
if self._active_print_job != print_job:
|
||||||
self._setSidebar()
|
if self._active_print_job:
|
||||||
self._setIconSource()
|
self._active_printer.stateChanged.disconnect(self._updateIconSource)
|
||||||
|
self._active_print_job = print_job
|
||||||
|
if self._active_print_job:
|
||||||
|
self._active_print_job.stateChanged.connect(self._updateIconSource)
|
||||||
|
|
||||||
def _setMainOverlay(self):
|
# Ensure that the right icon source is returned.
|
||||||
|
self._updateIconSource()
|
||||||
|
|
||||||
|
def _setActivePrinter(self, printer):
|
||||||
|
if self._active_printer != printer:
|
||||||
|
if self._active_printer:
|
||||||
|
self._active_printer.activePrintJobChanged.disconnect(self._onActivePrintJobChanged)
|
||||||
|
self._active_printer = printer
|
||||||
|
if self._active_printer:
|
||||||
|
self._setActivePrintJob(self._active_printer.activePrintJob)
|
||||||
|
# Jobs might change, so we need to listen to it's changes.
|
||||||
|
self._active_printer.activePrintJobChanged.connect(self._onActivePrintJobChanged)
|
||||||
|
else:
|
||||||
|
self._setActivePrintJob(None)
|
||||||
|
|
||||||
|
# Ensure that the right icon source is returned.
|
||||||
|
self._updateIconSource()
|
||||||
|
|
||||||
|
def _onActivePrintJobChanged(self):
|
||||||
|
self._setActivePrintJob(self._active_printer.activePrintJob)
|
||||||
|
|
||||||
|
def _onActivePrinterChanged(self):
|
||||||
|
self._setActivePrinter(self._printer_output_device.activePrinter)
|
||||||
|
|
||||||
|
def _onOutputDevicesChanged(self):
|
||||||
|
try:
|
||||||
|
# We assume that you are monitoring the device with the highest priority.
|
||||||
|
new_output_device = Application.getInstance().getMachineManager().printerOutputDevices[0]
|
||||||
|
if new_output_device != self._printer_output_device:
|
||||||
|
if self._printer_output_device:
|
||||||
|
self._printer_output_device.acceptsCommandsChanged.disconnect(self._updateIconSource)
|
||||||
|
self._printer_output_device.printersChanged.disconnect(self._onActivePrinterChanged)
|
||||||
|
|
||||||
|
self._printer_output_device = new_output_device
|
||||||
|
|
||||||
|
self._printer_output_device.acceptsCommandsChanged.connect(self._updateIconSource)
|
||||||
|
self._printer_output_device.printersChanged.connect(self._onActivePrinterChanged)
|
||||||
|
self._setActivePrinter(self._printer_output_device.activePrinter)
|
||||||
|
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def _onEngineCreated(self):
|
||||||
|
# We can only connect now, as we need to be sure that everything is loaded (plugins get created quite early)
|
||||||
|
Application.getInstance().getMachineManager().outputDevicesChanged.connect(self._onOutputDevicesChanged)
|
||||||
|
self._updateMainOverlay()
|
||||||
|
self._updateSidebar()
|
||||||
|
self._updateIconSource()
|
||||||
|
|
||||||
|
def _updateMainOverlay(self):
|
||||||
main_component_path = os.path.join(PluginRegistry.getInstance().getPluginPath("MonitorStage"), "MonitorMainView.qml")
|
main_component_path = os.path.join(PluginRegistry.getInstance().getPluginPath("MonitorStage"), "MonitorMainView.qml")
|
||||||
self.addDisplayComponent("main", main_component_path)
|
self.addDisplayComponent("main", main_component_path)
|
||||||
|
|
||||||
def _setSidebar(self):
|
def _updateSidebar(self):
|
||||||
# TODO: currently the sidebar component for prepare and monitor stages is the same, this will change with the printer output device refactor!
|
# TODO: currently the sidebar component for prepare and monitor stages is the same, this will change with the printer output device refactor!
|
||||||
sidebar_component_path = os.path.join(Resources.getPath(Application.getInstance().ResourceTypes.QmlFiles), "Sidebar.qml")
|
sidebar_component_path = os.path.join(Resources.getPath(Application.getInstance().ResourceTypes.QmlFiles), "Sidebar.qml")
|
||||||
self.addDisplayComponent("sidebar", sidebar_component_path)
|
self.addDisplayComponent("sidebar", sidebar_component_path)
|
||||||
|
|
||||||
def _setIconSource(self):
|
def _updateIconSource(self):
|
||||||
if Application.getInstance().getTheme() is not None:
|
if Application.getInstance().getTheme() is not None:
|
||||||
icon_name = self._getActiveOutputDeviceStatusIcon()
|
icon_name = self._getActiveOutputDeviceStatusIcon()
|
||||||
self.setIconSource(Application.getInstance().getTheme().getIcon(icon_name))
|
self.setIconSource(Application.getInstance().getTheme().getIcon(icon_name))
|
||||||
|
@ -56,25 +109,22 @@ class MonitorStage(CuraStage):
|
||||||
if output_device.activePrinter.state == "maintenance":
|
if output_device.activePrinter.state == "maintenance":
|
||||||
return "tab_status_busy"
|
return "tab_status_busy"
|
||||||
|
|
||||||
if output_device.state == "maintenance":
|
if output_device.activePrinter.activePrintJob is None:
|
||||||
return "tab_status_busy"
|
|
||||||
|
|
||||||
if output_device.activePrinter.activeJob is None:
|
|
||||||
return "tab_status_connected"
|
return "tab_status_connected"
|
||||||
|
|
||||||
if output_device.activePrinter.activeJob.state in ["printing", "pre_print", "pausing", "resuming"]:
|
if output_device.activePrinter.activePrintJob.state in ["printing", "pre_print", "pausing", "resuming"]:
|
||||||
return "tab_status_busy"
|
return "tab_status_busy"
|
||||||
|
|
||||||
if output_device.activePrinter.activeJob.state == "wait_cleanup":
|
if output_device.activePrinter.activePrintJob.state == "wait_cleanup":
|
||||||
return "tab_status_finished"
|
return "tab_status_finished"
|
||||||
|
|
||||||
if output_device.activePrinter.activeJob.state in ["ready", ""]:
|
if output_device.activePrinter.activePrintJob.state in ["ready", ""]:
|
||||||
return "tab_status_connected"
|
return "tab_status_connected"
|
||||||
|
|
||||||
if output_device.activePrinter.activeJob.state == "paused":
|
if output_device.activePrinter.activePrintJob.state == "paused":
|
||||||
return "tab_status_paused"
|
return "tab_status_paused"
|
||||||
|
|
||||||
if output_device.activePrinter.activeJob.state == "error":
|
if output_device.activePrinter.activePrintJob.state == "error":
|
||||||
return "tab_status_stopped"
|
return "tab_status_stopped"
|
||||||
|
|
||||||
return "tab_status_unknown"
|
return "tab_status_unknown"
|
||||||
|
|
|
@ -91,7 +91,7 @@ class LegacyUM3OutputDevice(NetworkedPrinterOutputDevice):
|
||||||
title=i18n_catalog.i18nc("@info:title",
|
title=i18n_catalog.i18nc("@info:title",
|
||||||
"Authentication status"))
|
"Authentication status"))
|
||||||
|
|
||||||
self._authentication_failed_message = Message(i18n_catalog.i18nc("@info:status", "Authentication failed"),
|
self._authentication_failed_message = Message(i18n_catalog.i18nc("@info:status", ""),
|
||||||
title=i18n_catalog.i18nc("@info:title", "Authentication Status"))
|
title=i18n_catalog.i18nc("@info:title", "Authentication Status"))
|
||||||
self._authentication_failed_message.addAction("Retry", i18n_catalog.i18nc("@action:button", "Retry"), None,
|
self._authentication_failed_message.addAction("Retry", i18n_catalog.i18nc("@action:button", "Retry"), None,
|
||||||
i18n_catalog.i18nc("@info:tooltip", "Re-send the access request"))
|
i18n_catalog.i18nc("@info:tooltip", "Re-send the access request"))
|
||||||
|
@ -352,7 +352,6 @@ class LegacyUM3OutputDevice(NetworkedPrinterOutputDevice):
|
||||||
|
|
||||||
return warnings
|
return warnings
|
||||||
|
|
||||||
|
|
||||||
def _update(self):
|
def _update(self):
|
||||||
if not super()._update():
|
if not super()._update():
|
||||||
return
|
return
|
||||||
|
@ -401,10 +400,12 @@ class LegacyUM3OutputDevice(NetworkedPrinterOutputDevice):
|
||||||
self._authentication_id = None
|
self._authentication_id = None
|
||||||
self._authentication_key = None
|
self._authentication_key = None
|
||||||
self.setAuthenticationState(AuthState.NotAuthenticated)
|
self.setAuthenticationState(AuthState.NotAuthenticated)
|
||||||
elif status_code == 403:
|
elif status_code == 403 and self._authentication_state != AuthState.Authenticated:
|
||||||
|
# If we were already authenticated, we probably got an older message back all of the sudden. Drop that.
|
||||||
Logger.log("d",
|
Logger.log("d",
|
||||||
"While trying to verify the authentication state, we got a forbidden response. Our own auth state was %s",
|
"While trying to verify the authentication state, we got a forbidden response. Our own auth state was %s. ",
|
||||||
self._authentication_state)
|
self._authentication_state)
|
||||||
|
print(reply.readAll())
|
||||||
self.setAuthenticationState(AuthState.AuthenticationDenied)
|
self.setAuthenticationState(AuthState.AuthenticationDenied)
|
||||||
self._authentication_failed_message.show()
|
self._authentication_failed_message.show()
|
||||||
elif status_code == 200:
|
elif status_code == 200:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue