mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00

Converted doxygen style comments to reStructuredText style in the files found in Cura/cura directory using the script dox_2_rst.py (provided in the Uranium repo). Comments were manually checked and changed if needed.
34 lines
No EOL
1.3 KiB
Python
34 lines
No EOL
1.3 KiB
Python
from PyQt5.QtGui import QImage
|
|
from PyQt5.QtQuick import QQuickImageProvider
|
|
from PyQt5.QtCore import QSize
|
|
|
|
from UM.Application import Application
|
|
from typing import Tuple
|
|
|
|
|
|
class PrintJobPreviewImageProvider(QQuickImageProvider):
|
|
def __init__(self):
|
|
super().__init__(QQuickImageProvider.Image)
|
|
|
|
def requestImage(self, id: str, size: QSize) -> Tuple[QImage, QSize]:
|
|
"""Request a new image.
|
|
|
|
:param id: id of the requested image
|
|
:param size: is not used defaults to QSize(15, 15)
|
|
:return: an tuple containing the image and size
|
|
"""
|
|
|
|
# The id will have an uuid and an increment separated by a slash. As we don't care about the value of the
|
|
# increment, we need to strip that first.
|
|
uuid = id[id.find("/") + 1:]
|
|
for output_device in Application.getInstance().getOutputDeviceManager().getOutputDevices():
|
|
if not hasattr(output_device, "printJobs"):
|
|
continue
|
|
|
|
for print_job in output_device.printJobs:
|
|
if print_job.key == uuid:
|
|
if print_job.getPreviewImage():
|
|
return print_job.getPreviewImage(), QSize(15, 15)
|
|
|
|
return QImage(), QSize(15, 15)
|
|
return QImage(), QSize(15, 15) |