Mercurial > minori
annotate src/gui/dialog/about.cc @ 338:f63dfa309380
dep/animone: separate *BSD into separate files
they are wholly different operating systems with very different
kernels on the inside
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Wed, 19 Jun 2024 13:06:10 -0400 |
parents | 92f63cf29faa |
children | eac06513db86 |
rev | line source |
---|---|
51 | 1 #include "gui/dialog/about.h" |
2 #include "core/json.h" | |
108 | 3 #include "core/session.h" |
104 | 4 #include "core/strings.h" |
63 | 5 #include "gui/widgets/text.h" |
292 | 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 | 8 |
292 | 9 #include "utf8proc.h" |
10 | |
330 | 11 #include <fmt/core.h> |
12 | |
258 | 13 #include <QCoreApplication> |
51 | 14 #include <QFont> |
15 #include <QHBoxLayout> | |
63 | 16 #include <QTextBrowser> |
17 #include <QTextCharFormat> | |
18 #include <QTextCursor> | |
258 | 19 |
63 | 20 #include <curl/curl.h> |
108 | 21 #ifdef WIN32 |
258 | 22 # include "sys/win32/dark_theme.h" |
108 | 23 #endif |
51 | 24 |
258 | 25 template<typename T, size_t N> |
104 | 26 constexpr size_t array_size(T (&)[N]) { |
27 return N; | |
28 } | |
51 | 29 |
330 | 30 static constexpr semver::version fmt_version{FMT_VERSION / 10000, FMT_VERSION / 100 % 100, FMT_VERSION % 100}; |
258 | 31 static constexpr semver::version pugixml_version{PUGIXML_VERSION / 1000 % 10, PUGIXML_VERSION / 10 % 100, |
32 PUGIXML_VERSION % 10}; | |
33 static constexpr semver::version json_version{NLOHMANN_JSON_VERSION_MAJOR, NLOHMANN_JSON_VERSION_MINOR, | |
34 NLOHMANN_JSON_VERSION_PATCH}; | |
255 | 35 static constexpr semver::version semver_version{SEMVER_VERSION_MAJOR, SEMVER_VERSION_MINOR, SEMVER_VERSION_PATCH}; |
330 | 36 static constexpr semver::version fugue_icons_version{3, 5, 6}; |
51 | 37 |
104 | 38 const char* get_curl_version() { |
39 const curl_version_info_data* data = curl_version_info(CURLVERSION_NOW); | |
40 return data->version; | |
41 } | |
51 | 42 |
330 | 43 static constexpr std::string_view about_template = |
44 "<body>" | |
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 <paper@paper.us.eu.org></p>" |
330 | 47 "<p><strong>Third party components:</strong><br>" |
48 "<a href=\"https://curl.se/\">libcurl v{}</a>, " | |
49 "<a href=\"https://p.yusukekamiyamane.com/\">Fugue Icons v{}</a>, " | |
50 "<a href=\"https://github.com/erengy/anitomy\">Anitomy</a>, " | |
51 "<a href=\"https://github.com/nlohmann/json\">JSON for Modern C++ v{}</a>, " | |
52 "<a href=\"https://pugixml.org/\">pugixml v{}</a>, " | |
53 "<a href=\"https://github.com/Neargye/semver\">semver v{}</a>, " | |
54 "<a href=\"http://juliastrings.github.io/utf8proc/\">utf8proc v{}</a>, " | |
55 "<a href=\"https://github.com/fmtlib/fmt\">fmt v{}</a>, " | |
56 "parts of <a href=\"https://github.com/erengy/anisthesia\">Anisthesia</a>" | |
57 "</p>" | |
58 "<span><strong>Special thanks:</strong></span>" | |
59 "<ul style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 15px; margin-right: 0px; -qt-list-indent:0;\">" | |
60 "<li><strong>Eren Okka</strong> for creating <a href=\"https://taiga.moe/\">Taiga</a></li>" | |
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>" | |
62 "<li><strong>Andy Brice</strong> for providing some sample code for detecting dark mode on Windows and macOS</li>" | |
63 "<li><strong>Manuel Wudka-Robles</strong> for providing information on getting open file descriptors on macOS</li>" | |
64 "</ul>" | |
65 "</body>"; | |
66 | |
51 | 67 AboutWindow::AboutWindow(QWidget* parent) : QDialog(parent) { |
104 | 68 setMinimumSize(641, 325); |
51 | 69 setWindowTitle(tr("About Minori")); |
70 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); | |
71 setAutoFillBackground(true); | |
72 | |
108 | 73 QHBoxLayout* layout = new QHBoxLayout(this); |
104 | 74 |
330 | 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 | 76 |
294 | 77 setBackgroundRole(QPalette::Base); |
108 | 78 |
79 { | |
80 QTextBrowser* paragraph = new QTextBrowser(this); | |
81 paragraph->setOpenExternalLinks(true); | |
82 paragraph->setFrameShape(QFrame::NoFrame); | |
83 paragraph->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
84 paragraph->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
330 | 85 paragraph->setHtml(Strings::ToQString(html)); |
108 | 86 |
87 layout->addWidget(paragraph); | |
88 } | |
51 | 89 } |
108 | 90 |
91 void AboutWindow::showEvent(QShowEvent* event) { | |
92 QDialog::showEvent(event); | |
93 #ifdef WIN32 | |
94 win32::SetTitleBarsToBlack(session.config.theme.IsInDarkTheme()); | |
95 #endif | |
96 } |