Skip to content

Commit

Permalink
move locationDistanceLabel into listview header
Browse files Browse the repository at this point in the history
computing of content heigh is no longer a mess
  • Loading branch information
janbar committed Nov 4, 2023
1 parent b5aac87 commit e675ce0
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions gui/controls2_515/LocationInfo.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit e675ce0

Please sign in to comment.