on xenial help sign in
Fix for tst_Card
a6678c0Andrea Cimitan
plugins/Dash/CardCreator.js+50−1
@@ -294,6 +294,18 @@ var kAttributesRowCode = 'CardAttributes { \n\
294 model: cardData && cardData["attributes"]; \n\
294 model: cardData && cardData["attributes"]; \n\
295 }\n';
295 }\n';
296
296
297+// %1 is used as anchors of socialAttributesRow
298+// %2 is used as color of socialAttributesRow
299+var kSocialAttributesRowCode = 'CardSocialAttributes { \n\
300+ id: socialAttributesRow; \n\
301+ objectName: "socialAttributesRow"; \n\
302+ anchors { %1 } \n\
303+ color: %2; \n\
304+ fontScale: root.fontScale; \n\
305+ model: cardData && cardData["socialAttributes"]; \n\
306+ onClicked: root.clicked(result); \n\
307+ }\n';
308+
297// %1 is used as top anchor of summary
309// %1 is used as top anchor of summary
298// %2 is used as topMargin anchor of summary
310// %2 is used as topMargin anchor of summary
299// %3 is used as color of summary
311// %3 is used as color of summary
@@ -352,6 +364,11 @@ function cardString(template, components) {
352 var hasSubtitle = hasTitle && components["subtitle"] || false;
364 var hasSubtitle = hasTitle && components["subtitle"] || false;
353 var hasHeaderRow = hasMascot && hasTitle;
365 var hasHeaderRow = hasMascot && hasTitle;
354 var hasAttributes = hasTitle && components["attributes"]["field"] || false;
366 var hasAttributes = hasTitle && components["attributes"]["field"] || false;
367+ var hasSocialAttributes = hasTitle && components["socialAttributes"] || false;
368+
369+ if (hasSocialAttributes) {
370+ code += 'signal clicked(var result);\n';
371+ }
355
372
356 if (hasBackground) {
373 if (hasBackground) {
357 var templateCardBackground = (template && typeof template["card-background"] === "string") ? template["card-background"] : "";
374 var templateCardBackground = (template && typeof template["card-background"] === "string") ? template["card-background"] : "";
@@ -657,6 +674,36 @@ function cardString(template, components) {
657 code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(summaryColor);
674 code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(summaryColor);
658 }
675 }
659
676
677+ if (hasSocialAttributes) {
678+ var socialAnchors;
679+ var socialTopAnchor;
680+
681+ if (hasSummary) {
682+ socialTopAnchor = 'summary.bottom;';
683+ } else {
684+ if (isHorizontal && hasArt) socialTopAnchor = 'artShapeHolder.bottom;';
685+ else if (headerAsOverlay && hasArt) socialTopAnchor = 'artShapeHolder.bottom;';
686+ else if (hasHeaderRow) socialTopAnchor = 'row.bottom;';
687+ else if (hasTitleContainer) socialTopAnchor = 'headerTitleContainer.bottom;';
688+ else if (hasMascot) socialTopAnchor = 'mascotImage.bottom;';
689+ else if (hasAttributes) socialTopAnchor = 'attributesRow.bottom;';
690+ else if (hasSubtitle) socialTopAnchor = 'subtitleLabel.bottom;';
691+ else if (hasTitle) socialTopAnchor = 'titleLabel.bottom;';
692+ else if (hasArt) socialTopAnchor = 'artShapeHolder.bottom;';
693+ else socialTopAnchor = 'parent.top';
694+ }
695+ socialAnchors = 'top: ' + socialTopAnchor + ' left: parent.left; right: parent.right; topMargin: units.gu(1);'
696+
697+ var socialColor;
698+ if (hasBackground) {
699+ socialColor = summaryColorWithBackground;
700+ } else {
701+ socialColor = 'root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText';
702+ }
703+
704+ code += kSocialAttributesRowCode.arg(socialAnchors).arg(socialColor);
705+ }
706+
660 var touchdownAnchors;
707 var touchdownAnchors;
661 if (hasBackground) {
708 if (hasBackground) {
662 touchdownAnchors = 'fill: backgroundLoader';
709 touchdownAnchors = 'fill: backgroundLoader';
@@ -668,7 +715,9 @@ function cardString(template, components) {
668 code += kTouchdownCode.arg(touchdownAnchors);
715 code += kTouchdownCode.arg(touchdownAnchors);
669
716
670 var implicitHeight = 'implicitHeight: ';
717 var implicitHeight = 'implicitHeight: ';
718+ if (hasSocialAttributes) {
719+ implicitHeight += 'socialAttributesRow.y + socialAttributesRow.height + units.gu(1);\n';
671− if (hasSummary) {
720+ } else if (hasSummary) {
672 implicitHeight += 'summary.y + summary.height + units.gu(1);\n';
721 implicitHeight += 'summary.y + summary.height + units.gu(1);\n';
673 } else if (headerAsOverlay) {
722 } else if (headerAsOverlay) {
674 implicitHeight += 'artShapeHolder.height;\n';
723 implicitHeight += 'artShapeHolder.height;\n';
plugins/Dash/qmldir+1
@@ -4,4 +4,5 @@ typeinfo Dash.qmltypes
4singleton CardCreatorCache 0.1 CardCreatorCache.qml
4singleton CardCreatorCache 0.1 CardCreatorCache.qml
5ScopeStyle 0.1 ScopeStyle.qml
5ScopeStyle 0.1 ScopeStyle.qml
6CardAttributes 0.1 CardAttributes.qml
6CardAttributes 0.1 CardAttributes.qml
7+CardSocialAttributes 0.1 CardSocialAttributes.qml
7CroppedImageMinimumSourceSize 0.1 CroppedImageMinimumSourceSize.qml
8CroppedImageMinimumSourceSize 0.1 CroppedImageMinimumSourceSize.qml
tests/qmltests/Dash/CardHelpers.js+5−3
@@ -16,7 +16,7 @@
16
16
17.pragma library
17.pragma library
18
18
19−var components = ["title", "art", "subtitle", "mascot", "emblem", "summary", "attributes", "overlayColor"]
19+var components = ["title", "art", "subtitle", "mascot", "emblem", "summary", "attributes", "socialAttributes", "overlayColor"]
20
20
21var defaultLayout = ' \
21var defaultLayout = ' \
22{ \
22{ \
@@ -38,7 +38,8 @@ var defaultLayout = ' \
38 "mascot": null, \
38 "mascot": null, \
39 "emblem": null, \
39 "emblem": null, \
40 "summary": null, \
40 "summary": null, \
41− "attributes": { "max-count": 2 } \
41+ "attributes": { "max-count": 2 },
42+ "socialAttributes": null \
42 }, \
43 }, \
43 "resources": {} \
44 "resources": {} \
44}'
45}'
@@ -52,7 +53,8 @@ var fullMapping = ' \
52 "emblem": "emblem", \
53 "emblem": "emblem", \
53 "overlayColor": "overlayColor", \
54 "overlayColor": "overlayColor", \
54 "summary": "summary", \
55 "summary": "summary", \
55− "attributes": "attributes" \
56+ "attributes": "attributes", \
57+ "socialAttributes": "socialAttributes" \
56}'
58}'
57
59
58
60
tests/qmltests/Dash/tst_Card.qml+6−3
@@ -35,7 +35,8 @@ Rectangle {
35 "title": "foo",
35 "title": "foo",
36 "subtitle": "bar",
36 "subtitle": "bar",
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.",
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.",
38− "attributes": [{"value":"text1","icon":"image://theme/ok"},{"value":"text2","icon":"image://theme/cancel"}]
38+ "attributes": [{"value":"text1","icon":"image://theme/ok"},{"value":"text2","icon":"image://theme/cancel"}],
39+ "socialAttributes": [{"label":"text1","icon":"image://theme/ok","temporaryIcon":"image://theme/undo"},{"label":"text2","icon":"image://theme/cancel"}]
39 }'
40 }'
40
41
41 property var cardsModel: [
42 property var cardsModel: [
@@ -267,9 +268,11 @@ Rectangle {
267 { tag: "Wide", width: units.gu(18), index: 0 },
268 { tag: "Wide", width: units.gu(18), index: 0 },
268 { tag: "Horizontal", width: units.gu(38), index: 5 },
269 { tag: "Horizontal", width: units.gu(38), index: 5 },
269 // Make sure card ends with header when there's no summary
270 // Make sure card ends with header when there's no summary
270− { tag: "NoSummary", height: function() { var cardToolRow = findChild(cardTool, "outerRow");
271+ { tag: "NoSummary", height: function() { var cardToolRow = findChild(cardTool, "socialAttributesRow");
271 return cardToolRow.y + cardToolRow.height + units.gu(1) }, index: 6 },
272 return cardToolRow.y + cardToolRow.height + units.gu(1) }, index: 6 },
273+ { tag: "HorizontalNoSummary", height: function() { var cardToolRow = findChild(cardTool, "socialAttributesRow");
274+ return cardToolRow.y + cardToolRow.height + units.gu(1) },
272− { tag: "HorizontalNoSummary", height: function() { return headerRow.height + units.gu(2) }, card_layout: "horizontal", index: 6 },
275+ card_layout: "horizontal", index: 6 },
273 ]
276 ]
274 }
277 }
275
278