From 7fb657376d81ed26074219db956d20fd98f7fb1a Mon Sep 17 00:00:00 2001 From: garak Date: Tue, 29 Apr 2025 15:50:55 -0400 Subject: [PATCH] use common version function for splash and about screen --- forms/loadingscreen.ui | 2 +- include/ui/aboutporymap.h | 2 ++ src/ui/aboutporymap.cpp | 14 +++++++++----- src/ui/loadingscreen.cpp | 6 ++++++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/forms/loadingscreen.ui b/forms/loadingscreen.ui index 799f0a9d..d6f52430 100644 --- a/forms/loadingscreen.ui +++ b/forms/loadingscreen.ui @@ -47,7 +47,7 @@ - Version 6.0.0 + Version X.x.x Qt::AlignCenter diff --git a/include/ui/aboutporymap.h b/include/ui/aboutporymap.h index 6bd0ed32..3a760f44 100644 --- a/include/ui/aboutporymap.h +++ b/include/ui/aboutporymap.h @@ -13,6 +13,8 @@ class AboutPorymap : public QDialog public: explicit AboutPorymap(QWidget *parent = nullptr); ~AboutPorymap(); + + static QString getVersionString(); private: Ui::AboutPorymap *ui; }; diff --git a/src/ui/aboutporymap.cpp b/src/ui/aboutporymap.cpp index 07654e14..5aa5f0c8 100644 --- a/src/ui/aboutporymap.cpp +++ b/src/ui/aboutporymap.cpp @@ -9,15 +9,19 @@ AboutPorymap::AboutPorymap(QWidget *parent) : setAttribute(Qt::WA_DeleteOnClose); static const QString commitHash = PORYMAP_LATEST_COMMIT; - this->ui->label_Version->setText(QString("Version %1%2\nQt %3 (%4)\n%5") + this->ui->label_Version->setText(getVersionString()); + + layout()->setSizeConstraint(QLayout::SetFixedSize); +} + +QString AboutPorymap::getVersionString() { + static const QString commitHash = PORYMAP_LATEST_COMMIT; + return QString("Version %1%2\nQt %3 (%4)\n%5") .arg(QCoreApplication::applicationVersion()) .arg(commitHash.isEmpty() ? "" : QString(" (%1)").arg(commitHash)) .arg(QStringLiteral(QT_VERSION_STR)) .arg(QSysInfo::buildCpuArchitecture()) - .arg(QStringLiteral(__DATE__)) - ); - - layout()->setSizeConstraint(QLayout::SetFixedSize); + .arg(QStringLiteral(__DATE__)); } AboutPorymap::~AboutPorymap() diff --git a/src/ui/loadingscreen.cpp b/src/ui/loadingscreen.cpp index d66ccf63..9cb08be1 100644 --- a/src/ui/loadingscreen.cpp +++ b/src/ui/loadingscreen.cpp @@ -1,5 +1,6 @@ #include "loadingscreen.h" +#include "aboutporymap.h" #include "ui_loadingscreen.h" #include "qgifimage.h" @@ -25,6 +26,11 @@ PorymapLoadingScreen::PorymapLoadingScreen(QWidget *parent) : QWidget(parent), u } void PorymapLoadingScreen::start() { + static bool shownVersion = false; + if (!shownVersion) { + this->ui->labelVersion->setText(AboutPorymap::getVersionString()); + shownVersion = true; + } this->timer.start(120); this->show(); }