annotate src/gui/dialog/about.cc @ 187:9613d72b097e

*: multiple performance improvements like marking `static const` when it makes sense... date: change old stupid heap-based method to a structure which should make copying the thing actually make a copy. also many performance-based changes, like removing the std::tie dependency and forward-declaring nlohmann json *: replace every instance of QString::fromUtf8 to Strings::ToQString. the main difference is that our function will always convert exactly what is in the string, while some other times it would only convert up to the nearest NUL byte
author Paper <mrpapersonic@gmail.com>
date Wed, 06 Dec 2023 13:43:54 -0500
parents 2004b41d4a59
children 649786bae914
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"
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
4 #include "core/session.h"
104
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
5 #include "core/strings.h"
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
6 #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
7 #include "pugixml.hpp"
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
8 #include <QFont>
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
9 #include <QHBoxLayout>
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
10 #include <QTextBrowser>
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
11 #include <QTextCharFormat>
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
12 #include <QTextCursor>
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
13 #include <QCoreApplication>
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
14 #include <curl/curl.h>
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
15 #ifdef WIN32
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
16 #include "sys/win32/dark_theme.h"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
17 #endif
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 template <typename T, size_t N>
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
20 constexpr size_t array_size(T (&)[N]) {
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
21 return N;
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
22 }
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
23
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
24 /* used for JSON for Modern C++ */
104
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
25 #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
26 #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
27
104
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
28 /* 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
29 static constexpr const char pugixml_version[] = {
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
30 PUGIXML_VERSION / 1000 % 10 + '0', /* Major */
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
31 '.',
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
32 PUGIXML_VERSION / 100 % 10 + '0', /* Minor */
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
33 PUGIXML_VERSION / 10 % 10 + '0',
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
34 '.',
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
35 PUGIXML_VERSION % 10 + '0', /* Patch */
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
36 '\0'
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
37 };
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
38
104
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
39 const char* get_curl_version() {
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
40 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
41 return data->version;
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
42 }
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
43
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
44 AboutWindow::AboutWindow(QWidget* parent) : QDialog(parent) {
104
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
45 setMinimumSize(641, 325);
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
46 setWindowTitle(tr("About Minori"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
47 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
48 setAutoFillBackground(true);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
49
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
50 QHBoxLayout* layout = new QHBoxLayout(this);
104
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
51
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
52 /* we have to generate this on-the-fly for localization purposes */
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
53 static const QString html = QString(
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
54 "<body>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
55 " <h2 style=\"font-weight: normal;\"><strong>Minori</strong> " MINORI_VERSION "</h2>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
56 " <p>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
57 " <strong>" + QCoreApplication::tr("Author:") + "</strong><br>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
58 " Paper (@mrpapersonic)"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
59 " </p>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
60 " <p>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
61 " <strong>" + QCoreApplication::tr("Third party components:") + "</strong><br>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
62 "<a href=\"https://curl.se/\">libcurl v") + get_curl_version() + "</a>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
63 ", "
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
64 "<a href=\"https://p.yusukekamiyamane.com/\">Fugue Icons v3.5.6</a>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
65 ", "
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
66 "<a href=\"https://github.com/erengy/anitomy\">Anitomy</a>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
67 ", "
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
68 "<a href=\"https://github.com/nlohmann/json\">JSON for Modern C++ " CONCAT_VERSION(NLOHMANN_JSON_VERSION_MAJOR,
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
69 NLOHMANN_JSON_VERSION_MINOR,
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
70 NLOHMANN_JSON_VERSION_PATCH) "</a>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
71 ", "
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
72 "<a href=\"https://pugixml.org/\">pugixml v" + pugixml_version + "</a>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
73 ", "
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
74 "<a href=\"https://github.com/pulzed/mINI\">mINI v0.9.14</a>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
75 " </p>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
76 "<span>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
77 "<strong>" + QCoreApplication::tr("Special thanks:") + "</strong>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
78 "</span>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
79 " <ul style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 15px; margin-right: 0px; -qt-list-indent:0;\">"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
80 " <li><strong>Eren Okka</strong> " + QCoreApplication::tr("for creating Taiga") + "</li>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
81 " <li><strong>Alex Huszagh</strong> " + QCoreApplication::tr("and") + " <strong>Colin Duquesnoy</strong> " +
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
82 QCoreApplication::tr("for creating BreezeStyleSheets, on which the dark theme in this program is "
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
83 "based off of") + "</li>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
84 " <li><strong>Andy Brice</strong> " + QCoreApplication::tr("for providing some sample code for "
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
85 "detecting dark mode on Windows and macOS") + "</li>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
86 " <li><strong>Manuel Wudka-Robles</strong> " + QCoreApplication::tr("for providing information on "
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
87 "getting open file descriptors on macOS") + "</li>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
88 " </ul>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
89 "</body>";
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
90
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
91 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
92 QPalette pal = QPalette();
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
93 pal.setColor(QPalette::Window, pal.color(QPalette::Base));
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
94 setPalette(pal);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
95 }
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
96
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
97 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
98 QTextBrowser* paragraph = new QTextBrowser(this);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
99 paragraph->setOpenExternalLinks(true);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
100 paragraph->setFrameShape(QFrame::NoFrame);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
101 paragraph->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
102 paragraph->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
103 paragraph->setHtml(html);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
104
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
105 layout->addWidget(paragraph);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
106 }
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
107 }
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
109 void AboutWindow::showEvent(QShowEvent* event) {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
110 QDialog::showEvent(event);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
111 #ifdef WIN32
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
112 win32::SetTitleBarsToBlack(session.config.theme.IsInDarkTheme());
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
113 #endif
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
114 }
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
115
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
116 #include "gui/dialog/moc_about.cpp"