From a10fb6dc6d9794033902f26daf59b6b5764ccdb7 Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Thu, 5 Dec 2024 07:18:03 +0200 Subject: [PATCH] Refactor the About screen to show the QGIS and GDAL/OGR versions Also small refactor on the `Label.text` implementation to bring it to the latest best practices in JavaScript: - `var` -> `const` - braces around `if`s --- src/core/qgismobileapp.cpp | 3 +++ src/qml/About.qml | 11 ++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/core/qgismobileapp.cpp b/src/core/qgismobileapp.cpp index a8de1c363c..7793214bc3 100644 --- a/src/core/qgismobileapp.cpp +++ b/src/core/qgismobileapp.cpp @@ -27,6 +27,7 @@ #include "cpl_conv.h" #include "cpl_string.h" #include "cpl_vsi.h" +#include "gdal_version.h" #ifdef WITH_BLUETOOTH #include "bluetoothdevicemodel.h" @@ -557,6 +558,8 @@ void QgisMobileapp::initDeclarative( QQmlEngine *engine ) // Register some globally available variables engine->rootContext()->setContextProperty( "qVersion", qVersion() ); + engine->rootContext()->setContextProperty( "qgisVersion", Qgis::version() ); + engine->rootContext()->setContextProperty( "gdalVersion", GDAL_RELEASE_NAME ); engine->rootContext()->setContextProperty( "withNfc", QVariant( NearFieldReader::isSupported() ) ); engine->rootContext()->setContextProperty( "systemFontPointSize", PlatformUtilities::instance()->systemFontPointSize() ); engine->rootContext()->setContextProperty( "mouseDoubleClickInterval", QApplication::styleHints()->mouseDoubleClickInterval() ); diff --git a/src/qml/About.qml b/src/qml/About.qml index 2f1db4b9c8..d2912511f5 100644 --- a/src/qml/About.qml +++ b/src/qml/About.qml @@ -74,10 +74,15 @@ Item { color: Theme.light textFormat: Text.RichText text: { - var links = '' + gitRev.substr(0, 6) + ''; - if (appVersion && appVersion !== '1.0.0') + let links = '' + gitRev.substr(0, 6) + ''; + if (appVersion && appVersion !== '1.0.0') { links += ' ' + appVersion + ''; - return "QField
" + appVersionStr + " (" + links + ")
Qt " + qVersion; + } + // the `qgisVersion` has the format `..-`, so we get everything before the first `-` + const qgisVersionWithoutName = qgisVersion.split("-", 1)[0]; + const dependencies = [["QGIS", qgisVersionWithoutName], ["GDAL/OGR", gdalVersion], ["Qt", qVersion]]; + const dependenciesStr = dependencies.map(pair => pair.join(" ")).join(" | "); + return "QField
" + appVersionStr + " (" + links + ")
" + dependenciesStr; } onLinkActivated: link => Qt.openUrlExternally(link) }