Mercurial > minori
annotate src/gui/dialog/about.cc @ 367:8d45d892be88 default tip
*: instead of pugixml, use Qt XML features
this means we have one extra Qt dependency though...
author | Paper <paper@tflc.us> |
---|---|
date | Sun, 17 Nov 2024 22:55:47 -0500 |
parents | eac06513db86 |
children |
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 |
8 #include "utf8proc.h" | |
367
8d45d892be88
*: instead of pugixml, use Qt XML features
Paper <paper@tflc.us>
parents:
339
diff
changeset
|
9 #include <toml11/toml.hpp> |
330 | 10 #include <fmt/core.h> |
11 | |
258 | 12 #include <QCoreApplication> |
51 | 13 #include <QFont> |
14 #include <QHBoxLayout> | |
63 | 15 #include <QTextBrowser> |
16 #include <QTextCharFormat> | |
17 #include <QTextCursor> | |
339
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
18 #include <QPushButton> |
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 json_version{NLOHMANN_JSON_VERSION_MAJOR, NLOHMANN_JSON_VERSION_MINOR, |
32 NLOHMANN_JSON_VERSION_PATCH}; | |
255 | 33 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
|
34 static constexpr semver::version toml11_version{TOML11_VERSION_MAJOR, TOML11_VERSION_MINOR, TOML11_VERSION_PATCH}; |
330 | 35 static constexpr semver::version fugue_icons_version{3, 5, 6}; |
51 | 36 |
104 | 37 const char* get_curl_version() { |
38 const curl_version_info_data* data = curl_version_info(CURLVERSION_NOW); | |
39 return data->version; | |
40 } | |
51 | 41 |
330 | 42 static constexpr std::string_view about_template = |
43 "<body>" | |
44 "<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
|
45 "<p><strong>Author:</strong><br>Paper <paper@paper.us.eu.org></p>" |
330 | 46 "<p><strong>Third party components:</strong><br>" |
47 "<a href=\"https://curl.se/\">libcurl v{}</a>, " | |
48 "<a href=\"https://p.yusukekamiyamane.com/\">Fugue Icons v{}</a>, " | |
49 "<a href=\"https://github.com/erengy/anitomy\">Anitomy</a>, " | |
50 "<a href=\"https://github.com/nlohmann/json\">JSON for Modern C++ v{}</a>, " | |
51 "<a href=\"https://github.com/Neargye/semver\">semver v{}</a>, " | |
52 "<a href=\"http://juliastrings.github.io/utf8proc/\">utf8proc v{}</a>, " | |
53 "<a href=\"https://github.com/fmtlib/fmt\">fmt v{}</a>, " | |
367
8d45d892be88
*: instead of pugixml, use Qt XML features
Paper <paper@tflc.us>
parents:
339
diff
changeset
|
54 "<a href=\"https://github.com/ToruNiina/toml11\">toml11 v{}</a>, " |
8d45d892be88
*: instead of pugixml, use Qt XML features
Paper <paper@tflc.us>
parents:
339
diff
changeset
|
55 "and parts of <a href=\"https://github.com/erengy/anisthesia\">Anisthesia</a>" |
330 | 56 "</p>" |
57 "<span><strong>Special thanks:</strong></span>" | |
58 "<ul style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 15px; margin-right: 0px; -qt-list-indent:0;\">" | |
59 "<li><strong>Eren Okka</strong> for creating <a href=\"https://taiga.moe/\">Taiga</a></li>" | |
60 "<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>" | |
61 "<li><strong>Andy Brice</strong> for providing some sample code for detecting dark mode on Windows and macOS</li>" | |
62 "<li><strong>Manuel Wudka-Robles</strong> for providing information on getting open file descriptors on macOS</li>" | |
63 "</ul>" | |
64 "</body>"; | |
65 | |
51 | 66 AboutWindow::AboutWindow(QWidget* parent) : QDialog(parent) { |
104 | 67 setMinimumSize(641, 325); |
51 | 68 setWindowTitle(tr("About Minori")); |
69 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); | |
70 setAutoFillBackground(true); | |
71 | |
339
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
72 QVBoxLayout* layout = new QVBoxLayout(this); |
104 | 73 |
367
8d45d892be88
*: instead of pugixml, use Qt XML features
Paper <paper@tflc.us>
parents:
339
diff
changeset
|
74 std::string html = fmt::format(about_template, session.version.to_string(), get_curl_version(), fugue_icons_version.to_string(), json_version.to_string(), semver_version.to_string(), utf8proc_version(), fmt_version.to_string(), toml11_version.to_string()); |
108 | 75 |
294 | 76 setBackgroundRole(QPalette::Base); |
108 | 77 |
78 { | |
79 QTextBrowser* paragraph = new QTextBrowser(this); | |
80 paragraph->setOpenExternalLinks(true); | |
81 paragraph->setFrameShape(QFrame::NoFrame); | |
82 paragraph->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
83 paragraph->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
330 | 84 paragraph->setHtml(Strings::ToQString(html)); |
108 | 85 |
86 layout->addWidget(paragraph); | |
87 } | |
339
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
88 |
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
89 { |
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
90 QPushButton *license = new QPushButton("&Licenses", this); |
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
91 layout->addWidget(license, Qt::AlignRight); |
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
92 connect(license, &QPushButton::clicked, this, []{ |
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
93 LicensesWindow dialog; |
eac06513db86
dialog/about: add licenses button
Paper <paper@paper.us.eu.org>
parents:
332
diff
changeset
|
94 dialog.exec(); |
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 } |
51 | 97 } |
108 | 98 |
99 void AboutWindow::showEvent(QShowEvent* event) { | |
100 QDialog::showEvent(event); | |
101 #ifdef WIN32 | |
102 win32::SetTitleBarsToBlack(session.config.theme.IsInDarkTheme()); | |
103 #endif | |
104 } |