# HG changeset patch # User Paper # Date 1718615817 14400 # Node ID e9d040e2045f5278b4d25e41c98a810b4f0efc66 # Parent 4aeffed717eff84fa1cf269e966fceb6c36544e2 dialog/about: templateize this should be pretty useful for e.g. localization diff -r 4aeffed717ef -r e9d040e2045f src/gui/dialog/about.cc --- a/src/gui/dialog/about.cc Mon Jun 17 04:54:44 2024 -0400 +++ b/src/gui/dialog/about.cc Mon Jun 17 05:16:57 2024 -0400 @@ -8,6 +8,8 @@ #include "utf8proc.h" +#include + #include #include #include @@ -25,17 +27,43 @@ return N; } +static constexpr semver::version fmt_version{FMT_VERSION / 10000, FMT_VERSION / 100 % 100, FMT_VERSION % 100}; static constexpr semver::version pugixml_version{PUGIXML_VERSION / 1000 % 10, PUGIXML_VERSION / 10 % 100, PUGIXML_VERSION % 10}; static constexpr semver::version json_version{NLOHMANN_JSON_VERSION_MAJOR, NLOHMANN_JSON_VERSION_MINOR, NLOHMANN_JSON_VERSION_PATCH}; static constexpr semver::version semver_version{SEMVER_VERSION_MAJOR, SEMVER_VERSION_MINOR, SEMVER_VERSION_PATCH}; +static constexpr semver::version fugue_icons_version{3, 5, 6}; const char* get_curl_version() { const curl_version_info_data* data = curl_version_info(CURLVERSION_NOW); return data->version; } +static constexpr std::string_view about_template = + "" + "

Minori v{}

" + "

Author:
Paper

" + "

Third party components:
" + "libcurl v{}, " + "Fugue Icons v{}, " + "Anitomy, " + "JSON for Modern C++ v{}, " + "pugixml v{}, " + "semver v{}, " + "utf8proc v{}, " + "fmt v{}, " + "parts of Anisthesia" + "

" + "Special thanks:" + "
    " + "
  • Eren Okka for creating Taiga
  • " + "
  • Alex Huszagh and Colin Duquesnoy for creating BreezeStyleSheets, on which the dark theme in this program is based off of
  • " + "
  • Andy Brice for providing some sample code for detecting dark mode on Windows and macOS
  • " + "
  • Manuel Wudka-Robles for providing information on getting open file descriptors on macOS
  • " + "
" + ""; + AboutWindow::AboutWindow(QWidget* parent) : QDialog(parent) { setMinimumSize(641, 325); setWindowTitle(tr("About Minori")); @@ -44,72 +72,7 @@ QHBoxLayout* layout = new QHBoxLayout(this); - /* we have to generate this on-the-fly for localization purposes */ - const QString html = - QString("" - "

Minori v" + - Strings::ToQString(session.version.to_string()) + - "

" - "

" - " " + - tr("Author:") + - "
" - " Paper (@mrpapersonic)" - "

" - "

" - " " + - tr("Third party components:") + - "
" - "libcurl v") + - get_curl_version() + - "" - ", " - "Fugue Icons v3.5.6" - ", " - "Anitomy" - ", " - "JSON for Modern C++ v" + - Strings::ToQString(json_version.to_string()) + - "" - ", " - "pugixml v" + - Strings::ToQString(pugixml_version.to_string()) + - "" - ", " - "semver v" + - Strings::ToQString(semver_version.to_string()) + - "" - ", " - "utf8proc v" + - Strings::ToQString(utf8proc_version()) + - "" - ", parts of " - "Anisthesia" - "

" - "" - "" + - tr("Special thanks:") + - "" - "" - "
    " - "
  • Eren Okka " + - tr("for creating Taiga") + - "
  • " - "
  • Alex Huszagh " + - tr("and") + " Colin Duquesnoy " + - tr("for creating BreezeStyleSheets, on which the dark theme in this program is " - "based off of") + - "
  • " - "
  • Andy Brice " + - tr("for providing some sample code for " - "detecting dark mode on Windows and macOS") + - "
  • " - "
  • Manuel Wudka-Robles " + - tr("for providing information on " - "getting open file descriptors on macOS") + - "
  • " - "
" - ""; + std::string html = fmt::format(about_template, session.version.to_string(), get_curl_version(), fugue_icons_version.to_string(), json_version.to_string(), pugixml_version.to_string(), semver_version.to_string(), utf8proc_version(), fmt_version.to_string()); setBackgroundRole(QPalette::Base); @@ -119,7 +82,7 @@ paragraph->setFrameShape(QFrame::NoFrame); paragraph->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); paragraph->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - paragraph->setHtml(html); + paragraph->setHtml(Strings::ToQString(html)); layout->addWidget(paragraph); }