annotate src/gui/dialog/about.cc @ 101:c537996cf67b

*: multitude of config changes 1. theme is now configurable from the settings menu (but you have to restart for it to apply) 2. config is now stored in an INI file, with no method of conversion from json (this repo is private-ish anyway)
author Paper <mrpapersonic@gmail.com>
date Fri, 03 Nov 2023 14:06:02 -0400
parents 9b2b41f83a5e
children 27455104ea37
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 "gui/dialog/about.h"
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
2 #include "core/json.h"
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
3 #include "core/version.h"
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
4 #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
5 #include "pugixml.hpp"
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
6 #include <QFont>
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
7 #include <QHBoxLayout>
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
8 #include <QTextBrowser>
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
9 #include <QTextCharFormat>
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
10 #include <QTextCursor>
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
11 #include <curl/curl.h>
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
12
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
13 #define CONCAT_VERSION_NX(major, minor, patch) ("v" #major "." #minor "." #patch)
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
14
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
15 #define CONCAT_VERSION(major, minor, patch) CONCAT_VERSION_NX(major, minor, patch)
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
16
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
17 #define SET_TITLE_FONT(font, format, cursor) \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
18 { \
77
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
19 QFont fnt; \
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
20 fnt.setPixelSize(16); \
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
21 format.setFont(fnt); \
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
22 cursor.setCharFormat(format); \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
23 }
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
24
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
25 #define SET_PARAGRAPH_FONT(font, format, cursor) \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
26 { \
77
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
27 QFont fnt; \
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
28 fnt.setPixelSize(12); \
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
29 format.setFont(fnt); \
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
30 cursor.setCharFormat(format); \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
31 }
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
32
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
33 #define SET_FONT_BOLD(font, format, cursor) \
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 font = cursor.charFormat().font(); \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
36 font.setBold(true); \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
37 format.setFont(font); \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
38 cursor.setCharFormat(format); \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
39 }
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
40
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
41 #define UNSET_FONT_BOLD(font, format, cursor) \
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 font = cursor.charFormat().font(); \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
44 font.setBold(false); \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
45 format.setFont(font); \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
46 cursor.setCharFormat(format); \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
47 }
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
48
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
49 #define SET_FORMAT_HYPERLINK(format, cursor, link) \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
50 { \
77
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
51 font = cursor.charFormat().font(); \
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
52 font.setUnderline(true); \
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
53 format.setFont(font); \
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
54 format.setAnchor(true); \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
55 format.setAnchorHref(link); \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
56 cursor.setCharFormat(format); \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
57 }
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
58 #define UNSET_FORMAT_HYPERLINK(format, cursor) \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
59 { \
77
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
60 font = cursor.charFormat().font(); \
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
61 font.setUnderline(false); \
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
62 format.setFont(font); \
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
63 format.setAnchor(false); \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
64 format.setAnchorHref(""); \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
65 cursor.setCharFormat(format); \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
66 }
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
67
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
68 AboutWindow::AboutWindow(QWidget* parent) : QDialog(parent) {
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
69 setWindowTitle(tr("About Minori"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
70 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
71 QHBoxLayout* layout = new QHBoxLayout(this);
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
72
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
73 QPalette pal = QPalette();
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
74 pal.setColor(QPalette::Window, pal.color(QPalette::Base));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
75 setPalette(pal);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
76 setAutoFillBackground(true);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
77
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
78 QFont font;
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
79 QTextCharFormat format;
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
80 QTextBrowser* paragraph = new QTextBrowser(this);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
81 paragraph->setOpenExternalLinks(true);
52
0c4138de2ea7 anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
82 paragraph->setFrameShape(QFrame::NoFrame);
0c4138de2ea7 anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
83 paragraph->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
0c4138de2ea7 anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
84 paragraph->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
85 QTextCursor cursor = paragraph->textCursor();
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
86 SET_TITLE_FONT(font, format, cursor);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
87 SET_FONT_BOLD(font, format, cursor);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
88 cursor.insertText("Minori");
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
89 UNSET_FONT_BOLD(font, format, cursor);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
90 cursor.insertText(" " MINORI_VERSION);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
91 SET_PARAGRAPH_FONT(font, format, cursor);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
92 cursor.insertBlock();
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 SET_FONT_BOLD(font, format, cursor);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
95 cursor.insertText(tr("Author:"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
96 UNSET_FONT_BOLD(font, format, cursor);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
97 cursor.insertBlock();
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
98 cursor.insertText(tr("Paper"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
99 cursor.insertBlock();
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_FONT_BOLD(font, format, cursor);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
102 cursor.insertText(tr("Third party components:"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
103 UNSET_FONT_BOLD(font, format, cursor);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
104 cursor.insertBlock();
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
105 SET_FORMAT_HYPERLINK(format, cursor, "https://github.com/nlohmann/json");
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
106 cursor.insertText(tr("JSON for Modern C++ ") + CONCAT_VERSION(NLOHMANN_JSON_VERSION_MAJOR,
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
107 NLOHMANN_JSON_VERSION_MINOR,
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
108 NLOHMANN_JSON_VERSION_PATCH));
51
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 curl_version_info_data* data = curl_version_info(CURLVERSION_NOW);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
113 SET_FORMAT_HYPERLINK(format, cursor, "https://curl.se/");
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
114 cursor.insertText(tr("libcurl v") + data->version);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
115 UNSET_FORMAT_HYPERLINK(format, cursor);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
116 cursor.insertText(", ");
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
117 }
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
118 SET_FORMAT_HYPERLINK(format, cursor, "https://p.yusukekamiyamane.com/");
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
119 cursor.insertText(tr("Fugue Icons ") + CONCAT_VERSION(3, 5, 6));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
120 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
121 cursor.insertText(", ");
d10b6c6b432e add xml lib, we will need to use it eventually
Paper <mrpapersonic@gmail.com>
parents: 52
diff changeset
122 SET_FORMAT_HYPERLINK(format, cursor, "https://pugixml.org/");
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
123 cursor.insertText(tr("pugixml v") + QString::number(PUGIXML_VERSION / 1000) + "." +
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
124 QString::number(PUGIXML_VERSION / 10 % 100) + "." + QString::number(PUGIXML_VERSION % 10));
55
d10b6c6b432e add xml lib, we will need to use it eventually
Paper <mrpapersonic@gmail.com>
parents: 52
diff changeset
125 UNSET_FORMAT_HYPERLINK(format, cursor);
d10b6c6b432e add xml lib, we will need to use it eventually
Paper <mrpapersonic@gmail.com>
parents: 52
diff changeset
126 cursor.insertText(", ");
d10b6c6b432e add xml lib, we will need to use it eventually
Paper <mrpapersonic@gmail.com>
parents: 52
diff changeset
127 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
128 cursor.insertText(tr("Anitomy"));
d10b6c6b432e add xml lib, we will need to use it eventually
Paper <mrpapersonic@gmail.com>
parents: 52
diff changeset
129 UNSET_FORMAT_HYPERLINK(format, cursor);
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
130 cursor.insertBlock();
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
131 cursor.insertBlock();
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
132 SET_FONT_BOLD(font, format, cursor);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
133 cursor.insertText(tr("Links:"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
134 UNSET_FONT_BOLD(font, format, cursor);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
135 cursor.insertBlock();
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
136 layout->addWidget(paragraph);
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
137 }