Mercurial > minori
annotate src/gui/dialog/about.cc @ 104:27455104ea37
about: switch to using HTML
it's still generated at runtime, but only once now
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sun, 05 Nov 2023 02:35:27 -0500 |
parents | 9b2b41f83a5e |
children | 6d8da6e64d61 |
rev | line source |
---|---|
51 | 1 #include "gui/dialog/about.h" |
2 #include "core/json.h" | |
63 | 3 #include "core/version.h" |
104 | 4 #include "core/strings.h" |
63 | 5 #include "gui/widgets/text.h" |
55
d10b6c6b432e
add xml lib, we will need to use it eventually
Paper <mrpapersonic@gmail.com>
parents:
52
diff
changeset
|
6 #include "pugixml.hpp" |
51 | 7 #include <QFont> |
8 #include <QHBoxLayout> | |
63 | 9 #include <QTextBrowser> |
10 #include <QTextCharFormat> | |
11 #include <QTextCursor> | |
12 #include <curl/curl.h> | |
51 | 13 |
104 | 14 template <typename T, size_t N> |
15 constexpr size_t array_size(T (&)[N]) { | |
16 return N; | |
17 } | |
51 | 18 |
104 | 19 #define CONCAT_VERSION_NX(major, minor, patch) "v" #major "." #minor "." #patch |
63 | 20 #define CONCAT_VERSION(major, minor, patch) CONCAT_VERSION_NX(major, minor, patch) |
51 | 21 |
104 | 22 /* Ahhh, my dumb little hack to get this to be constexpr :) */ |
23 static constexpr const char pugixml_version[] = { | |
24 PUGIXML_VERSION / 1000 % 10 + '0', /* Major */ | |
25 '.', | |
26 PUGIXML_VERSION / 100 % 10 + '0', /* Minor */ | |
27 PUGIXML_VERSION / 10 % 10 + '0', | |
28 '.', | |
29 PUGIXML_VERSION % 10 + '0', /* Patch */ | |
30 '\0' | |
31 }; | |
51 | 32 |
104 | 33 const char* get_curl_version() { |
34 const curl_version_info_data* data = curl_version_info(CURLVERSION_NOW); | |
35 return data->version; | |
36 } | |
51 | 37 |
104 | 38 /* I hate HTML so much... */ |
39 static const QString html = QString( | |
40 "<body>" | |
41 " <h2 style=\"font-weight: normal;\"><strong>Minori</strong> " MINORI_VERSION "</h2>" | |
42 " <p>" | |
43 " <strong>Author:</strong><br>" | |
44 " Paper (@mrpapersonic)" | |
45 " </p>" | |
46 " <p>" | |
47 " <strong>Third party components:</strong><br>" | |
48 "<a href=\"https://curl.se/\">libcurl v") + get_curl_version() + "</a>" | |
49 ", " | |
50 "<a href=\"https://p.yusukekamiyamane.com/\">Fugue Icons v3.5.6</a>" | |
51 ", " | |
52 "<a href=\"https://github.com/erengy/anitomy\">Anitomy</a>" | |
53 ", " | |
54 "<a href=\"https://github.com/nlohmann/json\">JSON for Modern C++ " CONCAT_VERSION(NLOHMANN_JSON_VERSION_MAJOR, | |
55 NLOHMANN_JSON_VERSION_MINOR, | |
56 NLOHMANN_JSON_VERSION_PATCH) "</a>" | |
57 ", " | |
58 "<a href=\"https://pugixml.org/\">pugixml v" + pugixml_version + "</a>" | |
59 ", " | |
60 "<a href=\"https://github.com/pulzed/mINI\">mINI v0.9.14</a>" | |
61 " </p>" | |
62 "<span>" | |
63 "<strong>Special thanks:</strong>" | |
64 "</span>" | |
65 " <ul style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 15px; margin-right: 0px; -qt-list-indent:0;\">" | |
66 " <li><strong>Eren Okka</strong> for creating Taiga</li>" | |
67 " <li><strong>Alex Huszagh</strong> and <strong>Colin Duquesnoy</strong> for " | |
68 "creating BreezeStyleSheets, on which the dark theme in this program is " | |
69 "based off of</li>" | |
70 " </ul>" | |
71 "</body>"; | |
51 | 72 |
73 AboutWindow::AboutWindow(QWidget* parent) : QDialog(parent) { | |
104 | 74 setMinimumSize(641, 325); |
51 | 75 setWindowTitle(tr("About Minori")); |
76 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); | |
64 | 77 QHBoxLayout* layout = new QHBoxLayout(this); |
51 | 78 |
79 QPalette pal = QPalette(); | |
80 pal.setColor(QPalette::Window, pal.color(QPalette::Base)); | |
81 setPalette(pal); | |
82 setAutoFillBackground(true); | |
83 | |
84 QTextBrowser* paragraph = new QTextBrowser(this); | |
85 paragraph->setOpenExternalLinks(true); | |
52
0c4138de2ea7
anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
86 paragraph->setFrameShape(QFrame::NoFrame); |
0c4138de2ea7
anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
87 paragraph->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
0c4138de2ea7
anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
88 paragraph->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
104 | 89 paragraph->setHtml(html); |
90 | |
64 | 91 layout->addWidget(paragraph); |
51 | 92 } |