Mercurial > minori
annotate src/gui/dialog/about.cpp @ 52:0c4138de2ea7
anime list: we are finally read-write
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Mon, 25 Sep 2023 22:49:42 -0400 |
parents | 75c804f713b2 |
children | d10b6c6b432e |
rev | line source |
---|---|
51 | 1 #include "core/version.h" |
2 #include "gui/widgets/text.h" | |
3 #include "gui/dialog/about.h" | |
4 #include "core/json.h" | |
5 #include <curl/curl.h> | |
6 #include <QFont> | |
7 #include <QTextCharFormat> | |
8 #include <QTextBrowser> | |
9 #include <QTextCursor> | |
10 #include <QHBoxLayout> | |
11 | |
12 #define CONCAT_VERSION_NX(major, minor, patch) \ | |
13 ("v" #major "." #minor "." #patch) | |
14 | |
15 #define CONCAT_VERSION(major, minor, patch) \ | |
16 CONCAT_VERSION_NX(major, minor, patch) | |
17 | |
18 #define SET_TITLE_FONT(font, format, cursor) \ | |
19 { \ | |
20 font = cursor.charFormat().font(); \ | |
21 font.setPointSize(10); \ | |
22 format.setFont(font); \ | |
23 cursor.setCharFormat(format); \ | |
24 } | |
25 | |
26 #define SET_PARAGRAPH_FONT(font, format, cursor) \ | |
27 { \ | |
28 font = cursor.charFormat().font(); \ | |
29 font.setPointSize(8); \ | |
30 format.setFont(font); \ | |
31 cursor.setCharFormat(format); \ | |
32 } | |
33 | |
34 #define SET_FONT_BOLD(font, format, cursor) \ | |
35 { \ | |
36 font = cursor.charFormat().font(); \ | |
37 font.setBold(true); \ | |
38 format.setFont(font); \ | |
39 cursor.setCharFormat(format); \ | |
40 } | |
41 | |
42 #define UNSET_FONT_BOLD(font, format, cursor) \ | |
43 { \ | |
44 font = cursor.charFormat().font(); \ | |
45 font.setBold(false); \ | |
46 format.setFont(font); \ | |
47 cursor.setCharFormat(format); \ | |
48 } | |
49 | |
50 #define SET_FORMAT_HYPERLINK(format, cursor, link) \ | |
51 { \ | |
52 format.setAnchor(true); \ | |
53 format.setAnchorHref(link); \ | |
54 cursor.setCharFormat(format); \ | |
55 } | |
56 #define UNSET_FORMAT_HYPERLINK(format, cursor) \ | |
57 { \ | |
58 format.setAnchor(false); \ | |
59 format.setAnchorHref(""); \ | |
60 cursor.setCharFormat(format); \ | |
61 } | |
62 | |
63 AboutWindow::AboutWindow(QWidget* parent) : QDialog(parent) { | |
64 setWindowTitle(tr("About Minori")); | |
65 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); | |
66 setLayout(new QHBoxLayout); | |
67 | |
68 QPalette pal = QPalette(); | |
69 pal.setColor(QPalette::Window, pal.color(QPalette::Base)); | |
70 setPalette(pal); | |
71 setAutoFillBackground(true); | |
72 | |
73 QFont font; | |
74 QTextCharFormat format; | |
75 QTextBrowser* paragraph = new QTextBrowser(this); | |
76 paragraph->setOpenExternalLinks(true); | |
52
0c4138de2ea7
anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
77 paragraph->setFrameShape(QFrame::NoFrame); |
0c4138de2ea7
anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
78 paragraph->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
0c4138de2ea7
anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
79 paragraph->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
51 | 80 QTextCursor cursor = paragraph->textCursor(); |
81 SET_TITLE_FONT(font, format, cursor); | |
82 SET_FONT_BOLD(font, format, cursor); | |
83 cursor.insertText("Minori"); | |
84 UNSET_FONT_BOLD(font, format, cursor); | |
85 cursor.insertText(" " MINORI_VERSION); | |
86 SET_PARAGRAPH_FONT(font, format, cursor); | |
87 cursor.insertBlock(); | |
88 cursor.insertBlock(); | |
89 SET_FONT_BOLD(font, format, cursor); | |
90 cursor.insertText(tr("Author:")); | |
91 UNSET_FONT_BOLD(font, format, cursor); | |
92 cursor.insertBlock(); | |
93 cursor.insertText(tr("Paper")); | |
94 cursor.insertBlock(); | |
95 cursor.insertBlock(); | |
96 SET_FONT_BOLD(font, format, cursor); | |
97 cursor.insertText(tr("Third party components:")); | |
98 UNSET_FONT_BOLD(font, format, cursor); | |
99 cursor.insertBlock(); | |
100 SET_FORMAT_HYPERLINK(format, cursor, "https://github.com/nlohmann/json"); | |
101 cursor.insertText(tr("JSON for Modern C++ ") + CONCAT_VERSION(NLOHMANN_JSON_VERSION_MAJOR, NLOHMANN_JSON_VERSION_MINOR, NLOHMANN_JSON_VERSION_PATCH)); | |
102 UNSET_FORMAT_HYPERLINK(format, cursor); | |
103 cursor.insertText(", "); | |
104 { | |
105 curl_version_info_data* data = curl_version_info(CURLVERSION_NOW); | |
106 SET_FORMAT_HYPERLINK(format, cursor, "https://curl.se/"); | |
107 cursor.insertText(tr("libcurl v") + data->version); | |
108 UNSET_FORMAT_HYPERLINK(format, cursor); | |
109 cursor.insertText(", "); | |
110 } | |
111 SET_FORMAT_HYPERLINK(format, cursor, "https://p.yusukekamiyamane.com/"); | |
112 cursor.insertText(tr("Fugue Icons ") + CONCAT_VERSION(3, 5, 6)); | |
113 UNSET_FORMAT_HYPERLINK(format, cursor); | |
114 cursor.insertBlock(); | |
115 cursor.insertBlock(); | |
116 SET_FONT_BOLD(font, format, cursor); | |
117 cursor.insertText(tr("Links:")); | |
118 UNSET_FONT_BOLD(font, format, cursor); | |
119 cursor.insertBlock(); | |
120 layout()->addWidget(paragraph); | |
121 } |