on xenial help sign in
Rename to social actions
ce3abbbAndrea Cimitan
plugins/Dash/CardCreator.js+15−15
@@ -336,16 +336,16 @@ var kAttributesRowCode = 'CardAttributes { \n\
336 model: cardData && cardData["attributes"]; \n\
336 model: cardData && cardData["attributes"]; \n\
337 }\n';
337 }\n';
338
338
339−// %1 is used as anchors of socialAttributesRow
339+// %1 is used as anchors of socialActionsRow
340−// %2 is used as color of socialAttributesRow
340+// %2 is used as color of socialActionsRow
341−var kSocialAttributesRowCode = 'CardSocialAttributes { \n\
341+var kSocialActionsRowCode = 'CardSocialActions { \n\
342− id: socialAttributesRow; \n\
342+ id: socialActionsRow; \n\
343− objectName: "socialAttributesRow"; \n\
343+ objectName: "socialActionsRow"; \n\
344− anchors { %1 } \n\
344+ anchors { %1 } \n\
345− color: %2; \n\
345+ color: %2; \n\
346− model: cardData && cardData["socialAttributes"]; \n\
346+ model: cardData && cardData["socialActions"]; \n\
347− onClicked: root.action(actionId); \n\
347+ onClicked: root.action(actionId); \n\
348− }\n';
348+ }\n';
349
349
350// %1 is used as top anchor of summary
350// %1 is used as top anchor of summary
351// %2 is used as topMargin anchor of summary
351// %2 is used as topMargin anchor of summary
@@ -433,7 +433,7 @@ function cardString(template, components) {
433 var hasSubtitle = hasTitle && components["subtitle"] || false;
433 var hasSubtitle = hasTitle && components["subtitle"] || false;
434 var hasHeaderRow = hasMascot && hasTitle;
434 var hasHeaderRow = hasMascot && hasTitle;
435 var hasAttributes = hasTitle && components["attributes"] && components["attributes"]["field"] || false;
435 var hasAttributes = hasTitle && components["attributes"] && components["attributes"]["field"] || false;
436− var hasSocialAttributes = hasTitle && components["socialAttributes"] || false;
436+ var hasSocialActions = hasTitle && components["socialActions"] || false;
437 var isAudio = template["quick-preview-type"] === "audio";
437 var isAudio = template["quick-preview-type"] === "audio";
438
438
439 code += 'signal action(var actionId);\n';
439 code += 'signal action(var actionId);\n';
@@ -806,7 +806,7 @@ function cardString(template, components) {
806 code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(summaryColor);
806 code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(summaryColor);
807 }
807 }
808
808
809− if (hasSocialAttributes) {
809+ if (hasSocialActions) {
810 var socialAnchors;
810 var socialAnchors;
811 var socialTopAnchor;
811 var socialTopAnchor;
812
812
@@ -833,7 +833,7 @@ function cardString(template, components) {
833 socialColor = 'root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText';
833 socialColor = 'root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText';
834 }
834 }
835
835
836− code += kSocialAttributesRowCode.arg(socialAnchors).arg(socialColor);
836+ code += kSocialActionsRowCode.arg(socialAnchors).arg(socialColor);
837 }
837 }
838
838
839 var touchdownAnchors;
839 var touchdownAnchors;
@@ -847,8 +847,8 @@ function cardString(template, components) {
847 code += kTouchdownCode.arg(touchdownAnchors);
847 code += kTouchdownCode.arg(touchdownAnchors);
848
848
849 var implicitHeight = 'implicitHeight: ';
849 var implicitHeight = 'implicitHeight: ';
850− if (hasSocialAttributes) {
850+ if (hasSocialActions) {
851− implicitHeight += 'socialAttributesRow.y + socialAttributesRow.height + units.gu(1);\n';
851+ implicitHeight += 'socialActionsRow.y + socialActionsRow.height + units.gu(1);\n';
852 } else if (hasSummary) {
852 } else if (hasSummary) {
853 implicitHeight += 'summary.y + summary.height + units.gu(1);\n';
853 implicitHeight += 'summary.y + summary.height + units.gu(1);\n';
854 } else if (isAudio) {
854 } else if (isAudio) {
plugins/Dash/CardSocialAttributes.qml → plugins/Dash/CardSocialActions.qmlrenamed+3−3
@@ -20,7 +20,7 @@ import Ubuntu.Components 1.3
20import "../../../qml/Components/ListItems" as ListItems
20import "../../../qml/Components/ListItems" as ListItems
21
21
22Column {
22Column {
23− id: socialAttributes
23+ id: socialActions
24 spacing: units.gu(0.5)
24 spacing: units.gu(0.5)
25
25
26 property alias model: repeater.model
26 property alias model: repeater.model
@@ -72,12 +72,12 @@ Column {
72 // FIXME Workaround for bug https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1421293
72 // FIXME Workaround for bug https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1421293
73 width: implicitWidth > 0 && implicitHeight > 0 ? (implicitWidth / implicitHeight * height) : implicitWidth
73 width: implicitWidth > 0 && implicitHeight > 0 ? (implicitWidth / implicitHeight * height) : implicitWidth
74 source: urlIcon
74 source: urlIcon
75− color: socialAttributes.color
75+ color: socialActions.color
76
76
77 onUrlIconChanged: if (urlIcon) source = urlIcon
77 onUrlIconChanged: if (urlIcon) source = urlIcon
78 }
78 }
79
79
80− onClicked: socialAttributes.clicked(modelData["id"]);
80+ onClicked: socialActions.clicked(modelData["id"]);
81 onPressedChanged: if (pressed && icon.urlTemporaryIcon != "") icon.source = icon.urlTemporaryIcon
81 onPressedChanged: if (pressed && icon.urlTemporaryIcon != "") icon.source = icon.urlTemporaryIcon
82 }
82 }
83 }
83 }
plugins/Dash/qmldir+1−1
@@ -5,7 +5,7 @@ singleton CardCreatorCache 0.1 CardCreatorCache.qml
5singleton DashAudioPlayer 0.1 DashAudioPlayer.qml
5singleton DashAudioPlayer 0.1 DashAudioPlayer.qml
6ScopeStyle 0.1 ScopeStyle.qml
6ScopeStyle 0.1 ScopeStyle.qml
7CardAttributes 0.1 CardAttributes.qml
7CardAttributes 0.1 CardAttributes.qml
8−CardSocialAttributes 0.1 CardSocialAttributes.qml
8+CardSocialActions 0.1 CardSocialActions.qml
9CroppedImageMinimumSourceSize 0.1 CroppedImageMinimumSourceSize.qml
9CroppedImageMinimumSourceSize 0.1 CroppedImageMinimumSourceSize.qml
10AudioProgressBar 0.1 AudioProgressBar.qml
10AudioProgressBar 0.1 AudioProgressBar.qml
11CardAudioProgress 0.1 CardAudioProgress.qml
11CardAudioProgress 0.1 CardAudioProgress.qml
qml/Dash/CardTool.qml+13−13
@@ -206,24 +206,24 @@ Item {
206 }
206 }
207
207
208 Item {
208 Item {
209− id: socialAttributesModel
209+ id: socialActionsModel
210− property int numOfAttributes: 0
210+ property int numOfActions: 0
211 property var model: []
211 property var model: []
212− property bool hasAttributes: {
212+ property bool hasActions: {
213− var attributes = components["socialAttributes"];
213+ var actions = components["socialActions"];
214− var hasAttributesFlag = (attributes != undefined);
214+ var hasActionsFlag = (actions != undefined);
215
215
216− if (hasAttributesFlag) {
216+ if (hasActionsFlag) {
217− if (attributes["max-count"]) {
217+ if (actions["max-count"]) {
218− numOfAttributes = attributes["max-count"];
218+ numOfActions = actions["max-count"];
219 }
219 }
220 }
220 }
221− return hasAttributesFlag
221+ return hasActionsFlag
222 }
222 }
223
223
224− onNumOfAttributesChanged: {
224+ onNumOfActionsChanged: {
225 model = []
225 model = []
226− for (var i = 0; i < numOfAttributes; i++) {
226+ for (var i = 0; i < numOfActions; i++) {
227 model.push( {"id":"text"+(i+1), "icon":"image://theme/ok" } );
227 model.push( {"id":"text"+(i+1), "icon":"image://theme/ok" } );
228 }
228 }
229 }
229 }
@@ -231,7 +231,7 @@ Item {
231
231
232 Loader {
232 Loader {
233 id: cardLoader
233 id: cardLoader
234− readonly property var fields: ["art", "mascot", "title", "subtitle", "summary", "attributes", "socialAttributes"]
234+ readonly property var fields: ["art", "mascot", "title", "subtitle", "summary", "attributes", "socialActions"]
235 readonly property var maxData: {
235 readonly property var maxData: {
236 "art": Qt.resolvedUrl("graphics/pixel.png"),
236 "art": Qt.resolvedUrl("graphics/pixel.png"),
237 "mascot": Qt.resolvedUrl("graphics/pixel.png"),
237 "mascot": Qt.resolvedUrl("graphics/pixel.png"),
@@ -239,7 +239,7 @@ Item {
239 "subtitle": "—",
239 "subtitle": "—",
240 "summary": "—\n—\n—\n—\n—",
240 "summary": "—\n—\n—\n—\n—",
241 "attributes": attributesModel.model,
241 "attributes": attributesModel.model,
242− "socialAttributes": socialAttributesModel.model
242+ "socialActions": socialActionsModel.model
243 }
243 }
244 sourceComponent: cardTool.cardComponent
244 sourceComponent: cardTool.cardComponent
245 onLoaded: {
245 onLoaded: {
tests/mocks/Unity/fake_categories.cpp+4−4
@@ -88,7 +88,7 @@ Categories::data(const QModelIndex& index, int role) const
88 }
88 }
89 case RoleComponents:
89 case RoleComponents:
90 {
90 {
91− QVariantMap map, artMap, attributeMap, socialAttributeMap;
91+ QVariantMap map, artMap, attributeMap, socialActionMap;
92 if (index.row() % 2 != 0) {
92 if (index.row() % 2 != 0) {
93 artMap["aspect-ratio"] = QString("1.%1").arg(index.row());
93 artMap["aspect-ratio"] = QString("1.%1").arg(index.row());
94 } else {
94 } else {
@@ -99,9 +99,9 @@ Categories::data(const QModelIndex& index, int role) const
99 map["title"] = "HOLA";
99 map["title"] = "HOLA";
100 map["subtitle"] = "HOLA";
100 map["subtitle"] = "HOLA";
101 attributeMap["field"] = "attribute";
101 attributeMap["field"] = "attribute";
102− socialAttributeMap["icon"] = "image://theme/cancel";
102+ socialActionMap["icon"] = "image://theme/cancel";
103− socialAttributeMap["id"] = "dislike";
103+ socialActionMap["id"] = "dislike";
104− map["socialAttributes"] = socialAttributeMap;
104+ map["socialActions"] = socialActionMap;
105 map["attributes"] = attributeMap;
105 map["attributes"] = attributeMap;
106 return map;
106 return map;
107 }
107 }
tests/plugins/Dash/cardcreator/12.res+5−5
@@ -127,12 +127,12 @@ Label {
127 text: cardData && cardData["subtitle"] || "";
127 text: cardData && cardData["subtitle"] || "";
128 font.weight: Font.Light;
128 font.weight: Font.Light;
129 }
129 }
130−CardSocialAttributes {
130+CardSocialActions {
131− id: socialAttributesRow;
131+ id: socialActionsRow;
132− objectName: "socialAttributesRow";
132+ objectName: "socialActionsRow";
133 anchors { top: subtitleLabel.bottom; left: parent.left; right: parent.right; topMargin: units.gu(1); }
133 anchors { top: subtitleLabel.bottom; left: parent.left; right: parent.right; topMargin: units.gu(1); }
134 color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
134 color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
135− model: cardData && cardData["socialAttributes"];
135+ model: cardData && cardData["socialActions"];
136 onClicked: root.action(actionId);
136 onClicked: root.action(actionId);
137}
137}
138UbuntuShape {
138UbuntuShape {
@@ -143,5 +143,5 @@ UbuntuShape {
143 radius: "medium";
143 radius: "medium";
144 borderSource: "radius_pressed.sci"
144 borderSource: "radius_pressed.sci"
145}
145}
146−implicitHeight: socialAttributesRow.y + socialAttributesRow.height + units.gu(1);
146+implicitHeight: socialActionsRow.y + socialActionsRow.height + units.gu(1);
147}
147}
tests/plugins/Dash/cardcreator/12.tst+1−1
@@ -1,3 +1,3 @@
1template: {"card-layout":"vertical","card-size":"small","category-layout":"grid","collapsed-rows":2}
1template: {"card-layout":"vertical","card-size":"small","category-layout":"grid","collapsed-rows":2}
2−components: {"art":{"aspect-ratio":0.75,"field":"art"},"subtitle":{"field":"price"},"title":{"field":"title"},"attributes":{},"socialAttributes":[{"id":"like","label":"text1","icon":"image://theme/ok","temporaryIcon":"image://theme/undo"},{"id":"share","label":"text2","icon":"image://theme/cancel"}]}
2+components: {"art":{"aspect-ratio":0.75,"field":"art"},"subtitle":{"field":"price"},"title":{"field":"title"},"attributes":{},"socialActions":[{"id":"like","label":"text1","icon":"image://theme/ok","temporaryIcon":"image://theme/undo"},{"id":"share","label":"text2","icon":"image://theme/cancel"}]}
3result: 12.res
3result: 12.res
tests/qmltests/Dash/CardHelpers.js+3−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", "socialAttributes", "overlayColor", "quickPreviewData"]
19+var components = ["title", "art", "subtitle", "mascot", "emblem", "summary", "attributes", "socialActions", "overlayColor", "quickPreviewData"]
20
20
21var defaultLayout = ' \
21var defaultLayout = ' \
22{ \
22{ \
@@ -39,7 +39,7 @@ var defaultLayout = ' \
39 "emblem": null, \
39 "emblem": null, \
40 "summary": null, \
40 "summary": null, \
41 "attributes": { "max-count": 2 },
41 "attributes": { "max-count": 2 },
42− "socialAttributes": { "max-count": 4 } \
42+ "socialActions": { "max-count": 4 } \
43 }, \
43 }, \
44 "resources": {} \
44 "resources": {} \
45}'
45}'
@@ -54,7 +54,7 @@ var fullMapping = ' \
54 "overlayColor": "overlayColor", \
54 "overlayColor": "overlayColor", \
55 "summary": "summary", \
55 "summary": "summary", \
56 "attributes": "attributes", \
56 "attributes": "attributes", \
57− "socialAttributes": "socialAttributes" \
57+ "socialActions": "socialActions" \
58}'
58}'
59
59
60
60
tests/qmltests/Dash/tst_Card.qml+11−11
@@ -36,10 +36,10 @@ Rectangle {
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": [{"id":"like","label":"text1","icon":"image://theme/ok","temporaryIcon":"image://theme/undo"},
39+ "socialActions": [{"id":"like","label":"text1","icon":"image://theme/ok","temporaryIcon":"image://theme/undo"},
40− {"id":"share","label":"text2","icon":"image://theme/cancel"},
40+ {"id":"share","label":"text2","icon":"image://theme/cancel"},
41− {"id":"like","label":"text1","icon":"image://theme/ok","temporaryIcon":"image://theme/undo"},
41+ {"id":"like","label":"text1","icon":"image://theme/ok","temporaryIcon":"image://theme/undo"},
42− {"id":"share","label":"text2","icon":"image://theme/cancel"}],
42+ {"id":"share","label":"text2","icon":"image://theme/cancel"}],
43 "quickPreviewData": {"uri": "/some/file", "duration": "14"}
43 "quickPreviewData": {"uri": "/some/file", "duration": "14"}
44 }'
44 }'
45
45
@@ -283,10 +283,10 @@ Rectangle {
283 { tag: "Wide", width: units.gu(18), index: 0 },
283 { tag: "Wide", width: units.gu(18), index: 0 },
284 { tag: "Horizontal", width: units.gu(38), index: 5 },
284 { tag: "Horizontal", width: units.gu(38), index: 5 },
285 // Make sure card ends with header when there's no summary
285 // Make sure card ends with header when there's no summary
286− { tag: "NoSummary", height: function() { var socialAttributesRow = findChild(cardTool, "socialAttributesRow");
286+ { tag: "NoSummary", height: function() { var socialActionsRow = findChild(cardTool, "socialActionsRow");
287− return socialAttributesRow.y + socialAttributesRow.height + units.gu(1) }, index: 6 },
287+ return socialActionsRow.y + socialActionsRow.height + units.gu(1) }, index: 6 },
288− { tag: "HorizontalNoSummary", height: function() { var socialAttributesRow = findChild(cardTool, "socialAttributesRow");
288+ { tag: "HorizontalNoSummary", height: function() { var socialActionsRow = findChild(cardTool, "socialActionsRow");
289− return socialAttributesRow.y + socialAttributesRow.height + units.gu(1) },
289+ return socialActionsRow.y + socialActionsRow.height + units.gu(1) },
290 card_layout: "horizontal", index: 6 },
290 card_layout: "horizontal", index: 6 },
291 ]
291 ]
292 }
292 }
@@ -640,10 +640,10 @@ Rectangle {
640 waitForRendering(card);
640 waitForRendering(card);
641
641
642 signalSpy.target = card;
642 signalSpy.target = card;
643− var socialAttributesRow = findChild(card, "socialAttributesRow");
643+ var socialActionsRow = findChild(card, "socialActionsRow");
644− var delegate0 = findChild(socialAttributesRow, "delegate0");
644+ var delegate0 = findChild(socialActionsRow, "delegate0");
645 var icon0 = findChild(delegate0, "icon");
645 var icon0 = findChild(delegate0, "icon");
646− var delegate1 = findChild(socialAttributesRow, "delegate1");
646+ var delegate1 = findChild(socialActionsRow, "delegate1");
647 var icon1 = findChild(delegate1, "icon");
647 var icon1 = findChild(delegate1, "icon");
648
648
649 compare(icon0.source, "image://theme/ok");
649 compare(icon0.source, "image://theme/ok");