on xenial help sign in
Fixes carousel shadow
commite7bd92dfffebc8bd457e393ef7757c6aed2d3772 authorAndrea Cimitan <andrea.cimitan@gmail.com> dateTue 27 May 2014, 07:46 (12 years ago) parentae0e9510534124
10 files changed+50−31
plugins/Dash/CardCreator.js+3−3 qml/Dash/CardCarousel.qml+1−1 qml/Dash/GenericScopeView.qml+1−1 tests/mocks/Unity/fake_categories.cpp+5−1 tests/plugins/Dash/cardcreator/1.res+3−3 tests/plugins/Dash/cardcreator/2.res+1−1 tests/plugins/Dash/cardcreator/3.res+3−3 tests/plugins/Dash/cardcreator/4.res+1−1 tests/plugins/Dash/cardcreator/5.res+3−3 tests/qmltests/Dash/tst_DashContent.qml+29−14
plugins/Dash/CardCreator.js+3−3
@@ -70,10 +70,9 @@ var kArtShapeHolderCode = 'Item { \n\
7070 radius: "medium"; \n\
7171 readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1; \n\
7272 readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect; \n\
73− Component.onCompleted: updateWidthHeightBindings(); \n\
73+ Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; } \n\
7474 onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings(); \n\
7575 visible: image.status == Image.Ready; \n\
76− borderSource: artShapeBorderSource; \n\
7776 function updateWidthHeightBindings() { \n\
7877 if (aspectSmallerThanImageAspect) { \n\
7978 width = Qt.binding(function() { return !visible ? 0 : image.width }); \n\
@@ -281,7 +280,7 @@ function cardString(template, components) {
281280 property var template; \n\
282281 property var components; \n\
283282 property var cardData; \n\
284− property var artShapeBorderSource; \n\
283+ property var artShapeBorderSource: undefined; \n\
285284 property real fontScale: 1.0; \n\
286285 property int headerAlignment: Text.AlignLeft; \n\
287286 property int fixedHeaderHeight: -1; \n\
@@ -307,6 +306,7 @@ function cardString(template, components) {
307306 }
308307
309308 if (hasArt) {
309+ code += 'onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artShapeLoader.item) artShapeLoader.item.borderSource = artShapeBorderSource; } \n';
310310 code += 'readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);\n';
311311
312312 var widthCode, heightCode;
qml/Dash/CardCarousel.qml+1−1
@@ -34,7 +34,7 @@ DashRenderer {
3434 Carousel {
3535 id: carousel
3636 anchors.fill: parent
37− tileAspectRatio: cardCarousel.components && cardCarousel.components["art"]["aspect-ratio"] || 1.0
37+ tileAspectRatio: cardTool.components && cardTool.components["art"]["aspect-ratio"] || 1.0
3838 // FIXME we need to "reverse" the carousel to make the selected item the size
3939 // and push others back.
4040 minimumTileWidth: cardTool.cardWidth / selectedItemScaleFactor
qml/Dash/GenericScopeView.qml+1−1
@@ -128,7 +128,7 @@ FocusScope {
128128
129129 CardTool {
130130 id: cardTool
131−
131+ objectName: "cardTool"
132132 count: results.count
133133 template: model.renderer
134134 components: model.components
tests/mocks/Unity/fake_categories.cpp+5−1
@@ -152,7 +152,11 @@ Categories::data(const QModelIndex& index, int role) const
152152 case RoleComponents:
153153 {
154154 QVariantMap map, artMap;
155− artMap["aspect-ratio"] = "1.0";
155+ if (index.row() % 2 != 0) {
156+ artMap["aspect-ratio"] = QString("1.%1").arg(index.row());
157+ } else {
158+ artMap["aspect-ratio"] = "1.0";
159+ }
156160 artMap["field"] = "art";
157161 map["art"] = artMap;
158162 map["title"] = "HOLA";
tests/plugins/Dash/cardcreator/1.res+3−3
@@ -3,7 +3,7 @@ AbstractButton {
33 property var template;
44 property var components;
55 property var cardData;
6− property var artShapeBorderSource;
6+ property var artShapeBorderSource: undefined;
77 property real fontScale: 1.0;
88 property int headerAlignment: Text.AlignLeft;
99 property int fixedHeaderHeight: -1;
@@ -12,6 +12,7 @@ AbstractButton {
1212 property bool asynchronous: true;
1313 property bool showHeader: true;
1414 implicitWidth: childrenRect.width;
15+onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artShapeLoader.item) artShapeLoader.item.borderSource = artShapeBorderSource; }
1516readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
1617Item {
1718 id: artShapeHolder;
@@ -30,10 +31,9 @@ Item {
3031 radius: "medium";
3132 readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1;
3233 readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect;
33− Component.onCompleted: updateWidthHeightBindings();
34+ Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; }
3435 onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
3536 visible: image.status == Image.Ready;
36− borderSource: artShapeBorderSource;
3737 function updateWidthHeightBindings() {
3838 if (aspectSmallerThanImageAspect) {
3939 width = Qt.binding(function() { return !visible ? 0 : image.width });
tests/plugins/Dash/cardcreator/2.res+1−1
@@ -3,7 +3,7 @@ AbstractButton {
33 property var template;
44 property var components;
55 property var cardData;
6− property var artShapeBorderSource;
6+ property var artShapeBorderSource: undefined;
77 property real fontScale: 1.0;
88 property int headerAlignment: Text.AlignLeft;
99 property int fixedHeaderHeight: -1;
tests/plugins/Dash/cardcreator/3.res+3−3
@@ -3,7 +3,7 @@ AbstractButton {
33 property var template;
44 property var components;
55 property var cardData;
6− property var artShapeBorderSource;
6+ property var artShapeBorderSource: undefined;
77 property real fontScale: 1.0;
88 property int headerAlignment: Text.AlignLeft;
99 property int fixedHeaderHeight: -1;
@@ -12,6 +12,7 @@ AbstractButton {
1212 property bool asynchronous: true;
1313 property bool showHeader: true;
1414 implicitWidth: childrenRect.width;
15+onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artShapeLoader.item) artShapeLoader.item.borderSource = artShapeBorderSource; }
1516readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
1617Item {
1718 id: artShapeHolder;
@@ -30,10 +31,9 @@ Item {
3031 radius: "medium";
3132 readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1;
3233 readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect;
33− Component.onCompleted: updateWidthHeightBindings();
34+ Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; }
3435 onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
3536 visible: image.status == Image.Ready;
36− borderSource: artShapeBorderSource;
3737 function updateWidthHeightBindings() {
3838 if (aspectSmallerThanImageAspect) {
3939 width = Qt.binding(function() { return !visible ? 0 : image.width });
tests/plugins/Dash/cardcreator/4.res+1−1
@@ -3,7 +3,7 @@ AbstractButton {
33 property var template;
44 property var components;
55 property var cardData;
6− property var artShapeBorderSource;
6+ property var artShapeBorderSource: undefined;
77 property real fontScale: 1.0;
88 property int headerAlignment: Text.AlignLeft;
99 property int fixedHeaderHeight: -1;
tests/plugins/Dash/cardcreator/5.res+3−3
@@ -3,7 +3,7 @@ AbstractButton {
33 property var template;
44 property var components;
55 property var cardData;
6− property var artShapeBorderSource;
6+ property var artShapeBorderSource: undefined;
77 property real fontScale: 1.0;
88 property int headerAlignment: Text.AlignLeft;
99 property int fixedHeaderHeight: -1;
@@ -12,6 +12,7 @@ AbstractButton {
1212 property bool asynchronous: true;
1313 property bool showHeader: true;
1414 implicitWidth: childrenRect.width;
15+onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artShapeLoader.item) artShapeLoader.item.borderSource = artShapeBorderSource; }
1516readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
1617Item {
1718 id: artShapeHolder;
@@ -30,10 +31,9 @@ Item {
3031 radius: "medium";
3132 readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1;
3233 readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect;
33− Component.onCompleted: updateWidthHeightBindings();
34+ Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; }
3435 onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
3536 visible: image.status == Image.Ready;
36− borderSource: artShapeBorderSource;
3737 function updateWidthHeightBindings() {
3838 if (aspectSmallerThanImageAspect) {
3939 width = Qt.binding(function() { return !visible ? 0 : image.width });
tests/qmltests/Dash/tst_DashContent.qml+29−14
@@ -67,13 +67,17 @@ Item {
6767 name: "DashContent"
6868 when: scopesModel.loaded && windowShown
6969
70− function init() {
71− scopesModel.clear();
70+ function loadScopes() {
7271 scopeLoadedSpy.clear();
7372 scopesModel.load();
7473 tryCompare(scopeLoadedSpy, "count", 4);
7574 }
7675
76+ function init() {
77+ scopesModel.clear();
78+ loadScopes();
79+ }
80+
7781 function cleanup() {
7882 movementStartedSpy.clear();
7983 dashContent.visible = true;
@@ -93,9 +97,7 @@ Item {
9397 compare(dashContentList.count, 0, "DashContent should have 0 items when it starts");
9498 tryCompare(dashContentList, "currentIndex", -1);
9599
96− scopeLoadedSpy.clear();
97− scopesModel.load();
98− tryCompare(scopeLoadedSpy, "count", 4);
100+ loadScopes();
99101
100102 verify(dashContentList.currentIndex >= 0);
101103 }
@@ -109,9 +111,7 @@ Item {
109111 // pretend we're running after a model reset
110112 dashContentList.currentIndex = 27;
111113
112− scopeLoadedSpy.clear();
113− scopesModel.load();
114− tryCompare(scopeLoadedSpy, "count", 4);
114+ loadScopes();
115115
116116 verify(dashContentList.currentIndex >= 0 && dashContentList.currentIndex < 5);
117117 }
@@ -326,8 +326,6 @@ Item {
326326 }
327327
328328 function test_previewOpenClose() {
329− tryCompare(scopeLoadedSpy, "count", 4);
330−
331329 var previewListView = findChild(dashContent, "dashContentPreviewList");
332330 tryCompare(previewListView, "open", false);
333331
@@ -352,8 +350,6 @@ Item {
352350 },
353351 true);
354352
355− tryCompare(scopeLoadedSpy, "count", 4);
356−
357353 var previewListView = findChild(dashContent, "dashContentPreviewList");
358354 tryCompare(previewListView, "open", false);
359355
@@ -368,8 +364,6 @@ Item {
368364 }
369365
370366 function test_previewCycle() {
371− tryCompare(scopeLoadedSpy, "count", 4);
372−
373367 var categoryListView = findChild(dashContent, "categoryListView");
374368 categoryListView.positionAtBeginning();
375369
@@ -392,5 +386,26 @@ Item {
392386 }
393387 closePreview();
394388 }
389+
390+ function test_carouselAspectRatio() {
391+ tryCompareFunction(function() {
392+ var scope = findChild(dashContent, "MockScope1 loader");
393+ if (scope != null) {
394+ var dashCategory1 = findChild(scope, "dashCategory1");
395+ if (dashCategory1 != null) {
396+ var tile = findChild(dashCategory1, "carouselDelegate1");
397+ return tile != null;
398+ }
399+ }
400+ return false;
401+ },
402+ true);
403+
404+ var scope = findChild(dashContent, "MockScope1 loader");
405+ var dashCategory1 = findChild(scope, "dashCategory1");
406+ var cardTool = findChild(dashCategory1, "cardTool");
407+ var carouselLV = findChild(dashCategory1, "listView");
408+ verify(carouselLV.tileWidth / carouselLV.tileHeight == cardTool.components["art"]["aspect-ratio"]);
409+ }
395410 }
396411}