Skip to content

Commit

Permalink
Refactor the About screen to show the QGIS and GDAL/OGR versions
Browse files Browse the repository at this point in the history
Also small refactor on the `Label.text` implementation to bring it to
the latest best practices in JavaScript:
- `var` -> `const`
- braces around `if`s
  • Loading branch information
suricactus authored and nirvn committed Dec 12, 2024
1 parent 4cd5cc7 commit a10fb6d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/core/qgismobileapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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() );
Expand Down
11 changes: 8 additions & 3 deletions src/qml/About.qml
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,15 @@ Item {
color: Theme.light
textFormat: Text.RichText
text: {
var links = '<a href="https://github.com/opengisch/QField/commit/' + gitRev + '">' + gitRev.substr(0, 6) + '</a>';
if (appVersion && appVersion !== '1.0.0')
let links = '<a href="https://github.com/opengisch/QField/commit/' + gitRev + '">' + gitRev.substr(0, 6) + '</a>';
if (appVersion && appVersion !== '1.0.0') {
links += ' <a href="https://github.com/opengisch/QField/releases/tag/' + appVersion + '">' + appVersion + '</a>';
return "QField<br>" + appVersionStr + " (" + links + ")<br>Qt " + qVersion;
}
// the `qgisVersion` has the format `<int>.<int>.<int>-<any text>`, 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<br>" + appVersionStr + " (" + links + ")<br>" + dependenciesStr;
}
onLinkActivated: link => Qt.openUrlExternally(link)
}
Expand Down

0 comments on commit a10fb6d

Please sign in to comment.