Mercurial > minori
annotate src/gui/dialog/about.cc @ 351:c844f8bb87ce
gui/theme: add xsettings backend
this also adds newly-necessary endianness methods in core/endian.h
which just so happen to be constexpr as well
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Sun, 14 Jul 2024 23:23:56 -0400 |
parents | eac06513db86 |
children | 8d45d892be88 |
rev | line source |
---|---|
51 | 1 #include "gui/dialog/about.h" |
339
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
2 #include "gui/dialog/licenses.h" |
51 | 3 #include "core/json.h" |
108 | 4 #include "core/session.h" |
104 | 5 #include "core/strings.h" |
63 | 6 #include "gui/widgets/text.h" |
292 | 7 |
55
d10b6c6b432e
add xml lib, we will need to use it eventually
Paper <mrpapersonic@gmail.com>
parents:
52
diff
changeset
|
8 #include "pugixml.hpp" |
258 | 9 |
292 | 10 #include "utf8proc.h" |
11 | |
330 | 12 #include <fmt/core.h> |
13 | |
258 | 14 #include <QCoreApplication> |
51 | 15 #include <QFont> |
16 #include <QHBoxLayout> | |
63 | 17 #include <QTextBrowser> |
18 #include <QTextCharFormat> | |
19 #include <QTextCursor> | |
339
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
20 #include <QPushButton> |
258 | 21 |
63 | 22 #include <curl/curl.h> |
108 | 23 #ifdef WIN32 |
258 | 24 # include "sys/win32/dark_theme.h" |
108 | 25 #endif |
51 | 26 |
258 | 27 template<typename T, size_t N> |
104 | 28 constexpr size_t array_size(T (&)[N]) { |
29 return N; | |
30 } | |
51 | 31 |
330 | 32 static constexpr semver::version fmt_version{FMT_VERSION / 10000, FMT_VERSION / 100 % 100, FMT_VERSION % 100}; |
258 | 33 static constexpr semver::version pugixml_version{PUGIXML_VERSION / 1000 % 10, PUGIXML_VERSION / 10 % 100, |
34 PUGIXML_VERSION % 10}; | |
35 static constexpr semver::version json_version{NLOHMANN_JSON_VERSION_MAJOR, NLOHMANN_JSON_VERSION_MINOR, | |
36 NLOHMANN_JSON_VERSION_PATCH}; | |
255 | 37 static constexpr semver::version semver_version{SEMVER_VERSION_MAJOR, SEMVER_VERSION_MINOR, SEMVER_VERSION_PATCH}; |
330 | 38 static constexpr semver::version fugue_icons_version{3, 5, 6}; |
51 | 39 |
104 | 40 const char* get_curl_version() { |
41 const curl_version_info_data* data = curl_version_info(CURLVERSION_NOW); | |
42 return data->version; | |
43 } | |
51 | 44 |
330 | 45 static constexpr std::string_view about_template = |
46 "<body>" | |
47 "<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
|
48 "<p><strong>Author:</strong><br>Paper <paper@paper.us.eu.org></p>" |
330 | 49 "<p><strong>Third party components:</strong><br>" |
50 "<a href=\"https://curl.se/\">libcurl v{}</a>, " | |
51 "<a href=\"https://p.yusukekamiyamane.com/\">Fugue Icons v{}</a>, " | |
52 "<a href=\"https://github.com/erengy/anitomy\">Anitomy</a>, " | |
53 "<a href=\"https://github.com/nlohmann/json\">JSON for Modern C++ v{}</a>, " | |
54 "<a href=\"https://pugixml.org/\">pugixml v{}</a>, " | |
55 "<a href=\"https://github.com/Neargye/semver\">semver v{}</a>, " | |
56 "<a href=\"http://juliastrings.github.io/utf8proc/\">utf8proc v{}</a>, " | |
57 "<a href=\"https://github.com/fmtlib/fmt\">fmt v{}</a>, " | |
58 "parts of <a href=\"https://github.com/erengy/anisthesia\">Anisthesia</a>" | |
59 "</p>" | |
60 "<span><strong>Special thanks:</strong></span>" | |
61 "<ul style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 15px; margin-right: 0px; -qt-list-indent:0;\">" | |
62 "<li><strong>Eren Okka</strong> for creating <a href=\"https://taiga.moe/\">Taiga</a></li>" | |
63 "<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>" | |
64 "<li><strong>Andy Brice</strong> for providing some sample code for detecting dark mode on Windows and macOS</li>" | |
65 "<li><strong>Manuel Wudka-Robles</strong> for providing information on getting open file descriptors on macOS</li>" | |
66 "</ul>" | |
67 "</body>"; | |
68 | |
51 | 69 AboutWindow::AboutWindow(QWidget* parent) : QDialog(parent) { |
104 | 70 setMinimumSize(641, 325); |
51 | 71 setWindowTitle(tr("About Minori")); |
72 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); | |
73 setAutoFillBackground(true); | |
74 | |
339
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
75 QVBoxLayout* layout = new QVBoxLayout(this); |
104 | 76 |
330 | 77 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 | 78 |
294 | 79 setBackgroundRole(QPalette::Base); |
108 | 80 |
81 { | |
82 QTextBrowser* paragraph = new QTextBrowser(this); | |
83 paragraph->setOpenExternalLinks(true); | |
84 paragraph->setFrameShape(QFrame::NoFrame); | |
85 paragraph->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
86 paragraph->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
330 | 87 paragraph->setHtml(Strings::ToQString(html)); |
108 | 88 |
89 layout->addWidget(paragraph); | |
90 } | |
339
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
91 |
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
92 { |
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
93 QPushButton *license = new QPushButton("&Licenses", this); |
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
94 layout->addWidget(license, Qt::AlignRight); |
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
95 connect(license, &QPushButton::clicked, this, []{ |
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
96 LicensesWindow dialog; |
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
97 dialog.exec(); |
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
98 }); |
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
99 } |
51 | 100 } |
108 | 101 |
102 void AboutWindow::showEvent(QShowEvent* event) { | |
103 QDialog::showEvent(event); | |
104 #ifdef WIN32 | |
105 win32::SetTitleBarsToBlack(session.config.theme.IsInDarkTheme()); | |
106 #endif | |
107 } |