on xenial help sign in
Do not create subtitle if not needed
57e3f5eAlbert Astals
qml/Dash/CardHeader.qml+13−10
@@ -21,7 +21,7 @@ Item {
21 id: root
21 id: root
22 property alias mascot: mascotImage.source
22 property alias mascot: mascotImage.source
23 property alias title: titleLabel.text
23 property alias title: titleLabel.text
24− property alias subtitle: subtitleLabel.text
24+ property var subtitle
25
25
26 property alias titleWeight: titleLabel.font.weight
26 property alias titleWeight: titleLabel.font.weight
27 property alias titleSize: titleLabel.fontSize
27 property alias titleSize: titleLabel.fontSize
@@ -103,16 +103,19 @@ Item {
103 color: fontColor
103 color: fontColor
104 }
104 }
105
105
106− Label {
106+ Loader {
107− id: subtitleLabel
107+ active: titleLabel.text && root.subtitle
108− objectName: "subtitleLabel"
109 anchors { left: parent.left; right: parent.right }
108 anchors { left: parent.left; right: parent.right }
109+ sourceComponent: Label {
110+ id: subtitleLabel
111+ objectName: "subtitleLabel"
110− elide: Text.ElideRight
112+ elide: Text.ElideRight
111− fontSize: "small"
113+ fontSize: "small"
112− font.weight: Font.Light
114+ font.weight: Font.Light
113− visible: titleLabel.text && text
114− font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale)
115+ font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale)
115− color: fontColor
116+ color: fontColor
117+ text: root.subtitle
118+ }
116 }
119 }
117 }
120 }
118 }
121 }