mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Add on-exit callback management and check for active USB printing
CURA-5384
This commit is contained in:
parent
ac3d3bc5c0
commit
c0b7e40b0d
5 changed files with 158 additions and 9 deletions
|
@ -88,6 +88,25 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
|||
self._command_received = Event()
|
||||
self._command_received.set()
|
||||
|
||||
CuraApplication.getInstance().getOnExitCallbackManager().addCallback(self._checkActivePrintingUponAppExit)
|
||||
|
||||
# This is a callback function that checks if there is any printing in progress via USB when the application tries
|
||||
# to exit. If so, it will show a confirmation before
|
||||
def _checkActivePrintingUponAppExit(self) -> None:
|
||||
application = CuraApplication.getInstance()
|
||||
if not self._is_printing:
|
||||
# This USB printer is not printing, so we have nothing to do. Call the next callback if exists.
|
||||
application.triggerNextExitCheck()
|
||||
return
|
||||
|
||||
application.setConfirmExitDialogCallback(self._onConfirmExitDialogResult)
|
||||
application.showConfirmExitDialog.emit("USB printing is in progress")
|
||||
|
||||
def _onConfirmExitDialogResult(self, result: bool) -> None:
|
||||
if result:
|
||||
application = CuraApplication.getInstance()
|
||||
application.triggerNextExitCheck()
|
||||
|
||||
## Reset USB device settings
|
||||
#
|
||||
def resetDeviceSettings(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue