on xenial help sign in
Fix emblem code and padding
commit4984c8538776ad1550f955e88ac8cc7928b26105 authorAndrea Cimitan <andrea.cimitan@gmail.com> dateTue 29 Jul 2014, 14:53 (12 years ago) parentfdf1d13
2 files changed+14−3
plugins/Dash/CardCreator.js+14−3 tests/qmltests/Dash/artwork/emblem.png
plugins/Dash/CardCreator.js+14−3
@@ -262,12 +262,14 @@ var kTitleLabelCode = 'Label { \n\
262262 horizontalAlignment: root.headerAlignment; \n\
263263 }\n';
264264
265+// %1 is used as additional anchors of emblem image
265266var kEmblemImageCode = 'Image { \n\
266267 id: emblemImage; \n\
267268 objectName: "emblemImage"; \n\
268269 anchors { \n\
269270 bottom: titleLabel.baseline; \n\
270− right: parent.right; \n\ } \n\
271+ right: parent.right; \n\
272+ %1 } \n\
271273 source: cardData && cardData["emblem"]; \n\
272274 width: height; \n\
273275 height: titleLabel.font.pixelSize; \n\
@@ -478,6 +480,9 @@ function cardString(template, components) {
478480 titleContainerAnchors = 'right: parent.right; ';
479481 titleContainerAnchors += headerLeftAnchor;
480482 titleContainerAnchors += headerVerticalAnchors;
483+ if (!headerLeftAnchorHasMargin) {
484+ titleContainerAnchors += 'leftMargin: units.gu(1);\n';
485+ }
481486 }
482487 if (hasEmblem) {
483488 titleRightAnchor = 'right: emblemImage.left;\n';
@@ -532,12 +537,18 @@ function cardString(template, components) {
532537 subtitleCode += kSubtitleLabelCode.arg(subtitleAnchors).arg(color);
533538 }
534539
540+ var emblemCode;
541+ if (hasMascot) {
542+ emblemCode = kEmblemImageCode.arg('');
543+ } else {
544+ emblemCode = kEmblemImageCode.arg('rightMargin: units.gu(1);');
545+ }
535546 if (hasEmblem && hasSubtitle) {
536547 // 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));
538549 } else if (hasEmblem) {
539550 // 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);
541552 } else if (hasMascot && hasSubtitle) {
542553 // container with subtitle
543554 titleSubtitleCode = kHeader2ContainerCode.arg(titleContainerAnchors).arg('titleLabel.height + subtitleLabel.height').arg(titleCode).arg(subtitleCode);
tests/qmltests/Dash/artwork/emblem.pngnew file

Binary file not shown.