annotate src/gui/dialog/about.cc @ 255:fe702c8f161f

*: whatever
author Paper <paper@paper.us.eu.org>
date Wed, 07 Feb 2024 17:04:06 -0500
parents 4d461ef7d424
children 862d0d8619f6
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"
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>
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
12 #include <QCoreApplication>
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
13 #include <curl/curl.h>
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
14 #ifdef WIN32
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
15 #include "sys/win32/dark_theme.h"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
16 #endif
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
17
104
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
18 template <typename T, size_t N>
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
19 constexpr size_t array_size(T (&)[N]) {
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
20 return N;
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
21 }
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
22
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
23 static constexpr semver::version pugixml_version{PUGIXML_VERSION / 1000 % 10, PUGIXML_VERSION / 10 % 100, PUGIXML_VERSION % 10};
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
24 static constexpr semver::version json_version{NLOHMANN_JSON_VERSION_MAJOR, NLOHMANN_JSON_VERSION_MINOR, NLOHMANN_JSON_VERSION_PATCH};
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
25 static constexpr semver::version semver_version{SEMVER_VERSION_MAJOR, SEMVER_VERSION_MINOR, SEMVER_VERSION_PATCH};
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
26
104
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
27 const char* get_curl_version() {
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
28 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
29 return data->version;
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
30 }
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
31
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
32 AboutWindow::AboutWindow(QWidget* parent) : QDialog(parent) {
104
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
33 setMinimumSize(641, 325);
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
34 setWindowTitle(tr("About Minori"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
35 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
36 setAutoFillBackground(true);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
37
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
38 QHBoxLayout* layout = new QHBoxLayout(this);
104
27455104ea37 about: switch to using HTML
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
39
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
40 /* we have to generate this on-the-fly for localization purposes */
189
649786bae914 *: etc. code cleanup
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
41 const QString html = QString(
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
42 "<body>"
221
53211cb1e7f5 library: add initial library stuff
Paper <paper@paper.us.eu.org>
parents: 189
diff changeset
43 " <h2 style=\"font-weight: normal;\"><strong>Minori</strong> v" + Strings::ToQString(session.version.to_string()) + "</h2>"
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
44 " <p>"
224
7ca56c4ac0bc about: don't abuse QCoreApplication:tr
Paper <mrpapersonic@gmail.com>
parents: 221
diff changeset
45 " <strong>" + tr("Author:") + "</strong><br>"
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
46 " Paper (@mrpapersonic)"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
47 " </p>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
48 " <p>"
224
7ca56c4ac0bc about: don't abuse QCoreApplication:tr
Paper <mrpapersonic@gmail.com>
parents: 221
diff changeset
49 " <strong>" + tr("Third party components:") + "</strong><br>"
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
50 "<a href=\"https://curl.se/\">libcurl v") + get_curl_version() + "</a>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
51 ", "
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
52 "<a href=\"https://p.yusukekamiyamane.com/\">Fugue Icons v3.5.6</a>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
53 ", "
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
54 "<a href=\"https://github.com/erengy/anitomy\">Anitomy</a>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
55 ", "
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
56 "<a href=\"https://github.com/nlohmann/json\">JSON for Modern C++ v" + Strings::ToQString(json_version.to_string()) + "</a>"
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
57 ", "
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
58 "<a href=\"https://pugixml.org/\">pugixml v" + Strings::ToQString(pugixml_version.to_string()) + "</a>"
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
59 ", "
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
60 "<a href=\"https://github.com/pulzed/mINI\">mINI v0.9.14</a>"
255
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
61 ", "
fe702c8f161f *: whatever
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
62 "<a href=\"https://github.com/Neargye/semver\">semver v" + Strings::ToQString(semver_version.to_string()) + "</a>"
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
63 " </p>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
64 "<span>"
224
7ca56c4ac0bc about: don't abuse QCoreApplication:tr
Paper <mrpapersonic@gmail.com>
parents: 221
diff changeset
65 "<strong>" + tr("Special thanks:") + "</strong>"
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
66 "</span>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
67 " <ul style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 15px; margin-right: 0px; -qt-list-indent:0;\">"
224
7ca56c4ac0bc about: don't abuse QCoreApplication:tr
Paper <mrpapersonic@gmail.com>
parents: 221
diff changeset
68 " <li><strong>Eren Okka</strong> " + tr("for creating Taiga") + "</li>"
7ca56c4ac0bc about: don't abuse QCoreApplication:tr
Paper <mrpapersonic@gmail.com>
parents: 221
diff changeset
69 " <li><strong>Alex Huszagh</strong> " + tr("and") + " <strong>Colin Duquesnoy</strong> " +
7ca56c4ac0bc about: don't abuse QCoreApplication:tr
Paper <mrpapersonic@gmail.com>
parents: 221
diff changeset
70 tr("for creating BreezeStyleSheets, on which the dark theme in this program is "
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
71 "based off of") + "</li>"
224
7ca56c4ac0bc about: don't abuse QCoreApplication:tr
Paper <mrpapersonic@gmail.com>
parents: 221
diff changeset
72 " <li><strong>Andy Brice</strong> " + tr("for providing some sample code for "
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
73 "detecting dark mode on Windows and macOS") + "</li>"
224
7ca56c4ac0bc about: don't abuse QCoreApplication:tr
Paper <mrpapersonic@gmail.com>
parents: 221
diff changeset
74 " <li><strong>Manuel Wudka-Robles</strong> " + tr("for providing information on "
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
75 "getting open file descriptors on macOS") + "</li>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
76 " </ul>"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
77 "</body>";
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 QPalette pal = QPalette();
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
81 pal.setColor(QPalette::Window, pal.color(QPalette::Base));
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
82 setPalette(pal);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
83 }
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
84
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
85 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
86 QTextBrowser* paragraph = new QTextBrowser(this);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
87 paragraph->setOpenExternalLinks(true);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
88 paragraph->setFrameShape(QFrame::NoFrame);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
89 paragraph->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
90 paragraph->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
91 paragraph->setHtml(html);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
92
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
93 layout->addWidget(paragraph);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
94 }
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
95 }
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
96
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
97 void AboutWindow::showEvent(QShowEvent* event) {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
98 QDialog::showEvent(event);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
99 #ifdef WIN32
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
100 win32::SetTitleBarsToBlack(session.config.theme.IsInDarkTheme());
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
101 #endif
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
102 }