on xenial help sign in
Fixes carousel shadow
e7bd92dAndrea Cimitan
plugins/Dash/CardCreator.js+3−3
@@ -70,10 +70,9 @@ var kArtShapeHolderCode = 'Item { \n\
70 radius: "medium"; \n\
70 radius: "medium"; \n\
71 readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1; \n\
71 readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1; \n\
72 readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect; \n\
72 readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect; \n\
73− Component.onCompleted: updateWidthHeightBindings(); \n\
73+ Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; } \n\
74 onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings(); \n\
74 onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings(); \n\
75 visible: image.status == Image.Ready; \n\
75 visible: image.status == Image.Ready; \n\
76− borderSource: artShapeBorderSource; \n\
77 function updateWidthHeightBindings() { \n\
76 function updateWidthHeightBindings() { \n\
78 if (aspectSmallerThanImageAspect) { \n\
77 if (aspectSmallerThanImageAspect) { \n\
79 width = Qt.binding(function() { return !visible ? 0 : image.width }); \n\
78 width = Qt.binding(function() { return !visible ? 0 : image.width }); \n\
@@ -281,7 +280,7 @@ function cardString(template, components) {
281 property var template; \n\
280 property var template; \n\
282 property var components; \n\
281 property var components; \n\
283 property var cardData; \n\
282 property var cardData; \n\
284− property var artShapeBorderSource; \n\
283+ property var artShapeBorderSource: undefined; \n\
285 property real fontScale: 1.0; \n\
284 property real fontScale: 1.0; \n\
286 property int headerAlignment: Text.AlignLeft; \n\
285 property int headerAlignment: Text.AlignLeft; \n\
287 property int fixedHeaderHeight: -1; \n\
286 property int fixedHeaderHeight: -1; \n\
@@ -307,6 +306,7 @@ function cardString(template, components) {
307 }
306 }
308
307
309 if (hasArt) {
308 if (hasArt) {
309+ code += 'onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artShapeLoader.item) artShapeLoader.item.borderSource = artShapeBorderSource; } \n';
310 code += 'readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);\n';
310 code += 'readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);\n';
311
311
312 var widthCode, heightCode;
312 var widthCode, heightCode;
qml/Dash/CardCarousel.qml+1−1
@@ -34,7 +34,7 @@ DashRenderer {
34 Carousel {
34 Carousel {
35 id: carousel
35 id: carousel
36 anchors.fill: parent
36 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
38 // FIXME we need to "reverse" the carousel to make the selected item the size
38 // FIXME we need to "reverse" the carousel to make the selected item the size
39 // and push others back.
39 // and push others back.
40 minimumTileWidth: cardTool.cardWidth / selectedItemScaleFactor
40 minimumTileWidth: cardTool.cardWidth / selectedItemScaleFactor
qml/Dash/GenericScopeView.qml+1−1
@@ -128,7 +128,7 @@ FocusScope {
128
128
129 CardTool {
129 CardTool {
130 id: cardTool
130 id: cardTool
131−
131+ objectName: "cardTool"
132 count: results.count
132 count: results.count
133 template: model.renderer
133 template: model.renderer
134 components: model.components
134 components: model.components
tests/mocks/Unity/fake_categories.cpp+5−1
@@ -152,7 +152,11 @@ Categories::data(const QModelIndex& index, int role) const
152 case RoleComponents:
152 case RoleComponents:
153 {
153 {
154 QVariantMap map, artMap;
154 QVariantMap map, artMap;
155+ if (index.row() % 2 != 0) {
155− artMap["aspect-ratio"] = "1.0";
156+ artMap["aspect-ratio"] = QString("1.%1").arg(index.row());
157+ } else {
158+ artMap["aspect-ratio"] = "1.0";
159+ }
156 artMap["field"] = "art";
160 artMap["field"] = "art";
157 map["art"] = artMap;
161 map["art"] = artMap;
158 map["title"] = "HOLA";
162 map["title"] = "HOLA";
tests/plugins/Dash/cardcreator/1.res+3−3
@@ -3,7 +3,7 @@ AbstractButton {
3 property var template;
3 property var template;
4 property var components;
4 property var components;
5 property var cardData;
5 property var cardData;
6− property var artShapeBorderSource;
6+ property var artShapeBorderSource: undefined;
7 property real fontScale: 1.0;
7 property real fontScale: 1.0;
8 property int headerAlignment: Text.AlignLeft;
8 property int headerAlignment: Text.AlignLeft;
9 property int fixedHeaderHeight: -1;
9 property int fixedHeaderHeight: -1;
@@ -12,6 +12,7 @@ AbstractButton {
12 property bool asynchronous: true;
12 property bool asynchronous: true;
13 property bool showHeader: true;
13 property bool showHeader: true;
14 implicitWidth: childrenRect.width;
14 implicitWidth: childrenRect.width;
15+onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artShapeLoader.item) artShapeLoader.item.borderSource = artShapeBorderSource; }
15readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
16readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
16Item {
17Item {
17 id: artShapeHolder;
18 id: artShapeHolder;
@@ -30,10 +31,9 @@ Item {
30 radius: "medium";
31 radius: "medium";
31 readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1;
32 readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1;
32 readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect;
33 readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect;
33− Component.onCompleted: updateWidthHeightBindings();
34+ Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; }
34 onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
35 onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
35 visible: image.status == Image.Ready;
36 visible: image.status == Image.Ready;
36− borderSource: artShapeBorderSource;
37 function updateWidthHeightBindings() {
37 function updateWidthHeightBindings() {
38 if (aspectSmallerThanImageAspect) {
38 if (aspectSmallerThanImageAspect) {
39 width = Qt.binding(function() { return !visible ? 0 : image.width });
39 width = Qt.binding(function() { return !visible ? 0 : image.width });
tests/plugins/Dash/cardcreator/2.res+1−1
@@ -3,7 +3,7 @@ AbstractButton {
3 property var template;
3 property var template;
4 property var components;
4 property var components;
5 property var cardData;
5 property var cardData;
6− property var artShapeBorderSource;
6+ property var artShapeBorderSource: undefined;
7 property real fontScale: 1.0;
7 property real fontScale: 1.0;
8 property int headerAlignment: Text.AlignLeft;
8 property int headerAlignment: Text.AlignLeft;
9 property int fixedHeaderHeight: -1;
9 property int fixedHeaderHeight: -1;
tests/plugins/Dash/cardcreator/3.res+3−3
@@ -3,7 +3,7 @@ AbstractButton {
3 property var template;
3 property var template;
4 property var components;
4 property var components;
5 property var cardData;
5 property var cardData;
6− property var artShapeBorderSource;
6+ property var artShapeBorderSource: undefined;
7 property real fontScale: 1.0;
7 property real fontScale: 1.0;
8 property int headerAlignment: Text.AlignLeft;
8 property int headerAlignment: Text.AlignLeft;
9 property int fixedHeaderHeight: -1;
9 property int fixedHeaderHeight: -1;
@@ -12,6 +12,7 @@ AbstractButton {
12 property bool asynchronous: true;
12 property bool asynchronous: true;
13 property bool showHeader: true;
13 property bool showHeader: true;
14 implicitWidth: childrenRect.width;
14 implicitWidth: childrenRect.width;
15+onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artShapeLoader.item) artShapeLoader.item.borderSource = artShapeBorderSource; }
15readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
16readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
16Item {
17Item {
17 id: artShapeHolder;
18 id: artShapeHolder;
@@ -30,10 +31,9 @@ Item {
30 radius: "medium";
31 radius: "medium";
31 readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1;
32 readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1;
32 readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect;
33 readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect;
33− Component.onCompleted: updateWidthHeightBindings();
34+ Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; }
34 onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
35 onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
35 visible: image.status == Image.Ready;
36 visible: image.status == Image.Ready;
36− borderSource: artShapeBorderSource;
37 function updateWidthHeightBindings() {
37 function updateWidthHeightBindings() {
38 if (aspectSmallerThanImageAspect) {
38 if (aspectSmallerThanImageAspect) {
39 width = Qt.binding(function() { return !visible ? 0 : image.width });
39 width = Qt.binding(function() { return !visible ? 0 : image.width });
tests/plugins/Dash/cardcreator/4.res+1−1
@@ -3,7 +3,7 @@ AbstractButton {
3 property var template;
3 property var template;
4 property var components;
4 property var components;
5 property var cardData;
5 property var cardData;
6− property var artShapeBorderSource;
6+ property var artShapeBorderSource: undefined;
7 property real fontScale: 1.0;
7 property real fontScale: 1.0;
8 property int headerAlignment: Text.AlignLeft;
8 property int headerAlignment: Text.AlignLeft;
9 property int fixedHeaderHeight: -1;
9 property int fixedHeaderHeight: -1;
tests/plugins/Dash/cardcreator/5.res+3−3
@@ -3,7 +3,7 @@ AbstractButton {
3 property var template;
3 property var template;
4 property var components;
4 property var components;
5 property var cardData;
5 property var cardData;
6− property var artShapeBorderSource;
6+ property var artShapeBorderSource: undefined;
7 property real fontScale: 1.0;
7 property real fontScale: 1.0;
8 property int headerAlignment: Text.AlignLeft;
8 property int headerAlignment: Text.AlignLeft;
9 property int fixedHeaderHeight: -1;
9 property int fixedHeaderHeight: -1;
@@ -12,6 +12,7 @@ AbstractButton {
12 property bool asynchronous: true;
12 property bool asynchronous: true;
13 property bool showHeader: true;
13 property bool showHeader: true;
14 implicitWidth: childrenRect.width;
14 implicitWidth: childrenRect.width;
15+onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artShapeLoader.item) artShapeLoader.item.borderSource = artShapeBorderSource; }
15readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
16readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
16Item {
17Item {
17 id: artShapeHolder;
18 id: artShapeHolder;
@@ -30,10 +31,9 @@ Item {
30 radius: "medium";
31 radius: "medium";
31 readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1;
32 readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1;
32 readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect;
33 readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect;
33− Component.onCompleted: updateWidthHeightBindings();
34+ Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; }
34 onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
35 onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
35 visible: image.status == Image.Ready;
36 visible: image.status == Image.Ready;
36− borderSource: artShapeBorderSource;
37 function updateWidthHeightBindings() {
37 function updateWidthHeightBindings() {
38 if (aspectSmallerThanImageAspect) {
38 if (aspectSmallerThanImageAspect) {
39 width = Qt.binding(function() { return !visible ? 0 : image.width });
39 width = Qt.binding(function() { return !visible ? 0 : image.width });
tests/qmltests/Dash/tst_DashContent.qml+29−14
@@ -67,13 +67,17 @@ Item {
67 name: "DashContent"
67 name: "DashContent"
68 when: scopesModel.loaded && windowShown
68 when: scopesModel.loaded && windowShown
69
69
70− function init() {
70+ function loadScopes() {
71− scopesModel.clear();
72 scopeLoadedSpy.clear();
71 scopeLoadedSpy.clear();
73 scopesModel.load();
72 scopesModel.load();
74 tryCompare(scopeLoadedSpy, "count", 4);
73 tryCompare(scopeLoadedSpy, "count", 4);
75 }
74 }
76
75
76+ function init() {
77+ scopesModel.clear();
78+ loadScopes();
79+ }
80+
77 function cleanup() {
81 function cleanup() {
78 movementStartedSpy.clear();
82 movementStartedSpy.clear();
79 dashContent.visible = true;
83 dashContent.visible = true;
@@ -93,9 +97,7 @@ Item {
93 compare(dashContentList.count, 0, "DashContent should have 0 items when it starts");
97 compare(dashContentList.count, 0, "DashContent should have 0 items when it starts");
94 tryCompare(dashContentList, "currentIndex", -1);
98 tryCompare(dashContentList, "currentIndex", -1);
95
99
96− scopeLoadedSpy.clear();
100+ loadScopes();
97− scopesModel.load();
98− tryCompare(scopeLoadedSpy, "count", 4);
99
101
100 verify(dashContentList.currentIndex >= 0);
102 verify(dashContentList.currentIndex >= 0);
101 }
103 }
@@ -109,9 +111,7 @@ Item {
109 // pretend we're running after a model reset
111 // pretend we're running after a model reset
110 dashContentList.currentIndex = 27;
112 dashContentList.currentIndex = 27;
111
113
112− scopeLoadedSpy.clear();
114+ loadScopes();
113− scopesModel.load();
114− tryCompare(scopeLoadedSpy, "count", 4);
115
115
116 verify(dashContentList.currentIndex >= 0 && dashContentList.currentIndex < 5);
116 verify(dashContentList.currentIndex >= 0 && dashContentList.currentIndex < 5);
117 }
117 }
@@ -326,8 +326,6 @@ Item {
326 }
326 }
327
327
328 function test_previewOpenClose() {
328 function test_previewOpenClose() {
329− tryCompare(scopeLoadedSpy, "count", 4);
330−
331 var previewListView = findChild(dashContent, "dashContentPreviewList");
329 var previewListView = findChild(dashContent, "dashContentPreviewList");
332 tryCompare(previewListView, "open", false);
330 tryCompare(previewListView, "open", false);
333
331
@@ -352,8 +350,6 @@ Item {
352 },
350 },
353 true);
351 true);
354
352
355− tryCompare(scopeLoadedSpy, "count", 4);
356−
357 var previewListView = findChild(dashContent, "dashContentPreviewList");
353 var previewListView = findChild(dashContent, "dashContentPreviewList");
358 tryCompare(previewListView, "open", false);
354 tryCompare(previewListView, "open", false);
359
355
@@ -368,8 +364,6 @@ Item {
368 }
364 }
369
365
370 function test_previewCycle() {
366 function test_previewCycle() {
371− tryCompare(scopeLoadedSpy, "count", 4);
372−
373 var categoryListView = findChild(dashContent, "categoryListView");
367 var categoryListView = findChild(dashContent, "categoryListView");
374 categoryListView.positionAtBeginning();
368 categoryListView.positionAtBeginning();
375
369
@@ -392,5 +386,26 @@ Item {
392 }
386 }
393 closePreview();
387 closePreview();
394 }
388 }
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+ }
395 }
410 }
396}
411}