on xenial help sign in
Fix right padding on overlay card
3f36d30Andrea Cimitan
plugins/Dash/CardCreator.js+2
@@ -467,6 +467,8 @@ function cardString(template, components) {
467 if (!touchdownOnArtShape) {
467 if (!touchdownOnArtShape) {
468 extraRightAnchor = 'rightMargin: units.gu(1); \n';
468 extraRightAnchor = 'rightMargin: units.gu(1); \n';
469 extraLeftAnchor = 'leftMargin: units.gu(1); \n';
469 extraLeftAnchor = 'leftMargin: units.gu(1); \n';
470+ } else if (headerAsOverlay && !hasEmblem) {
471+ extraRightAnchor = 'rightMargin: units.gu(1); \n';
470 }
472 }
471
473
472 if (hasMascot) {
474 if (hasMascot) {
tests/plugins/Dash/cardcreator/5.res+2
@@ -103,6 +103,7 @@ Label {
103 id: titleLabel;
103 id: titleLabel;
104 objectName: "titleLabel";
104 objectName: "titleLabel";
105 anchors { right: parent.right;
105 anchors { right: parent.right;
106+ rightMargin: units.gu(1);
106 left: parent.left;
107 left: parent.left;
107 leftMargin: units.gu(1);
108 leftMargin: units.gu(1);
108 top: overlayLoader.top;
109 top: overlayLoader.top;
@@ -124,6 +125,7 @@ Label {
124 objectName: "subtitleLabel";
125 objectName: "subtitleLabel";
125 anchors { left: titleLabel.left;
126 anchors { left: titleLabel.left;
126 leftMargin: titleLabel.leftMargin;
127 leftMargin: titleLabel.leftMargin;
128+ rightMargin: units.gu(1);
127 right: titleLabel.right;
129 right: titleLabel.right;
128 top: titleLabel.bottom;
130 top: titleLabel.bottom;
129 }
131 }
tests/qmltests/Dash/tst_Card.qml+62−1
@@ -96,6 +96,11 @@ Rectangle {
96 "layout": { "template": { "card-background": Qt.resolvedUrl("artwork/checkers.png") },
96 "layout": { "template": { "card-background": Qt.resolvedUrl("artwork/checkers.png") },
97 "components": JSON.parse(Helpers.fullMapping) }
97 "components": JSON.parse(Helpers.fullMapping) }
98 },
98 },
99+ {
100+ "name": "Art, title - overlaid",
101+ "layout": { "template": { "overlay": true },
102+ "components": { "art": "art", "title": "title" } }
103+ },
99 ]
104 ]
100
105
101 CardTool {
106 CardTool {
@@ -217,6 +222,7 @@ Rectangle {
217
222
218 function test_card_binding(data) {
223 function test_card_binding(data) {
219 selector.selectedIndex = data.index;
224 selector.selectedIndex = data.index;
225+ waitForRendering(selector);
220 waitForRendering(card);
226 waitForRendering(card);
221
227
222 tryCompareFunction(function() { return testCase[data.object] !== null }, true);
228 tryCompareFunction(function() { return testCase[data.object] !== null }, true);
@@ -247,6 +253,8 @@ Rectangle {
247
253
248 function test_card_size(data) {
254 function test_card_size(data) {
249 selector.selectedIndex = data.index;
255 selector.selectedIndex = data.index;
256+ waitForRendering(selector);
257+ waitForRendering(card);
250
258
251 if (data.hasOwnProperty("card_layout")) {
259 if (data.hasOwnProperty("card_layout")) {
252 cardTool.template['card-layout'] = data.card_layout;
260 cardTool.template['card-layout'] = data.card_layout;
@@ -279,6 +287,7 @@ Rectangle {
279
287
280 function test_art_size(data) {
288 function test_art_size(data) {
281 selector.selectedIndex = data.index;
289 selector.selectedIndex = data.index;
290+ waitForRendering(selector);
282 if (data.hasOwnProperty("size")) {
291 if (data.hasOwnProperty("size")) {
283 cardTool.template['card-size'] = data.size;
292 cardTool.template['card-size'] = data.size;
284 cardTool.templateChanged();
293 cardTool.templateChanged();
@@ -310,6 +319,7 @@ Rectangle {
310
319
311 function test_art_shape_fixed_size() {
320 function test_art_shape_fixed_size() {
312 selector.selectedIndex = 6;
321 selector.selectedIndex = 6;
322+ waitForRendering(selector);
313 card.fixedArtShapeSize = Qt.size( units.gu(8), units.gu(4) );
323 card.fixedArtShapeSize = Qt.size( units.gu(8), units.gu(4) );
314 waitForRendering(card);
324 waitForRendering(card);
315 tryCompare(art, "width", units.gu(8));
325 tryCompare(art, "width", units.gu(8));
@@ -326,6 +336,7 @@ Rectangle {
326
336
327 function test_art_layout(data) {
337 function test_art_layout(data) {
328 selector.selectedIndex = data.index;
338 selector.selectedIndex = data.index;
339+ waitForRendering(selector);
329 waitForRendering(card);
340 waitForRendering(card);
330
341
331 tryCompare(headerRow, "x", data.left());
342 tryCompare(headerRow, "x", data.left());
@@ -344,6 +355,7 @@ Rectangle {
344
355
345 function test_header_layout(data) {
356 function test_header_layout(data) {
346 selector.selectedIndex = data.index;
357 selector.selectedIndex = data.index;
358+ waitForRendering(selector);
347 waitForRendering(card);
359 waitForRendering(card);
348
360
349 tryCompareFunction(function() { return testCase.headerRow.y === data.top() }, true);
361 tryCompareFunction(function() { return testCase.headerRow.y === data.top() }, true);
@@ -359,7 +371,7 @@ Rectangle {
359
371
360 function test_summary_layout(data) {
372 function test_summary_layout(data) {
361 selector.selectedIndex = data.index;
373 selector.selectedIndex = data.index;
362−
374+ waitForRendering(selector);
363 waitForRendering(card);
375 waitForRendering(card);
364
376
365 tryCompareFunction(function() { return art.height > 0 && testCase.summary.y === data.top() }, true);
377 tryCompareFunction(function() { return art.height > 0 && testCase.summary.y === data.top() }, true);
@@ -367,6 +379,8 @@ Rectangle {
367
379
368 function test_art_visibility() {
380 function test_art_visibility() {
369 selector.selectedIndex = 8;
381 selector.selectedIndex = 8;
382+ waitForRendering(selector);
383+ waitForRendering(card);
370
384
371 compare(testCase.artImage, null);
385 compare(testCase.artImage, null);
372 compare(testCase.art, null);
386 compare(testCase.art, null);
@@ -389,6 +403,7 @@ Rectangle {
389
403
390 function test_background(data) {
404 function test_background(data) {
391 selector.selectedIndex = data.index;
405 selector.selectedIndex = data.index;
406+ waitForRendering(selector);
392
407
393 if (data.hasOwnProperty("background")) {
408 if (data.hasOwnProperty("background")) {
394 card.cardData["background"] = data.background;
409 card.cardData["background"] = data.background;
@@ -425,6 +440,8 @@ Rectangle {
425
440
426 function test_font_weights(data) {
441 function test_font_weights(data) {
427 selector.selectedIndex = data.index;
442 selector.selectedIndex = data.index;
443+ waitForRendering(selector);
444+ waitForRendering(card);
428
445
429 tryCompare(testCase.title.font, "weight", data.weight);
446 tryCompare(testCase.title.font, "weight", data.weight);
430 }
447 }
@@ -448,6 +465,7 @@ Rectangle {
448
465
449 function test_fontColor(data) {
466 function test_fontColor(data) {
450 selector.selectedIndex = 10;
467 selector.selectedIndex = 10;
468+ waitForRendering(selector);
451 waitForRendering(card);
469 waitForRendering(card);
452
470
453 background.color = data.tag;
471 background.color = data.tag;
@@ -470,6 +488,7 @@ Rectangle {
470
488
471 function test_emblemIcon(data) {
489 function test_emblemIcon(data) {
472 selector.selectedIndex = data.index;
490 selector.selectedIndex = data.index;
491+ waitForRendering(selector);
473 waitForRendering(card);
492 waitForRendering(card);
474
493
475 var emblemIcon = findChild(card, "emblemIcon");
494 var emblemIcon = findChild(card, "emblemIcon");
@@ -486,6 +505,7 @@ Rectangle {
486
505
487 function test_mascotShape(data) {
506 function test_mascotShape(data) {
488 selector.selectedIndex = data.index;
507 selector.selectedIndex = data.index;
508+ waitForRendering(selector);
489 waitForRendering(card);
509 waitForRendering(card);
490
510
491 var shape = findChild(card, "mascotShapeLoader");
511 var shape = findChild(card, "mascotShapeLoader");
@@ -496,6 +516,8 @@ Rectangle {
496
516
497 function test_touchdown_visibility() {
517 function test_touchdown_visibility() {
498 selector.selectedIndex = 0;
518 selector.selectedIndex = 0;
519+ waitForRendering(selector);
520+ waitForRendering(card);
499
521
500 var touchdown = findChild(card, "touchdown");
522 var touchdown = findChild(card, "touchdown");
501
523
@@ -505,5 +527,44 @@ Rectangle {
505 mouseRelease(card, card.width/2, card.height/2);
527 mouseRelease(card, card.width/2, card.height/2);
506 compare(touchdown.visible, false);
528 compare(touchdown.visible, false);
507 }
529 }
530+
531+ function test_paddings_data() {
532+ return [
533+ { tag: "Art and summary", index: 0 },
534+ { tag: "No Summary", index: 6 },
535+ { tag: "No header", index: 7 },
536+ { tag: "Header only", index: 8 },
537+ { tag: "Art, header, summary - overlaid", index: 9 },
538+ { tag: "Art, title - overlaid", index: 13 },
539+ ];
540+ }
541+
542+ function test_paddings(data) {
543+ selector.selectedIndex = data.index;
544+ waitForRendering(selector);
545+ waitForRendering(card);
546+
547+ if (title) var titleToCard = title.mapToItem(card, 0, 0, title.width, title.height);
548+
549+ // left margin
550+ if (mascotImage) {
551+ var mascotToCard = mascotImage.mapToItem(card, 0, 0, mascotImage.width, mascotImage.height);
552+ verify(mascotToCard.x === units.gu(1));
553+ if (title) {
554+ verify((titleToCard.x - mascotToCard.x - mascotToCard.width) === units.gu(1));
555+ }
556+ } else if (title) {
557+ verify(titleToCard.x === units.gu(1));
558+ }
559+
560+ // right margin
561+ var emblemIcon = findChild(card, "emblemIcon");
562+ if (emblemIcon) {
563+ var emblemToCard = emblemIcon.mapToItem(card, 0, 0, emblemIcon.width, emblemIcon.height);
564+ verify((card.width - emblemToCard.x - emblemToCard.width) === units.gu(1));
565+ } else if (title) {
566+ verify((card.width - titleToCard.x - titleToCard.width) === units.gu(1));
567+ }
568+ }
508 }
569 }
509}
570}