Merge remote-tracking branch 'origin/qt6_beyond_the_splash' into qt6_beyond_the_splash

This commit is contained in:
Jelle Spijker 2022-04-14 08:32:53 +02:00
commit b3cd1fee09
No known key found for this signature in database
GPG key ID: 6662DC033BE6B99A
14 changed files with 24 additions and 20 deletions

View file

@ -206,7 +206,7 @@ class ContainerManager(QObject):
if os.path.exists(file_url):
result = QMessageBox.question(None, catalog.i18nc("@title:window", "File Already Exists"),
catalog.i18nc("@label Don't translate the XML tag <filename>!", "The file <filename>{0}</filename> already exists. Are you sure you want to overwrite it?").format(file_url))
if result == QMessageBox.No:
if result == QMessageBox.ButtonRole.NoRole:
return {"status": "cancelled", "message": "User cancelled"}
try:

View file

@ -139,7 +139,7 @@ class CuraContainerRegistry(ContainerRegistry):
if os.path.exists(file_name):
result = QMessageBox.question(None, catalog.i18nc("@title:window", "File Already Exists"),
catalog.i18nc("@label Don't translate the XML tag <filename>!", "The file <filename>{0}</filename> already exists. Are you sure you want to overwrite it?").format(file_name))
if result == QMessageBox.No:
if result == QMessageBox.ButtonRole.NoRole:
return False
profile_writer = self._findProfileWriter(extension, description)

View file

@ -6,6 +6,7 @@ from PyQt6 import QtCore
from PyQt6.QtCore import QCoreApplication
from PyQt6.QtGui import QImage
from UM.Logger import Logger
from cura.PreviewPass import PreviewPass
from UM.Application import Application
@ -20,7 +21,7 @@ class Snapshot:
def getImageBoundaries(image: QImage):
# Look at the resulting image to get a good crop.
# Get the pixels as byte array
pixel_array = image.bits().asarray(image.byteCount())
pixel_array = image.bits().asarray(image.sizeInBytes())
width, height = image.width(), image.height()
# Convert to numpy array, assume it's 32 bit (it should always be)
pixels = numpy.frombuffer(pixel_array, dtype=numpy.uint8).reshape([height, width, 4])
@ -64,6 +65,7 @@ class Snapshot:
bbox = bbox + node.getBoundingBox()
# If there is no bounding box, it means that there is no model in the buildplate
if bbox is None:
Logger.log("w", "Unable to create snapshot as we seem to have an empty buildplate")
return None
look_at = bbox.center
@ -96,6 +98,7 @@ class Snapshot:
try:
min_x, max_x, min_y, max_y = Snapshot.getImageBoundaries(pixel_output)
except (ValueError, AttributeError):
Logger.logException("w", "Failed to crop the snapshot!")
return None
size = max((max_x - min_x) / render_width, (max_y - min_y) / render_height)
@ -117,7 +120,7 @@ class Snapshot:
# Scale it to the correct size
scaled_image = cropped_image.scaled(
width, height,
aspectRatioMode = QtCore.Qt.IgnoreAspectRatio,
transformMode = QtCore.Qt.SmoothTransformation)
aspectRatioMode = QtCore.Qt.AspectRatioMode.IgnoreAspectRatio,
transformMode = QtCore.Qt.TransformationMode.SmoothTransformation)
return scaled_image

View file

@ -76,7 +76,7 @@ class CuraSplashScreen(QSplashScreen):
if len(version) == 1:
painter.drawText(40, 104 + self._version_y_offset, round(330 * self._scale), round(230 * self._scale), Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignTop, version[0] if not ApplicationMetadata.IsAlternateVersion else ApplicationMetadata.CuraBuildType)
elif len(version) > 1:
painter.drawText(40, 104 + self._version_y_offset, round(330 * self._scale), round(230 * self._scale), Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignTop, version[0] +" "+ version[1] if not ApplicationMetadata.IsAlternateVersion else ApplicationMetadata.CuraBuildType)
painter.drawText(40, 104 + self._version_y_offset, round(330 * self._scale), round(230 * self._scale), Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignTop, {"version[0]_version[1]"} if not ApplicationMetadata.IsAlternateVersion else ApplicationMetadata.CuraBuildType)
# Draw the loading image
pen = QPen()
@ -93,7 +93,7 @@ class CuraSplashScreen(QSplashScreen):
pen.setColor(QColor(255, 255, 255, 255))
painter.setPen(pen)
painter.setFont(font)
painter.drawText(70, 320, 170, 24,
painter.drawText(70, 308, 170, 48,
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter | Qt.TextFlag.TextWordWrap,
self._current_message)

View file

@ -157,7 +157,7 @@ class ThreeMFWriter(MeshWriter):
snapshot = self._createSnapshot()
if snapshot:
thumbnail_buffer = QBuffer()
thumbnail_buffer.open(QBuffer.ReadWrite)
thumbnail_buffer.open(QBuffer.OpenModeFlag.ReadWrite)
snapshot.save(thumbnail_buffer, "PNG")
thumbnail_file = zipfile.ZipInfo("Metadata/thumbnail.png")

View file

@ -56,7 +56,7 @@ Item
id: createNewProjectButton
text: "New Library project"
visible: createNewProjectButtonVisible && manager.userAccountCanCreateNewLibraryProject && (manager.retrievingProjectsStatus == DF.RetrievalStatus.Success || manager.retrievingProjectsStatus == DF.RetrievalStatus.Failed)
visible: createNewProjectButtonVisible && manager.userAccountCanCreateNewLibraryProject && (manager.retrievingProjectsStatus == 2 || manager.retrievingProjectsStatus == 3) // Status is succeeded or failed
onClicked:
{

View file

@ -63,7 +63,7 @@ class ImageReader(MeshReader):
aspect = height / width
if img.width() < 2 or img.height() < 2:
img = img.scaled(width, height, Qt.IgnoreAspectRatio)
img = img.scaled(width, height, Qt.AspectRatioMode.IgnoreAspectRatio)
height_from_base = max(height_from_base, 0)
base_height = max(base_height, 0)
@ -84,15 +84,15 @@ class ImageReader(MeshReader):
width = int(max(round(width * scale_factor), 2))
height = int(max(round(height * scale_factor), 2))
img = img.scaled(width, height, Qt.IgnoreAspectRatio)
img = img.scaled(width, height, Qt.AspectRatioMode.IgnoreAspectRatio)
width_minus_one = width - 1
height_minus_one = height - 1
Job.yieldThread()
texel_width = 1.0 / (width_minus_one) * scale_vector.x
texel_height = 1.0 / (height_minus_one) * scale_vector.z
texel_width = 1.0 / width_minus_one * scale_vector.x
texel_height = 1.0 / height_minus_one * scale_vector.z
height_data = numpy.zeros((height, width), dtype = numpy.float32)

View file

@ -85,7 +85,7 @@ class ImageReaderUI(QObject):
Logger.log("d", "Creating ImageReader config UI")
path = os.path.join(PluginRegistry.getInstance().getPluginPath("ImageReader"), "ConfigUI.qml")
self._ui_view = Application.getInstance().createQmlComponent(path, {"manager": self})
self._ui_view.setFlags(self._ui_view.flags() & ~Qt.WindowCloseButtonHint & ~Qt.WindowMinimizeButtonHint & ~Qt.WindowMaximizeButtonHint)
self._ui_view.setFlags(self._ui_view.flags() & ~Qt.WindowType.WindowCloseButtonHint & ~Qt.WindowType.WindowMinimizeButtonHint & ~Qt.WindowType.WindowMaximizeButtonHint)
self._disable_size_callbacks = False
@pyqtSlot()

View file

@ -22,7 +22,7 @@ class CreateThumbnail(Script):
Logger.log("d", "Encoding thumbnail image...")
try:
thumbnail_buffer = QBuffer()
thumbnail_buffer.open(QBuffer.ReadWrite)
thumbnail_buffer.open(QBuffer.OpenModeFlag.ReadWrite)
thumbnail_image = snapshot
thumbnail_image.save(thumbnail_buffer, "PNG")
base64_bytes = base64.b64encode(thumbnail_buffer.data())

View file

@ -266,7 +266,7 @@ Item
anchors.bottom: parent.top
anchors.bottomMargin: UM.Theme.getSize("narrow_margin").height
anchors.horizontalCenter: parent.horizontalCenter
target: Qt.point(parent.width / 2, parent.top)
target: Qt.point(parent.width / 2, 1)
visible: sliderRoot.activeHandle == parent || sliderRoot.activeHandle == rangeHandle
// custom properties
@ -376,7 +376,7 @@ Item
anchors.top: parent.bottom
anchors.topMargin: UM.Theme.getSize("narrow_margin").height
anchors.horizontalCenter: parent.horizontalCenter
target: Qt.point(parent.width / 2, parent.bottom)
target: Qt.point(parent.width / 2, -1)
visible: sliderRoot.activeHandle == parent || sliderRoot.activeHandle == rangeHandle
// custom properties

View file

@ -83,7 +83,7 @@ class UFPWriter(MeshWriter):
thumbnail = archive.getStream("/Metadata/thumbnail.png")
thumbnail_buffer = QBuffer()
thumbnail_buffer.open(QBuffer.ReadWrite)
thumbnail_buffer.open(QBuffer.OpenModeFlag.ReadWrite)
snapshot.save(thumbnail_buffer, "PNG")
thumbnail.write(thumbnail_buffer.data())

View file

@ -480,7 +480,7 @@ class CloudOutputDeviceManager:
if remove_printers_ids == all_ids:
question_content = self.i18n_catalog.i18nc("@label", "You are about to remove all printers from Cura. This action cannot be undone.\nAre you sure you want to continue?")
result = QMessageBox.question(None, question_title, question_content)
if result == QMessageBox.No:
if result == QMessageBox.ButtonRole.NoRole:
return
for machine_cloud_id in self.reported_device_ids:

View file

@ -119,6 +119,7 @@ Column
text: widget.waitingForSliceToStart ? catalog.i18nc("@button", "Processing"): catalog.i18nc("@button", "Slice")
tooltip: catalog.i18nc("@label", "Start the slicing process")
hoverEnabled: !widget.waitingForSliceToStart
enabled: widget.backendState != UM.Backend.Error && !widget.waitingForSliceToStart
visible: widget.backendState == UM.Backend.NotStarted || widget.backendState == UM.Backend.Error
onClicked: {

View file

@ -157,7 +157,7 @@ Item
anchors.topMargin: base.activeY
z: buttons.z - 1
target: Qt.point(parent.right, base.activeY + Math.round(UM.Theme.getSize("button").height/2))
target: Qt.point(-1, base.activeY + Math.round(UM.Theme.getSize("button").height / 2))
arrowSize: UM.Theme.getSize("default_arrow").width
width: