Mercurial > minori
annotate src/gui/dialog/about.cc @ 375:abd956418fe9
gui/pages/now_playing: automatically update progress when the episode is "finished"
author | Paper <paper@tflc.us> |
---|---|
date | Fri, 25 Jul 2025 11:22:55 -0400 |
parents | ea3a74ed2ef9 |
children |
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" |
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
5 #include "gui/dialog/licenses.h" |
63 | 6 #include "gui/widgets/text.h" |
292 | 7 |
8 #include "utf8proc.h" | |
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
9 #include <fmt/core.h> |
367
8d45d892be88
*: instead of pugixml, use Qt XML features
Paper <paper@tflc.us>
parents:
339
diff
changeset
|
10 #include <toml11/toml.hpp> |
330 | 11 |
258 | 12 #include <QCoreApplication> |
51 | 13 #include <QFont> |
14 #include <QHBoxLayout> | |
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
15 #include <QPushButton> |
63 | 16 #include <QTextBrowser> |
17 #include <QTextCharFormat> | |
18 #include <QTextCursor> | |
258 | 19 |
63 | 20 #include <curl/curl.h> |
108 | 21 #ifdef WIN32 |
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
22 # include "sys/win32/dark_theme.h" |
108 | 23 #endif |
51 | 24 |
258 | 25 template<typename T, size_t N> |
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
26 constexpr size_t array_size(T (&)[N]) |
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
27 { |
104 | 28 return N; |
29 } | |
51 | 30 |
330 | 31 static constexpr semver::version fmt_version{FMT_VERSION / 10000, FMT_VERSION / 100 % 100, FMT_VERSION % 100}; |
258 | 32 static constexpr semver::version json_version{NLOHMANN_JSON_VERSION_MAJOR, NLOHMANN_JSON_VERSION_MINOR, |
33 NLOHMANN_JSON_VERSION_PATCH}; | |
255 | 34 static constexpr semver::version semver_version{SEMVER_VERSION_MAJOR, SEMVER_VERSION_MINOR, SEMVER_VERSION_PATCH}; |
367
8d45d892be88
*: instead of pugixml, use Qt XML features
Paper <paper@tflc.us>
parents:
339
diff
changeset
|
35 static constexpr semver::version toml11_version{TOML11_VERSION_MAJOR, TOML11_VERSION_MINOR, TOML11_VERSION_PATCH}; |
330 | 36 static constexpr semver::version fugue_icons_version{3, 5, 6}; |
51 | 37 |
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
38 const char *get_curl_version() |
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
39 { |
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
40 const curl_version_info_data *data = curl_version_info(CURLVERSION_NOW); |
104 | 41 return data->version; |
42 } | |
51 | 43 |
330 | 44 static constexpr std::string_view about_template = |
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
45 "<body>" |
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
46 "<h2 style=\"font-weight: normal;\"><strong>Minori</strong> v{}</h2>" |
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
47 "<p><strong>Author:</strong><br>Paper <paper@paper.us.eu.org></p>" |
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
48 "<p><strong>Third party components:</strong><br>" |
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
49 "<a href=\"https://curl.se/\">libcurl v{}</a>, " |
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
50 "<a href=\"https://p.yusukekamiyamane.com/\">Fugue Icons v{}</a>, " |
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
51 "<a href=\"https://github.com/erengy/anitomy\">Anitomy</a>, " |
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
52 "<a href=\"https://github.com/nlohmann/json\">JSON for Modern C++ v{}</a>, " |
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
53 "<a href=\"https://github.com/Neargye/semver\">semver v{}</a>, " |
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
54 "<a href=\"http://juliastrings.github.io/utf8proc/\">utf8proc v{}</a>, " |
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
55 "<a href=\"https://github.com/fmtlib/fmt\">fmt v{}</a>, " |
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
56 "<a href=\"https://github.com/ToruNiina/toml11\">toml11 v{}</a>, " |
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
57 "and parts of <a href=\"https://github.com/erengy/anisthesia\">Anisthesia</a>" |
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
58 "</p>" |
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
59 "<span><strong>Special thanks:</strong></span>" |
330 | 60 "<ul style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 15px; margin-right: 0px; -qt-list-indent:0;\">" |
61 "<li><strong>Eren Okka</strong> for creating <a href=\"https://taiga.moe/\">Taiga</a></li>" | |
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
62 "<li><strong>Alex Huszagh</strong> and <strong>Colin Duquesnoy</strong> for creating BreezeStyleSheets, on which " |
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
63 "the dark theme in this program is based off of</li>" |
330 | 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 | |
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
69 AboutWindow::AboutWindow(QWidget *parent) : Dialog(parent) |
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
70 { |
104 | 71 setMinimumSize(641, 325); |
51 | 72 setWindowTitle(tr("About Minori")); |
73 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); | |
74 setAutoFillBackground(true); | |
75 | |
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
76 QVBoxLayout *layout = new QVBoxLayout(this); |
104 | 77 |
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
78 std::string html = |
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
79 fmt::format(about_template, session.version.to_string(), get_curl_version(), fugue_icons_version.to_string(), |
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
80 json_version.to_string(), semver_version.to_string(), utf8proc_version(), fmt_version.to_string(), |
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
81 toml11_version.to_string()); |
108 | 82 |
294 | 83 setBackgroundRole(QPalette::Base); |
108 | 84 |
85 { | |
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
86 QTextBrowser *paragraph = new QTextBrowser(this); |
108 | 87 paragraph->setOpenExternalLinks(true); |
88 paragraph->setFrameShape(QFrame::NoFrame); | |
89 paragraph->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
90 paragraph->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
330 | 91 paragraph->setHtml(Strings::ToQString(html)); |
108 | 92 |
93 layout->addWidget(paragraph); | |
94 } | |
339
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
95 |
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
96 { |
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
97 QPushButton *license = new QPushButton("&Licenses", this); |
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
98 layout->addWidget(license, Qt::AlignRight); |
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
368
diff
changeset
|
99 connect(license, &QPushButton::clicked, this, [] { |
339
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
100 LicensesWindow dialog; |
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
101 dialog.exec(); |
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
102 }); |
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
103 } |
51 | 104 } |