From 158c99daef1c40bb7fbebe4968dbf3e7e9e0f7bf Mon Sep 17 00:00:00 2001 From: James Graham Date: Thu, 22 Dec 2022 20:23:00 +0000 Subject: [PATCH] Improve timeline image sizing Improve the initial resizing of an image in the timeline by always looking to see whether sourcesize or image.info is populated first. This allows the actual size of the image to be calculated as soon as possible while still maintaining the fix fo CCBUG: 460205 May also help CCBUG: 463235 I need help testing this it currently no longer happens for me. --- src/qml/Component/Timeline/ImageDelegate.qml | 26 +++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/qml/Component/Timeline/ImageDelegate.qml b/src/qml/Component/Timeline/ImageDelegate.qml index 95ede95f1..ad8586d58 100644 --- a/src/qml/Component/Timeline/ImageDelegate.qml +++ b/src/qml/Component/Timeline/ImageDelegate.qml @@ -31,10 +31,30 @@ TimelineContainer { innerObject: AnimatedImage { id: img + property var imageWidth: { + if (imageDelegate.info.w > 0) { + return imageDelegate.info.w; + } else if (sourceSize.width > 0) { + return sourceSize.width; + } else { + return imageDelegate.contentMaxWidth; + } + } + property var imageHeight: { + if (imageDelegate.info.h > 0) { + return imageDelegate.info.h; + } else if (sourceSize.height > 0) { + return sourceSize.height; + } else { + // Default to a 16:9 placeholder + return imageDelegate.contentMaxWidth / 16 * 9; + } + } + Layout.maximumWidth: Math.min(imageDelegate.contentMaxWidth, imageDelegate.maxWidth) - Layout.maximumHeight: Math.min(imageDelegate.contentMaxWidth / sourceSize.width * sourceSize.height, imageDelegate.maxWidth / sourceSize.width * sourceSize.height) - Layout.preferredWidth: imageDelegate.info.w > 0 ? imageDelegate.info.w : sourceSize.width - Layout.preferredHeight: imageDelegate.info.h > 0 ? imageDelegate.info.h : sourceSize.height + Layout.maximumHeight: Math.min(imageDelegate.contentMaxWidth / imageWidth * imageHeight, imageDelegate.maxWidth / imageWidth * imageHeight) + Layout.preferredWidth: imageWidth + Layout.preferredHeight: imageHeight source: model.mediaUrl Image {