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);
|
|
77 QTextCursor cursor = paragraph->textCursor();
|
|
78 SET_TITLE_FONT(font, format, cursor);
|
|
79 SET_FONT_BOLD(font, format, cursor);
|
|
80 cursor.insertText("Minori");
|
|
81 UNSET_FONT_BOLD(font, format, cursor);
|
|
82 cursor.insertText(" " MINORI_VERSION);
|
|
83 SET_PARAGRAPH_FONT(font, format, cursor);
|
|
84 cursor.insertBlock();
|
|
85 cursor.insertBlock();
|
|
86 SET_FONT_BOLD(font, format, cursor);
|
|
87 cursor.insertText(tr("Author:"));
|
|
88 UNSET_FONT_BOLD(font, format, cursor);
|
|
89 cursor.insertBlock();
|
|
90 cursor.insertText(tr("Paper"));
|
|
91 cursor.insertBlock();
|
|
92 cursor.insertBlock();
|
|
93 SET_FONT_BOLD(font, format, cursor);
|
|
94 cursor.insertText(tr("Third party components:"));
|
|
95 UNSET_FONT_BOLD(font, format, cursor);
|
|
96 cursor.insertBlock();
|
|
97 SET_FORMAT_HYPERLINK(format, cursor, "https://github.com/nlohmann/json");
|
|
98 cursor.insertText(tr("JSON for Modern C++ ") + CONCAT_VERSION(NLOHMANN_JSON_VERSION_MAJOR, NLOHMANN_JSON_VERSION_MINOR, NLOHMANN_JSON_VERSION_PATCH));
|
|
99 UNSET_FORMAT_HYPERLINK(format, cursor);
|
|
100 cursor.insertText(", ");
|
|
101 {
|
|
102 curl_version_info_data* data = curl_version_info(CURLVERSION_NOW);
|
|
103 SET_FORMAT_HYPERLINK(format, cursor, "https://curl.se/");
|
|
104 cursor.insertText(tr("libcurl v") + data->version);
|
|
105 UNSET_FORMAT_HYPERLINK(format, cursor);
|
|
106 cursor.insertText(", ");
|
|
107 }
|
|
108 SET_FORMAT_HYPERLINK(format, cursor, "https://p.yusukekamiyamane.com/");
|
|
109 cursor.insertText(tr("Fugue Icons ") + CONCAT_VERSION(3, 5, 6));
|
|
110 UNSET_FORMAT_HYPERLINK(format, cursor);
|
|
111 cursor.insertBlock();
|
|
112 cursor.insertBlock();
|
|
113 SET_FONT_BOLD(font, format, cursor);
|
|
114 cursor.insertText(tr("Links:"));
|
|
115 UNSET_FONT_BOLD(font, format, cursor);
|
|
116 cursor.insertBlock();
|
|
117 layout()->addWidget(paragraph);
|
|
118 }
|