Mercurial > minori
comparison src/gui/dialog/about.cc @ 81:9b2b41f83a5e
boring: mass rename to cc
because this is a very unix-y project, it makes more sense to use the
'cc' extension
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Mon, 23 Oct 2023 12:07:27 -0400 |
parents | src/gui/dialog/about.cpp@6f7385bd334c |
children | 27455104ea37 |
comparison
equal
deleted
inserted
replaced
80:825506f0e221 | 81:9b2b41f83a5e |
---|---|
1 #include "gui/dialog/about.h" | |
2 #include "core/json.h" | |
3 #include "core/version.h" | |
4 #include "gui/widgets/text.h" | |
5 #include "pugixml.hpp" | |
6 #include <QFont> | |
7 #include <QHBoxLayout> | |
8 #include <QTextBrowser> | |
9 #include <QTextCharFormat> | |
10 #include <QTextCursor> | |
11 #include <curl/curl.h> | |
12 | |
13 #define CONCAT_VERSION_NX(major, minor, patch) ("v" #major "." #minor "." #patch) | |
14 | |
15 #define CONCAT_VERSION(major, minor, patch) CONCAT_VERSION_NX(major, minor, patch) | |
16 | |
17 #define SET_TITLE_FONT(font, format, cursor) \ | |
18 { \ | |
19 QFont fnt; \ | |
20 fnt.setPixelSize(16); \ | |
21 format.setFont(fnt); \ | |
22 cursor.setCharFormat(format); \ | |
23 } | |
24 | |
25 #define SET_PARAGRAPH_FONT(font, format, cursor) \ | |
26 { \ | |
27 QFont fnt; \ | |
28 fnt.setPixelSize(12); \ | |
29 format.setFont(fnt); \ | |
30 cursor.setCharFormat(format); \ | |
31 } | |
32 | |
33 #define SET_FONT_BOLD(font, format, cursor) \ | |
34 { \ | |
35 font = cursor.charFormat().font(); \ | |
36 font.setBold(true); \ | |
37 format.setFont(font); \ | |
38 cursor.setCharFormat(format); \ | |
39 } | |
40 | |
41 #define UNSET_FONT_BOLD(font, format, cursor) \ | |
42 { \ | |
43 font = cursor.charFormat().font(); \ | |
44 font.setBold(false); \ | |
45 format.setFont(font); \ | |
46 cursor.setCharFormat(format); \ | |
47 } | |
48 | |
49 #define SET_FORMAT_HYPERLINK(format, cursor, link) \ | |
50 { \ | |
51 font = cursor.charFormat().font(); \ | |
52 font.setUnderline(true); \ | |
53 format.setFont(font); \ | |
54 format.setAnchor(true); \ | |
55 format.setAnchorHref(link); \ | |
56 cursor.setCharFormat(format); \ | |
57 } | |
58 #define UNSET_FORMAT_HYPERLINK(format, cursor) \ | |
59 { \ | |
60 font = cursor.charFormat().font(); \ | |
61 font.setUnderline(false); \ | |
62 format.setFont(font); \ | |
63 format.setAnchor(false); \ | |
64 format.setAnchorHref(""); \ | |
65 cursor.setCharFormat(format); \ | |
66 } | |
67 | |
68 AboutWindow::AboutWindow(QWidget* parent) : QDialog(parent) { | |
69 setWindowTitle(tr("About Minori")); | |
70 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); | |
71 QHBoxLayout* layout = new QHBoxLayout(this); | |
72 | |
73 QPalette pal = QPalette(); | |
74 pal.setColor(QPalette::Window, pal.color(QPalette::Base)); | |
75 setPalette(pal); | |
76 setAutoFillBackground(true); | |
77 | |
78 QFont font; | |
79 QTextCharFormat format; | |
80 QTextBrowser* paragraph = new QTextBrowser(this); | |
81 paragraph->setOpenExternalLinks(true); | |
82 paragraph->setFrameShape(QFrame::NoFrame); | |
83 paragraph->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
84 paragraph->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
85 QTextCursor cursor = paragraph->textCursor(); | |
86 SET_TITLE_FONT(font, format, cursor); | |
87 SET_FONT_BOLD(font, format, cursor); | |
88 cursor.insertText("Minori"); | |
89 UNSET_FONT_BOLD(font, format, cursor); | |
90 cursor.insertText(" " MINORI_VERSION); | |
91 SET_PARAGRAPH_FONT(font, format, cursor); | |
92 cursor.insertBlock(); | |
93 cursor.insertBlock(); | |
94 SET_FONT_BOLD(font, format, cursor); | |
95 cursor.insertText(tr("Author:")); | |
96 UNSET_FONT_BOLD(font, format, cursor); | |
97 cursor.insertBlock(); | |
98 cursor.insertText(tr("Paper")); | |
99 cursor.insertBlock(); | |
100 cursor.insertBlock(); | |
101 SET_FONT_BOLD(font, format, cursor); | |
102 cursor.insertText(tr("Third party components:")); | |
103 UNSET_FONT_BOLD(font, format, cursor); | |
104 cursor.insertBlock(); | |
105 SET_FORMAT_HYPERLINK(format, cursor, "https://github.com/nlohmann/json"); | |
106 cursor.insertText(tr("JSON for Modern C++ ") + CONCAT_VERSION(NLOHMANN_JSON_VERSION_MAJOR, | |
107 NLOHMANN_JSON_VERSION_MINOR, | |
108 NLOHMANN_JSON_VERSION_PATCH)); | |
109 UNSET_FORMAT_HYPERLINK(format, cursor); | |
110 cursor.insertText(", "); | |
111 { | |
112 curl_version_info_data* data = curl_version_info(CURLVERSION_NOW); | |
113 SET_FORMAT_HYPERLINK(format, cursor, "https://curl.se/"); | |
114 cursor.insertText(tr("libcurl v") + data->version); | |
115 UNSET_FORMAT_HYPERLINK(format, cursor); | |
116 cursor.insertText(", "); | |
117 } | |
118 SET_FORMAT_HYPERLINK(format, cursor, "https://p.yusukekamiyamane.com/"); | |
119 cursor.insertText(tr("Fugue Icons ") + CONCAT_VERSION(3, 5, 6)); | |
120 UNSET_FORMAT_HYPERLINK(format, cursor); | |
121 cursor.insertText(", "); | |
122 SET_FORMAT_HYPERLINK(format, cursor, "https://pugixml.org/"); | |
123 cursor.insertText(tr("pugixml v") + QString::number(PUGIXML_VERSION / 1000) + "." + | |
124 QString::number(PUGIXML_VERSION / 10 % 100) + "." + QString::number(PUGIXML_VERSION % 10)); | |
125 UNSET_FORMAT_HYPERLINK(format, cursor); | |
126 cursor.insertText(", "); | |
127 SET_FORMAT_HYPERLINK(format, cursor, "https://github.com/erengy/anitomy"); | |
128 cursor.insertText(tr("Anitomy")); | |
129 UNSET_FORMAT_HYPERLINK(format, cursor); | |
130 cursor.insertBlock(); | |
131 cursor.insertBlock(); | |
132 SET_FONT_BOLD(font, format, cursor); | |
133 cursor.insertText(tr("Links:")); | |
134 UNSET_FONT_BOLD(font, format, cursor); | |
135 cursor.insertBlock(); | |
136 layout->addWidget(paragraph); | |
137 } |