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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
1 #include "gui/dialog/about.h"
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
2 #include "core/json.h"
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
3 #include "core/version.h"
104
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
4 #include "core/strings.h"
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
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
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
7 #include <QFont>
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
8 #include <QHBoxLayout>
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
9 #include <QTextBrowser>
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
10 #include <QTextCharFormat>
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
11 #include <QTextCursor>
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
12 #include <curl/curl.h>
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
13
104
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
14 template <typename T, size_t N>
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
15 constexpr size_t array_size(T (&)[N]) {
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
16 return N;
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
17 }
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
18
104
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
19 #define CONCAT_VERSION_NX(major, minor, patch) "v" #major "." #minor "." #patch
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
20 #define CONCAT_VERSION(major, minor, patch) CONCAT_VERSION_NX(major, minor, patch)
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
21
104
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
22 /* Ahhh, my dumb little hack to get this to be constexpr :) */
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
23 static constexpr const char pugixml_version[] = {
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
24 PUGIXML_VERSION / 1000 % 10 + '0', /* Major */
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
25 '.',
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
26 PUGIXML_VERSION / 100 % 10 + '0', /* Minor */
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
27 PUGIXML_VERSION / 10 % 10 + '0',
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
28 '.',
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
29 PUGIXML_VERSION % 10 + '0', /* Patch */
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
30 '\0'
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
31 };
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
32
104
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
33 const char* get_curl_version() {
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
34 const curl_version_info_data* data = curl_version_info(CURLVERSION_NOW);
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
35 return data->version;
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
36 }
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
37
104
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
38 /* I hate HTML so much... */
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
39 static const QString html = QString(
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
40 "<body>"
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
41 " <h2 style=\"font-weight: normal;\"><strong>Minori</strong> " MINORI_VERSION "</h2>"
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
42 " <p>"
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
43 " <strong>Author:</strong><br>"
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
44 " Paper (@mrpapersonic)"
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
45 " </p>"
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
46 " <p>"
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
47 " <strong>Third party components:</strong><br>"
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
48 "<a href=\"https://curl.se/\">libcurl v") + get_curl_version() + "</a>"
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
49 ", "
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
50 "<a href=\"https://p.yusukekamiyamane.com/\">Fugue Icons v3.5.6</a>"
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
51 ", "
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
52 "<a href=\"https://github.com/erengy/anitomy\">Anitomy</a>"
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
53 ", "
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
54 "<a href=\"https://github.com/nlohmann/json\">JSON for Modern C++ " CONCAT_VERSION(NLOHMANN_JSON_VERSION_MAJOR,
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
55 NLOHMANN_JSON_VERSION_MINOR,
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
56 NLOHMANN_JSON_VERSION_PATCH) "</a>"
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
57 ", "
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
58 "<a href=\"https://pugixml.org/\">pugixml v" + pugixml_version + "</a>"
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
59 ", "
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
60 "<a href=\"https://github.com/pulzed/mINI\">mINI v0.9.14</a>"
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
61 " </p>"
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
62 "<span>"
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
63 "<strong>Special thanks:</strong>"
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
64 "</span>"
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
65 " <ul style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 15px; margin-right: 0px; -qt-list-indent:0;\">"
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
66 " <li><strong>Eren Okka</strong> for creating Taiga</li>"
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
67 " <li><strong>Alex Huszagh</strong> and <strong>Colin Duquesnoy</strong> for "
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
68 "creating BreezeStyleSheets, on which the dark theme in this program is "
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
69 "based off of</li>"
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
70 " </ul>"
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
71 "</body>";
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
72
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
73 AboutWindow::AboutWindow(QWidget* parent) : QDialog(parent) {
104
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
74 setMinimumSize(641, 325);
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
75 setWindowTitle(tr("About Minori"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
76 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
77 QHBoxLayout* layout = new QHBoxLayout(this);
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
78
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
79 QPalette pal = QPalette();
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
80 pal.setColor(QPalette::Window, pal.color(QPalette::Base));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
81 setPalette(pal);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
82 setAutoFillBackground(true);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
83
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
84 QTextBrowser* paragraph = new QTextBrowser(this);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
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
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
89 paragraph->setHtml(html);
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
90
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
91 layout->addWidget(paragraph);
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
92 }