feat: add build option for freestanding text in about page (#6766)

Example usage:
```
cmake -DCHATTERINO_EXTRA_BUILD_STRING="hi im <a href=\"https://forsen.tv\">forsen</a>" ..
```
This commit is contained in:
pajlada
2026-01-25 12:08:33 +01:00
committed by GitHub
parent 799b51018f
commit 83b0cce015
7 changed files with 41 additions and 4 deletions
+1 -1
View File
@@ -42,7 +42,7 @@ body:
description: While optional, it's highly encouraged to include screenshots or videos to illustrate what you mean.
placeholder: You can upload them using the text editor's dedicated button.
- type: input
- type: textarea
id: versions
validations:
required: true
+1
View File
@@ -86,6 +86,7 @@
- Dev: Added Clazy linting in CI. (#6623)
- Dev: Added custom clang-tidy module linting in CI. (#6626)
- Dev: CMake option `USE_ALTERNATE_LINKER` now errors if the given linker can't be found. (#6692)
- Dev: Added a CMake option `CHATTERINO_EXTRA_BUILD_STRING` which allows the packager to provide an optional freestanding Qt-HTML string that shows up in the About page under the Chatterino version. (#6766)
- Dev: Enable C++ 23. (#6693)
- Dev: Prefer `std::expected` over `nonstd::expected_lite`. (#6693)
- Dev: Moved Twitch PubSub to liveupdates. (#6638)
+2
View File
@@ -40,6 +40,8 @@ add_feature_info("Chatterino code sanitizer support" CHATTERINO_SANITIZER_SUPPOR
option(CHATTERINO_UPDATER "Enable update checks" ON)
mark_as_advanced(CHATTERINO_UPDATER)
set(CHATTERINO_EXTRA_BUILD_STRING "" CACHE STRING "Provide an extra string to show in the about page under the Chatterino version. This string allows the use of Qt's HTML subset.")
set(USE_ALTERNATE_LINKER "" CACHE STRING "Use alternate linker. Leave empty for system default. CMake 3.29 users can use CMAKE_LINKER_TYPE instead.")
if(CHATTERINO_SANITIZER_SUPPORT)
+1
View File
@@ -1111,6 +1111,7 @@ set_target_properties(${LIBRARY_PROJECT}
set(VERSION_SOURCE_FILES common/Version.cpp common/Version.hpp)
add_library(${VERSION_PROJECT} STATIC ${VERSION_SOURCE_FILES})
target_compile_definitions(${VERSION_PROJECT} PRIVATE
CHATTERINO_EXTRA_BUILD_STRING=${CHATTERINO_EXTRA_BUILD_STRING}
$<$<BOOL:${WIN32}>:USEWINSDK>
$<$<BOOL:${BUILD_WITH_CRASHPAD}>:CHATTERINO_WITH_CRASHPAD>
)
+19
View File
@@ -40,6 +40,7 @@ Version::Version()
this->generateBuildString();
this->generateRunningString();
this->generateExtraString();
#ifdef Q_OS_WIN
// keep in sync with .CI/chatterino-installer.iss
@@ -123,6 +124,11 @@ const QString &Version::runningString() const
return this->runningString_;
}
const QString &Version::extraString() const
{
return this->extraString_;
}
void Version::generateBuildString()
{
// e.g. Chatterino 2.3.5 or Chatterino Nightly 2.3.5
@@ -174,6 +180,19 @@ void Version::generateRunningString()
this->runningString_ = s;
}
#define STRINGIFY(x) #x
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define STRINGIFY2(x) STRINGIFY(x)
void Version::generateExtraString()
{
this->extraString_ =
QStringLiteral(STRINGIFY2(CHATTERINO_EXTRA_BUILD_STRING)).trimmed();
}
#undef STRINGIFY2
#undef STRINGIFY
#ifdef Q_OS_WIN
const std::wstring &Version::appUserModelID() const
{
+7
View File
@@ -60,6 +60,9 @@ public:
// Returns a string about the current running system
const QString &runningString() const;
// Returns an extra string about this specific build
const QString &extraString() const;
#ifdef Q_OS_WIN
/// Chatterino's App ID on Windows
///
@@ -85,6 +88,10 @@ private:
// Generate a running string (e.g. Running on Arch Linux, kernel 5.14.3) and store it in runningString_ for future use
void generateRunningString();
QString extraString_;
// Generate an extra string (e.g. "Built for Fedora 42.<br>Report bugs <a href...>here</a>")
void generateExtraString();
#ifdef Q_OS_WIN
std::wstring appUserModelID_;
#endif
+10 -3
View File
@@ -56,10 +56,17 @@ AboutPage::AboutPage()
auto versionInfo = layout.emplace<QGroupBox>("Version");
{
auto vbox = versionInfo.emplace<QVBoxLayout>();
auto version = Version::instance();
const auto &version = Version::instance();
auto label = vbox.emplace<QLabel>(version.buildString() + "<br>" +
version.runningString());
QString string =
version.buildString() % "<br>" % version.runningString();
if (!version.extraString().isEmpty())
{
string += "<br>" % version.extraString();
}
auto label = vbox.emplace<QLabel>(string);
label->setWordWrap(true);
label->setOpenExternalLinks(true);
label->setTextInteractionFlags(Qt::TextBrowserInteraction);