16
16
readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
18
18
id: artShapeHolder;
19
height: root.fixedArtShapeSize.height != -1 ? root.fixedArtShapeSize.height : artShapeLoader.height;
20
width: root.fixedArtShapeSize.width != -1 ? root.fixedArtShapeSize.width : artShapeLoader.width;
19
height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
20
width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
21
21
anchors { horizontalCenter: parent.horizontalCenter; }
23
23
id: artShapeLoader;
30
30
objectName: "artShape";
32
readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1;
33
readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect;
34
Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; }
35
onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
36
32
visible: image.status == Image.Ready;
37
function updateWidthHeightBindings() {
38
if (aspectSmallerThanImageAspect) {
39
width = Qt.binding(function() { return !visible ? 0 : image.width });
40
height = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.height : width / image.aspect });
42
width = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.width : height * image.aspect });
43
height = Qt.binding(function() { return !visible ? 0 : image.height });
33
readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
34
readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : components !== undefined ? components["art"]["aspect-ratio"] : 1;
35
readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect;
36
Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; }
37
onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
38
Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); }
39
function updateWidthHeightBindings() {
40
if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) {
41
width = root.fixedArtShapeSize.width;
42
height = root.fixedArtShapeSize.height;
43
} else if (aspectSmallerThanImageAspect) {
44
width = Qt.binding(function() { return !visible ? 0 : image.width });
45
height = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.height : width / image.aspect });
47
width = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.width : height * image.aspect });
48
height = Qt.binding(function() { return !visible ? 0 : image.height });
47
52
objectName: "artImage";