annotate src/gui/dialog/about.cpp @ 64:fe719c109dbc

*: update 1. add media tracking ability, and it displays info on the `now playing` page 2. the `now playing` page now actually shows something 3. renamed every page class to be more accurate to what it is 4. ...
author Paper <mrpapersonic@gmail.com>
date Sun, 01 Oct 2023 23:15:43 -0400
parents 3d2decf093bb
children 5ccb99bfa605
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 { \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
19 font = cursor.charFormat().font(); \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
20 font.setPointSize(10); \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
21 format.setFont(font); \
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 { \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
27 font = cursor.charFormat().font(); \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
28 font.setPointSize(8); \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
29 format.setFont(font); \
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 { \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
51 format.setAnchor(true); \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
52 format.setAnchorHref(link); \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
53 cursor.setCharFormat(format); \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
54 }
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
55 #define UNSET_FORMAT_HYPERLINK(format, cursor) \
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 format.setAnchor(false); \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
58 format.setAnchorHref(""); \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
59 cursor.setCharFormat(format); \
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
60 }
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
61
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
62 AboutWindow::AboutWindow(QWidget* parent) : QDialog(parent) {
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
63 setWindowTitle(tr("About Minori"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
64 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
65 QHBoxLayout* layout = new QHBoxLayout(this);
51
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 QPalette pal = QPalette();
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
68 pal.setColor(QPalette::Window, pal.color(QPalette::Base));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
69 setPalette(pal);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
70 setAutoFillBackground(true);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
71
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
72 QFont font;
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
73 QTextCharFormat format;
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
74 QTextBrowser* paragraph = new QTextBrowser(this);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
75 paragraph->setOpenExternalLinks(true);
52
0c4138de2ea7 anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
76 paragraph->setFrameShape(QFrame::NoFrame);
0c4138de2ea7 anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
77 paragraph->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
0c4138de2ea7 anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
78 paragraph->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
79 QTextCursor cursor = paragraph->textCursor();
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
80 SET_TITLE_FONT(font, format, cursor);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
81 SET_FONT_BOLD(font, format, cursor);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
82 cursor.insertText("Minori");
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
83 UNSET_FONT_BOLD(font, format, cursor);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
84 cursor.insertText(" " MINORI_VERSION);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
85 SET_PARAGRAPH_FONT(font, format, cursor);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
86 cursor.insertBlock();
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
87 cursor.insertBlock();
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
88 SET_FONT_BOLD(font, format, cursor);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
89 cursor.insertText(tr("Author:"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
90 UNSET_FONT_BOLD(font, format, cursor);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
91 cursor.insertBlock();
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
92 cursor.insertText(tr("Paper"));
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.insertBlock();
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
95 SET_FONT_BOLD(font, format, cursor);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
96 cursor.insertText(tr("Third party components:"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
97 UNSET_FONT_BOLD(font, format, cursor);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
98 cursor.insertBlock();
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
99 SET_FORMAT_HYPERLINK(format, cursor, "https://github.com/nlohmann/json");
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
100 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
101 NLOHMANN_JSON_VERSION_MINOR,
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
102 NLOHMANN_JSON_VERSION_PATCH));
51
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/");
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
117 cursor.insertText(tr("pugixml v") + QString::number(PUGIXML_VERSION / 1000) + "." +
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 55
diff changeset
118 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
119 UNSET_FORMAT_HYPERLINK(format, cursor);
d10b6c6b432e add xml lib, we will need to use it eventually
Paper <mrpapersonic@gmail.com>
parents: 52
diff changeset
120 cursor.insertText(", ");
d10b6c6b432e add xml lib, we will need to use it eventually
Paper <mrpapersonic@gmail.com>
parents: 52
diff changeset
121 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
122 cursor.insertText(tr("Anitomy"));
d10b6c6b432e add xml lib, we will need to use it eventually
Paper <mrpapersonic@gmail.com>
parents: 52
diff changeset
123 UNSET_FORMAT_HYPERLINK(format, cursor);
51
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 cursor.insertBlock();
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
126 SET_FONT_BOLD(font, format, cursor);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
127 cursor.insertText(tr("Links:"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
128 UNSET_FONT_BOLD(font, format, cursor);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
129 cursor.insertBlock();
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
130 layout->addWidget(paragraph);
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
131 }