diff --git a/porymap.pro b/porymap.pro index f36f536f..c83dd1d7 100644 --- a/porymap.pro +++ b/porymap.pro @@ -18,6 +18,14 @@ RC_ICONS = resources/icons/porymap-icon-2.ico ICON = resources/icons/porymap.icns QMAKE_CXXFLAGS += -std=c++17 -Wall QMAKE_TARGET_BUNDLE_PREFIX = com.pret + +# Get latest commit hash if we can (to display alongside version information). +GIT_PATH = $$system(which git) +!isEmpty(GIT_PATH) { + LATEST_COMMIT = $$system($$GIT_PATH rev-parse --short HEAD) +} +DEFINES += PORYMAP_LATEST_COMMIT=\\\"$$LATEST_COMMIT\\\" + VERSION = 5.4.1 DEFINES += PORYMAP_VERSION=\\\"$$VERSION\\\" diff --git a/src/ui/aboutporymap.cpp b/src/ui/aboutporymap.cpp index 22c5fabc..24d76ce5 100644 --- a/src/ui/aboutporymap.cpp +++ b/src/ui/aboutporymap.cpp @@ -9,7 +9,13 @@ AboutPorymap::AboutPorymap(QWidget *parent) : ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); - this->ui->label_Version->setText(QString("Version %1 - %2").arg(QCoreApplication::applicationVersion()).arg(QStringLiteral(__DATE__))); + QString versionInfo = QString("Version %1 - %2").arg(QCoreApplication::applicationVersion()).arg(QStringLiteral(__DATE__)); + + static const QString commitHash = PORYMAP_LATEST_COMMIT; + if (!commitHash.isEmpty()) + versionInfo.append(QString("\nCommit %1").arg(commitHash)); + + this->ui->label_Version->setText(versionInfo); this->ui->textBrowser->setSource(QUrl("qrc:/CHANGELOG.md")); }