Mercurial > minori
annotate src/gui/dialog/about.cc @ 174:f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Wed, 29 Nov 2023 13:53:56 -0500 |
parents | 2004b41d4a59 |
children | 649786bae914 |
rev | line source |
---|---|
51 | 1 #include "gui/dialog/about.h" |
2 #include "core/json.h" | |
63 | 3 #include "core/version.h" |
108 | 4 #include "core/session.h" |
104 | 5 #include "core/strings.h" |
63 | 6 #include "gui/widgets/text.h" |
55
d10b6c6b432e
add xml lib, we will need to use it eventually
Paper <mrpapersonic@gmail.com>
parents:
52
diff
changeset
|
7 #include "pugixml.hpp" |
51 | 8 #include <QFont> |
9 #include <QHBoxLayout> | |
63 | 10 #include <QTextBrowser> |
11 #include <QTextCharFormat> | |
12 #include <QTextCursor> | |
108 | 13 #include <QCoreApplication> |
63 | 14 #include <curl/curl.h> |
108 | 15 #ifdef WIN32 |
16 #include "sys/win32/dark_theme.h" | |
17 #endif | |
51 | 18 |
104 | 19 template <typename T, size_t N> |
20 constexpr size_t array_size(T (&)[N]) { | |
21 return N; | |
22 } | |
51 | 23 |
108 | 24 /* used for JSON for Modern C++ */ |
104 | 25 #define CONCAT_VERSION_NX(major, minor, patch) "v" #major "." #minor "." #patch |
63 | 26 #define CONCAT_VERSION(major, minor, patch) CONCAT_VERSION_NX(major, minor, patch) |
51 | 27 |
104 | 28 /* Ahhh, my dumb little hack to get this to be constexpr :) */ |
29 static constexpr const char pugixml_version[] = { | |
30 PUGIXML_VERSION / 1000 % 10 + '0', /* Major */ | |
31 '.', | |
32 PUGIXML_VERSION / 100 % 10 + '0', /* Minor */ | |
33 PUGIXML_VERSION / 10 % 10 + '0', | |
34 '.', | |
35 PUGIXML_VERSION % 10 + '0', /* Patch */ | |
36 '\0' | |
37 }; | |
51 | 38 |
104 | 39 const char* get_curl_version() { |
40 const curl_version_info_data* data = curl_version_info(CURLVERSION_NOW); | |
41 return data->version; | |
42 } | |
51 | 43 |
44 AboutWindow::AboutWindow(QWidget* parent) : QDialog(parent) { | |
104 | 45 setMinimumSize(641, 325); |
51 | 46 setWindowTitle(tr("About Minori")); |
47 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); | |
48 setAutoFillBackground(true); | |
49 | |
108 | 50 QHBoxLayout* layout = new QHBoxLayout(this); |
104 | 51 |
108 | 52 /* we have to generate this on-the-fly for localization purposes */ |
53 static const QString html = QString( | |
54 "<body>" | |
55 " <h2 style=\"font-weight: normal;\"><strong>Minori</strong> " MINORI_VERSION "</h2>" | |
56 " <p>" | |
57 " <strong>" + QCoreApplication::tr("Author:") + "</strong><br>" | |
58 " Paper (@mrpapersonic)" | |
59 " </p>" | |
60 " <p>" | |
61 " <strong>" + QCoreApplication::tr("Third party components:") + "</strong><br>" | |
62 "<a href=\"https://curl.se/\">libcurl v") + get_curl_version() + "</a>" | |
63 ", " | |
64 "<a href=\"https://p.yusukekamiyamane.com/\">Fugue Icons v3.5.6</a>" | |
65 ", " | |
66 "<a href=\"https://github.com/erengy/anitomy\">Anitomy</a>" | |
67 ", " | |
68 "<a href=\"https://github.com/nlohmann/json\">JSON for Modern C++ " CONCAT_VERSION(NLOHMANN_JSON_VERSION_MAJOR, | |
69 NLOHMANN_JSON_VERSION_MINOR, | |
70 NLOHMANN_JSON_VERSION_PATCH) "</a>" | |
71 ", " | |
72 "<a href=\"https://pugixml.org/\">pugixml v" + pugixml_version + "</a>" | |
73 ", " | |
74 "<a href=\"https://github.com/pulzed/mINI\">mINI v0.9.14</a>" | |
75 " </p>" | |
76 "<span>" | |
77 "<strong>" + QCoreApplication::tr("Special thanks:") + "</strong>" | |
78 "</span>" | |
79 " <ul style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 15px; margin-right: 0px; -qt-list-indent:0;\">" | |
80 " <li><strong>Eren Okka</strong> " + QCoreApplication::tr("for creating Taiga") + "</li>" | |
81 " <li><strong>Alex Huszagh</strong> " + QCoreApplication::tr("and") + " <strong>Colin Duquesnoy</strong> " + | |
82 QCoreApplication::tr("for creating BreezeStyleSheets, on which the dark theme in this program is " | |
83 "based off of") + "</li>" | |
84 " <li><strong>Andy Brice</strong> " + QCoreApplication::tr("for providing some sample code for " | |
85 "detecting dark mode on Windows and macOS") + "</li>" | |
86 " <li><strong>Manuel Wudka-Robles</strong> " + QCoreApplication::tr("for providing information on " | |
87 "getting open file descriptors on macOS") + "</li>" | |
88 " </ul>" | |
89 "</body>"; | |
90 | |
91 { | |
92 QPalette pal = QPalette(); | |
93 pal.setColor(QPalette::Window, pal.color(QPalette::Base)); | |
94 setPalette(pal); | |
95 } | |
96 | |
97 { | |
98 QTextBrowser* paragraph = new QTextBrowser(this); | |
99 paragraph->setOpenExternalLinks(true); | |
100 paragraph->setFrameShape(QFrame::NoFrame); | |
101 paragraph->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
102 paragraph->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
103 paragraph->setHtml(html); | |
104 | |
105 layout->addWidget(paragraph); | |
106 } | |
51 | 107 } |
108 | 108 |
109 void AboutWindow::showEvent(QShowEvent* event) { | |
110 QDialog::showEvent(event); | |
111 #ifdef WIN32 | |
112 win32::SetTitleBarsToBlack(session.config.theme.IsInDarkTheme()); | |
113 #endif | |
114 } | |
115 | |
116 #include "gui/dialog/moc_about.cpp" |