Merge lp:~cimi/unity8/card_emblems_single_container into lp:unity8

Proposed by Andrea Cimitan
Status: Rejected
Rejected by: Michał Sawicz
Proposed branch: lp:~cimi/unity8/card_emblems_single_container
Merge into: lp:unity8
Diff against target: 1046 lines (+524/-286)
11 files modified
plugins/Dash/CardCreator.js (+111/-28)
tests/plugins/Dash/cardcreator/1.res (+2/-1)
tests/plugins/Dash/cardcreator/2.res (+94/-89)
tests/plugins/Dash/cardcreator/3.res (+50/-48)
tests/plugins/Dash/cardcreator/4.res (+72/-68)
tests/plugins/Dash/cardcreator/5.res (+50/-50)
tests/plugins/Dash/cardcreator/6.res (+115/-0)
tests/plugins/Dash/cardcreator/6.tst (+3/-0)
tests/plugins/Dash/cardcreatortest.cpp (+8/-2)
tests/qmltests/Dash/CardHelpers.js (+1/-0)
tests/qmltests/Dash/tst_Card.qml (+18/-0)
To merge this branch: bzr merge lp:~cimi/unity8/card_emblems_single_container
Reviewer Review Type Date Requested Status
Michał Sawicz Disapprove
PS Jenkins bot (community) continuous-integration Needs Fixing
Albert Astals Cid (community) Needs Fixing
Review via email: mp+223899@code.launchpad.net

Commit message

Add emblems using a single container

Description of the change

 * Are there any related MPs required for this MP to build/function as expected? Please list.
No
 * Did you perform an exploratory manual test run of your code change and any related functionality?
Yes
 * Did you make sure that your branch does not contain spurious tags?
Yes
 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A
 * If you changed the UI, has there been a design review?
N/A

To post a comment you must log in.
941. By Andrea Cimitan

var rename

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ying-Chun Liu (paulliu) wrote :

hi. For kHeader[2|3]ContainerCode. Can we have a more generic one that can have arbitrary fields?

I've wrote a function in https://code.launchpad.net/~paulliu/unity8/attribute/+merge/223242

For example, the function kHeaderColumnCodeGenerator()

Because I'll also need to add more childs for attribute UI later.

Revision history for this message
Andrea Cimitan (cimi) wrote :

> hi. For kHeader[2|3]ContainerCode. Can we have a more generic one that can
> have arbitrary fields?
>
> I've wrote a function in
> https://code.launchpad.net/~paulliu/unity8/attribute/+merge/223242
>
> For example, the function kHeaderColumnCodeGenerator()
>
> Because I'll also need to add more childs for attribute UI later.
Ok, will do it tomorrow

942. By Andrea Cimitan

[ Ying-Chun Liu ]
* Add logout support. Reviewed by: Daniel d'Andrada (LP: #1302213)
[ Michał Sawicz ]
* Make so that fixedArtShapeSize actually fixes artShapeSize.
[ Albert Astals ]
* Add VerticalJournal integration to Dash/scopes/QML (LP: #1326467)
* Make so that fixedArtShapeSize actually fixes artShapeSize.
[ Mirco Müller ]
* Added the frontend-part of sound-hint support for notifications with
  updated QML-tests.
* New rebuild forced
[ Albert Astals ]
* Departments support (LP: #1320847)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

Text conflict in tests/plugins/Dash/cardcreator/3.res
1 conflicts encountered.

review: Needs Fixing
943. By Andrea Cimitan

[ Michael Terry ]
* Fix path in launcher mock after moving our mock icons, to avoid a
  lot of "icon not found" warnings during qmluitests.
* Fix the testMultiGreeter qmluitest. Incoming method variables are
  apparently read-only in Qt5.3. (LP: #1332488)
[ CI bot ]
* Resync trunk
[ Michał Sawicz ]
* Adapt scope mock to new api and quiet unused variable warnings.
* Fix dynamic overlay height. (LP: #1334879)
* Don't center items in CardVerticalJournal, kind of beats the
  purpose... Also don't bind unnecessarily.
[ Ying-Chun Liu ]
* Fix LP:1330957 Fix some failed test cases. (LP: #1330957)
[ Albert Astals ]
* Don't seem to need this waitForRendering And makes test fail in 5.3
[ Alberto Aguirre ]
* Update Powerd plugin and Shell.qml to accommodate changes in the
  display power state notification.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

All the whitespace changes should not be here.

Can you experiment using a GridLayout for mascot, title, subtitle and emblem? Or maybe just (sub)title and emblem, vcentering might be tricky otherwise.

Also see inline.

review: Needs Fixing
Revision history for this message
Albert Astals Cid (aacid) wrote :

Text conflict in tests/plugins/Dash/cardcreator/2.res
Text conflict in tests/plugins/Dash/cardcreator/3.res
Text conflict in tests/plugins/Dash/cardcreator/4.res
Text conflict in tests/plugins/Dash/cardcreator/5.res
Conflict adding file tests/plugins/Dash/cardcreator/6.res. Moved existing file to tests/plugins/Dash/cardcreator/6.res.moved.
Conflict adding file tests/plugins/Dash/cardcreator/6.tst. Moved existing file to tests/plugins/Dash/cardcreator/6.tst.moved.
6 conflicts encountered.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :
review: Disapprove

Unmerged revisions

943. By Andrea Cimitan

[ Michael Terry ]
* Fix path in launcher mock after moving our mock icons, to avoid a
  lot of "icon not found" warnings during qmluitests.
* Fix the testMultiGreeter qmluitest. Incoming method variables are
  apparently read-only in Qt5.3. (LP: #1332488)
[ CI bot ]
* Resync trunk
[ Michał Sawicz ]
* Adapt scope mock to new api and quiet unused variable warnings.
* Fix dynamic overlay height. (LP: #1334879)
* Don't center items in CardVerticalJournal, kind of beats the
  purpose... Also don't bind unnecessarily.
[ Ying-Chun Liu ]
* Fix LP:1330957 Fix some failed test cases. (LP: #1330957)
[ Albert Astals ]
* Don't seem to need this waitForRendering And makes test fail in 5.3
[ Alberto Aguirre ]
* Update Powerd plugin and Shell.qml to accommodate changes in the
  display power state notification.

942. By Andrea Cimitan

[ Ying-Chun Liu ]
* Add logout support. Reviewed by: Daniel d'Andrada (LP: #1302213)
[ Michał Sawicz ]
* Make so that fixedArtShapeSize actually fixes artShapeSize.
[ Albert Astals ]
* Add VerticalJournal integration to Dash/scopes/QML (LP: #1326467)
* Make so that fixedArtShapeSize actually fixes artShapeSize.
[ Mirco Müller ]
* Added the frontend-part of sound-hint support for notifications with
  updated QML-tests.
* New rebuild forced
[ Albert Astals ]
* Departments support (LP: #1320847)

941. By Andrea Cimitan

var rename

940. By Andrea Cimitan

Works

939. By Andrea Cimitan

WIP AND BROKEN

938. By Andrea Cimitan

Add parsing test for emblem

937. By Andrea Cimitan

Add tests for emblem

936. By Andrea Cimitan

Test pass again

935. By Andrea Cimitan

Some fixes for the emblem

934. By Andrea Cimitan

Better tests

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/Dash/CardCreator.js'
--- plugins/Dash/CardCreator.js 2014-06-27 08:47:33 +0000
+++ plugins/Dash/CardCreator.js 2014-06-27 14:25:45 +0000
@@ -181,15 +181,35 @@
181 ] \n\181 ] \n\
182 }\n';182 }\n';
183183
184// %1 is used as first child of the column184// %1 is used as anchors
185// %2 is used as second child of the column185// %2 is used as height of the container
186var kHeaderColumnCode = 'Column { \n\186// %3 is used as first child of the container
187 anchors.verticalCenter: parent.verticalCenter; \n\187// %4 is used as second child of the container
188 spacing: units.dp(2); \n\188var kHeader2ContainerCode = 'Item { \n\
189 width: parent.width - x;\n\189 id: headerTitleContainer; \n\
190 data: [ %1\n\190 anchors { %1 } \n\
191 ,\n\191 width: parent.width - x; \n\
192 %2 \n\192 implicitHeight: %2; \n\
193 data: [ %3\n\
194 ,\n\
195 %4 \n\
196 ] \n\
197 }\n';
198
199// %1 is used as anchors
200// %2 is used as first child of the container
201// %3 is used as second child of the container
202// %4 is used as third child of the container
203var kHeader3ContainerCode = 'Item { \n\
204 id: headerTitleContainer; \n\
205 anchors { %1 } \n\
206 width: parent.width - x; \n\
207 implicitHeight: titleLabel.height + subtitleLabel.height; \n\
208 data: [ %2\n\
209 ,\n\
210 %3 \n\
211 ,\n\
212 %4 \n\
193 ] \n\213 ] \n\
194 }\n';214 }\n';
195215
@@ -242,12 +262,25 @@
242 horizontalAlignment: root.headerAlignment; \n\262 horizontalAlignment: root.headerAlignment; \n\
243 }\n';263 }\n';
244264
265var kEmblemImageCode = 'Image { \n\
266 id: emblemImage; \n\
267 objectName: "emblemImage"; \n\
268 anchors { \n\
269 bottom: titleLabel.baseline; \n\
270 right: parent.right; \n\ } \n\
271 source: cardData && cardData["emblem"]; \n\
272 width: height; \n\
273 height: titleLabel.font.pixelSize; \n\
274 fillMode: Image.PreserveAspectFit; \n\
275 }\n';
276
245// %1 is used as anchors of subtitleLabel277// %1 is used as anchors of subtitleLabel
246// %2 is used as color of subtitleLabel278// %2 is used as color of subtitleLabel
247var kSubtitleLabelCode = 'Label { \n\279var kSubtitleLabelCode = 'Label { \n\
248 id: subtitleLabel; \n\280 id: subtitleLabel; \n\
249 objectName: "subtitleLabel"; \n\281 objectName: "subtitleLabel"; \n\
250 anchors { %1 } \n\282 anchors { %1 } \n\
283 anchors.topMargin: units.dp(2); \n\
251 elide: Text.ElideRight; \n\284 elide: Text.ElideRight; \n\
252 fontSize: "small"; \n\285 fontSize: "small"; \n\
253 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); \n\286 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); \n\
@@ -304,6 +337,7 @@
304 var hasBackground = !isHorizontal && (template["card-background"] || components["background"] || artAndSummary);337 var hasBackground = !isHorizontal && (template["card-background"] || components["background"] || artAndSummary);
305 var hasTitle = components["title"] || false;338 var hasTitle = components["title"] || false;
306 var hasMascot = components["mascot"] || false;339 var hasMascot = components["mascot"] || false;
340 var hasEmblem = components["emblem"] && !(hasMascot && template["card-size"] === "small") || false;
307 var headerAsOverlay = hasArt && template && template["overlay"] === true && (hasTitle || hasMascot);341 var headerAsOverlay = hasArt && template && template["overlay"] === true && (hasTitle || hasMascot);
308 var hasSubtitle = components["subtitle"] || false;342 var hasSubtitle = components["subtitle"] || false;
309 var hasHeaderRow = hasMascot && hasTitle;343 var hasHeaderRow = hasMascot && hasTitle;
@@ -424,24 +458,44 @@
424458
425 var titleAnchors;459 var titleAnchors;
426 var subtitleAnchors;460 var subtitleAnchors;
427 if (hasMascot && hasSubtitle) {461 var titleRightAnchor;
428 // Using row + column462 var titleContainerAnchors;
429 titleAnchors = 'left: parent.left; right: parent.right';463
430 subtitleAnchors = titleAnchors;464 if (hasMascot) {
465 titleContainerAnchors = 'verticalCenter: parent.verticalCenter; ';
466 } else {
467 titleContainerAnchors = 'right: parent.right; ';
468 titleContainerAnchors += headerLeftAnchor;
469 titleContainerAnchors += headerVerticalAnchors;
470 }
471 if (hasEmblem) {
472 titleRightAnchor = 'right: emblemImage.left;\n';
473 } else {
474 titleRightAnchor = 'right: parent.right;\n';
475 }
476
477 if (hasEmblem || (hasMascot && hasSubtitle)) {
478 // Using titleContainer (and maybe row)
479 titleAnchors = titleRightAnchor;
480 titleAnchors += 'left: parent.left;\n\
481 top: parent.top;';
482 subtitleAnchors = 'right: parent.right;\n\
483 left: parent.left;\n\
484 top: titleLabel.bottom;\n';
431 } else if (hasMascot) {485 } else if (hasMascot) {
432 // Using row + label486 // Using row + titleContainer
433 titleAnchors = 'verticalCenter: parent.verticalCenter;\n'487 titleAnchors = 'verticalCenter: parent.verticalCenter;\n';
434 } else {488 } else {
435 if (headerAsOverlay) {489 if (headerAsOverlay) {
436 // Using anchors to the overlay490 // Using anchors to the overlay
437 titleAnchors = 'left: parent.left; \n\491 titleAnchors = titleRightAnchor;
438 leftMargin: units.gu(1); \n\492 titleAnchors += 'left: parent.left; \n\
439 right: parent.right; \n\493 leftMargin: units.gu(1); \n\
440 top: overlayLoader.top; \n\494 top: overlayLoader.top; \n\
441 topMargin: units.gu(1);\n';495 topMargin: units.gu(1);\n';
442 } else {496 } else {
443 // Using anchors to the mascot/parent497 // Using anchors to the mascot/parent
444 titleAnchors = "right: parent.right;";498 titleAnchors = titleRightAnchor;
445 titleAnchors += headerLeftAnchor;499 titleAnchors += headerLeftAnchor;
446 titleAnchors += headerVerticalAnchors;500 titleAnchors += headerVerticalAnchors;
447 if (!headerLeftAnchorHasMargin) {501 if (!headerLeftAnchorHasMargin) {
@@ -450,22 +504,34 @@
450 }504 }
451 subtitleAnchors = 'left: titleLabel.left; \n\505 subtitleAnchors = 'left: titleLabel.left; \n\
452 leftMargin: titleLabel.leftMargin; \n\506 leftMargin: titleLabel.leftMargin; \n\
453 right: titleLabel.right; \n\507 top: titleLabel.bottom;\n';
454 top: titleLabel.bottom; \n\508 if (hasEmblem) {
455 topMargin: units.dp(2);\n';509 // using container
510 subtitleAnchors += 'right: parent.right; \n';
511 } else {
512 subtitleAnchors += 'right: titleLabel.right; \n';
513 }
456 }514 }
457515
458 var titleLabelVisibleExtra = (headerAsOverlay ? '&& overlayLoader.active': '');516 var titleLabelVisibleExtra = (headerAsOverlay ? '&& overlayLoader.active': '');
459 var titleCode = kTitleLabelCode.arg(titleAnchors).arg(color).arg(titleLabelVisibleExtra);517 var titleCode;
518 titleCode = kTitleLabelCode.arg(titleAnchors).arg(color).arg(titleLabelVisibleExtra);
460 var subtitleCode = "";519 var subtitleCode = "";
461 if (hasSubtitle) {520 if (hasSubtitle) {
462 subtitleCode += kSubtitleLabelCode.arg(subtitleAnchors).arg(color);521 subtitleCode += kSubtitleLabelCode.arg(subtitleAnchors).arg(color);
463 }522 }
464523
465 if (hasMascot && hasSubtitle) {524 if (hasEmblem && hasSubtitle) {
466 // If using row + column wrap the code in the column525 // using container 3
467 titleSubtitleCode = kHeaderColumnCode.arg(titleCode).arg(subtitleCode);526 titleSubtitleCode = kHeader3ContainerCode.arg(titleContainerAnchors).arg(titleCode).arg(kEmblemImageCode).arg(kSubtitleLabelCode.arg(subtitleAnchors).arg(color));
527 } else if (hasEmblem) {
528 // container with emblem
529 titleSubtitleCode = kHeader2ContainerCode.arg(titleContainerAnchors).arg('titleLabel.height').arg(titleCode).arg(kEmblemImageCode);
530 } else if (hasMascot && hasSubtitle) {
531 // container with subtitle
532 titleSubtitleCode = kHeader2ContainerCode.arg(titleContainerAnchors).arg('titleLabel.height + subtitleLabel.height').arg(titleCode).arg(subtitleCode);
468 } else {533 } else {
534 // no container
469 titleSubtitleCode = titleCode + subtitleCode;535 titleSubtitleCode = titleCode + subtitleCode;
470 }536 }
471 }537 }
@@ -485,6 +551,7 @@
485 if (isHorizontal && hasArt) summaryTopAnchor = "artShapeHolder.bottom";551 if (isHorizontal && hasArt) summaryTopAnchor = "artShapeHolder.bottom";
486 else if (headerAsOverlay && hasArt) summaryTopAnchor = "artShapeHolder.bottom";552 else if (headerAsOverlay && hasArt) summaryTopAnchor = "artShapeHolder.bottom";
487 else if (hasHeaderRow) summaryTopAnchor = "row.bottom";553 else if (hasHeaderRow) summaryTopAnchor = "row.bottom";
554 else if (hasEmblem || (hasMascot && hasSubtitle)) summaryTopAnchor = "headerTitleContainer.bottom";
488 else if (hasMascot) summaryTopAnchor = "mascotImage.bottom";555 else if (hasMascot) summaryTopAnchor = "mascotImage.bottom";
489 else if (hasSubtitle) summaryTopAnchor = "subtitleLabel.bottom";556 else if (hasSubtitle) summaryTopAnchor = "subtitleLabel.bottom";
490 else if (hasTitle) summaryTopAnchor = "titleLabel.bottom";557 else if (hasTitle) summaryTopAnchor = "titleLabel.bottom";
@@ -526,5 +593,21 @@
526 import Ubuntu.Thumbnailer 0.1;\n';593 import Ubuntu.Thumbnailer 0.1;\n';
527 var card = cardString(template, components);594 var card = cardString(template, components);
528 var code = imports + 'Component {\n' + card + '}\n';595 var code = imports + 'Component {\n' + card + '}\n';
596
597// var splitCode = code.split("\n");
598// for (var i = 0; i < splitCode.length; ++i) {
599// var lineNumber = i;
600// if (i < 10) {
601// lineNumber = lineNumber + " |";
602// } else if (i < 100) {
603// lineNumber = lineNumber + " |";
604// } else if (i < 1000) {
605// lineNumber = lineNumber + " |";
606// } else {
607// lineNumber = lineNumber + "|";
608// }
609// console.log(lineNumber, splitCode[i]);
610// }
611
529 return Qt.createQmlObject(code, parent, "createCardComponent");612 return Qt.createQmlObject(code, parent, "createCardComponent");
530}613}
531614
=== modified file 'tests/plugins/Dash/cardcreator/1.res'
--- tests/plugins/Dash/cardcreator/1.res 2014-06-27 08:47:04 +0000
+++ tests/plugins/Dash/cardcreator/1.res 2014-06-27 14:25:45 +0000
@@ -65,7 +65,8 @@
65Label { 65Label {
66 id: titleLabel; 66 id: titleLabel;
67 objectName: "titleLabel"; 67 objectName: "titleLabel";
68 anchors { right: parent.right;left: parent.left;68 anchors { right: parent.right;
69left: parent.left;
69top: artShapeHolder.bottom; 70top: artShapeHolder.bottom;
70 topMargin: units.gu(1);71 topMargin: units.gu(1);
71leftMargin: units.gu(1);72leftMargin: units.gu(1);
7273
=== modified file 'tests/plugins/Dash/cardcreator/2.res'
--- tests/plugins/Dash/cardcreator/2.res 2014-06-18 10:26:01 +0000
+++ tests/plugins/Dash/cardcreator/2.res 2014-06-27 14:25:45 +0000
@@ -1,49 +1,49 @@
1AbstractButton { 1AbstractButton {
2 id: root; 2 id: root;
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: undefined; 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;
10 property size fixedArtShapeSize: Qt.size(-1, -1); 10 property size fixedArtShapeSize: Qt.size(-1, -1);
11 readonly property string title: cardData && cardData["title"] || ""; 11 readonly property string title: cardData && cardData["title"] || "";
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;
15Loader {15Loader {
16 id: backgroundLoader; 16 id: backgroundLoader;
17 objectName: "backgroundLoader"; 17 objectName: "backgroundLoader";
18 anchors.fill: parent; 18 anchors.fill: parent;
19 asynchronous: root.asynchronous; 19 asynchronous: root.asynchronous;
20 visible: status == Loader.Ready; 20 visible: status == Loader.Ready;
21 sourceComponent: UbuntuShape { 21 sourceComponent: UbuntuShape {
22 objectName: "background"; 22 objectName: "background";
23 radius: "medium"; 23 radius: "medium";
24 color: getColor(0) || "white"; 24 color: getColor(0) || "white";
25 gradientColor: getColor(1) || color; 25 gradientColor: getColor(1) || color;
26 anchors.fill: parent; 26 anchors.fill: parent;
27 image: backgroundImage.source ? backgroundImage : null; 27 image: backgroundImage.source ? backgroundImage : null;
28 property real luminance: 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b; 28 property real luminance: 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
29 property Image backgroundImage: Image { 29 property Image backgroundImage: Image {
30 objectName: "backgroundImage"; 30 objectName: "backgroundImage";
31 source: { 31 source: {
32 if (cardData && typeof cardData["background"] === "string") return cardData["background"]; 32 if (cardData && typeof cardData["background"] === "string") return cardData["background"];
33 else if (template && typeof template["card-background"] === "string") return template["card-background"]; 33 else if (template && typeof template["card-background"] === "string") return template["card-background"];
34 else return ""; 34 else return "";
35 } 35 }
36 } 36 }
37 function getColor(index) { 37 function getColor(index) {
38 if (cardData && typeof cardData["background"] === "object" 38 if (cardData && typeof cardData["background"] === "object"
39 && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) { 39 && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
40 return cardData["background"]["elements"][index]; 40 return cardData["background"]["elements"][index];
41 } else if (template && typeof template["card-background"] === "object" 41 } else if (template && typeof template["card-background"] === "object"
42 && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) { 42 && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) {
43 return template["card-background"]["elements"][index]; 43 return template["card-background"]["elements"][index];
44 } else return undefined; 44 } else return undefined;
45 } 45 }
46 } 46 }
47 }47 }
48readonly property size artShapeSize: Qt.size(-1, -1);48readonly property size artShapeSize: Qt.size(-1, -1);
49readonly property int headerHeight: row.height;49readonly property int headerHeight: row.height;
@@ -57,57 +57,62 @@
57 topMargin: units.gu(1);57 topMargin: units.gu(1);
58 left: parent.left;58 left: parent.left;
59}59}
60 anchors.right: parent.right; 60 anchors.right: parent.right;
61 anchors.margins: margins;61 anchors.margins: margins;
62data: [ Image { 62data: [ Image {
63 id: mascotImage; 63 id: mascotImage;
64 objectName: "mascotImage"; 64 objectName: "mascotImage";
65 anchors { verticalCenter: parent.verticalCenter; }65 anchors { verticalCenter: parent.verticalCenter; }
66 readonly property int maxSize: Math.max(width, height) * 4; 66 readonly property int maxSize: Math.max(width, height) * 4;
67 source: cardData && cardData["mascot"]; 67 source: cardData && cardData["mascot"];
68 width: units.gu(6); 68 width: units.gu(6);
69 height: units.gu(5.625); 69 height: units.gu(5.625);
70 sourceSize { width: maxSize; height: maxSize } 70 sourceSize { width: maxSize; height: maxSize }
71 fillMode: Image.PreserveAspectCrop; 71 fillMode: Image.PreserveAspectCrop;
72 horizontalAlignment: Image.AlignHCenter; 72 horizontalAlignment: Image.AlignHCenter;
73 verticalAlignment: Image.AlignVCenter; 73 verticalAlignment: Image.AlignVCenter;
74 visible: showHeader; 74 visible: showHeader;
75 }75 }
76,76,
77Column { 77Item {
78 anchors.verticalCenter: parent.verticalCenter; 78 id: headerTitleContainer;
79 spacing: units.dp(2); 79 anchors { verticalCenter: parent.verticalCenter; }
80 width: parent.width - x;80 width: parent.width - x;
81 data: [81 implicitHeight: titleLabel.height + subtitleLabel.height;
82Label { 82 data: [ Label {
83 id: titleLabel; 83 id: titleLabel;
84 objectName: "titleLabel"; 84 objectName: "titleLabel";
85 anchors { left: parent.left; right: parent.right }85 anchors { right: parent.right;
86 elide: Text.ElideRight; 86 left: parent.left;
87 fontSize: "small"; 87 top: parent.top; }
88 wrapMode: Text.Wrap; 88 elide: Text.ElideRight;
89 maximumLineCount: 2; 89 fontSize: "small";
90 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); 90 wrapMode: Text.Wrap;
91 color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : "grey"; 91 maximumLineCount: 2;
92 visible: showHeader ; 92 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
93 text: root.title; 93 color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : "grey";
94 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal; 94 visible: showHeader ;
95 horizontalAlignment: root.headerAlignment; 95 text: root.title;
96 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
97 horizontalAlignment: root.headerAlignment;
96 }98 }
97,99,
98Label { 100Label {
99 id: subtitleLabel; 101 id: subtitleLabel;
100 objectName: "subtitleLabel"; 102 objectName: "subtitleLabel";
101 anchors { left: parent.left; right: parent.right }103 anchors { right: parent.right;
102104 left: parent.left;
103 elide: Text.ElideRight; 105 top: titleLabel.bottom;
104 fontSize: "small"; 106 }
105 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); 107 anchors.topMargin: units.dp(2);
106 color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : "grey"; 108 elide: Text.ElideRight;
107 visible: titleLabel.visible && titleLabel.text; 109 fontSize: "small";
108 text: cardData && cardData["subtitle"] || ""; 110 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
109 font.weight: Font.Light; 111 color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : "grey";
110 horizontalAlignment: root.headerAlignment; 112 visible: titleLabel.visible && titleLabel.text;
113 text: cardData && cardData["subtitle"] || "";
114 font.weight: Font.Light;
115 horizontalAlignment: root.headerAlignment;
111 }116 }
112]117]
113}118}
114119
=== modified file 'tests/plugins/Dash/cardcreator/3.res'
--- tests/plugins/Dash/cardcreator/3.res 2014-06-27 08:47:04 +0000
+++ tests/plugins/Dash/cardcreator/3.res 2014-06-27 14:25:45 +0000
@@ -1,18 +1,18 @@
1AbstractButton { 1AbstractButton {
2 id: root; 2 id: root;
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: undefined; 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;
10 property size fixedArtShapeSize: Qt.size(-1, -1); 10 property size fixedArtShapeSize: Qt.size(-1, -1);
11 readonly property string title: cardData && cardData["title"] || ""; 11 readonly property string title: cardData && cardData["title"] || "";
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;
15onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artShapeLoader.item) artShapeLoader.item.borderSource = artShapeBorderSource; } 15onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artShapeLoader.item) artShapeLoader.item.borderSource = artShapeBorderSource; }
16readonly 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);
17Item { 17Item {
18 id: artShapeHolder; 18 id: artShapeHolder;
@@ -57,46 +57,48 @@
57 readonly property real aspect: implicitWidth / implicitHeight; 57 readonly property real aspect: implicitWidth / implicitHeight;
58 width: root.width; 58 width: root.width;
59 height: width / artShape.aspect;59 height: width / artShape.aspect;
60 } 60 }
61 } 61 }
62 } 62 }
63 }63 }
64readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;64readonly property int headerHeight: titleLabel.height + subtitleLabel.height + subtitleLabel.anchors.topMargin;
65Label { 65Label {
66 id: titleLabel; 66 id: titleLabel;
67 objectName: "titleLabel"; 67 objectName: "titleLabel";
68 anchors { right: parent.right;left: parent.left;68 anchors { right: parent.right;
69top: artShapeHolder.bottom; 69 left: parent.left;
70 topMargin: units.gu(1);70 top: artShapeHolder.bottom;
71leftMargin: units.gu(1);71 topMargin: units.gu(1);
72 leftMargin: units.gu(1);
72}73}
73 elide: Text.ElideRight; 74 elide: Text.ElideRight;
74 fontSize: "small"; 75 fontSize: "small";
75 wrapMode: Text.Wrap; 76 wrapMode: Text.Wrap;
76 maximumLineCount: 2; 77 maximumLineCount: 2;
77 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); 78 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
78 color: "grey"; 79 color: "grey";
79 visible: showHeader ; 80 visible: showHeader ;
80 text: root.title; 81 text: root.title;
81 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal; 82 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
82 horizontalAlignment: root.headerAlignment; 83 horizontalAlignment: root.headerAlignment;
83 }84 }
84Label { 85Label {
85 id: subtitleLabel; 86 id: subtitleLabel;
86 objectName: "subtitleLabel"; 87 objectName: "subtitleLabel";
87 anchors { left: titleLabel.left; 88 anchors { left: titleLabel.left;
88 leftMargin: titleLabel.leftMargin; 89 leftMargin: titleLabel.leftMargin;
89 right: titleLabel.right; 90 top: titleLabel.bottom;
90 top: titleLabel.bottom; 91 right: titleLabel.right;
91 topMargin: units.dp(2); }92 }
92 elide: Text.ElideRight; 93 anchors.topMargin: units.dp(2);
93 fontSize: "small"; 94 elide: Text.ElideRight;
94 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); 95 fontSize: "small";
95 color: "grey"; 96 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
96 visible: titleLabel.visible && titleLabel.text; 97 color: "grey";
97 text: cardData && cardData["subtitle"] || ""; 98 visible: titleLabel.visible && titleLabel.text;
98 font.weight: Font.Light; 99 text: cardData && cardData["subtitle"] || "";
99 horizontalAlignment: root.headerAlignment; 100 font.weight: Font.Light;
101 horizontalAlignment: root.headerAlignment;
100 }102 }
101implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);103implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);
102}104}
103105
=== modified file 'tests/plugins/Dash/cardcreator/4.res'
--- tests/plugins/Dash/cardcreator/4.res 2014-06-18 10:26:01 +0000
+++ tests/plugins/Dash/cardcreator/4.res 2014-06-27 14:25:45 +0000
@@ -1,17 +1,17 @@
1AbstractButton { 1AbstractButton {
2 id: root; 2 id: root;
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: undefined; 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;
10 property size fixedArtShapeSize: Qt.size(-1, -1); 10 property size fixedArtShapeSize: Qt.size(-1, -1);
11 readonly property string title: cardData && cardData["title"] || ""; 11 readonly property string title: cardData && cardData["title"] || "";
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;
15readonly property size artShapeSize: Qt.size(-1, -1);15readonly property size artShapeSize: Qt.size(-1, -1);
16readonly property int headerHeight: row.height;16readonly property int headerHeight: row.height;
17Row { 17Row {
@@ -24,70 +24,74 @@
24 topMargin: units.gu(1);24 topMargin: units.gu(1);
25 left: parent.left;25 left: parent.left;
26}26}
27 anchors.right: parent.right; 27 anchors.right: parent.right;
28 anchors.margins: margins;28 anchors.margins: margins;
29data: [ Loader { 29data: [ Loader {
30 id: mascotShapeLoader; 30 id: mascotShapeLoader;
31 objectName: "mascotShapeLoader"; 31 objectName: "mascotShapeLoader";
32 asynchronous: root.asynchronous; 32 asynchronous: root.asynchronous;
33 active: mascotImage.status === Image.Ready; 33 active: mascotImage.status === Image.Ready;
34 visible: showHeader && active && status == Loader.Ready; 34 visible: showHeader && active && status == Loader.Ready;
35 width: units.gu(6); 35 width: units.gu(6);
36 height: units.gu(5.625); 36 height: units.gu(5.625);
37 sourceComponent: UbuntuShape { image: mascotImage } 37 sourceComponent: UbuntuShape { image: mascotImage }
38 anchors { verticalCenter: parent.verticalCenter; }38 anchors { verticalCenter: parent.verticalCenter; }
39 }39 }
40
41,40,
42Image { 41Image {
43 id: mascotImage; 42 id: mascotImage;
44 objectName: "mascotImage"; 43 objectName: "mascotImage";
45 anchors { verticalCenter: parent.verticalCenter; }44 anchors { verticalCenter: parent.verticalCenter; }
46 readonly property int maxSize: Math.max(width, height) * 4; 45 readonly property int maxSize: Math.max(width, height) * 4;
47 source: cardData && cardData["mascot"]; 46 source: cardData && cardData["mascot"];
48 width: units.gu(6); 47 width: units.gu(6);
49 height: units.gu(5.625); 48 height: units.gu(5.625);
50 sourceSize { width: maxSize; height: maxSize } 49 sourceSize { width: maxSize; height: maxSize }
51 fillMode: Image.PreserveAspectCrop; 50 fillMode: Image.PreserveAspectCrop;
52 horizontalAlignment: Image.AlignHCenter; 51 horizontalAlignment: Image.AlignHCenter;
53 verticalAlignment: Image.AlignVCenter; 52 verticalAlignment: Image.AlignVCenter;
54 visible: false; 53 visible: false;
55 }54 }
56
57,55,
58Column { 56Item {
59 anchors.verticalCenter: parent.verticalCenter; 57 id: headerTitleContainer;
60 spacing: units.dp(2); 58 anchors { verticalCenter: parent.verticalCenter; }
61 width: parent.width - x;59 width: parent.width - x;
62data: [ Label { 60 implicitHeight: titleLabel.height + subtitleLabel.height;
63 id: titleLabel; 61data: [ Label {
64 objectName: "titleLabel"; 62 id: titleLabel;
65 anchors { left: parent.left; right: parent.right }63 objectName: "titleLabel";
66 elide: Text.ElideRight; 64 anchors { right: parent.right;
67 fontSize: "small"; 65 left: parent.left;
68 wrapMode: Text.Wrap; 66 top: parent.top; }
69 maximumLineCount: 2; 67 elide: Text.ElideRight;
70 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); 68 fontSize: "small";
71 color: "grey"; 69 wrapMode: Text.Wrap;
72 visible: showHeader ; 70 maximumLineCount: 2;
73 text: root.title; 71 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
74 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal; 72 color: "grey";
75 horizontalAlignment: root.headerAlignment; 73 visible: showHeader ;
74 text: root.title;
75 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
76 horizontalAlignment: root.headerAlignment;
76 }77 }
77,78,
78Label { 79Label {
79 id: subtitleLabel; 80 id: subtitleLabel;
80 objectName: "subtitleLabel"; 81 objectName: "subtitleLabel";
81 anchors { left: parent.left; right: parent.right }82 anchors { right: parent.right;
8283 left: parent.left;
83 elide: Text.ElideRight; 84 top: titleLabel.bottom;
84 fontSize: "small"; 85 }
85 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); 86 anchors.topMargin: units.dp(2);
86 color: "grey"; 87 elide: Text.ElideRight;
87 visible: titleLabel.visible && titleLabel.text; 88 fontSize: "small";
88 text: cardData && cardData["subtitle"] || ""; 89 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
89 font.weight: Font.Light; 90 color: "grey";
90 horizontalAlignment: root.headerAlignment; 91 visible: titleLabel.visible && titleLabel.text;
92 text: cardData && cardData["subtitle"] || "";
93 font.weight: Font.Light;
94 horizontalAlignment: root.headerAlignment;
91 }95 }
92]96]
93}97}
9498
=== modified file 'tests/plugins/Dash/cardcreator/5.res'
--- tests/plugins/Dash/cardcreator/5.res 2014-06-24 11:08:23 +0000
+++ tests/plugins/Dash/cardcreator/5.res 2014-06-27 14:25:45 +0000
@@ -1,18 +1,18 @@
1AbstractButton { 1AbstractButton {
2 id: root; 2 id: root;
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: undefined; 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;
10 property size fixedArtShapeSize: Qt.size(-1, -1); 10 property size fixedArtShapeSize: Qt.size(-1, -1);
11 readonly property string title: cardData && cardData["title"] || ""; 11 readonly property string title: cardData && cardData["title"] || "";
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;
15onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artShapeLoader.item) artShapeLoader.item.borderSource = artShapeBorderSource; } 15onArtShapeBorderSourceChanged: { if (artShapeBorderSource !== undefined && artShapeLoader.item) artShapeLoader.item.borderSource = artShapeBorderSource; }
16readonly 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);
17Item { 17Item {
18 id: artShapeHolder; 18 id: artShapeHolder;
@@ -57,9 +57,9 @@
57 readonly property real aspect: implicitWidth / implicitHeight; 57 readonly property real aspect: implicitWidth / implicitHeight;
58 width: root.width; 58 width: root.width;
59 height: width / artShape.aspect;59 height: width / artShape.aspect;
60 } 60 }
61 } 61 }
62 } 62 }
63 }63 }
64Loader { 64Loader {
65 id: overlayLoader; 65 id: overlayLoader;
@@ -105,40 +105,40 @@
105Label { 105Label {
106 id: titleLabel; 106 id: titleLabel;
107 objectName: "titleLabel"; 107 objectName: "titleLabel";
108 anchors { left: parent.left; 108 anchors { right: parent.right;
109 leftMargin: units.gu(1); 109 left: parent.left;
110 right: parent.right; 110 leftMargin: units.gu(1);
111 top: overlayLoader.top; 111 top: overlayLoader.top;
112 topMargin: units.gu(1);112 topMargin: units.gu(1);
113}113}
114 elide: Text.ElideRight; 114 elide: Text.ElideRight;
115 fontSize: "small"; 115 fontSize: "small";
116 wrapMode: Text.Wrap; 116 wrapMode: Text.Wrap;
117 maximumLineCount: 2; 117 maximumLineCount: 2;
118 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); 118 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
119 color: "white"; 119 color: "white";
120 visible: showHeader && overlayLoader.active; 120 visible: showHeader && overlayLoader.active;
121 text: root.title; 121 text: root.title;
122 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal; 122 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
123 horizontalAlignment: root.headerAlignment; 123 horizontalAlignment: root.headerAlignment;
124 }124 }
125Label { 125Label {
126 id: subtitleLabel; 126 id: subtitleLabel;
127 objectName: "subtitleLabel"; 127 objectName: "subtitleLabel";
128 anchors { left: titleLabel.left; 128 anchors { left: titleLabel.left;
129 leftMargin: titleLabel.leftMargin; 129 leftMargin: titleLabel.leftMargin;
130 right: titleLabel.right; 130 top: titleLabel.bottom;
131 top: titleLabel.bottom; 131 right: titleLabel.right;
132 topMargin: units.dp(2);132 }
133 }133 anchors.topMargin: units.dp(2);
134 elide: Text.ElideRight; 134 elide: Text.ElideRight;
135 fontSize: "small"; 135 fontSize: "small";
136 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale); 136 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
137 color: "white"; 137 color: "white";
138 visible: titleLabel.visible && titleLabel.text; 138 visible: titleLabel.visible && titleLabel.text;
139 text: cardData && cardData["subtitle"] || ""; 139 text: cardData && cardData["subtitle"] || "";
140 font.weight: Font.Light; 140 font.weight: Font.Light;
141 horizontalAlignment: root.headerAlignment; 141 horizontalAlignment: root.headerAlignment;
142 }142 }
143implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);143implicitHeight: subtitleLabel.y + subtitleLabel.height + units.gu(1);
144}144}
145145
=== added file 'tests/plugins/Dash/cardcreator/6.res'
--- tests/plugins/Dash/cardcreator/6.res 1970-01-01 00:00:00 +0000
+++ tests/plugins/Dash/cardcreator/6.res 2014-06-27 14:25:45 +0000
@@ -0,0 +1,115 @@
1AbstractButton {
2 id: root;
3 property var template;
4 property var components;
5 property var cardData;
6 property var artShapeBorderSource: undefined;
7 property real fontScale: 1.0;
8 property int headerAlignment: Text.AlignLeft;
9 property int fixedHeaderHeight: -1;
10 property size fixedArtShapeSize: Qt.size(-1, -1);
11 readonly property string title: cardData && cardData["title"] || "";
12 property bool asynchronous: true;
13 property bool showHeader: true;
14 implicitWidth: childrenRect.width;
15readonly property size artShapeSize: Qt.size(-1, -1);
16readonly property int headerHeight: row.height;
17Row {
18 id: row;
19 objectName: "outerRow";
20 property real margins: units.gu(1);
21 spacing: margins;
22 height: root.fixedHeaderHeight != -1 ? root.fixedHeaderHeight : implicitHeight;
23 anchors { top: parent.top;
24 topMargin: units.gu(1);
25 left: parent.left;
26}
27 anchors.right: parent.right;
28 anchors.margins: margins;
29data: [ Loader {
30 id: mascotShapeLoader;
31 objectName: "mascotShapeLoader";
32 asynchronous: root.asynchronous;
33 active: mascotImage.status === Image.Ready;
34 visible: showHeader && active && status == Loader.Ready;
35 width: units.gu(6);
36 height: units.gu(5.625);
37 sourceComponent: UbuntuShape { image: mascotImage }
38 anchors { verticalCenter: parent.verticalCenter; }
39 }
40,
41Image {
42 id: mascotImage;
43 objectName: "mascotImage";
44 anchors { verticalCenter: parent.verticalCenter; }
45 readonly property int maxSize: Math.max(width, height) * 4;
46 source: cardData && cardData["mascot"];
47 width: units.gu(6);
48 height: units.gu(5.625);
49 sourceSize { width: maxSize; height: maxSize }
50 fillMode: Image.PreserveAspectCrop;
51 horizontalAlignment: Image.AlignHCenter;
52 verticalAlignment: Image.AlignVCenter;
53 visible: false;
54 }
55,
56Item {
57 id: headerTitleContainer;
58 anchors { verticalCenter: parent.verticalCenter; }
59 width: parent.width - x;
60 implicitHeight: titleLabel.height + subtitleLabel.height;
61data: [ Label {
62 id: titleLabel;
63 objectName: "titleLabel";
64 anchors { right: emblemImage.left;
65 left: parent.left;
66 top: parent.top; }
67 elide: Text.ElideRight;
68 fontSize: "small";
69 wrapMode: Text.Wrap;
70 maximumLineCount: 2;
71 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
72 color: "grey";
73 visible: showHeader ;
74 text: root.title;
75 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
76 horizontalAlignment: root.headerAlignment;
77 }
78 ,
79 Image {
80 id: emblemImage;
81 objectName: "emblemImage";
82 anchors {
83 bottom: titleLabel.baseline;
84 right: parent.right;
85 }
86 source: cardData && cardData["emblem"];
87 width: height;
88 height: titleLabel.font.pixelSize;
89 fillMode: Image.PreserveAspectFit;
90 }
91
92,
93Label {
94 id: subtitleLabel;
95 objectName: "subtitleLabel";
96 anchors { right: parent.right;
97 left: parent.left;
98 top: titleLabel.bottom;
99 }
100 anchors.topMargin: units.dp(2);
101 elide: Text.ElideRight;
102 fontSize: "small";
103 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
104 color: "grey";
105 visible: titleLabel.visible && titleLabel.text;
106 text: cardData && cardData["subtitle"] || "";
107 font.weight: Font.Light;
108 horizontalAlignment: root.headerAlignment;
109 }
110]
111}
112]
113}
114implicitHeight: row.y + row.height + units.gu(1);
115}
0116
=== added file 'tests/plugins/Dash/cardcreator/6.tst'
--- tests/plugins/Dash/cardcreator/6.tst 1970-01-01 00:00:00 +0000
+++ tests/plugins/Dash/cardcreator/6.tst 2014-06-27 14:25:45 +0000
@@ -0,0 +1,3 @@
1template: {"card-layout":"horizontal","card-size":"large","category-layout":"grid","collapsed-rows":2}
2components: {"art":{"aspect-ratio":1,"fill-mode":"crop"},"mascot":{"field":"mascot"},"subtitle":{"field":"domain"},"title":{"field":"title"},"emblem":{"field":"emblem"}}
3result: 6.res
04
=== modified file 'tests/plugins/Dash/cardcreatortest.cpp'
--- tests/plugins/Dash/cardcreatortest.cpp 2014-05-06 13:09:08 +0000
+++ tests/plugins/Dash/cardcreatortest.cpp 2014-06-27 14:25:45 +0000
@@ -19,6 +19,7 @@
19#include <QQuickItem>19#include <QQuickItem>
20#include <QQuickView>20#include <QQuickView>
21#include <QtTestGui>21#include <QtTestGui>
22#include <QDebug>
2223
23class CardCreatorTest : public QObject24class CardCreatorTest : public QObject
24{25{
@@ -73,8 +74,13 @@
73 QFile testResultFile(testDirPath + resultFileName);74 QFile testResultFile(testDirPath + resultFileName);
74 QVERIFY(testResultFile.open(QIODevice::ReadOnly));75 QVERIFY(testResultFile.open(QIODevice::ReadOnly));
75 QTextStream ts2(&testResultFile);76 QTextStream ts2(&testResultFile);
76 const QString expectedResult = ts2.readAll();77 const QStringList expectedLines = ts2.readAll().trimmed().replace(QRegExp("\n\\s*\n"),"\n").split("\n");
77 QCOMPARE(cardStringResult.toString().simplified(), expectedResult.simplified());78 const QStringList cardStringResultLines = cardStringResult.toString().trimmed().replace(QRegExp("\n\\s*\n"),"\n").split("\n");
79 //QCOMPARE(cardStringResultLines.size(), expectedLines.size()); // This is not really needed... following for does that deeply
80 for (int i = 0; i < expectedLines.size(); ++i) {
81 //qDebug() << cardStringResultLines[i].simplified() << expectedLines[i].simplified();
82 QCOMPARE(cardStringResultLines[i].simplified(), expectedLines[i].simplified());
83 }
7884
79 QVariant createCardComponentResult;85 QVariant createCardComponentResult;
80 QMetaObject::invokeMethod(view->rootObject(), "createCardComponent", Q_RETURN_ARG(QVariant, createCardComponentResult), Q_ARG(QVariant, templateJSON), Q_ARG(QVariant, componentsJSON));86 QMetaObject::invokeMethod(view->rootObject(), "createCardComponent", Q_RETURN_ARG(QVariant, createCardComponentResult), Q_ARG(QVariant, templateJSON), Q_ARG(QVariant, componentsJSON));
8187
=== modified file 'tests/qmltests/Dash/CardHelpers.js'
--- tests/qmltests/Dash/CardHelpers.js 2014-02-04 18:14:07 +0000
+++ tests/qmltests/Dash/CardHelpers.js 2014-06-27 14:25:45 +0000
@@ -59,6 +59,7 @@
59 "art": "art", \59 "art": "art", \
60 "subtitle": "subtitle", \60 "subtitle": "subtitle", \
61 "mascot": "mascot", \61 "mascot": "mascot", \
62 "emblem": "emblem", \
62 "summary": "summary" \63 "summary": "summary" \
63}'64}'
6465
6566
=== added file 'tests/qmltests/Dash/artwork/emblem.png'
66Binary files tests/qmltests/Dash/artwork/emblem.png 1970-01-01 00:00:00 +0000 and tests/qmltests/Dash/artwork/emblem.png 2014-06-27 14:25:45 +0000 differ67Binary files tests/qmltests/Dash/artwork/emblem.png 1970-01-01 00:00:00 +0000 and tests/qmltests/Dash/artwork/emblem.png 2014-06-27 14:25:45 +0000 differ
=== modified file 'tests/qmltests/Dash/tst_Card.qml'
--- tests/qmltests/Dash/tst_Card.qml 2014-06-27 08:47:04 +0000
+++ tests/qmltests/Dash/tst_Card.qml 2014-06-27 14:25:45 +0000
@@ -31,6 +31,7 @@
31 {31 {
32 "art": "../../../tests/qmltests/Dash/artwork/music-player-design.png",32 "art": "../../../tests/qmltests/Dash/artwork/music-player-design.png",
33 "mascot": "../../../tests/qmltests/Dash/artwork/avatar.png",33 "mascot": "../../../tests/qmltests/Dash/artwork/avatar.png",
34 "emblem": "../../../tests/qmltests/Dash/artwork/emblem.png",
34 "title": "foo",35 "title": "foo",
35 "subtitle": "bar",36 "subtitle": "bar",
36 "summary": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."37 "summary": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
@@ -456,6 +457,23 @@
456 tryCompareFunction(function() { return Qt.colorEqual(subtitle.color, fontColor); }, true);457 tryCompareFunction(function() { return Qt.colorEqual(subtitle.color, fontColor); }, true);
457 }458 }
458459
460 function test_emblemImage_data() {
461 return [
462 { tag: "Art and summary", emblem: true, index: 0 },
463 { tag: "Art and summary, small", emblem: false, index: 1 },
464 { tag: "No header", emblem: false, index: 7 },
465 { tag: "With background", emblem: true, index: 10 },
466 ];
467 }
468
469 function test_emblemImage(data) {
470 selector.selectedIndex = data.index;
471 waitForRendering(card);
472
473 var emblemImage = findChild(card, "emblemImage");
474 compare(emblemImage !== null, data.emblem);
475 }
476
459 function test_mascotShape_data() {477 function test_mascotShape_data() {
460 return [478 return [
461 { tag: "Art and summary", shape: false, index: 0 },479 { tag: "Art and summary", shape: false, index: 0 },

Subscribers

People subscribed via source and target branches