From e675ce08ce925acc47d91fe2c4afa5bd754e1f89 Mon Sep 17 00:00:00 2001 From: janbar Date: Sat, 4 Nov 2023 17:07:59 +0100 Subject: [PATCH] move locationDistanceLabel into listview header computing of content heigh is no longer a mess --- gui/controls2_515/LocationInfo.qml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/gui/controls2_515/LocationInfo.qml b/gui/controls2_515/LocationInfo.qml index 04e34d88..3062569f 100644 --- a/gui/controls2_515/LocationInfo.qml +++ b/gui/controls2_515/LocationInfo.qml @@ -74,19 +74,6 @@ PopOver { id: locationInfoBody spacing: units.gu(1) - Label { - id: locationDistanceLabel - text: locationInfoModel.distance(sourceLat, sourceLon, placeLat, placeLon) < 5 ? - qsTr("You are here") : - qsTr("%1 %2 from you") - .arg(Converter.readableDistance(locationInfoModel.distance(sourceLat, sourceLon, placeLat, placeLon))) - .arg(Converter.readableBearing(locationInfoModel.bearing(sourceLat, sourceLon, placeLat, placeLon))) - - color: styleMap.popover.highlightedColor - font.pointSize: units.fs("small") - visible: sourceValid - } - ListView { id: locationInfoView width: parent.width @@ -96,14 +83,27 @@ PopOver { model: locationInfoModel onCountChanged: { - var h = (locationDistanceLabel.visible ? locationDistanceLabel.implicitHeight : 0) + locationInfoBody.spacing + - locationInfoView.contentHeight + locationInfoView.spacing * locationInfoView.count; + var h = locationInfoView.contentHeight + locationInfoView.spacing; resizeBox(h); } opacity: locationInfoModel.ready ? 1.0 : 0.0 Behavior on opacity { NumberAnimation {} } + header: Label { + id: locationDistanceLabel + text: locationInfoModel.distance(sourceLat, sourceLon, placeLat, placeLon) < 5 ? + qsTr("You are here") : + qsTr("%1 %2 from you") + .arg(Converter.readableDistance(locationInfoModel.distance(sourceLat, sourceLon, placeLat, placeLon))) + .arg(Converter.readableBearing(locationInfoModel.bearing(sourceLat, sourceLon, placeLat, placeLon))) + + color: styleMap.popover.highlightedColor + font.pointSize: units.fs("small") + bottomPadding: locationInfoView.spacing + visible: sourceValid + } + delegate: Column { spacing: 0