Mercurial > minori
comparison src/gui/dialog/about.cc @ 370:ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
author | Paper <paper@tflc.us> |
---|---|
date | Fri, 25 Jul 2025 10:22:04 -0400 |
parents | 6d37a998cf91 |
children |
comparison
equal
deleted
inserted
replaced
369:47c9f8502269 | 370:ea3a74ed2ef9 |
---|---|
1 #include "gui/dialog/about.h" | 1 #include "gui/dialog/about.h" |
2 #include "gui/dialog/licenses.h" | |
3 #include "core/json.h" | 2 #include "core/json.h" |
4 #include "core/session.h" | 3 #include "core/session.h" |
5 #include "core/strings.h" | 4 #include "core/strings.h" |
5 #include "gui/dialog/licenses.h" | |
6 #include "gui/widgets/text.h" | 6 #include "gui/widgets/text.h" |
7 | 7 |
8 #include "utf8proc.h" | 8 #include "utf8proc.h" |
9 #include <fmt/core.h> | |
9 #include <toml11/toml.hpp> | 10 #include <toml11/toml.hpp> |
10 #include <fmt/core.h> | |
11 | 11 |
12 #include <QCoreApplication> | 12 #include <QCoreApplication> |
13 #include <QFont> | 13 #include <QFont> |
14 #include <QHBoxLayout> | 14 #include <QHBoxLayout> |
15 #include <QPushButton> | |
15 #include <QTextBrowser> | 16 #include <QTextBrowser> |
16 #include <QTextCharFormat> | 17 #include <QTextCharFormat> |
17 #include <QTextCursor> | 18 #include <QTextCursor> |
18 #include <QPushButton> | |
19 | 19 |
20 #include <curl/curl.h> | 20 #include <curl/curl.h> |
21 #ifdef WIN32 | 21 #ifdef WIN32 |
22 # include "sys/win32/dark_theme.h" | 22 # include "sys/win32/dark_theme.h" |
23 #endif | 23 #endif |
24 | 24 |
25 template<typename T, size_t N> | 25 template<typename T, size_t N> |
26 constexpr size_t array_size(T (&)[N]) { | 26 constexpr size_t array_size(T (&)[N]) |
27 { | |
27 return N; | 28 return N; |
28 } | 29 } |
29 | 30 |
30 static constexpr semver::version fmt_version{FMT_VERSION / 10000, FMT_VERSION / 100 % 100, FMT_VERSION % 100}; | 31 static constexpr semver::version fmt_version{FMT_VERSION / 10000, FMT_VERSION / 100 % 100, FMT_VERSION % 100}; |
31 static constexpr semver::version json_version{NLOHMANN_JSON_VERSION_MAJOR, NLOHMANN_JSON_VERSION_MINOR, | 32 static constexpr semver::version json_version{NLOHMANN_JSON_VERSION_MAJOR, NLOHMANN_JSON_VERSION_MINOR, |
32 NLOHMANN_JSON_VERSION_PATCH}; | 33 NLOHMANN_JSON_VERSION_PATCH}; |
33 static constexpr semver::version semver_version{SEMVER_VERSION_MAJOR, SEMVER_VERSION_MINOR, SEMVER_VERSION_PATCH}; | 34 static constexpr semver::version semver_version{SEMVER_VERSION_MAJOR, SEMVER_VERSION_MINOR, SEMVER_VERSION_PATCH}; |
34 static constexpr semver::version toml11_version{TOML11_VERSION_MAJOR, TOML11_VERSION_MINOR, TOML11_VERSION_PATCH}; | 35 static constexpr semver::version toml11_version{TOML11_VERSION_MAJOR, TOML11_VERSION_MINOR, TOML11_VERSION_PATCH}; |
35 static constexpr semver::version fugue_icons_version{3, 5, 6}; | 36 static constexpr semver::version fugue_icons_version{3, 5, 6}; |
36 | 37 |
37 const char* get_curl_version() { | 38 const char *get_curl_version() |
38 const curl_version_info_data* data = curl_version_info(CURLVERSION_NOW); | 39 { |
40 const curl_version_info_data *data = curl_version_info(CURLVERSION_NOW); | |
39 return data->version; | 41 return data->version; |
40 } | 42 } |
41 | 43 |
42 static constexpr std::string_view about_template = | 44 static constexpr std::string_view about_template = |
43 "<body>" | 45 "<body>" |
44 "<h2 style=\"font-weight: normal;\"><strong>Minori</strong> v{}</h2>" | 46 "<h2 style=\"font-weight: normal;\"><strong>Minori</strong> v{}</h2>" |
45 "<p><strong>Author:</strong><br>Paper <paper@paper.us.eu.org></p>" | 47 "<p><strong>Author:</strong><br>Paper <paper@paper.us.eu.org></p>" |
46 "<p><strong>Third party components:</strong><br>" | 48 "<p><strong>Third party components:</strong><br>" |
47 "<a href=\"https://curl.se/\">libcurl v{}</a>, " | 49 "<a href=\"https://curl.se/\">libcurl v{}</a>, " |
48 "<a href=\"https://p.yusukekamiyamane.com/\">Fugue Icons v{}</a>, " | 50 "<a href=\"https://p.yusukekamiyamane.com/\">Fugue Icons v{}</a>, " |
49 "<a href=\"https://github.com/erengy/anitomy\">Anitomy</a>, " | 51 "<a href=\"https://github.com/erengy/anitomy\">Anitomy</a>, " |
50 "<a href=\"https://github.com/nlohmann/json\">JSON for Modern C++ v{}</a>, " | 52 "<a href=\"https://github.com/nlohmann/json\">JSON for Modern C++ v{}</a>, " |
51 "<a href=\"https://github.com/Neargye/semver\">semver v{}</a>, " | 53 "<a href=\"https://github.com/Neargye/semver\">semver v{}</a>, " |
52 "<a href=\"http://juliastrings.github.io/utf8proc/\">utf8proc v{}</a>, " | 54 "<a href=\"http://juliastrings.github.io/utf8proc/\">utf8proc v{}</a>, " |
53 "<a href=\"https://github.com/fmtlib/fmt\">fmt v{}</a>, " | 55 "<a href=\"https://github.com/fmtlib/fmt\">fmt v{}</a>, " |
54 "<a href=\"https://github.com/ToruNiina/toml11\">toml11 v{}</a>, " | 56 "<a href=\"https://github.com/ToruNiina/toml11\">toml11 v{}</a>, " |
55 "and parts of <a href=\"https://github.com/erengy/anisthesia\">Anisthesia</a>" | 57 "and parts of <a href=\"https://github.com/erengy/anisthesia\">Anisthesia</a>" |
56 "</p>" | 58 "</p>" |
57 "<span><strong>Special thanks:</strong></span>" | 59 "<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;\">" | 60 "<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>" | 61 "<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>" | 62 "<li><strong>Alex Huszagh</strong> and <strong>Colin Duquesnoy</strong> for creating BreezeStyleSheets, on which " |
63 "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>" | 64 "<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>" | 65 "<li><strong>Manuel Wudka-Robles</strong> for providing information on getting open file descriptors on macOS</li>" |
63 "</ul>" | 66 "</ul>" |
64 "</body>"; | 67 "</body>"; |
65 | 68 |
66 AboutWindow::AboutWindow(QWidget* parent) : Dialog(parent) { | 69 AboutWindow::AboutWindow(QWidget *parent) : Dialog(parent) |
70 { | |
67 setMinimumSize(641, 325); | 71 setMinimumSize(641, 325); |
68 setWindowTitle(tr("About Minori")); | 72 setWindowTitle(tr("About Minori")); |
69 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); | 73 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); |
70 setAutoFillBackground(true); | 74 setAutoFillBackground(true); |
71 | 75 |
72 QVBoxLayout* layout = new QVBoxLayout(this); | 76 QVBoxLayout *layout = new QVBoxLayout(this); |
73 | 77 |
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()); | 78 std::string html = |
79 fmt::format(about_template, session.version.to_string(), get_curl_version(), fugue_icons_version.to_string(), | |
80 json_version.to_string(), semver_version.to_string(), utf8proc_version(), fmt_version.to_string(), | |
81 toml11_version.to_string()); | |
75 | 82 |
76 setBackgroundRole(QPalette::Base); | 83 setBackgroundRole(QPalette::Base); |
77 | 84 |
78 { | 85 { |
79 QTextBrowser* paragraph = new QTextBrowser(this); | 86 QTextBrowser *paragraph = new QTextBrowser(this); |
80 paragraph->setOpenExternalLinks(true); | 87 paragraph->setOpenExternalLinks(true); |
81 paragraph->setFrameShape(QFrame::NoFrame); | 88 paragraph->setFrameShape(QFrame::NoFrame); |
82 paragraph->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | 89 paragraph->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
83 paragraph->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | 90 paragraph->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
84 paragraph->setHtml(Strings::ToQString(html)); | 91 paragraph->setHtml(Strings::ToQString(html)); |
87 } | 94 } |
88 | 95 |
89 { | 96 { |
90 QPushButton *license = new QPushButton("&Licenses", this); | 97 QPushButton *license = new QPushButton("&Licenses", this); |
91 layout->addWidget(license, Qt::AlignRight); | 98 layout->addWidget(license, Qt::AlignRight); |
92 connect(license, &QPushButton::clicked, this, []{ | 99 connect(license, &QPushButton::clicked, this, [] { |
93 LicensesWindow dialog; | 100 LicensesWindow dialog; |
94 dialog.exec(); | 101 dialog.exec(); |
95 }); | 102 }); |
96 } | 103 } |
97 } | 104 } |