on xenial help sign in
Add colorisation
commit4f7b8e0f41229a28212df8e648e140d514a11429 authorAndrea Cimitan <andrea.cimitan@gmail.com> dateFri 8 Aug 2014, 17:52 (12 years ago) parent4439914
4 files changed+21−19
plugins/Dash/CardCreator.js+11−9 tests/plugins/Dash/cardcreator/6.res+6−6 tests/qmltests/Dash/artwork/emblem.png tests/qmltests/Dash/tst_Card.qml+4−4
plugins/Dash/CardCreator.js+11−9
@@ -224,19 +224,20 @@ var kTitleLabelCode = 'Label { \n\
224224 horizontalAlignment: root.headerAlignment; \n\
225225 }\n';
226226
227−// %1 is used as extra anchors of emblemImage
228−var kEmblemImageCode = 'Image { \n\
229− id: emblemImage; \n\
230− objectName: "emblemImage"; \n\
227+// %1 is used as extra anchors of emblemIcon
228+// %2 is used as color of emblemIcon
229+var kEmblemIconCode = 'Icon { \n\
230+ id: emblemIcon; \n\
231+ objectName: "emblemIcon"; \n\
231232 anchors { \n\
232233 bottom: titleLabel.baseline; \n\
233234 right: parent.right; \n\
234235 %1
235236 } \n\
236237 source: cardData && cardData["emblem"] || ""; \n\
238+ color: %2; \n\
237239 width: height; \n\
238240 height: status === Image.Ready ? titleLabel.font.pixelSize : 0; \n\
239− fillMode: Image.PreserveAspectFit; \n\
240241 }\n';
241242
242243// %1 is used as anchors of touchdown effect
@@ -267,6 +268,7 @@ var kSubtitleLabelCode = 'Label { \n\
267268 }\n';
268269
269270// %1 is used as anchors of attributesRow
271+// %2 is used as color of attributesRow
270272var kAttributesRowCode = 'CardAttributes { \n\
271273 id: attributesRow; \n\
272274 objectName: "attributesRow"; \n\
@@ -477,8 +479,8 @@ function cardString(template, components) {
477479 }
478480 }
479481 if (hasEmblem) {
480− titleRightAnchor = 'right: emblemImage.left; \n\
481− rightMargin: emblemImage.width > 0 ? units.gu(0.5) : 0; \n';
482+ titleRightAnchor = 'right: emblemIcon.left; \n\
483+ rightMargin: emblemIcon.width > 0 ? units.gu(0.5) : 0; \n';
482484 } else {
483485 titleRightAnchor = 'right: parent.right; \n'
484486 titleRightAnchor += extraRightAnchor;
@@ -552,7 +554,7 @@ function cardString(template, components) {
552554 containerHeight += ' + subtitleLabel.height';
553555 }
554556 if (hasEmblem) {
555− containerCode.push(kEmblemImageCode.arg(extraRightAnchor));
557+ containerCode.push(kEmblemIconCode.arg(extraRightAnchor).arg(titleColor));
556558 }
557559 if (hasAttributes) {
558560 attributesCode = kAttributesRowCode.arg(attributesAnchors).arg(titleColor);
@@ -646,7 +648,7 @@ function cardString(template, components) {
646648
647649function createCardComponent(parent, template, components) {
648650 var imports = 'import QtQuick 2.2; \n\
649− import Ubuntu.Components 0.1; \n\
651+ import Ubuntu.Components 1.1; \n\
650652 import Dash 0.1;\n';
651653 var card = cardString(template, components);
652654 var code = imports + 'Component {\n' + card + '}\n';
tests/plugins/Dash/cardcreator/6.res+6−6
@@ -61,8 +61,8 @@ Item {
6161 Label {
6262 id: titleLabel;
6363 objectName: "titleLabel";
64− anchors { right: emblemImage.left;
65− rightMargin: emblemImage.width > 0 ? units.gu(0.5) : 0;
64+ anchors { right: emblemIcon.left;
65+ rightMargin: emblemIcon.width > 0 ? units.gu(0.5) : 0;
6666 left: parent.left;
6767 top: parent.top; }
6868 elide: Text.ElideRight;
@@ -94,18 +94,18 @@ Item {
9494 font.weight: Font.Light;
9595 horizontalAlignment: root.headerAlignment;
9696 }
97−,Image {
98− id: emblemImage;
99− objectName: "emblemImage";
97+,Icon {
98+ id: emblemIcon;
99+ objectName: "emblemIcon";
100100 anchors {
101101 bottom: titleLabel.baseline;
102102 right: parent.right;
103103 rightMargin: units.gu(1);
104104 }
105105 source: cardData && cardData["emblem"] || "";
106+ color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < (root.scopeStyle ? root.scopeStyle.threshold : 0.7) ? (root.scopeStyle ? root.scopeStyle.light : "white") : (root.scopeStyle ? root.scopeStyle.dark : "grey");
106107 width: height;
107108 height: status === Image.Ready ? titleLabel.font.pixelSize : 0;
108− fillMode: Image.PreserveAspectFit;
109109 }
110110
111111 ]
tests/qmltests/Dash/artwork/emblem.png

Binary file not shown.

tests/qmltests/Dash/tst_Card.qml+4−4
@@ -459,7 +459,7 @@ Rectangle {
459459 tryCompareFunction(function() { return Qt.colorEqual(subtitle.color, fontColor); }, true);
460460 }
461461
462− function test_emblemImage_data() {
462+ function test_emblemIcon_data() {
463463 return [
464464 { tag: "Art and summary", emblem: true, index: 0 },
465465 { tag: "Art and summary, small", emblem: false, index: 1 },
@@ -468,12 +468,12 @@ Rectangle {
468468 ];
469469 }
470470
471− function test_emblemImage(data) {
471+ function test_emblemIcon(data) {
472472 selector.selectedIndex = data.index;
473473 waitForRendering(card);
474474
475− var emblemImage = findChild(card, "emblemImage");
476− compare(emblemImage !== null, data.emblem);
475+ var emblemIcon = findChild(card, "emblemIcon");
476+ compare(emblemIcon !== null, data.emblem);
477477 }
478478
479479 function test_mascotShape_data() {