on xenial help sign in
Preserve the aspect ratio for the card attribute images

Fixes: #1411751 Approved by: Michał Sawicz, Andrea Cimitan

commite26c2d6052b344b4f1b0c32406a1cc725d92b268 authorAlbert Astals Cid <albert.astals@canonical.com> dateTue 24 Feb 2015, 10:15 (12 years ago) parentaf668d5915ceea
4 files changed+8
plugins/Dash/CardAttributes.qml+2 plugins/Dash/CardCreator.js+3 qml/Panel/IndicatorItem.qml+2 tests/plugins/Dash/cardcreator/6.res+1
plugins/Dash/CardAttributes.qml+2
@@ -49,6 +49,8 @@ GridLayout {
4949 Icon {
5050 id: icon
5151 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
5254 source: "icon" in modelData && modelData["icon"] || ""
5355 color: grid.color
5456 }
plugins/Dash/CardCreator.js+3
@@ -224,6 +224,8 @@ var kTitleLabelCode = 'Label { \n\
224224
225225// %1 is used as extra anchors of emblemIcon
226226// %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
227229var kEmblemIconCode = 'Icon { \n\
228230 id: emblemIcon; \n\
229231 objectName: "emblemIcon"; \n\
@@ -235,6 +237,7 @@ var kEmblemIconCode = 'Icon { \n\
235237 source: cardData && cardData["emblem"] || ""; \n\
236238 color: %2; \n\
237239 height: source != "" ? titleLabel.font.pixelSize : 0; \n\
240+ width: implicitWidth > 0 && implicitHeight > 0 ? (implicitWidth / implicitHeight * height) : implicitWidth; \n\
238241 }\n';
239242
240243// %1 is used as anchors of touchdown effect
qml/Panel/IndicatorItem.qml+2
@@ -95,6 +95,8 @@ IndicatorDelegate {
9595 id: itemImage
9696 objectName: "icon"+index
9797 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;
98100 source: modelData
99101 color: root.color
100102 Behavior on color { ColorAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing } }
tests/plugins/Dash/cardcreator/6.res+1
@@ -106,6 +106,7 @@ Item {
106106 source: cardData && cardData["emblem"] || "";
107107 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");
108108 height: source != "" ? titleLabel.font.pixelSize : 0;
109+ width: implicitWidth > 0 && implicitHeight > 0 ? (implicitWidth / implicitHeight * height) : implicitWidth;
109110 }
110111
111112 ]