~macslow/unity8/swipe-dismiss-snap-decisions

« back to all changes in this revision

Viewing changes to plugins/Dash/CroppedImageMinimumSourceSize.qml

Merge from wizard-import

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 */
16
16
 
17
17
import QtQuick 2.3
18
 
 
19
 
Image {
20
 
    property bool resized: false
21
 
    property bool resizing: false
22
 
    fillMode: Image.PreserveAspectCrop
23
 
    visible: resized
24
 
    onSourceSizeChanged: {
25
 
        if (!resized && !resizing) {
26
 
            resizing = true;
27
 
            var ar = width / height;
28
 
            var ssar = sourceSize.width / sourceSize.height;
29
 
            if (ar > ssar) {
30
 
                sourceSize = Qt.size(width, 0);
31
 
            } else {
32
 
                sourceSize = Qt.size(0, height);
33
 
            }
34
 
            resizing = false;
35
 
            resized = true;
36
 
        }
 
18
import Dash 0.1
 
19
 
 
20
Item {
 
21
    id: root
 
22
 
 
23
    property string source
 
24
    property alias image: innerImage
 
25
    property alias asynchronous: innerImage.asynchronous
 
26
    property alias verticalAlignment: innerImage.verticalAlignment
 
27
    property alias horizontalAlignment: innerImage.horizontalAlignment
 
28
    property alias fillMode: innerImage.fillMode
 
29
 
 
30
    CroppedImageSizer {
 
31
        id: sizer
 
32
        source: root.source
 
33
        width: root.width
 
34
        height: root.height
 
35
    }
 
36
 
 
37
    Image {
 
38
        id: innerImage
 
39
        anchors.fill: parent
 
40
        fillMode: Image.PreserveAspectCrop
 
41
        sourceSize: sizer.sourceSize.width == 0 && sizer.sourceSize.height == 0 ? undefined : sizer.sourceSize
 
42
        source: sizer.sourceSize.width == -1 && sizer.sourceSize.height == -1 ? "" : root.source
37
43
    }
38
44
}