Mercurial > minori
changeset 330:e9d040e2045f
dialog/about: templateize
this should be pretty useful for e.g. localization
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Mon, 17 Jun 2024 05:16:57 -0400 |
parents | 4aeffed717ef |
children | 3c755136f074 |
files | src/gui/dialog/about.cc |
diffstat | 1 files changed, 30 insertions(+), 67 deletions(-) [+] |
line wrap: on
line diff
--- 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 <fmt/core.h> + #include <QCoreApplication> #include <QFont> #include <QHBoxLayout> @@ -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 = + "<body>" + "<h2 style=\"font-weight: normal;\"><strong>Minori</strong> v{}</h2>" + "<p><strong>Author:</strong><br>Paper <paper@paper.us.eu.org></p>" + "<p><strong>Third party components:</strong><br>" + "<a href=\"https://curl.se/\">libcurl v{}</a>, " + "<a href=\"https://p.yusukekamiyamane.com/\">Fugue Icons v{}</a>, " + "<a href=\"https://github.com/erengy/anitomy\">Anitomy</a>, " + "<a href=\"https://github.com/nlohmann/json\">JSON for Modern C++ v{}</a>, " + "<a href=\"https://pugixml.org/\">pugixml v{}</a>, " + "<a href=\"https://github.com/Neargye/semver\">semver v{}</a>, " + "<a href=\"http://juliastrings.github.io/utf8proc/\">utf8proc v{}</a>, " + "<a href=\"https://github.com/fmtlib/fmt\">fmt v{}</a>, " + "parts of <a href=\"https://github.com/erengy/anisthesia\">Anisthesia</a>" + "</p>" + "<span><strong>Special thanks:</strong></span>" + "<ul style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 15px; margin-right: 0px; -qt-list-indent:0;\">" + "<li><strong>Eren Okka</strong> for creating <a href=\"https://taiga.moe/\">Taiga</a></li>" + "<li><strong>Alex Huszagh</strong> and <strong>Colin Duquesnoy</strong> for creating BreezeStyleSheets, on which the dark theme in this program is based off of</li>" + "<li><strong>Andy Brice</strong> for providing some sample code for detecting dark mode on Windows and macOS</li>" + "<li><strong>Manuel Wudka-Robles</strong> for providing information on getting open file descriptors on macOS</li>" + "</ul>" + "</body>"; + 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("<body>" - " <h2 style=\"font-weight: normal;\"><strong>Minori</strong> v" + - Strings::ToQString(session.version.to_string()) + - "</h2>" - " <p>" - " <strong>" + - tr("Author:") + - "</strong><br>" - " Paper (@mrpapersonic)" - " </p>" - " <p>" - " <strong>" + - tr("Third party components:") + - "</strong><br>" - "<a href=\"https://curl.se/\">libcurl v") + - get_curl_version() + - "</a>" - ", " - "<a href=\"https://p.yusukekamiyamane.com/\">Fugue Icons v3.5.6</a>" - ", " - "<a href=\"https://github.com/erengy/anitomy\">Anitomy</a>" - ", " - "<a href=\"https://github.com/nlohmann/json\">JSON for Modern C++ v" + - Strings::ToQString(json_version.to_string()) + - "</a>" - ", " - "<a href=\"https://pugixml.org/\">pugixml v" + - Strings::ToQString(pugixml_version.to_string()) + - "</a>" - ", " - "<a href=\"https://github.com/Neargye/semver\">semver v" + - Strings::ToQString(semver_version.to_string()) + - "</a>" - ", " - "<a href=\"http://juliastrings.github.io/utf8proc/\">utf8proc v" + - Strings::ToQString(utf8proc_version()) + - "</a>" - ", parts of " - "<a href=\"https://github.com/erengy/anisthesia\">Anisthesia</a>" - " </p>" - "<span>" - "<strong>" + - tr("Special thanks:") + - "</strong>" - "</span>" - " <ul style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 15px; margin-right: 0px; -qt-list-indent:0;\">" - " <li><strong>Eren Okka</strong> " + - tr("for creating <a href=\"https://taiga.moe/\">Taiga</a>") + - "</li>" - " <li><strong>Alex Huszagh</strong> " + - tr("and") + " <strong>Colin Duquesnoy</strong> " + - tr("for creating BreezeStyleSheets, on which the dark theme in this program is " - "based off of") + - "</li>" - " <li><strong>Andy Brice</strong> " + - tr("for providing some sample code for " - "detecting dark mode on Windows and macOS") + - "</li>" - " <li><strong>Manuel Wudka-Robles</strong> " + - tr("for providing information on " - "getting open file descriptors on macOS") + - "</li>" - " </ul>" - "</body>"; + 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); }