on xenial help sign in
move the code that sets headerHeight a bit

Makes it easier to understand and also allows me to add the final else

commitfd487f22158985413144c65def825d9932efb875 authorAlbert Astals <albert.astals@canonical.com> dateTue 6 May 2014, 10:34 (12 years ago) parent4201b33
1 file changed+8−8
plugins/Dash/CardCreator.js+8−8
plugins/Dash/CardCreator.js+8−8
@@ -222,6 +222,14 @@ function cardString(template, components) {
222222 ' + headerLeftAnchor + '\
223223 anchors.right: parent.right; \
224224 anchors.margins: margins;';
225+ } else if (hasMascot) {
226+ code += 'readonly property int headerHeight: mascotImage.height + units.gu(1) * 2;'
227+ } else if (hasSubtitle) {
228+ code += 'readonly property int headerHeight: subtitleLabel.y + subtitleLabel.height - titleLabel.y + titleLabel.anchors.topMargin * 2 + subtitleLabel.anchors.topMargin;'
229+ } else if (hasTitle) {
230+ code += 'readonly property int headerHeight: titleLabel.height + titleLabel.anchors.topMargin * 2;'
231+ } else {
232+ code += 'readonly property int headerHeight: 0;'
225233 }
226234
227235 if (hasMascot) {
@@ -231,7 +239,6 @@ function cardString(template, components) {
231239 anchors += headerLeftAnchor;
232240 anchors += 'anchors.leftMargin: units.gu(1);'
233241 anchors += headerVerticalAnchors;
234− code += 'readonly property int headerHeight: mascotImage.height + units.gu(1) * 2;'
235242 } else {
236243 anchors = "anchors.verticalCenter: parent.verticalCenter;"
237244 }
@@ -317,13 +324,6 @@ function cardString(template, components) {
317324 anchors.top: titleLabel.bottom; \
318325 anchors.topMargin: units.dp(2);';
319326 }
320− if (!hasHeaderRow) {
321− if (hasSubtitle) {
322− code += 'readonly property int headerHeight: subtitleLabel.y + subtitleLabel.height - titleLabel.y + titleLabel.anchors.topMargin * 2 + subtitleLabel.anchors.topMargin;'
323− } else {
324− code += 'readonly property int headerHeight: titleLabel.height + titleLabel.anchors.topMargin * 2;'
325− }
326− }
327327
328328 code += 'Label { \
329329 id: titleLabel; \