From 58b0f78d4ba2c7c1896cce230358a798e7cdc909 Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Tue, 21 May 2024 10:53:46 +0700 Subject: [PATCH 1/3] Add a couple of properties to the elevation profile canvas to style axis labels --- .../qgsquickelevationprofilecanvas.cpp | 54 +++++++++++++++++++ .../qgsquick/qgsquickelevationprofilecanvas.h | 43 ++++++++++++++- src/qml/ElevationProfile.qml | 9 ++-- 3 files changed, 101 insertions(+), 5 deletions(-) diff --git a/src/core/qgsquick/qgsquickelevationprofilecanvas.cpp b/src/core/qgsquick/qgsquickelevationprofilecanvas.cpp index ea276cdb0f..6a050a4958 100644 --- a/src/core/qgsquick/qgsquickelevationprofilecanvas.cpp +++ b/src/core/qgsquick/qgsquickelevationprofilecanvas.cpp @@ -171,6 +171,7 @@ QgsQuickElevationProfileCanvas::QgsQuickElevationProfileCanvas( QQuickItem *pare connect( mDeferredRedrawTimer, &QTimer::timeout, this, &QgsQuickElevationProfileCanvas::startDeferredRedraw ); mPlotItem = new QgsElevationProfilePlotItem( this ); + updateAxisLabelStyle(); setTransformOrigin( QQuickItem::TopLeft ); setFlags( QQuickItem::ItemHasContents ); @@ -726,6 +727,59 @@ void QgsQuickElevationProfileCanvas::setVisiblePlotRange( double minimumDistance refineResults(); } +QColor QgsQuickElevationProfileCanvas::axisLabelColor() const +{ + return mAxisLabelColor; +} + +void QgsQuickElevationProfileCanvas::setAxisLabelColor( const QColor &color ) +{ + if ( mAxisLabelColor == color ) + return; + + mAxisLabelColor = color; + emit axisLabelColorChanged(); + + updateAxisLabelStyle(); +} + +double QgsQuickElevationProfileCanvas::axisLabelSize() const +{ + return mAxisLabelSize; +} + +void QgsQuickElevationProfileCanvas::setAxisLabelSize( double size ) +{ + if ( mAxisLabelSize == size ) + return; + + mAxisLabelSize = size; + emit axisLabelSizeChanged(); + + updateAxisLabelStyle(); +} + +void QgsQuickElevationProfileCanvas::updateAxisLabelStyle() +{ + if ( mPlotItem ) + { + QgsTextFormat textFormat = mPlotItem->xAxis().textFormat(); + textFormat.setColor( mAxisLabelColor ); + textFormat.setSize( mAxisLabelSize ); + textFormat.setSizeUnit( Qgis::RenderUnit::Points ); + mPlotItem->xAxis().setTextFormat( textFormat ); + + textFormat = mPlotItem->yAxis().textFormat(); + textFormat.setColor( mAxisLabelColor ); + textFormat.setSize( mAxisLabelSize ); + textFormat.setSizeUnit( Qgis::RenderUnit::Points ); + mPlotItem->yAxis().setTextFormat( textFormat ); + + mDirty = true; + refresh(); + } +} + QgsDoubleRange QgsQuickElevationProfileCanvas::visibleDistanceRange() const { return QgsDoubleRange( mPlotItem->xMinimum(), mPlotItem->xMaximum() ); diff --git a/src/core/qgsquick/qgsquickelevationprofilecanvas.h b/src/core/qgsquick/qgsquickelevationprofilecanvas.h index 900808c437..c4b75e39b6 100644 --- a/src/core/qgsquick/qgsquickelevationprofilecanvas.h +++ b/src/core/qgsquick/qgsquickelevationprofilecanvas.h @@ -34,11 +34,12 @@ class QgsQuickElevationProfileCanvas : public QQuickItem Q_PROPERTY( QgsProject *project READ project WRITE setProject NOTIFY projectChanged ) Q_PROPERTY( QgsCoordinateReferenceSystem crs READ crs WRITE setCrs NOTIFY crsChanged ) - Q_PROPERTY( QgsGeometry profileCurve READ profileCurve WRITE setProfileCurve NOTIFY profileCurveChanged ) - Q_PROPERTY( double tolerance READ tolerance WRITE setTolerance NOTIFY toleranceChanged ) + Q_PROPERTY( QColor axisLabelColor READ axisLabelColor WRITE setAxisLabelColor NOTIFY axisLabelColorChanged ) + Q_PROPERTY( double axisLabelSize READ axisLabelSize WRITE setAxisLabelSize NOTIFY axisLabelSizeChanged ) + /** * The isRendering property is set to true while a rendering job is pending for this * elevation profile canvas. It can be used to show a notification icon about an @@ -168,6 +169,34 @@ class QgsQuickElevationProfileCanvas : public QQuickItem */ QgsDoubleRange visibleElevationRange() const; + /** + * Returns the axis label color used when rendering the elevation profile. + * + * \see setAxisLabelColor + */ + QColor axisLabelColor() const; + + /** + * Sets the axis label color used when rendering the elevation profile. + * + * \see axisLabelColor + */ + void setAxisLabelColor( const QColor &color ); + + /** + * Returns the axis label size (in point) used when rendering the elevation profile. + * + * \see setAxisLabelSize + */ + double axisLabelSize() const; + + /** + * Sets the axis label size (in point) used when rendering the elevation profile. + * + * \see axisLabelSize + */ + void setAxisLabelSize( double size ); + signals: //! Emitted when the number of active background jobs changes. @@ -188,6 +217,12 @@ class QgsQuickElevationProfileCanvas : public QQuickItem //! \copydoc QgsQuickMapCanvasMap::isRendering void isRenderingChanged(); + //! Emitted when the axis label color changes. + void axisLabelColorChanged(); + + //! Emitted when the axis label size (in point) changes. + void axisLabelSizeChanged(); + protected: #if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) void geometryChanged( const QRectF &newGeometry, const QRectF &oldGeometry ) override; @@ -227,6 +262,7 @@ class QgsQuickElevationProfileCanvas : public QQuickItem private: void setupLayerConnections( QgsMapLayer *layer, bool isDisconnect ); + void updateAxisLabelStyle(); QgsCoordinateReferenceSystem mCrs; QgsProject *mProject = nullptr; @@ -255,6 +291,9 @@ class QgsQuickElevationProfileCanvas : public QQuickItem static constexpr double MAX_ERROR_PIXELS = 2; bool mDirty = false; + + QColor mAxisLabelColor = QColor( 0, 0, 0 ); + double mAxisLabelSize = 16; }; #endif // QGSELEVATIONPROFILECANVAS_H diff --git a/src/qml/ElevationProfile.qml b/src/qml/ElevationProfile.qml index ff44e68602..18c8d96e55 100644 --- a/src/qml/ElevationProfile.qml +++ b/src/qml/ElevationProfile.qml @@ -27,7 +27,7 @@ Rectangle { elevationProfileCanvas.clear(); } - color: "#bbfafafa" + color: Theme.mainBackgroundColorSemiOpaque radius: 0 ElevationProfileCanvas { @@ -37,6 +37,9 @@ Rectangle { height: elevationProfile.height tolerance: crs.isGeographic ? 0.00005 : 5 + + axisLabelColor: Theme.mainTextColor + axisLabelSize: Theme.tipFont } ProgressBar { @@ -82,7 +85,7 @@ Rectangle { visible: elevationProfileCanvas.isRendering || elevationProfileCanvas.profileCurve.isNull anchors.centerIn: parent width: parent.width - color: Theme.gray + color: Theme.mainTextColor font: Theme.tinyFont horizontalAlignment: Text.AlignHCenter wrapMode: Text.WordWrap @@ -90,6 +93,6 @@ Rectangle { ? qsTr('Rendering elevation profile…') : qsTr('Digitize a path to render the elevation profile') style: Text.Outline - styleColor: "white" + styleColor: Theme.mainBackgroundColorSemiOpaque } } From f20e0d6dd6fc4a94142afb6e09c1e98e5abe9011 Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Tue, 21 May 2024 11:34:45 +0700 Subject: [PATCH 2/3] Increase focus on information values by fading out labels --- src/qml/NavigationInformationView.qml | 102 +++++--- src/qml/PositioningInformationView.qml | 323 +++++++++++++++++-------- src/qml/SensorInformationView.qml | 27 ++- 3 files changed, 319 insertions(+), 133 deletions(-) diff --git a/src/qml/NavigationInformationView.qml b/src/qml/NavigationInformationView.qml index f6ea9a78dc..a82f86c703 100644 --- a/src/qml/NavigationInformationView.qml +++ b/src/qml/NavigationInformationView.qml @@ -132,17 +132,28 @@ Rectangle { width: grid.cellWidth color: alternateBackgroundColor - Text { + RowLayout { anchors.margins: cellPadding anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left - font: Theme.tipFont - color: textColor - text: coordinatesIsXY - ? (coordinatesIsGeographic ? qsTr( "Lon" ) : qsTr( "X" )) + ': ' - + Number( coordinates.x ).toLocaleString( Qt.locale(), 'f', coordinatesIsGeographic ? 7 : 3 ) - : (coordinatesIsGeographic ? qsTr( "Lat" ) : qsTr( "Y" )) + ': ' - + Number( coordinates.y ).toLocaleString( Qt.locale(), 'f', coordinatesIsGeographic ? 7 : 3 ) + + Text { + Layout.fillWidth: false + font: Theme.tipFont + color: Theme.secondaryTextColor + text: coordinatesIsXY + ? coordinatesIsGeographic ? qsTr( "Lon" ) : qsTr( "X" ) + : coordinatesIsGeographic ? qsTr( "Lat" ) : qsTr( "Y" ) + } + + Text { + Layout.fillWidth: true + font: Theme.tipFont + color: textColor + text: coordinatesIsXY + ? Number( coordinates.x ).toLocaleString( Qt.locale(), 'f', coordinatesIsGeographic ? 7 : 3 ) + : Number( coordinates.y ).toLocaleString( Qt.locale(), 'f', coordinatesIsGeographic ? 7 : 3 ) + } } } @@ -151,17 +162,28 @@ Rectangle { width: grid.cellWidth color: backgroundColor - Text { + RowLayout { anchors.margins: cellPadding anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left - font: Theme.tipFont - color: textColor - text: coordinatesIsXY - ? (coordinatesIsGeographic ? qsTr( "Lat" ) : qsTr( "Y" )) + ': ' - + Number( coordinates.y ).toLocaleString( Qt.locale(), 'f', coordinatesIsGeographic ? 7 : 3 ) - : (coordinatesIsGeographic ? qsTr( "Lon" ) : qsTr( "X" )) + ': ' - + Number( coordinates.x ).toLocaleString( Qt.locale(), 'f', coordinatesIsGeographic ? 7 : 3 ) + + Text { + Layout.fillWidth: false + font: Theme.tipFont + color: Theme.secondaryTextColor + text: coordinatesIsXY + ? coordinatesIsGeographic ? qsTr( "Lat" ) : qsTr( "Y" ) + : coordinatesIsGeographic ? qsTr( "Lon" ) : qsTr( "X" ) + } + + Text { + Layout.fillWidth: true + font: Theme.tipFont + color: textColor + text: coordinatesIsXY + ? Number( coordinates.y ).toLocaleString( Qt.locale(), 'f', coordinatesIsGeographic ? 7 : 3 ) + : Number( coordinates.x ).toLocaleString( Qt.locale(), 'f', coordinatesIsGeographic ? 7 : 3 ) + } } } @@ -170,16 +192,26 @@ Rectangle { width: grid.cellWidth color: grid.rows == 2 ? backgroundColor : alternateBackgroundColor - Text { + RowLayout { anchors.margins: cellPadding anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left - font: Theme.tipFont - color: textColor - text: qsTr( "Dist." ) + ': ' + - ( positionSource.active && positionSource.positionInformation && positionSource.positionInformation.latitudeValid - ? ( UnitTypes.formatDistance( navigation.distance * UnitTypes.fromUnitToUnitFactor( navigation.distanceUnits, projectInfo.distanceUnits ), 3, projectInfo.distanceUnits ) ) - : qsTr( "N/A" ) ) + + Text { + Layout.fillWidth: false + font: Theme.tipFont + color: Theme.secondaryTextColor + text: qsTr("Dist.") + } + + Text { + Layout.fillWidth: true + font: Theme.tipFont + color: textColor + text: positionSource.active && positionSource.positionInformation && positionSource.positionInformation.latitudeValid + ? UnitTypes.formatDistance( navigation.distance * UnitTypes.fromUnitToUnitFactor( navigation.distanceUnits, projectInfo.distanceUnits ), 3, projectInfo.distanceUnits ) + : qsTr( "N/A" ) + } } } @@ -188,16 +220,26 @@ Rectangle { width: grid.cellWidth color: grid.rows == 2 ? alternateBackgroundColor : backgroundColor - Text { + RowLayout { anchors.margins: cellPadding anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left - font: Theme.tipFont - color: textColor - text: qsTr( "Bearing" ) + ': ' + - ( positionSource.active && positionSource.positionInformation && positionSource.positionInformation.latitudeValid - ? ( Number( navigation.bearing ).toLocaleString( Qt.locale(), 'f', 1 ) ) + '°' - : qsTr( "N/A" ) ) + + Text { + Layout.fillWidth: false + font: Theme.tipFont + color: Theme.secondaryTextColor + text: qsTr("Bearing") + } + + Text { + Layout.fillWidth: true + font: Theme.tipFont + color: textColor + text: positionSource.active && positionSource.positionInformation && positionSource.positionInformation.latitudeValid + ? Number( navigation.bearing ).toLocaleString( Qt.locale(), 'f', 1 ) + '°' + : qsTr( "N/A" ) + } } } } diff --git a/src/qml/PositioningInformationView.qml b/src/qml/PositioningInformationView.qml index aa1fd094d1..11c53e78c5 100644 --- a/src/qml/PositioningInformationView.qml +++ b/src/qml/PositioningInformationView.qml @@ -43,21 +43,32 @@ Rectangle { width: grid.cellWidth color: alternateBackgroundColor - Text { + RowLayout { anchors.margins: cellPadding anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left - font: Theme.tipFont - color: textColor - text: coordinatesIsXY - ? (coordinatesIsGeographic ? qsTr( "Lon" ) : qsTr( "X" )) + ': ' - + ( positionSource.positionInformation && positionSource.positionInformation.longitudeValid - ? Number( coordinates.x ).toLocaleString( Qt.locale(), 'f', coordinatesIsGeographic ? 7 : 3 ) - : qsTr( "N/A" ) ) - : (coordinatesIsGeographic ? qsTr( "Lat" ) : qsTr( "Y" )) + ': ' - + ( positionSource.positionInformation && positionSource.positionInformation.latitudeValid - ? Number( coordinates.y ).toLocaleString( Qt.locale(), 'f', coordinatesIsGeographic ? 7 : 3 ) - : qsTr( "N/A" ) ) + + Text { + Layout.fillWidth: false + font: Theme.tipFont + color: Theme.secondaryTextColor + text: coordinatesIsXY + ? coordinatesIsGeographic ? qsTr( "Lon" ) : qsTr( "X" ) + : coordinatesIsGeographic ? qsTr( "Lat" ) : qsTr( "Y" ) + } + + Text { + Layout.fillWidth: true + font: Theme.tipFont + color: textColor + text: coordinatesIsXY + ? positionSource.positionInformation && positionSource.positionInformation.longitudeValid + ? Number( coordinates.x ).toLocaleString( Qt.locale(), 'f', coordinatesIsGeographic ? 7 : 3 ) + : qsTr( "N/A" ) + : positionSource.positionInformation && positionSource.positionInformation.latitudeValid + ? Number( coordinates.y ).toLocaleString( Qt.locale(), 'f', coordinatesIsGeographic ? 7 : 3 ) + : qsTr( "N/A" ) + } } } @@ -66,22 +77,34 @@ Rectangle { width: grid.cellWidth color: backgroundColor - Text { + RowLayout { anchors.margins: cellPadding anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left - font: Theme.tipFont - color: textColor - text: coordinatesIsXY - ? (coordinatesIsGeographic ? qsTr( "Lat" ) : qsTr( "Y" )) + ': ' - + ( positionSource.positionInformation && positionSource.positionInformation.longitudeValid - ? Number( coordinates.y ).toLocaleString( Qt.locale(), 'f', coordinatesIsGeographic ? 7 : 3 ) - : qsTr( "N/A" ) ) - : (coordinatesIsGeographic ? qsTr( "Lon" ) : qsTr( "X" )) + ': ' - + ( positionSource.positionInformation && positionSource.positionInformation.latitudeValid - ? Number( coordinates.x ).toLocaleString( Qt.locale(), 'f', coordinatesIsGeographic ? 7 : 3 ) - : qsTr( "N/A" ) ) + Text { + Layout.fillWidth: false + font: Theme.tipFont + color: Theme.secondaryTextColor + text: coordinatesIsXY + ? coordinatesIsGeographic ? qsTr( "Lat" ) : qsTr( "Y" ) + : coordinatesIsGeographic ? qsTr( "Lon" ) : qsTr( "X" ) + + } + + Text { + Layout.fillWidth: true + font: Theme.tipFont + color: textColor + text: coordinatesIsXY + ? positionSource.positionInformation && positionSource.positionInformation.longitudeValid + ? Number( coordinates.y ).toLocaleString( Qt.locale(), 'f', coordinatesIsGeographic ? 7 : 3 ) + : qsTr( "N/A" ) + : positionSource.positionInformation && positionSource.positionInformation.latitudeValid + ? Number( coordinates.x ).toLocaleString( Qt.locale(), 'f', coordinatesIsGeographic ? 7 : 3 ) + : qsTr( "N/A" ) + + } } } @@ -89,34 +112,46 @@ Rectangle { height: cellHeight width: grid.cellWidth color: grid.rows === 2 ? backgroundColor : alternateBackgroundColor - Text { + + RowLayout { anchors.margins: cellPadding anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left - font: Theme.tipFont - color: textColor - text: { - var altitude = qsTr( "Altitude" ) + ': ' - if (positionSource.positionInformation && positionSource.positionInformation.elevationValid) { - altitude += Number(positionSource.projectedPosition.z * distanceUnitFactor).toLocaleString(Qt.locale(), 'f', 3) + ' ' + distanceUnitAbbreviation + ' ' - var details = [] - if (positionSource.elevationCorrectionMode === Positioning.ElevationCorrectionMode.OrthometricFromGeoidFile) { - details.push('grid') - } else if (positionSource.elevationCorrectionMode === Positioning.ElevationCorrectionMode.OrthometricFromDevice) { - details.push('ortho.') - } - if (!isNaN(parseFloat(antennaHeight))) { - details.push('ant.') + + Text { + Layout.fillWidth: false + font: Theme.tipFont + color: Theme.secondaryTextColor + text: qsTr("Altitude") + } + + Text { + Layout.fillWidth: true + font: Theme.tipFont + color: textColor + text: { + var altitude = '' + if (positionSource.positionInformation && positionSource.positionInformation.elevationValid) { + altitude += Number(positionSource.projectedPosition.z * distanceUnitFactor).toLocaleString(Qt.locale(), 'f', 3) + ' ' + distanceUnitAbbreviation + ' ' + var details = [] + if (positionSource.elevationCorrectionMode === Positioning.ElevationCorrectionMode.OrthometricFromGeoidFile) { + details.push('grid') + } else if (positionSource.elevationCorrectionMode === Positioning.ElevationCorrectionMode.OrthometricFromDevice) { + details.push('ortho.') + } + if (!isNaN(parseFloat(antennaHeight))) { + details.push('ant.') + } + if (details.length > 0) { + altitude += ' (%1)'.arg( details.join(', ')) + } } - if (details.length > 0) { - altitude += ' (%1)'.arg( details.join(', ')) + else + { + altitude += qsTr('N/A'); } + return altitude } - else - { - altitude += qsTr('N/A'); - } - return altitude } } } @@ -126,13 +161,26 @@ Rectangle { width: grid.cellWidth color: grid.rows === 2 ? alternateBackgroundColor : backgroundColor - Text { + RowLayout { anchors.margins: cellPadding anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left - font: Theme.tipFont - color: textColor - text: qsTr( "Speed" ) + ': ' + ( positionSource.positionInformation && positionSource.positionInformation.speedValid ? positionSource.positionInformation.speed.toLocaleString(Qt.locale(), 'f', 3) + " m/s" : qsTr( "N/A" ) ) + + Text { + Layout.fillWidth: false + font: Theme.tipFont + color: Theme.secondaryTextColor + text: qsTr("Speed") + } + + Text { + Layout.fillWidth: true + font: Theme.tipFont + color: textColor + text: positionSource.positionInformation && positionSource.positionInformation.speedValid + ? positionSource.positionInformation.speed.toLocaleString(Qt.locale(), 'f', 3) + " m/s" + : qsTr( "N/A" ) + } } } @@ -141,15 +189,26 @@ Rectangle { width: grid.cellWidth color: grid.rows === 4 ? backgroundColor : alternateBackgroundColor - Text { + RowLayout { anchors.margins: cellPadding anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left - font: Theme.tipFont - color: textColor - text: qsTr("H. Accuracy") + ': ' + (positionSource.positionInformation && positionSource.positionInformation.haccValid - ? Number(positionSource.positionInformation.hacc * distanceUnitFactor).toLocaleString(Qt.locale(), 'f', 3) + ' ' + distanceUnitAbbreviation - : qsTr("N/A")) + + Text { + Layout.fillWidth: false + font: Theme.tipFont + color: Theme.secondaryTextColor + text: qsTr("H. Accuracy") + } + + Text { + Layout.fillWidth: true + font: Theme.tipFont + color: textColor + text: positionSource.positionInformation && positionSource.positionInformation.haccValid + ? Number(positionSource.positionInformation.hacc * distanceUnitFactor).toLocaleString(Qt.locale(), 'f', 3) + ' ' + distanceUnitAbbreviation + : qsTr("N/A") + } } } @@ -158,15 +217,26 @@ Rectangle { width: grid.cellWidth color: grid.rows === 4 ? alternateBackgroundColor : backgroundColor - Text { + RowLayout { anchors.margins: cellPadding anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left - font: Theme.tipFont - color: textColor - text: qsTr( "V. Accuracy" ) + ': ' + (positionSource.positionInformation && positionSource.positionInformation.vaccValid - ? Number(positionSource.positionInformation.vacc * distanceUnitFactor).toLocaleString(Qt.locale(), 'f', 3) + ' ' + distanceUnitAbbreviation - : qsTr("N/A")) + + Text { + Layout.fillWidth: false + font: Theme.tipFont + color: Theme.secondaryTextColor + text: qsTr("V. Accuracy") + } + + Text { + Layout.fillWidth: true + font: Theme.tipFont + color: textColor + text: positionSource.positionInformation && positionSource.positionInformation.vaccValid + ? Number(positionSource.positionInformation.vacc * distanceUnitFactor).toLocaleString(Qt.locale(), 'f', 3) + ' ' + distanceUnitAbbreviation + : qsTr("N/A") + } } } @@ -176,16 +246,26 @@ Rectangle { color: grid.rows % 2 === 0 ? backgroundColor : alternateBackgroundColor visible: positionSource.deviceId !== '' - Text { + RowLayout { anchors.margins: cellPadding anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left - font: Theme.tipFont - color: textColor - text: qsTr( "PDOP" ) + ': ' + - (positionSource.positionInformation && !isNaN(positionSource.positionInformation.pdop) - ? positionSource.positionInformation.pdop.toLocaleString(Qt.locale(), 'f', 1) - : qsTr('N/A')) + + Text { + Layout.fillWidth: false + font: Theme.tipFont + color: Theme.secondaryTextColor + text: qsTr("PDOP") + } + + Text { + Layout.fillWidth: true + font: Theme.tipFont + color: textColor + text: positionSource.positionInformation && !isNaN(positionSource.positionInformation.pdop) + ? positionSource.positionInformation.pdop.toLocaleString(Qt.locale(), 'f', 1) + : qsTr('N/A') + } } } @@ -195,16 +275,26 @@ Rectangle { color: grid.rows % 2 === 0 ? alternateBackgroundColor : backgroundColor visible: positionSource.deviceId !== '' - Text { + RowLayout { anchors.margins: cellPadding anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left - font: Theme.tipFont - color: textColor - text: qsTr( "HDOP" ) + ': ' + - (positionSource.positionInformation && !isNaN(positionSource.positionInformation.hdop) - ? positionSource.positionInformation.hdop.toLocaleString(Qt.locale(), 'f', 1) - : qsTr('N/A')) + + Text { + Layout.fillWidth: false + font: Theme.tipFont + color: Theme.secondaryTextColor + text: qsTr("HDOP") + } + + Text { + Layout.fillWidth: true + font: Theme.tipFont + color: textColor + text: positionSource.positionInformation && !isNaN(positionSource.positionInformation.hdop) + ? positionSource.positionInformation.hdop.toLocaleString(Qt.locale(), 'f', 1) + : qsTr('N/A') + } } } @@ -214,16 +304,26 @@ Rectangle { color: grid.rows === 6 ? backgroundColor : alternateBackgroundColor visible: positionSource.deviceId !== '' - Text { + RowLayout { anchors.margins: cellPadding anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left - font: Theme.tipFont - color: textColor - text: qsTr( "VDOP" ) + ': ' + - (positionSource.positionInformation && !isNaN(positionSource.positionInformation.vdop) - ? positionSource.positionInformation.vdop.toLocaleString(Qt.locale(), 'f', 1) - : qsTr('N/A')) + + Text { + Layout.fillWidth: false + font: Theme.tipFont + color: Theme.secondaryTextColor + text: qsTr("VDOP") + } + + Text { + Layout.fillWidth: true + font: Theme.tipFont + color: textColor + text: positionSource.positionInformation && !isNaN(positionSource.positionInformation.vdop) + ? positionSource.positionInformation.vdop.toLocaleString(Qt.locale(), 'f', 1) + : qsTr('N/A') + } } } @@ -233,13 +333,24 @@ Rectangle { color: grid.rows === 6 ? alternateBackgroundColor : backgroundColor visible: positionSource.deviceId !== '' - Text { + RowLayout { anchors.margins: cellPadding anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left - font: Theme.tipFont - color: textColor - text: qsTr( "Valid" ) + ': ' + ( positionSource.positionInformation && positionSource.positionInformation.isValid ? 'True' : 'False' ) + + Text { + Layout.fillWidth: false + font: Theme.tipFont + color: Theme.secondaryTextColor + text: qsTr("Valid") + } + + Text { + Layout.fillWidth: true + font: Theme.tipFont + color: textColor + text: positionSource.positionInformation && positionSource.positionInformation.isValid ? 'True' : 'False' + } } } @@ -249,13 +360,24 @@ Rectangle { color: grid.rows === 2 || grid.rows === 6 ? backgroundColor : alternateBackgroundColor visible: positionSource.deviceId !== '' - Text { + RowLayout { anchors.margins: cellPadding anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left - font: Theme.tipFont - color: textColor - text: qsTr( "Fix" ) + ': ' + ( positionSource.positionInformation ? positionSource.positionInformation.fixStatusDescription : qsTr('N/A') ) + + Text { + Layout.fillWidth: false + font: Theme.tipFont + color: Theme.secondaryTextColor + text: qsTr("Fix") + } + + Text { + Layout.fillWidth: true + font: Theme.tipFont + color: textColor + text: positionSource.positionInformation ? positionSource.positionInformation.fixStatusDescription : qsTr('N/A') + } } } @@ -265,13 +387,24 @@ Rectangle { color: grid.rows === 2 || grid.rows === 6 ? alternateBackgroundColor : backgroundColor visible: positionSource.deviceId !== '' - Text { + RowLayout { anchors.margins: cellPadding anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left - font: Theme.tipFont - color: textColor - text: qsTr( "Quality" ) + ': ' + ( positionSource.positionInformation ? positionSource.positionInformation.qualityDescription : qsTr('N/A') ) + + Text { + Layout.fillWidth: false + font: Theme.tipFont + color: Theme.secondaryTextColor + text: qsTr("Quality") + } + + Text { + Layout.fillWidth: true + font: Theme.tipFont + color: textColor + text: positionSource.positionInformation ? positionSource.positionInformation.qualityDescription : qsTr('N/A') + } } } } diff --git a/src/qml/SensorInformationView.qml b/src/qml/SensorInformationView.qml index f9abc217f0..1130352919 100644 --- a/src/qml/SensorInformationView.qml +++ b/src/qml/SensorInformationView.qml @@ -48,17 +48,28 @@ Rectangle { height: grid.cellHeight color: index % 2 == 0 ? sensorInformationView.alternateBackgroundColor : sensorInformationView.backgroundColor - Text { + RowLayout { anchors.margins: cellPadding anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left - width: grid.cellWidth - 20 - height: grid.cellHeight - 20 - font: Theme.tipFont - color: sensorInformationView.textColor - text: SensorName + ': ' + (SensorLastValue ? (SensorLastValue + '').trim() : 'N/A') - verticalAlignment: Text.AlignVCenter - elide: Text.ElideRight + + Text { + Layout.fillWidth: false + font: Theme.tipFont + color: Theme.secondaryTextColor + text: SensorName + } + + Text { + Layout.fillWidth: true + width: grid.cellWidth - 20 + height: grid.cellHeight - 20 + font: Theme.tipFont + color: sensorInformationView.textColor + text: SensorLastValue ? (SensorLastValue + '').trim() : qsTr( "N/A" ) + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + } } } } From 35c227361da49cb25348661a6897934486087102 Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Tue, 21 May 2024 13:52:04 +0700 Subject: [PATCH 3/3] Silence a couple more clang-tidy warnings to insure we don't get angry at the bot --- .github/workflows/linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index fd4681f5e6..9d2bab5042 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -98,7 +98,7 @@ jobs: with: build_dir: "build" lgtm_comment_body: '' - exclude: 'cppcoreguidelines-avoid-magic-numbers,bugprone-easily-swappable-parameters,misc-non-private-member-variables-in-classes,cppcoreguidelines-macro-usage' + exclude: 'cppcoreguidelines-avoid-magic-numbers,bugprone-easily-swappable-parameters,misc-non-private-member-variables-in-classes,cppcoreguidelines-macro-usage,readability-braces-around-statements,readability-implicit-bool-conversion,cppcoreguidelines-avoid-magic-numbers' - name: Package run: |