Connect buttons for selected printers: Print and refresh.

part of CURA-9278
This commit is contained in:
Remco Burema 2022-09-09 15:14:29 +02:00
parent 2b1909b7b5
commit b7611da95e
3 changed files with 22 additions and 9 deletions

View file

@ -1,5 +1,5 @@
from time import time
from typing import List, Optional
from typing import Callable, List, Optional
from PyQt6.QtCore import QObject, pyqtSlot
from PyQt6.QtNetwork import QNetworkReply
@ -14,7 +14,6 @@ from cura.CuraApplication import CuraApplication
from cura.PrinterOutput.NetworkedPrinterOutputDevice import AuthState
from cura.PrinterOutput.PrinterOutputDevice import ConnectionType
from .CloudApiClient import CloudApiClient
from ..Models.Http.CloudClusterResponse import CloudClusterResponse
from ..Models.Http.CloudClusterWithConfigResponse import CloudClusterWithConfigResponse
from ..UltimakerNetworkedPrinterOutputDevice import UltimakerNetworkedPrinterOutputDevice
@ -24,7 +23,7 @@ I18N_CATALOG = i18nCatalog("cura")
class AbstractCloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
API_CHECK_INTERVAL = 10.0 # seconds
def __init__(self, api_client: CloudApiClient, printer_type: str, parent: QObject = None) -> None:
def __init__(self, api_client: CloudApiClient, printer_type: str, request_write_callback: Callable, refresh_callback: Callable, parent: QObject = None) -> None:
self._api = api_client
properties = {b"printer_type": printer_type.encode()}
@ -37,6 +36,9 @@ class AbstractCloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
)
self._on_print_dialog: Optional[QObject] = None
self._nodes: List[SceneNode] = None
self._request_write_callback = request_write_callback
self._refresh_callback = refresh_callback
self._setInterfaceElements()
@ -94,14 +96,14 @@ class AbstractCloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
@pyqtSlot(str)
def printerSelected(self, unique_id: str):
print(unique_id)
self._request_write_callback(unique_id, self._nodes)
if self._on_print_dialog:
self._on_print_dialog.close()
@pyqtSlot()
def refresh(self):
print("-REFRESH-")
pass
self._refresh_callback()
self._update()
def _openChoosePrinterDialog(self) -> None:
if self._on_print_dialog is None:
@ -113,5 +115,8 @@ class AbstractCloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
self._on_print_dialog.show()
def requestWrite(self, nodes: List[SceneNode], file_name: Optional[str] = None, limit_mimetypes: bool = False, file_handler: Optional[FileHandler] = None, **kwargs) -> None:
if not nodes or len(nodes) < 1:
Logger.log("w", "Nothing to print.")
return
self._nodes = nodes
self._openChoosePrinterDialog()