mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-05 06:14:01 +08:00
Merge branch 'CURA-7147_preview_img_for_cloud' of github.com:Ultimaker/Cura into 4.6
This commit is contained in:
commit
2da965e46e
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2019 Ultimaker B.V.
|
||||
# Copyright (c) 2020 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
from typing import List, Optional, Union, Dict, Any
|
||||
|
||||
@ -44,6 +44,7 @@ class ClusterPrintJobStatus(BaseModel):
|
||||
# \param compatible_machine_families: Family names of machines suitable for this print job
|
||||
# \param impediments_to_printing: A list of reasons that prevent this job from being printed on the associated
|
||||
# printer
|
||||
# \param preview_url: URL to the preview image (same as wou;d've been included in the ufp).
|
||||
def __init__(self, created_at: str, force: bool, machine_variant: str, name: str, started: bool, status: str,
|
||||
time_total: int, uuid: str,
|
||||
configuration: List[Union[Dict[str, Any], ClusterPrintCoreConfiguration]],
|
||||
@ -57,6 +58,7 @@ class ClusterPrintJobStatus(BaseModel):
|
||||
build_plate: Union[Dict[str, Any], ClusterBuildPlate] = None,
|
||||
compatible_machine_families: List[str] = None,
|
||||
impediments_to_printing: List[Union[Dict[str, Any], ClusterPrintJobImpediment]] = None,
|
||||
preview_url: Optional[str] = None,
|
||||
**kwargs) -> None:
|
||||
self.assigned_to = assigned_to
|
||||
self.configuration = self.parseModels(ClusterPrintCoreConfiguration, configuration)
|
||||
@ -76,6 +78,7 @@ class ClusterPrintJobStatus(BaseModel):
|
||||
self.uuid = uuid
|
||||
self.deleted_at = deleted_at
|
||||
self.printed_on_uuid = printed_on_uuid
|
||||
self.preview_url = preview_url
|
||||
|
||||
self.configuration_changes_required = self.parseModels(ClusterPrintJobConfigurationChange,
|
||||
configuration_changes_required) \
|
||||
|
@ -1,10 +1,13 @@
|
||||
# Copyright (c) 2019 Ultimaker B.V.
|
||||
# Copyright (c) 2020 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
from typing import List
|
||||
from typing import List, Optional
|
||||
|
||||
from PyQt5.QtCore import pyqtProperty, pyqtSignal
|
||||
from PyQt5.QtGui import QImage
|
||||
from PyQt5.QtNetwork import QNetworkReply, QNetworkRequest
|
||||
|
||||
from UM.Logger import Logger
|
||||
from UM.TaskManagement.HttpRequestManager import HttpRequestManager
|
||||
from cura.PrinterOutput.Models.PrintJobOutputModel import PrintJobOutputModel
|
||||
from cura.PrinterOutput.PrinterOutputController import PrinterOutputController
|
||||
|
||||
@ -32,3 +35,13 @@ class UM3PrintJobOutputModel(PrintJobOutputModel):
|
||||
image = QImage()
|
||||
image.loadFromData(data)
|
||||
self.updatePreviewImage(image)
|
||||
|
||||
def loadPreviewImageFromUrl(self, url: str) -> None:
|
||||
HttpRequestManager.getInstance().get(url=url, callback=self._onImageLoaded, error_callback=self._onImageLoaded)
|
||||
|
||||
def _onImageLoaded(self, reply: QNetworkReply, error: Optional["QNetworkReply.NetworkError"] = None) -> None:
|
||||
if not HttpRequestManager.replyIndicatesSuccess(reply, error):
|
||||
Logger.warning("Requesting preview image failed, response code {0} while trying to connect to {1}".format(
|
||||
reply.attribute(QNetworkRequest.HttpStatusCodeAttribute), reply.url()))
|
||||
return
|
||||
self.updatePreviewImageData(reply.readAll())
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2019 Ultimaker B.V.
|
||||
# Copyright (c) 2020 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
import os
|
||||
from time import time
|
||||
@ -330,6 +330,8 @@ class UltimakerNetworkedPrinterOutputDevice(NetworkedPrinterOutputDevice):
|
||||
self._updateAssignedPrinter(model, remote_job.printer_uuid)
|
||||
if remote_job.assigned_to:
|
||||
self._updateAssignedPrinter(model, remote_job.assigned_to)
|
||||
if remote_job.preview_url:
|
||||
model.loadPreviewImageFromUrl(remote_job.preview_url)
|
||||
return model
|
||||
|
||||
## Updates the printer assignment for the given print job model.
|
||||
|
Loading…
x
Reference in New Issue
Block a user