@@ -36,6 +36,10 @@ FocusScope {
3636 property alias currentFrame: sequencePlayer .frameId
3737 property alias frameRange: sequencePlayer .frameRange
3838
39+ property bool fittedOnce: false
40+ property int previousWidth: - 1
41+ property int previousHeight: - 1
42+
3943 QtObject {
4044 id: m
4145 property variant viewpointMetadata: {
@@ -472,12 +476,13 @@ FocusScope {
472476 orientationTag: imgContainer .orientationTag
473477 xOrigin: imgContainer .width / 2
474478 yOrigin: imgContainer .height / 2
475- property bool fittedOnce: false
476- property int previousWidth: 0
477- property int previousHeight: 0
479+
478480 property real targetSize: Math .max (width, height) * imgContainer .scale
479481 property real resizeRatio: imgContainer .scale
480- onHeightChanged: {
482+
483+
484+
485+ function sizeChanged () {
481486 /* Image size is not updated through a single signal with the floatImage viewer, unlike
482487 * the simple QML image viewer: instead of updating straight away the width and height to x and
483488 * y, the emitted signals look like:
@@ -489,13 +494,29 @@ FocusScope {
489494 * group has already been auto-fitted. If we change the group of images (when another project is
490495 * opened, for example, and the images have a different size), then another auto-fit needs to be
491496 * performed */
492- if ((! fittedOnce && imgContainer .image && imgContainer .image .height > 0 ) ||
493- (fittedOnce && ((width > 1 && previousWidth != width) ||
494- (height > 1 && previousHeight != height)))) {
497+
498+ var sizeValid = (width > 0 ) && (height > 0 )
499+ var layoutValid = (root .width > 50 ) && (root .height > 50 )
500+ var sizeChanged = (root .previousWidth != width) || (root .previousHeight != height)
501+ var sizeChanged = (root .previousWidth != width) || (root .previousHeight != height)
502+
503+ if ((! root .fittedOnce && imgContainer .image && sizeValid && layoutValid) ||
504+ (root .fittedOnce && sizeChanged && sizeValid && layoutValid)) {
495505 fit ()
496- fittedOnce = true
497- previousWidth = width
498- previousHeight = height
506+ root .fittedOnce = true
507+ root .previousWidth = width
508+ root .previousHeight = height
509+ }
510+ }
511+
512+ onHeightChanged : {
513+ floatImageViewerLoader .sizeChanged ();
514+ }
515+
516+ Connections {
517+ target: root
518+ function onHeightChanged () {
519+ floatImageViewerLoader .sizeChanged ()
499520 }
500521 }
501522
0 commit comments