on xenial help sign in
Do not calculate implicitHeight for Cards in a CardGrid
a1bb75eAlbert Astals Cid
plugins/Dash/CardCreator.js+30−26
@@ -437,7 +437,7 @@ function sanitizeColor(colorString) {
437 return colorString;
437 return colorString;
438}
438}
439
439
440−function cardString(template, components, isCardTool, artShapeStyle) {
440+function cardString(template, components, isCardTool, artShapeStyle, categoryLayout) {
441 var code;
441 var code;
442
442
443 var templateInteractive = (template == null ? true : (template["non-interactive"] !== undefined ? !template["non-interactive"] : true)) ? "true" : "false";
443 var templateInteractive = (template == null ? true : (template["non-interactive"] !== undefined ? !template["non-interactive"] : true)) ? "true" : "false";
@@ -943,29 +943,33 @@ function cardString(template, components, isCardTool, artShapeStyle) {
943 code += kTouchdownCode.arg(touchdownAnchors);
943 code += kTouchdownCode.arg(touchdownAnchors);
944 }
944 }
945
945
946+ if (isCardTool || categoryLayout !== "grid") {
946− var implicitHeight = 'implicitHeight: ';
947+ var implicitHeight = 'implicitHeight: ';
947− if (hasSocialActions) {
948+ if (hasSocialActions) {
948− implicitHeight += 'socialActionsRow.y + socialActionsRow.height + units.gu(1);\n';
949+ implicitHeight += 'socialActionsRow.y + socialActionsRow.height + units.gu(1);\n';
949− } else if (hasSummary) {
950+ } else if (hasSummary) {
950− implicitHeight += 'summary.y + summary.height + units.gu(1);\n';
951+ implicitHeight += 'summary.y + summary.height + units.gu(1);\n';
951− } else if (isAudio) {
952+ } else if (isAudio) {
952− implicitHeight += 'audioButton.height;\n';
953+ implicitHeight += 'audioButton.height;\n';
953− } else if (headerAsOverlay) {
954+ } else if (headerAsOverlay) {
954− implicitHeight += 'artShapeHolder.height;\n';
955+ implicitHeight += 'artShapeHolder.height;\n';
955− } else if (hasHeaderRow) {
956+ } else if (hasHeaderRow) {
956− implicitHeight += 'row.y + row.height + units.gu(1);\n';
957+ implicitHeight += 'row.y + row.height + units.gu(1);\n';
957− } else if (hasMascot) {
958+ } else if (hasMascot) {
958− implicitHeight += 'mascotImage.y + mascotImage.height;\n';
959+ implicitHeight += 'mascotImage.y + mascotImage.height;\n';
959− } else if (hasTitleContainer) {
960+ } else if (hasTitleContainer) {
960− implicitHeight += 'headerTitleContainer.y + headerTitleContainer.height + units.gu(1);\n';
961+ implicitHeight += 'headerTitleContainer.y + headerTitleContainer.height + units.gu(1);\n';
961− } else if (hasAttributes) {
962+ } else if (hasAttributes) {
962− implicitHeight += 'attributesRow.y + attributesRow.height + units.gu(1);\n';
963+ implicitHeight += 'attributesRow.y + attributesRow.height + units.gu(1);\n';
963− } else if (hasSubtitle) {
964+ } else if (hasSubtitle) {
964− implicitHeight += 'subtitleLabel.y + subtitleLabel.height + units.gu(1);\n';
965+ implicitHeight += 'subtitleLabel.y + subtitleLabel.height + units.gu(1);\n';
965− } else if (hasTitle) {
966+ } else if (hasTitle) {
966− implicitHeight += 'titleLabel.y + titleLabel.height + units.gu(1);\n';
967+ implicitHeight += 'titleLabel.y + titleLabel.height + units.gu(1);\n';
967− } else if (hasArt) {
968+ } else if (hasArt) {
968− implicitHeight += 'artShapeHolder.height;\n';
969+ implicitHeight += 'artShapeHolder.height;\n';
970+ } else {
971+ implicitHeight = '';
972+ }
969 } else {
973 } else {
970 implicitHeight = '';
974 implicitHeight = '';
971 }
975 }
@@ -976,13 +980,13 @@ function cardString(template, components, isCardTool, artShapeStyle) {
976 return code;
980 return code;
977}
981}
978
982
979−function createCardComponent(parent, template, components, isCardTool, artShapeStyle, identifier) {
983+function createCardComponent(parent, template, components, isCardTool, artShapeStyle, categoryLayout, identifier) {
980 var imports = 'import QtQuick 2.4; \n\
984 var imports = 'import QtQuick 2.4; \n\
981 import Ubuntu.Components 1.3; \n\
985 import Ubuntu.Components 1.3; \n\
982 import Ubuntu.Settings.Components 0.1; \n\
986 import Ubuntu.Settings.Components 0.1; \n\
983 import Dash 0.1;\n\
987 import Dash 0.1;\n\
984 import Utils 0.1;\n';
988 import Utils 0.1;\n';
985− var card = cardString(template, components, isCardTool, artShapeStyle);
989+ var card = cardString(template, components, isCardTool, artShapeStyle, categoryLayout);
986 var code = imports + 'Component {\n' + card + '}\n';
990 var code = imports + 'Component {\n' + card + '}\n';
987
991
988 try {
992 try {
plugins/Dash/CardCreatorCache.qml+3−3
@@ -23,16 +23,16 @@ QtObject {
23
23
24 property var cache: new Object();
24 property var cache: new Object();
25
25
26− function getCardComponent(template, components, isCardTool, artShapeStyle) {
26+ function getCardComponent(template, components, isCardTool, artShapeStyle, categoryLayout) {
27 if (template === undefined || components === undefined)
27 if (template === undefined || components === undefined)
28 return undefined;
28 return undefined;
29
29
30 var tString = JSON.stringify(template);
30 var tString = JSON.stringify(template);
31 var cString = JSON.stringify(components);
31 var cString = JSON.stringify(components);
32− var allString = tString + cString + isCardTool + artShapeStyle;
32+ var allString = tString + cString + isCardTool + artShapeStyle + categoryLayout;
33 var component = cache[allString];
33 var component = cache[allString];
34 if (component === undefined) {
34 if (component === undefined) {
35− component = CardCreator.createCardComponent(root, template, components, isCardTool, artShapeStyle, allString);
35+ component = CardCreator.createCardComponent(root, template, components, isCardTool, artShapeStyle, categoryLayout, allString);
36 cache[allString] = component;
36 cache[allString] = component;
37 }
37 }
38 return component;
38 return component;
qml/Dash/CardTool.qml+2−2
@@ -71,7 +71,7 @@ Item {
71 // Not readonly because gets overwritten from GenericScopeView in some cases
71 // Not readonly because gets overwritten from GenericScopeView in some cases
72 property string artShapeStyle: categoryLayout === "carousel" ? "shadow" : "inset"
72 property string artShapeStyle: categoryLayout === "carousel" ? "shadow" : "inset"
73
73
74− property var cardComponent: CardCreatorCache.getCardComponent(cardTool.template, cardTool.components, false, cardTool.artShapeStyle);
74+ property var cardComponent: CardCreatorCache.getCardComponent(cardTool.template, cardTool.components, false, cardTool.artShapeStyle, cardTool.categoryLayout);
75
75
76 // FIXME: Saviq
76 // FIXME: Saviq
77 // Only way for the card below to actually be laid out completely.
77 // Only way for the card below to actually be laid out completely.
@@ -213,7 +213,7 @@ Item {
213 "attributes": attributesModel.model,
213 "attributes": attributesModel.model,
214 "socialActions": socialActionsModel.model
214 "socialActions": socialActionsModel.model
215 }
215 }
216− sourceComponent: CardCreatorCache.getCardComponent(cardTool.template, cardTool.components, true, cardTool.artShapeStyle);
216+ sourceComponent: CardCreatorCache.getCardComponent(cardTool.template, cardTool.components, true, cardTool.artShapeStyle, cardTool.categoryLayout);
217 onLoaded: {
217 onLoaded: {
218 item.objectName = "cardToolCard";
218 item.objectName = "cardToolCard";
219 item.width = Qt.binding(function() { return cardTool.cardWidth !== -1 ? cardTool.cardWidth : item.implicitWidth; });
219 item.width = Qt.binding(function() { return cardTool.cardWidth !== -1 ? cardTool.cardWidth : item.implicitWidth; });