annotate src/gui/dialog/about.cpp @ 55:d10b6c6b432e

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