on xenial help sign in
Rename to social actions
commitce3abbb40969103e7451813c820ff6abd07a95e8 authorAndrea Cimitan <andrea.cimitan@gmail.com> dateFri 4 Mar 2016, 10:43 (11 years ago) parent535c3a6
9 files changed+56−56
plugins/Dash/CardCreator.js+15−15 plugins/Dash/CardSocialAttributes.qml → plugins/Dash/CardSocialActions.qml+3−3 plugins/Dash/qmldir+1−1 qml/Dash/CardTool.qml+13−13 tests/mocks/Unity/fake_categories.cpp+4−4 tests/plugins/Dash/cardcreator/12.res+5−5 tests/plugins/Dash/cardcreator/12.tst+1−1 tests/qmltests/Dash/CardHelpers.js+3−3 tests/qmltests/Dash/tst_Card.qml+11−11
plugins/Dash/CardCreator.js+15−15
@@ -336,16 +336,16 @@ var kAttributesRowCode = 'CardAttributes { \n\
336336 model: cardData && cardData["attributes"]; \n\
337337 }\n';
338338
339−// %1 is used as anchors of socialAttributesRow
340−// %2 is used as color of socialAttributesRow
341−var kSocialAttributesRowCode = 'CardSocialAttributes { \n\
342− id: socialAttributesRow; \n\
343− objectName: "socialAttributesRow"; \n\
344− anchors { %1 } \n\
345− color: %2; \n\
346− model: cardData && cardData["socialAttributes"]; \n\
347− onClicked: root.action(actionId); \n\
348− }\n';
339+// %1 is used as anchors of socialActionsRow
340+// %2 is used as color of socialActionsRow
341+var kSocialActionsRowCode = 'CardSocialActions { \n\
342+ id: socialActionsRow; \n\
343+ objectName: "socialActionsRow"; \n\
344+ anchors { %1 } \n\
345+ color: %2; \n\
346+ model: cardData && cardData["socialActions"]; \n\
347+ onClicked: root.action(actionId); \n\
348+ }\n';
349349
350350// %1 is used as top anchor of summary
351351// %2 is used as topMargin anchor of summary
@@ -433,7 +433,7 @@ function cardString(template, components) {
433433 var hasSubtitle = hasTitle && components["subtitle"] || false;
434434 var hasHeaderRow = hasMascot && hasTitle;
435435 var hasAttributes = hasTitle && components["attributes"] && components["attributes"]["field"] || false;
436− var hasSocialAttributes = hasTitle && components["socialAttributes"] || false;
436+ var hasSocialActions = hasTitle && components["socialActions"] || false;
437437 var isAudio = template["quick-preview-type"] === "audio";
438438
439439 code += 'signal action(var actionId);\n';
@@ -806,7 +806,7 @@ function cardString(template, components) {
806806 code += kSummaryLabelCode.arg(summaryTopAnchor).arg(summaryTopMargin).arg(summaryColor);
807807 }
808808
809− if (hasSocialAttributes) {
809+ if (hasSocialActions) {
810810 var socialAnchors;
811811 var socialTopAnchor;
812812
@@ -833,7 +833,7 @@ function cardString(template, components) {
833833 socialColor = 'root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText';
834834 }
835835
836− code += kSocialAttributesRowCode.arg(socialAnchors).arg(socialColor);
836+ code += kSocialActionsRowCode.arg(socialAnchors).arg(socialColor);
837837 }
838838
839839 var touchdownAnchors;
@@ -847,8 +847,8 @@ function cardString(template, components) {
847847 code += kTouchdownCode.arg(touchdownAnchors);
848848
849849 var implicitHeight = 'implicitHeight: ';
850− if (hasSocialAttributes) {
851− implicitHeight += 'socialAttributesRow.y + socialAttributesRow.height + units.gu(1);\n';
850+ if (hasSocialActions) {
851+ implicitHeight += 'socialActionsRow.y + socialActionsRow.height + units.gu(1);\n';
852852 } else if (hasSummary) {
853853 implicitHeight += 'summary.y + summary.height + units.gu(1);\n';
854854 } else if (isAudio) {
plugins/Dash/CardSocialAttributes.qml → plugins/Dash/CardSocialActions.qmlrenamed+3−3
@@ -20,7 +20,7 @@ import Ubuntu.Components 1.3
2020import "../../../qml/Components/ListItems" as ListItems
2121
2222Column {
23− id: socialAttributes
23+ id: socialActions
2424 spacing: units.gu(0.5)
2525
2626 property alias model: repeater.model
@@ -72,12 +72,12 @@ Column {
7272 // FIXME Workaround for bug https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1421293
7373 width: implicitWidth > 0 && implicitHeight > 0 ? (implicitWidth / implicitHeight * height) : implicitWidth
7474 source: urlIcon
75− color: socialAttributes.color
75+ color: socialActions.color
7676
7777 onUrlIconChanged: if (urlIcon) source = urlIcon
7878 }
7979
80− onClicked: socialAttributes.clicked(modelData["id"]);
80+ onClicked: socialActions.clicked(modelData["id"]);
8181 onPressedChanged: if (pressed && icon.urlTemporaryIcon != "") icon.source = icon.urlTemporaryIcon
8282 }
8383 }
plugins/Dash/qmldir+1−1
@@ -5,7 +5,7 @@ singleton CardCreatorCache 0.1 CardCreatorCache.qml
55singleton DashAudioPlayer 0.1 DashAudioPlayer.qml
66ScopeStyle 0.1 ScopeStyle.qml
77CardAttributes 0.1 CardAttributes.qml
8−CardSocialAttributes 0.1 CardSocialAttributes.qml
8+CardSocialActions 0.1 CardSocialActions.qml
99CroppedImageMinimumSourceSize 0.1 CroppedImageMinimumSourceSize.qml
1010AudioProgressBar 0.1 AudioProgressBar.qml
1111CardAudioProgress 0.1 CardAudioProgress.qml
qml/Dash/CardTool.qml+13−13
@@ -206,24 +206,24 @@ Item {
206206 }
207207
208208 Item {
209− id: socialAttributesModel
210− property int numOfAttributes: 0
209+ id: socialActionsModel
210+ property int numOfActions: 0
211211 property var model: []
212− property bool hasAttributes: {
213− var attributes = components["socialAttributes"];
214− var hasAttributesFlag = (attributes != undefined);
212+ property bool hasActions: {
213+ var actions = components["socialActions"];
214+ var hasActionsFlag = (actions != undefined);
215215
216− if (hasAttributesFlag) {
217− if (attributes["max-count"]) {
218− numOfAttributes = attributes["max-count"];
216+ if (hasActionsFlag) {
217+ if (actions["max-count"]) {
218+ numOfActions = actions["max-count"];
219219 }
220220 }
221− return hasAttributesFlag
221+ return hasActionsFlag
222222 }
223223
224− onNumOfAttributesChanged: {
224+ onNumOfActionsChanged: {
225225 model = []
226− for (var i = 0; i < numOfAttributes; i++) {
226+ for (var i = 0; i < numOfActions; i++) {
227227 model.push( {"id":"text"+(i+1), "icon":"image://theme/ok" } );
228228 }
229229 }
@@ -231,7 +231,7 @@ Item {
231231
232232 Loader {
233233 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"]
235235 readonly property var maxData: {
236236 "art": Qt.resolvedUrl("graphics/pixel.png"),
237237 "mascot": Qt.resolvedUrl("graphics/pixel.png"),
@@ -239,7 +239,7 @@ Item {
239239 "subtitle": "—",
240240 "summary": "—\n—\n—\n—\n—",
241241 "attributes": attributesModel.model,
242− "socialAttributes": socialAttributesModel.model
242+ "socialActions": socialActionsModel.model
243243 }
244244 sourceComponent: cardTool.cardComponent
245245 onLoaded: {
tests/mocks/Unity/fake_categories.cpp+4−4
@@ -88,7 +88,7 @@ Categories::data(const QModelIndex& index, int role) const
8888 }
8989 case RoleComponents:
9090 {
91− QVariantMap map, artMap, attributeMap, socialAttributeMap;
91+ QVariantMap map, artMap, attributeMap, socialActionMap;
9292 if (index.row() % 2 != 0) {
9393 artMap["aspect-ratio"] = QString("1.%1").arg(index.row());
9494 } else {
@@ -99,9 +99,9 @@ Categories::data(const QModelIndex& index, int role) const
9999 map["title"] = "HOLA";
100100 map["subtitle"] = "HOLA";
101101 attributeMap["field"] = "attribute";
102− socialAttributeMap["icon"] = "image://theme/cancel";
103− socialAttributeMap["id"] = "dislike";
104− map["socialAttributes"] = socialAttributeMap;
102+ socialActionMap["icon"] = "image://theme/cancel";
103+ socialActionMap["id"] = "dislike";
104+ map["socialActions"] = socialActionMap;
105105 map["attributes"] = attributeMap;
106106 return map;
107107 }
tests/plugins/Dash/cardcreator/12.res+5−5
@@ -127,12 +127,12 @@ Label {
127127 text: cardData && cardData["subtitle"] || "";
128128 font.weight: Font.Light;
129129 }
130−CardSocialAttributes {
131− id: socialAttributesRow;
132− objectName: "socialAttributesRow";
130+CardSocialActions {
131+ id: socialActionsRow;
132+ objectName: "socialActionsRow";
133133 anchors { top: subtitleLabel.bottom; left: parent.left; right: parent.right; topMargin: units.gu(1); }
134134 color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText;
135− model: cardData && cardData["socialAttributes"];
135+ model: cardData && cardData["socialActions"];
136136 onClicked: root.action(actionId);
137137}
138138UbuntuShape {
@@ -143,5 +143,5 @@ UbuntuShape {
143143 radius: "medium";
144144 borderSource: "radius_pressed.sci"
145145}
146−implicitHeight: socialAttributesRow.y + socialAttributesRow.height + units.gu(1);
146+implicitHeight: socialActionsRow.y + socialActionsRow.height + units.gu(1);
147147}
tests/plugins/Dash/cardcreator/12.tst+1−1
@@ -1,3 +1,3 @@
11template: {"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"}]}
33result: 12.res
tests/qmltests/Dash/CardHelpers.js+3−3
@@ -16,7 +16,7 @@
1616
1717.pragma library
1818
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"]
2020
2121var defaultLayout = ' \
2222{ \
@@ -39,7 +39,7 @@ var defaultLayout = ' \
3939 "emblem": null, \
4040 "summary": null, \
4141 "attributes": { "max-count": 2 },
42− "socialAttributes": { "max-count": 4 } \
42+ "socialActions": { "max-count": 4 } \
4343 }, \
4444 "resources": {} \
4545}'
@@ -54,7 +54,7 @@ var fullMapping = ' \
5454 "overlayColor": "overlayColor", \
5555 "summary": "summary", \
5656 "attributes": "attributes", \
57− "socialAttributes": "socialAttributes" \
57+ "socialActions": "socialActions" \
5858}'
5959
6060
tests/qmltests/Dash/tst_Card.qml+11−11
@@ -36,10 +36,10 @@ Rectangle {
3636 "subtitle": "bar",
3737 "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.",
3838 "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"},
40− {"id":"share","label":"text2","icon":"image://theme/cancel"},
41− {"id":"like","label":"text1","icon":"image://theme/ok","temporaryIcon":"image://theme/undo"},
42− {"id":"share","label":"text2","icon":"image://theme/cancel"}],
39+ "socialActions": [{"id":"like","label":"text1","icon":"image://theme/ok","temporaryIcon":"image://theme/undo"},
40+ {"id":"share","label":"text2","icon":"image://theme/cancel"},
41+ {"id":"like","label":"text1","icon":"image://theme/ok","temporaryIcon":"image://theme/undo"},
42+ {"id":"share","label":"text2","icon":"image://theme/cancel"}],
4343 "quickPreviewData": {"uri": "/some/file", "duration": "14"}
4444 }'
4545
@@ -283,10 +283,10 @@ Rectangle {
283283 { tag: "Wide", width: units.gu(18), index: 0 },
284284 { tag: "Horizontal", width: units.gu(38), index: 5 },
285285 // Make sure card ends with header when there's no summary
286− { tag: "NoSummary", height: function() { var socialAttributesRow = findChild(cardTool, "socialAttributesRow");
287− return socialAttributesRow.y + socialAttributesRow.height + units.gu(1) }, index: 6 },
288− { tag: "HorizontalNoSummary", height: function() { var socialAttributesRow = findChild(cardTool, "socialAttributesRow");
289− return socialAttributesRow.y + socialAttributesRow.height + units.gu(1) },
286+ { tag: "NoSummary", height: function() { var socialActionsRow = findChild(cardTool, "socialActionsRow");
287+ return socialActionsRow.y + socialActionsRow.height + units.gu(1) }, index: 6 },
288+ { tag: "HorizontalNoSummary", height: function() { var socialActionsRow = findChild(cardTool, "socialActionsRow");
289+ return socialActionsRow.y + socialActionsRow.height + units.gu(1) },
290290 card_layout: "horizontal", index: 6 },
291291 ]
292292 }
@@ -640,10 +640,10 @@ Rectangle {
640640 waitForRendering(card);
641641
642642 signalSpy.target = card;
643− var socialAttributesRow = findChild(card, "socialAttributesRow");
644− var delegate0 = findChild(socialAttributesRow, "delegate0");
643+ var socialActionsRow = findChild(card, "socialActionsRow");
644+ var delegate0 = findChild(socialActionsRow, "delegate0");
645645 var icon0 = findChild(delegate0, "icon");
646− var delegate1 = findChild(socialAttributesRow, "delegate1");
646+ var delegate1 = findChild(socialActionsRow, "delegate1");
647647 var icon1 = findChild(delegate1, "icon");
648648
649649 compare(icon0.source, "image://theme/ok");