on xenial help sign in
Fix anchors/non-subtitles.
647d737Ying-Chun Liu
plugins/Dash/CardAttributes.qml+2
@@ -54,6 +54,8 @@ GridLayout {
54 elide: Text.ElideRight
54 elide: Text.ElideRight
55 maximumLineCount: 1
55 maximumLineCount: 1
56 font.weight: "style" in modelData && modelData["style"] == "highlighted" ? Font.DemiBold : Font.Light
56 font.weight: "style" in modelData && modelData["style"] == "highlighted" ? Font.DemiBold : Font.Light
57+ fontSize: "small"
58+ font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale)
57 }
59 }
58 }
60 }
59 }
61 }
plugins/Dash/CardCreator.js+14−5
@@ -402,7 +402,7 @@ function cardString(template, components) {
402 } else if (hasMascot) {
402 } else if (hasMascot) {
403 code += 'readonly property int headerHeight: mascotImage.height;\n'
403 code += 'readonly property int headerHeight: mascotImage.height;\n'
404 } else if (hasAttributes) {
404 } else if (hasAttributes) {
405− if (hasSubtitle) {
405+ if (hasTitle && hasSubtitle) {
406 code += 'readonly property int headerHeight: titleLabel.height + titleLabel.anchors.topMargin + subtitleLabel.height + subtitleLabel.anchors.topMargin + attributesRow.height + attributesRow.anchors.topMargin;\n'
406 code += 'readonly property int headerHeight: titleLabel.height + titleLabel.anchors.topMargin + subtitleLabel.height + subtitleLabel.anchors.topMargin + attributesRow.height + attributesRow.anchors.topMargin;\n'
407 } else if (hasTitle) {
407 } else if (hasTitle) {
408 code += 'readonly property int headerHeight: titleLabel.height + titleLabel.anchors.topMargin + attributesRow.height + attributesRow.anchors.topMargin;\n'
408 code += 'readonly property int headerHeight: titleLabel.height + titleLabel.anchors.topMargin + attributesRow.height + attributesRow.anchors.topMargin;\n'
@@ -458,7 +458,7 @@ function cardString(template, components) {
458 var titleAnchors;
458 var titleAnchors;
459 var subtitleAnchors;
459 var subtitleAnchors;
460 var attributesAnchors;
460 var attributesAnchors;
461− if (hasMascot && hasSubtitle) {
461+ if (hasMascot && (hasSubtitle || hasAttributes)) {
462 // Using row + column
462 // Using row + column
463 titleAnchors = 'left: parent.left; right: parent.right';
463 titleAnchors = 'left: parent.left; right: parent.right';
464 subtitleAnchors = titleAnchors;
464 subtitleAnchors = titleAnchors;
@@ -506,15 +506,23 @@ function cardString(template, components) {
506 subtitleCode += kSubtitleLabelCode.arg(subtitleAnchors).arg(color);
506 subtitleCode += kSubtitleLabelCode.arg(subtitleAnchors).arg(color);
507 }
507 }
508
508
509− if (hasMascot && hasSubtitle) {
509+ if (hasMascot && (hasSubtitle || hasAttributes)) {
510 // If using row + column wrap the code in the column
510 // If using row + column wrap the code in the column
511 titleSubtitleCode = kHeaderColumnCode.arg(titleCode).arg(subtitleCode);
511 titleSubtitleCode = kHeaderColumnCode.arg(titleCode).arg(subtitleCode);
512− if (hasAttributes) {
512+ if (hasSubtitle && hasAttributes) {
513 var attributesCode = kAttributesRowCode.arg(attributesAnchors);
513 var attributesCode = kAttributesRowCode.arg(attributesAnchors);
514 titleSubtitleCode = kHeaderColumnCodeGenerator(titleCode, subtitleCode, attributesCode);
514 titleSubtitleCode = kHeaderColumnCodeGenerator(titleCode, subtitleCode, attributesCode);
515+ } else if (hasSubtitle) {
516+ titleSubtitleCode = kHeaderColumnCode.arg(titleCode).arg(subtitleCode);
517+ } else if (hasAttributes) {
518+ var attributesCode = kAttributesRowCode.arg(attributesAnchors);
519+ titleSubtitleCode = kHeaderColumnCode.arg(titleCode).arg(attributesCode);
515 }
520 }
516 } else {
521 } else {
517− titleSubtitleCode = titleCode + subtitleCode;
522+ titleSubtitleCode = titleCode;
523+ if (hasSubtitle) {
524+ titleSubtitleCode = titleSubtitleCode + subtitleCode;
525+ }
518 if (hasAttributes) {
526 if (hasAttributes) {
519 var attributesCode = kAttributesRowCode.arg(attributesAnchors);
527 var attributesCode = kAttributesRowCode.arg(attributesAnchors);
520 titleSubtitleCode = titleSubtitleCode + attributesCode;
528 titleSubtitleCode = titleSubtitleCode + attributesCode;
@@ -581,5 +589,6 @@ function createCardComponent(parent, template, components) {
581 import Dash 0.1;\n';
589 import Dash 0.1;\n';
582 var card = cardString(template, components);
590 var card = cardString(template, components);
583 var code = imports + 'Component {\n' + card + '}\n';
591 var code = imports + 'Component {\n' + card + '}\n';
592+
584 return Qt.createQmlObject(code, parent, "createCardComponent");
593 return Qt.createQmlObject(code, parent, "createCardComponent");
585}
594}