on xenial help sign in
Fix anchors/non-subtitles.
commit647d737ec1ddbde67ce955e6e1d543217ee71eb3 authorYing-Chun Liu <paul.liu@canonical.com> dateWed 23 Jul 2014, 23:03 (12 years ago) parent07ce507
2 files changed+16−5
plugins/Dash/CardAttributes.qml+2 plugins/Dash/CardCreator.js+14−5
plugins/Dash/CardAttributes.qml+2
@@ -54,6 +54,8 @@ GridLayout {
5454 elide: Text.ElideRight
5555 maximumLineCount: 1
5656 font.weight: "style" in modelData && modelData["style"] == "highlighted" ? Font.DemiBold : Font.Light
57+ fontSize: "small"
58+ font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale)
5759 }
5860 }
5961 }
plugins/Dash/CardCreator.js+14−5
@@ -402,7 +402,7 @@ function cardString(template, components) {
402402 } else if (hasMascot) {
403403 code += 'readonly property int headerHeight: mascotImage.height;\n'
404404 } else if (hasAttributes) {
405− if (hasSubtitle) {
405+ if (hasTitle && hasSubtitle) {
406406 code += 'readonly property int headerHeight: titleLabel.height + titleLabel.anchors.topMargin + subtitleLabel.height + subtitleLabel.anchors.topMargin + attributesRow.height + attributesRow.anchors.topMargin;\n'
407407 } else if (hasTitle) {
408408 code += 'readonly property int headerHeight: titleLabel.height + titleLabel.anchors.topMargin + attributesRow.height + attributesRow.anchors.topMargin;\n'
@@ -458,7 +458,7 @@ function cardString(template, components) {
458458 var titleAnchors;
459459 var subtitleAnchors;
460460 var attributesAnchors;
461− if (hasMascot && hasSubtitle) {
461+ if (hasMascot && (hasSubtitle || hasAttributes)) {
462462 // Using row + column
463463 titleAnchors = 'left: parent.left; right: parent.right';
464464 subtitleAnchors = titleAnchors;
@@ -506,15 +506,23 @@ function cardString(template, components) {
506506 subtitleCode += kSubtitleLabelCode.arg(subtitleAnchors).arg(color);
507507 }
508508
509− if (hasMascot && hasSubtitle) {
509+ if (hasMascot && (hasSubtitle || hasAttributes)) {
510510 // If using row + column wrap the code in the column
511511 titleSubtitleCode = kHeaderColumnCode.arg(titleCode).arg(subtitleCode);
512− if (hasAttributes) {
512+ if (hasSubtitle && hasAttributes) {
513513 var attributesCode = kAttributesRowCode.arg(attributesAnchors);
514514 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);
515520 }
516521 } else {
517− titleSubtitleCode = titleCode + subtitleCode;
522+ titleSubtitleCode = titleCode;
523+ if (hasSubtitle) {
524+ titleSubtitleCode = titleSubtitleCode + subtitleCode;
525+ }
518526 if (hasAttributes) {
519527 var attributesCode = kAttributesRowCode.arg(attributesAnchors);
520528 titleSubtitleCode = titleSubtitleCode + attributesCode;
@@ -581,5 +589,6 @@ function createCardComponent(parent, template, components) {
581589 import Dash 0.1;\n';
582590 var card = cardString(template, components);
583591 var code = imports + 'Component {\n' + card + '}\n';
592+
584593 return Qt.createQmlObject(code, parent, "createCardComponent");
585594}