From bf962f06d3f177267dc42f4657be7199b399ea45 Mon Sep 17 00:00:00 2001 From: fredrik Date: Wed, 23 Oct 2024 11:40:30 +0200 Subject: [PATCH] fix: center labels based on screen width and not progress width --- src/ui/toolbar/MainToolBar.qml | 49 ++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/src/ui/toolbar/MainToolBar.qml b/src/ui/toolbar/MainToolBar.qml index b10523c51306..2d890253247b 100644 --- a/src/ui/toolbar/MainToolBar.qml +++ b/src/ui/toolbar/MainToolBar.qml @@ -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 @@ -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 @@ -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 {