on xenial help sign in
Fix emblem code and padding
4984c85Andrea Cimitan
plugins/Dash/CardCreator.js+14−3
@@ -262,12 +262,14 @@ var kTitleLabelCode = 'Label { \n\
262 horizontalAlignment: root.headerAlignment; \n\
262 horizontalAlignment: root.headerAlignment; \n\
263 }\n';
263 }\n';
264
264
265+// %1 is used as additional anchors of emblem image
265var kEmblemImageCode = 'Image { \n\
266var kEmblemImageCode = 'Image { \n\
266 id: emblemImage; \n\
267 id: emblemImage; \n\
267 objectName: "emblemImage"; \n\
268 objectName: "emblemImage"; \n\
268 anchors { \n\
269 anchors { \n\
269 bottom: titleLabel.baseline; \n\
270 bottom: titleLabel.baseline; \n\
270− right: parent.right; \n\ } \n\
271+ right: parent.right; \n\
272+ %1 } \n\
271 source: cardData && cardData["emblem"]; \n\
273 source: cardData && cardData["emblem"]; \n\
272 width: height; \n\
274 width: height; \n\
273 height: titleLabel.font.pixelSize; \n\
275 height: titleLabel.font.pixelSize; \n\
@@ -478,6 +480,9 @@ function cardString(template, components) {
478 titleContainerAnchors = 'right: parent.right; ';
480 titleContainerAnchors = 'right: parent.right; ';
479 titleContainerAnchors += headerLeftAnchor;
481 titleContainerAnchors += headerLeftAnchor;
480 titleContainerAnchors += headerVerticalAnchors;
482 titleContainerAnchors += headerVerticalAnchors;
483+ if (!headerLeftAnchorHasMargin) {
484+ titleContainerAnchors += 'leftMargin: units.gu(1);\n';
485+ }
481 }
486 }
482 if (hasEmblem) {
487 if (hasEmblem) {
483 titleRightAnchor = 'right: emblemImage.left;\n';
488 titleRightAnchor = 'right: emblemImage.left;\n';
@@ -532,12 +537,18 @@ function cardString(template, components) {
532 subtitleCode += kSubtitleLabelCode.arg(subtitleAnchors).arg(color);
537 subtitleCode += kSubtitleLabelCode.arg(subtitleAnchors).arg(color);
533 }
538 }
534
539
540+ var emblemCode;
541+ if (hasMascot) {
542+ emblemCode = kEmblemImageCode.arg('');
543+ } else {
544+ emblemCode = kEmblemImageCode.arg('rightMargin: units.gu(1);');
545+ }
535 if (hasEmblem && hasSubtitle) {
546 if (hasEmblem && hasSubtitle) {
536 // using container 3
547 // using container 3
537− titleSubtitleCode = kHeader3ContainerCode.arg(titleContainerAnchors).arg(titleCode).arg(kEmblemImageCode).arg(kSubtitleLabelCode.arg(subtitleAnchors).arg(color));
548+ titleSubtitleCode = kHeader3ContainerCode.arg(titleContainerAnchors).arg(titleCode).arg(emblemCode).arg(kSubtitleLabelCode.arg(subtitleAnchors).arg(color));
538 } else if (hasEmblem) {
549 } else if (hasEmblem) {
539 // container with emblem
550 // container with emblem
540− titleSubtitleCode = kHeader2ContainerCode.arg(titleContainerAnchors).arg('titleLabel.height').arg(titleCode).arg(kEmblemImageCode);
551+ titleSubtitleCode = kHeader2ContainerCode.arg(titleContainerAnchors).arg('titleLabel.height').arg(titleCode).arg(emblemCode);
541 } else if (hasMascot && hasSubtitle) {
552 } else if (hasMascot && hasSubtitle) {
542 // container with subtitle
553 // container with subtitle
543 titleSubtitleCode = kHeader2ContainerCode.arg(titleContainerAnchors).arg('titleLabel.height + subtitleLabel.height').arg(titleCode).arg(subtitleCode);
554 titleSubtitleCode = kHeader2ContainerCode.arg(titleContainerAnchors).arg('titleLabel.height + subtitleLabel.height').arg(titleCode).arg(subtitleCode);
tests/qmltests/Dash/artwork/emblem.pngnew file

Binary file not shown.