on xenial help sign in
Preserve the aspect ratio for the card attribute images
e26c2d6Albert Astals Cid
plugins/Dash/CardAttributes.qml+2
@@ -49,6 +49,8 @@ GridLayout {
49 Icon {
49 Icon {
50 id: icon
50 id: icon
51 height: units.gu(2)
51 height: units.gu(2)
52+ // FIXME Workaround for bug https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1421293
53+ width: implicitWidth > 0 && implicitHeight > 0 ? (implicitWidth / implicitHeight * height) : implicitWidth
52 source: "icon" in modelData && modelData["icon"] || ""
54 source: "icon" in modelData && modelData["icon"] || ""
53 color: grid.color
55 color: grid.color
54 }
56 }
plugins/Dash/CardCreator.js+3
@@ -224,6 +224,8 @@ var kTitleLabelCode = 'Label { \n\
224
224
225// %1 is used as extra anchors of emblemIcon
225// %1 is used as extra anchors of emblemIcon
226// %2 is used as color of emblemIcon
226// %2 is used as color of emblemIcon
227+// FIXME The width code is a
228+// Workaround for bug https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1421293
227var kEmblemIconCode = 'Icon { \n\
229var kEmblemIconCode = 'Icon { \n\
228 id: emblemIcon; \n\
230 id: emblemIcon; \n\
229 objectName: "emblemIcon"; \n\
231 objectName: "emblemIcon"; \n\
@@ -235,6 +237,7 @@ var kEmblemIconCode = 'Icon { \n\
235 source: cardData && cardData["emblem"] || ""; \n\
237 source: cardData && cardData["emblem"] || ""; \n\
236 color: %2; \n\
238 color: %2; \n\
237 height: source != "" ? titleLabel.font.pixelSize : 0; \n\
239 height: source != "" ? titleLabel.font.pixelSize : 0; \n\
240+ width: implicitWidth > 0 && implicitHeight > 0 ? (implicitWidth / implicitHeight * height) : implicitWidth; \n\
238 }\n';
241 }\n';
239
242
240// %1 is used as anchors of touchdown effect
243// %1 is used as anchors of touchdown effect
qml/Panel/IndicatorItem.qml+2
@@ -95,6 +95,8 @@ IndicatorDelegate {
95 id: itemImage
95 id: itemImage
96 objectName: "icon"+index
96 objectName: "icon"+index
97 height: iconHeight
97 height: iconHeight
98+ // FIXME Workaround for bug https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1421293
99+ width: implicitWidth > 0 && implicitHeight > 0 ? (implicitWidth / implicitHeight * height) : implicitWidth;
98 source: modelData
100 source: modelData
99 color: root.color
101 color: root.color
100 Behavior on color { ColorAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing } }
102 Behavior on color { ColorAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing } }
tests/plugins/Dash/cardcreator/6.res+1
@@ -106,6 +106,7 @@ Item {
106 source: cardData && cardData["emblem"] || "";
106 source: cardData && cardData["emblem"] || "";
107 color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
107 color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
108 height: source != "" ? titleLabel.font.pixelSize : 0;
108 height: source != "" ? titleLabel.font.pixelSize : 0;
109+ width: implicitWidth > 0 && implicitHeight > 0 ? (implicitWidth / implicitHeight * height) : implicitWidth;
109 }
110 }
110
111
111 ]
112 ]