Merge lp:~saviq/unity8/lazyimage-crop into lp:unity8

Proposed by Michał Sawicz
Status: Work in progress
Proposed branch: lp:~saviq/unity8/lazyimage-crop
Merge into: lp:unity8
Diff against target: 123 lines (+37/-9)
2 files modified
qml/Components/LazyImage.qml (+6/-6)
tests/qmltests/Components/tst_LazyImage.qml (+31/-3)
To merge this branch: bzr merge lp:~saviq/unity8/lazyimage-crop
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Michael Zanetti Pending
Review via email: mp+203897@code.launchpad.net

Commit message

Add crop mode to LazyImage.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:663
http://jenkins.qa.ubuntu.com/job/unity8-ci/2168/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/2739
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/2503/console
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-trusty/1041
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-amd64-ci/690
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/692
        deb: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/692/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-i386-ci/690
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/2398
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/2741
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/2741/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/2504
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/2504/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/4938/console
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/3471

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/2168/rebuild

review: Needs Fixing (continuous-integration)

Unmerged revisions

663. By Michał Sawicz

Add crop mode to LazyImage.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qml/Components/LazyImage.qml'
2--- qml/Components/LazyImage.qml 2013-10-14 22:13:48 +0000
3+++ qml/Components/LazyImage.qml 2014-01-30 09:21:51 +0000
4@@ -27,8 +27,8 @@
5 // TODO convert into enums when available in QML
6 property string scaleTo
7
8- property real initialWidth: scaleTo == "width" || scaleTo == "fit" ? width : units.gu(10)
9- property real initialHeight: scaleTo == "height" || scaleTo == "fit" ? height : units.gu(10)
10+ property real initialWidth: scaleTo == "width" || scaleTo == "fit" || scaleTo == "crop" ? width : units.gu(10)
11+ property real initialHeight: scaleTo == "height" || scaleTo == "fit" || scaleTo == "crop" ? height : units.gu(10)
12
13 property alias sourceSize: image.sourceSize
14 property alias fillMode: image.fillMode
15@@ -93,7 +93,7 @@
16 property url nextSource
17 property string format: image.implicitWidth > image.implicitHeight ? "landscape" : "portrait"
18
19- fillMode: Image.PreserveAspectFit
20+ fillMode: root.scaleTo == "crop" ? Image.PreserveAspectCrop : Image.PreserveAspectFit
21 asynchronous: true
22 cache: false
23 horizontalAlignment: Image.AlignHCenter
24@@ -126,9 +126,9 @@
25 PropertyChanges { target: root; implicitWidth: shape.width; implicitHeight: shape.height }
26 PropertyChanges { target: placeholder; opacity: 0 }
27 PropertyChanges { target: shape; opacity: 1
28- width: root.scaleTo == "width" || (root.scaleTo == "fit" && image.format == "landscape") ? root.width
29- : root.scaleTo == "" ? image.implicitWidth : image.implicitWidth * height / image.implicitHeight
30- height: root.scaleTo == "height" || (root.scaleTo == "fit" && image.format == "portrait") ? root.height
31+ width: root.scaleTo == "width" || root.scaleTo == "crop" || (root.scaleTo == "fit" && image.format == "landscape") ? root.width
32+ : root.scaleTo == "" ? image.implicitWidth : image.implicitWidth * height / image.implicitHeight
33+ height: root.scaleTo == "height" || root.scaleTo == "crop" || (root.scaleTo == "fit" && image.format == "portrait") ? root.height
34 : root.scaleTo == "" ? image.implicitHeight : image.implicitHeight * width / image.implicitWidth
35 }
36 },
37
38=== modified file 'tests/qmltests/Components/tst_LazyImage.qml'
39--- tests/qmltests/Components/tst_LazyImage.qml 2013-12-17 16:04:47 +0000
40+++ tests/qmltests/Components/tst_LazyImage.qml 2014-01-30 09:21:51 +0000
41@@ -27,15 +27,21 @@
42
43 Rectangle {
44 id: baseRect
45+ color: "grey"
46+ anchors.fill: parent
47+ }
48+
49+ Flickable {
50 anchors {
51 fill: parent
52+ margins: units.gu(3)
53 rightMargin: 2 * parent.width / 3
54 }
55
56- color: "grey"
57+ contentHeight: column.height
58
59 Column {
60- anchors { fill: parent; margins: units.gu(5) }
61+ id: column
62
63 Label {
64 height: units.gu(4)
65@@ -87,6 +93,20 @@
66 width: units.gu(12)
67 scaleTo: "fit"
68 }
69+
70+ Label {
71+ height: units.gu(4)
72+ text: "Crop"
73+ color: "white"
74+ verticalAlignment: Text.AlignBottom
75+ }
76+
77+ LazyImage {
78+ id: lazy5
79+ height: units.gu(12)
80+ width: units.gu(12)
81+ scaleTo: "crop"
82+ }
83 }
84 }
85
86@@ -109,6 +129,7 @@
87 ImageControls { id: controls2; image: lazy2 }
88 ImageControls { id: controls3; image: lazy3 }
89 ImageControls { id: controls4; image: lazy4 }
90+ ImageControls { id: controls5; image: lazy5 }
91 }
92 }
93
94@@ -123,6 +144,8 @@
95 tryCompare(lazy2, "height", units.gu(10));
96 controls3.blank();
97 tryCompare(lazy3, "width", units.gu(10));
98+ controls4.blank();
99+ controls5.blank();
100 }
101
102 function test_lazyimage_data() {
103@@ -147,6 +170,11 @@
104 {tag: "Fit Square", image: lazy4, func: controls4.square, transition: "readyTransition", width: units.gu(12), height: units.gu(12), imageWidth: units.gu(12), imageHeight: units.gu(12), initialWidth: units.gu(12), initialHeight: units.gu(12)},
105 {tag: "Fit Portrait", image: lazy4, func: controls4.portrait, transition: "readyTransition", width: units.gu(12), height: units.gu(12), imageWidth: units.gu(6), imageHeight: units.gu(12), initialWidth: units.gu(12), initialHeight: units.gu(12)},
106 {tag: "Fit Bad path", image: lazy4, func: controls4.badpath, transition: "genericTransition", width: units.gu(12), height: units.gu(12), imageWidth: units.gu(12), imageHeight: units.gu(12), initialWidth: units.gu(12), initialHeight: units.gu(12), placeholder: true, error: true},
107+ {tag: "Crop Blank", image: lazy5, func: controls5.blank, width: units.gu(12), height: units.gu(12), imageWidth: units.gu(12), imageHeight: units.gu(12), initialWidth: units.gu(12), initialHeight: units.gu(12), placeholder: true},
108+ {tag: "Crop Wide", image: lazy5, func: controls5.wide, width: units.gu(12), height: units.gu(12), imageWidth: units.gu(12), imageHeight: units.gu(12), initialWidth: units.gu(12), initialHeight: units.gu(12)},
109+ {tag: "Crop Square", image: lazy5, func: controls5.square, width: units.gu(12), height: units.gu(12), imageWidth: units.gu(12), imageHeight: units.gu(12), initialWidth: units.gu(12), initialHeight: units.gu(12)},
110+ {tag: "Crop Portrait", image: lazy5, func: controls5.portrait, width: units.gu(12), height: units.gu(12), imageWidth: units.gu(12), imageHeight: units.gu(12), initialWidth: units.gu(12), initialHeight: units.gu(12)},
111+ {tag: "Crop Bad path", image: lazy5, func: controls5.badpath, width: units.gu(12), height: units.gu(12), imageWidth: units.gu(12), imageHeight: units.gu(12), initialWidth: units.gu(12), initialHeight: units.gu(12), placeholder: true, error: true},
112 ]
113 }
114
115@@ -175,7 +203,7 @@
116
117 // check the placeholder
118 var placeholder = findChild(data.image, "placeholder");
119- compare(placeholder.visible, data.placeholder ? true : false);
120+ tryCompare(placeholder, "visible", data.placeholder ? true : false);
121
122 // check the error image
123 var error = findChild(data.image, "errorImage");

Subscribers

People subscribed via source and target branches