# HG changeset patch # User Paper # Date 1699169727 18000 # Node ID 27455104ea3798249b0d6deddbc9ed1a54d4e523 # Parent 621084cc542c898b3a2da4ebe28320d5f74ab077 about: switch to using HTML it's still generated at runtime, but only once now diff -r 621084cc542c -r 27455104ea37 src/gui/dialog/about.cc --- a/src/gui/dialog/about.cc Fri Nov 03 22:52:41 2023 -0400 +++ b/src/gui/dialog/about.cc Sun Nov 05 02:35:27 2023 -0500 @@ -1,6 +1,7 @@ #include "gui/dialog/about.h" #include "core/json.h" #include "core/version.h" +#include "core/strings.h" #include "gui/widgets/text.h" #include "pugixml.hpp" #include @@ -10,62 +11,67 @@ #include #include -#define CONCAT_VERSION_NX(major, minor, patch) ("v" #major "." #minor "." #patch) +template +constexpr size_t array_size(T (&)[N]) { + return N; +} +#define CONCAT_VERSION_NX(major, minor, patch) "v" #major "." #minor "." #patch #define CONCAT_VERSION(major, minor, patch) CONCAT_VERSION_NX(major, minor, patch) -#define SET_TITLE_FONT(font, format, cursor) \ - { \ - QFont fnt; \ - fnt.setPixelSize(16); \ - format.setFont(fnt); \ - cursor.setCharFormat(format); \ - } +/* Ahhh, my dumb little hack to get this to be constexpr :) */ +static constexpr const char pugixml_version[] = { + PUGIXML_VERSION / 1000 % 10 + '0', /* Major */ + '.', + PUGIXML_VERSION / 100 % 10 + '0', /* Minor */ + PUGIXML_VERSION / 10 % 10 + '0', + '.', + PUGIXML_VERSION % 10 + '0', /* Patch */ + '\0' +}; -#define SET_PARAGRAPH_FONT(font, format, cursor) \ - { \ - QFont fnt; \ - fnt.setPixelSize(12); \ - format.setFont(fnt); \ - cursor.setCharFormat(format); \ - } - -#define SET_FONT_BOLD(font, format, cursor) \ - { \ - font = cursor.charFormat().font(); \ - font.setBold(true); \ - format.setFont(font); \ - cursor.setCharFormat(format); \ - } +const char* get_curl_version() { + const curl_version_info_data* data = curl_version_info(CURLVERSION_NOW); + return data->version; +} -#define UNSET_FONT_BOLD(font, format, cursor) \ - { \ - font = cursor.charFormat().font(); \ - font.setBold(false); \ - format.setFont(font); \ - cursor.setCharFormat(format); \ - } - -#define SET_FORMAT_HYPERLINK(format, cursor, link) \ - { \ - font = cursor.charFormat().font(); \ - font.setUnderline(true); \ - format.setFont(font); \ - format.setAnchor(true); \ - format.setAnchorHref(link); \ - cursor.setCharFormat(format); \ - } -#define UNSET_FORMAT_HYPERLINK(format, cursor) \ - { \ - font = cursor.charFormat().font(); \ - font.setUnderline(false); \ - format.setFont(font); \ - format.setAnchor(false); \ - format.setAnchorHref(""); \ - cursor.setCharFormat(format); \ - } +/* I hate HTML so much... */ +static const QString html = QString( + "" + "

Minori " MINORI_VERSION "

" + "

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

" + "

" + " Third party components:
" + "libcurl v") + get_curl_version() + "" + ", " + "Fugue Icons v3.5.6" + ", " + "Anitomy" + ", " + "JSON for Modern C++ " CONCAT_VERSION(NLOHMANN_JSON_VERSION_MAJOR, + NLOHMANN_JSON_VERSION_MINOR, + NLOHMANN_JSON_VERSION_PATCH) "" + ", " + "pugixml v" + pugixml_version + "" + ", " + "mINI v0.9.14" + "

" + "" + "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
  • " + "
" + ""; AboutWindow::AboutWindow(QWidget* parent) : QDialog(parent) { + setMinimumSize(641, 325); setWindowTitle(tr("About Minori")); setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); QHBoxLayout* layout = new QHBoxLayout(this); @@ -75,63 +81,12 @@ setPalette(pal); setAutoFillBackground(true); - QFont font; - QTextCharFormat format; QTextBrowser* paragraph = new QTextBrowser(this); paragraph->setOpenExternalLinks(true); paragraph->setFrameShape(QFrame::NoFrame); paragraph->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); paragraph->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - QTextCursor cursor = paragraph->textCursor(); - SET_TITLE_FONT(font, format, cursor); - SET_FONT_BOLD(font, format, cursor); - cursor.insertText("Minori"); - UNSET_FONT_BOLD(font, format, cursor); - cursor.insertText(" " MINORI_VERSION); - SET_PARAGRAPH_FONT(font, format, cursor); - cursor.insertBlock(); - cursor.insertBlock(); - SET_FONT_BOLD(font, format, cursor); - cursor.insertText(tr("Author:")); - UNSET_FONT_BOLD(font, format, cursor); - cursor.insertBlock(); - cursor.insertText(tr("Paper")); - cursor.insertBlock(); - cursor.insertBlock(); - SET_FONT_BOLD(font, format, cursor); - cursor.insertText(tr("Third party components:")); - UNSET_FONT_BOLD(font, format, cursor); - cursor.insertBlock(); - SET_FORMAT_HYPERLINK(format, cursor, "https://github.com/nlohmann/json"); - cursor.insertText(tr("JSON for Modern C++ ") + CONCAT_VERSION(NLOHMANN_JSON_VERSION_MAJOR, - NLOHMANN_JSON_VERSION_MINOR, - NLOHMANN_JSON_VERSION_PATCH)); - UNSET_FORMAT_HYPERLINK(format, cursor); - cursor.insertText(", "); - { - curl_version_info_data* data = curl_version_info(CURLVERSION_NOW); - SET_FORMAT_HYPERLINK(format, cursor, "https://curl.se/"); - cursor.insertText(tr("libcurl v") + data->version); - UNSET_FORMAT_HYPERLINK(format, cursor); - cursor.insertText(", "); - } - SET_FORMAT_HYPERLINK(format, cursor, "https://p.yusukekamiyamane.com/"); - cursor.insertText(tr("Fugue Icons ") + CONCAT_VERSION(3, 5, 6)); - UNSET_FORMAT_HYPERLINK(format, cursor); - cursor.insertText(", "); - SET_FORMAT_HYPERLINK(format, cursor, "https://pugixml.org/"); - cursor.insertText(tr("pugixml v") + QString::number(PUGIXML_VERSION / 1000) + "." + - QString::number(PUGIXML_VERSION / 10 % 100) + "." + QString::number(PUGIXML_VERSION % 10)); - UNSET_FORMAT_HYPERLINK(format, cursor); - cursor.insertText(", "); - SET_FORMAT_HYPERLINK(format, cursor, "https://github.com/erengy/anitomy"); - cursor.insertText(tr("Anitomy")); - UNSET_FORMAT_HYPERLINK(format, cursor); - cursor.insertBlock(); - cursor.insertBlock(); - SET_FONT_BOLD(font, format, cursor); - cursor.insertText(tr("Links:")); - UNSET_FONT_BOLD(font, format, cursor); - cursor.insertBlock(); + paragraph->setHtml(html); + layout->addWidget(paragraph); }