show running qt version if it differs from compiled version (#5501)

This commit is contained in:
nerix 2024-07-09 16:18:35 +02:00 committed by GitHub
parent 354079c74c
commit 126200da82
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 4 deletions

View file

@ -45,6 +45,7 @@
- Dev: Refactor/unsingletonize `UserDataController`. (#5459) - Dev: Refactor/unsingletonize `UserDataController`. (#5459)
- Dev: Cleanup `BrowserExtension`. (#5465) - Dev: Cleanup `BrowserExtension`. (#5465)
- Dev: Deprecate Qt 5.12. (#5396) - Dev: Deprecate Qt 5.12. (#5396)
- Dev: The running Qt version is now shown in the about page if it differs from the compiled version. (#5501)
## 2.5.1 ## 2.5.1

View file

@ -947,6 +947,10 @@ set_target_properties(${LIBRARY_PROJECT}
# this is its own project. # this is its own project.
set(VERSION_SOURCE_FILES common/Version.cpp common/Version.hpp) set(VERSION_SOURCE_FILES common/Version.cpp common/Version.hpp)
add_library(${VERSION_PROJECT} STATIC ${VERSION_SOURCE_FILES}) add_library(${VERSION_PROJECT} STATIC ${VERSION_SOURCE_FILES})
target_compile_definitions(${VERSION_PROJECT} PRIVATE
$<$<BOOL:${WIN32}>:USEWINSDK>
$<$<BOOL:${BUILD_WITH_CRASHPAD}>:CHATTERINO_WITH_CRASHPAD>
)
# source group for IDEs # source group for IDEs
source_group(TREE ${CMAKE_SOURCE_DIR} FILES ${VERSION_SOURCE_FILES}) source_group(TREE ${CMAKE_SOURCE_DIR} FILES ${VERSION_SOURCE_FILES})

View file

@ -1,11 +1,15 @@
#include "common/Version.hpp" #include "common/Version.hpp"
#include "common/Literals.hpp"
#include "common/Modes.hpp" #include "common/Modes.hpp"
#include <QFileInfo> #include <QFileInfo>
#include <QStringBuilder>
namespace chatterino { namespace chatterino {
using namespace literals;
Version::Version() Version::Version()
: version_(CHATTERINO_VERSION) : version_(CHATTERINO_VERSION)
, commitHash_(QStringLiteral(CHATTERINO_GIT_HASH)) , commitHash_(QStringLiteral(CHATTERINO_GIT_HASH))
@ -79,11 +83,17 @@ QStringList Version::buildTags() const
{ {
QStringList tags; QStringList tags;
tags.append("Qt " QT_VERSION_STR); const auto *runtimeVersion = qVersion();
if (runtimeVersion != QLatin1String{QT_VERSION_STR})
{
tags.append(u"Qt "_s QT_VERSION_STR u" (running on " % runtimeVersion %
u")");
}
else
{
tags.append(u"Qt "_s QT_VERSION_STR);
}
#ifdef USEWINSDK
tags.append("Windows SDK");
#endif
#ifdef _MSC_FULL_VER #ifdef _MSC_FULL_VER
tags.append("MSVC " + QString::number(_MSC_FULL_VER, 10)); tags.append("MSVC " + QString::number(_MSC_FULL_VER, 10));
#endif #endif