Skip to content

Commit

Permalink
fix: center labels based on screen width and not progress width
Browse files Browse the repository at this point in the history
  • Loading branch information
Fredrikbjornland committed Oct 23, 2024
1 parent 3e24f77 commit bf962f0
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions src/ui/toolbar/MainToolBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,11 @@ Rectangle {

// Geofence download progress
Rectangle {
id: geoFenceProgressBar
height: parent.height / 2
color: qgcPal.colorBlue
width: _geoFenceControllerProgressPct * parent.width
visible: _geoFenceControllerProgressPct > 0 && _geoFenceControllerProgressPct < 1 &&

QGCLabel {
anchors.centerIn: parent
text: qsTr("Geofence Downloading: %1%").arg(Math.round(_geoFenceControllerProgressPct * 100))
font.pointSize: ScreenTools.defaultFontPointSize
}
visible: _geoFenceControllerProgressPct > 0 && _geoFenceControllerProgressPct < 1
}

// Rally point download progress
Expand All @@ -241,12 +236,6 @@ Rectangle {
color: qgcPal.colorBlue
width: _rallyPointControllerProgressPct * parent.width
visible: _rallyPointControllerProgressPct > 0 && _rallyPointControllerProgressPct < 1

QGCLabel {
anchors.centerIn: parent
text: qsTr("Rally point Downloading: %1%").arg(Math.round(_rallyPointControllerProgressPct * 100))
font.pointSize: ScreenTools.defaultFontPointSize
}
}

// Mission download progress
Expand All @@ -255,26 +244,40 @@ Rectangle {
color: qgcPal.colorBlue
width: _missionControllerProgressPct * parent.width
visible: _missionControllerProgressPct > 0 && _missionControllerProgressPct < 1

QGCLabel {
anchors.centerIn: parent
text: qsTr("Mission Downloading: %1%").arg(Math.round(_missionControllerProgressPct * 100))
font.pointSize: ScreenTools.defaultFontPointSize
}
}

// Parameter download progress
Rectangle {
id: parameterProgressBar
height: parent.height / 2
y: parent.height / 2
color: qgcPal.colorBlue
width: _activeVehicle ? _activeVehicle.loadProgress * parent.width : 0
}

QGCLabel {
anchors.centerIn: parent
text: qsTr("Parameter Downloading: %1%").arg(Math.round((_activeVehicle ? _activeVehicle.loadProgress : 0) * 100))
font.pointSize: ScreenTools.defaultFontPointSize
QGCLabel {
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: geoFenceProgressBar.verticalCenter
text: {
if (_geoFenceControllerProgressPct > 0 && _geoFenceControllerProgressPct < 1) {
return qsTr("Geofence Downloading: %1%").arg(Math.round(_geoFenceControllerProgressPct * 100))
} else if (_rallyPointControllerProgressPct > 0 && _rallyPointControllerProgressPct < 1) {
return qsTr("Rally point Downloading: %1%").arg(Math.round(_rallyPointControllerProgressPct * 100))
} else if (_missionControllerProgressPct > 0 && _missionControllerProgressPct < 1) {
return qsTr("Mission Downloading: %1%").arg(Math.round(_missionControllerProgressPct * 100))
} else {
return ""
}
}
font.pointSize: ScreenTools.defaultFontPointSize
}

// Label for parameter downloading
QGCLabel {
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parameterProgressBar.verticalCenter
text: qsTr("Parameter Downloading: %1%").arg(Math.round((_activeVehicle ? _activeVehicle.loadProgress : 0) * 100))
font.pointSize: ScreenTools.defaultFontPointSize
}

QGCLabel {
Expand Down

0 comments on commit bf962f0

Please sign in to comment.