annotate src/gui/dialog/about.cc @ 337:a7d4e5107531

dep/animone: REFACTOR ALL THE THINGS 1: animone now has its own syntax divergent from anisthesia, making different platforms actually have their own sections 2: process names in animone are now called `comm' (this will probably break things). this is what its called in bsd/linux so I'm just going to use it everywhere 3: the X11 code now checks for the existence of a UTF-8 window title and passes it if available 4: ANYTHING THATS NOT LINUX IS 100% UNTESTED AND CAN AND WILL BREAK! I still actually need to test the bsd code. to be honest I'm probably going to move all of the bsds into separate files because they're all essentially different operating systems at this point
author Paper <paper@paper.us.eu.org>
date Wed, 19 Jun 2024 12:51:15 -0400
parents 92f63cf29faa
children eac06513db86
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"
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
3 #include "core/session.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"
292
ac1451035c85 dialog/about: add utf8proc
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
6
55
d10b6c6b432e add xml lib, we will need to use it eventually
Paper <mrpapersonic@gmail.com>
parents: 52
diff changeset
7 #include "pugixml.hpp"
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 255
diff changeset
8
292
ac1451035c85 dialog/about: add utf8proc
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
9 #include "utf8proc.h"
ac1451035c85 dialog/about: add utf8proc
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
10
330
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
11 #include <fmt/core.h>
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
12
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 255
diff changeset
13 #include <QCoreApplication>
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
14 #include <QFont>
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
15 #include <QHBoxLayout>
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
16 #include <QTextBrowser>
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
17 #include <QTextCharFormat>
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
18 #include <QTextCursor>
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 255
diff changeset
19
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
20 #include <curl/curl.h>
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
21 #ifdef WIN32
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 255
diff changeset
22 # include "sys/win32/dark_theme.h"
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
23 #endif
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
24
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 255
diff changeset
25 template<typename T, size_t N>
104
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
26 constexpr size_t array_size(T (&)[N]) {
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
27 return N;
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
28 }
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
29
330
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
30 static constexpr semver::version fmt_version{FMT_VERSION / 10000, FMT_VERSION / 100 % 100, FMT_VERSION % 100};
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 255
diff changeset
31 static constexpr semver::version pugixml_version{PUGIXML_VERSION / 1000 % 10, PUGIXML_VERSION / 10 % 100,
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 255
diff changeset
32 PUGIXML_VERSION % 10};
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 255
diff changeset
33 static constexpr semver::version json_version{NLOHMANN_JSON_VERSION_MAJOR, NLOHMANN_JSON_VERSION_MINOR,
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 255
diff changeset
34 NLOHMANN_JSON_VERSION_PATCH};
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
35 static constexpr semver::version semver_version{SEMVER_VERSION_MAJOR, SEMVER_VERSION_MINOR, SEMVER_VERSION_PATCH};
330
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
36 static constexpr semver::version fugue_icons_version{3, 5, 6};
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 const char* get_curl_version() {
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
39 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
40 return data->version;
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
41 }
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
42
330
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
43 static constexpr std::string_view about_template =
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
44 "<body>"
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
45 "<h2 style=\"font-weight: normal;\"><strong>Minori</strong> v{}</h2>"
332
92f63cf29faa dialog/about: fix displaying of my email address
Paper <paper@paper.us.eu.org>
parents: 330
diff changeset
46 "<p><strong>Author:</strong><br>Paper &lt;paper@paper.us.eu.org&gt;</p>"
330
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
47 "<p><strong>Third party components:</strong><br>"
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
48 "<a href=\"https://curl.se/\">libcurl v{}</a>, "
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
49 "<a href=\"https://p.yusukekamiyamane.com/\">Fugue Icons v{}</a>, "
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
50 "<a href=\"https://github.com/erengy/anitomy\">Anitomy</a>, "
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
51 "<a href=\"https://github.com/nlohmann/json\">JSON for Modern C++ v{}</a>, "
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
52 "<a href=\"https://pugixml.org/\">pugixml v{}</a>, "
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
53 "<a href=\"https://github.com/Neargye/semver\">semver v{}</a>, "
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
54 "<a href=\"http://juliastrings.github.io/utf8proc/\">utf8proc v{}</a>, "
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
55 "<a href=\"https://github.com/fmtlib/fmt\">fmt v{}</a>, "
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
56 "parts of <a href=\"https://github.com/erengy/anisthesia\">Anisthesia</a>"
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
57 "</p>"
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
58 "<span><strong>Special thanks:</strong></span>"
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
59 "<ul style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 15px; margin-right: 0px; -qt-list-indent:0;\">"
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
60 "<li><strong>Eren Okka</strong> for creating <a href=\"https://taiga.moe/\">Taiga</a></li>"
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
61 "<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>"
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
62 "<li><strong>Andy Brice</strong> for providing some sample code for detecting dark mode on Windows and macOS</li>"
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
63 "<li><strong>Manuel Wudka-Robles</strong> for providing information on getting open file descriptors on macOS</li>"
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
64 "</ul>"
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
65 "</body>";
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
66
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
67 AboutWindow::AboutWindow(QWidget* parent) : QDialog(parent) {
104
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
68 setMinimumSize(641, 325);
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
69 setWindowTitle(tr("About Minori"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
70 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
71 setAutoFillBackground(true);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
72
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
73 QHBoxLayout* layout = new QHBoxLayout(this);
104
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
74
330
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
75 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());
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
76
294
99cbc51433e4 *: cleanup uses of QPalette
Paper <paper@paper.us.eu.org>
parents: 292
diff changeset
77 setBackgroundRole(QPalette::Base);
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
78
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
79 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
80 QTextBrowser* paragraph = new QTextBrowser(this);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
81 paragraph->setOpenExternalLinks(true);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
82 paragraph->setFrameShape(QFrame::NoFrame);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
83 paragraph->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
84 paragraph->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
330
e9d040e2045f dialog/about: templateize
Paper <paper@paper.us.eu.org>
parents: 318
diff changeset
85 paragraph->setHtml(Strings::ToQString(html));
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
86
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
87 layout->addWidget(paragraph);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
88 }
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
89 }
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
90
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
91 void AboutWindow::showEvent(QShowEvent* event) {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
92 QDialog::showEvent(event);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
93 #ifdef WIN32
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
94 win32::SetTitleBarsToBlack(session.config.theme.IsInDarkTheme());
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
95 #endif
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
96 }