Mercurial > minori
annotate src/gui/dialog/about.cpp @ 62:4c6dd5999b39
*: update
1. updated animia
2. use widestrings for filesystem on Windows
| author | Paper <mrpapersonic@gmail.com> |
|---|---|
| date | Sun, 01 Oct 2023 06:16:06 -0400 |
| parents | d10b6c6b432e |
| children | 3d2decf093bb |
| 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" | |
|
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 | 6 #include <curl/curl.h> |
| 7 #include <QFont> | |
| 8 #include <QTextCharFormat> | |
| 9 #include <QTextBrowser> | |
| 10 #include <QTextCursor> | |
| 11 #include <QHBoxLayout> | |
| 12 | |
| 13 #define CONCAT_VERSION_NX(major, minor, patch) \ | |
| 14 ("v" #major "." #minor "." #patch) | |
| 15 | |
| 16 #define CONCAT_VERSION(major, minor, patch) \ | |
| 17 CONCAT_VERSION_NX(major, minor, patch) | |
| 18 | |
| 19 #define SET_TITLE_FONT(font, format, cursor) \ | |
| 20 { \ | |
| 21 font = cursor.charFormat().font(); \ | |
| 22 font.setPointSize(10); \ | |
| 23 format.setFont(font); \ | |
| 24 cursor.setCharFormat(format); \ | |
| 25 } | |
| 26 | |
| 27 #define SET_PARAGRAPH_FONT(font, format, cursor) \ | |
| 28 { \ | |
| 29 font = cursor.charFormat().font(); \ | |
| 30 font.setPointSize(8); \ | |
| 31 format.setFont(font); \ | |
| 32 cursor.setCharFormat(format); \ | |
| 33 } | |
| 34 | |
| 35 #define SET_FONT_BOLD(font, format, cursor) \ | |
| 36 { \ | |
| 37 font = cursor.charFormat().font(); \ | |
| 38 font.setBold(true); \ | |
| 39 format.setFont(font); \ | |
| 40 cursor.setCharFormat(format); \ | |
| 41 } | |
| 42 | |
| 43 #define UNSET_FONT_BOLD(font, format, cursor) \ | |
| 44 { \ | |
| 45 font = cursor.charFormat().font(); \ | |
| 46 font.setBold(false); \ | |
| 47 format.setFont(font); \ | |
| 48 cursor.setCharFormat(format); \ | |
| 49 } | |
| 50 | |
| 51 #define SET_FORMAT_HYPERLINK(format, cursor, link) \ | |
| 52 { \ | |
| 53 format.setAnchor(true); \ | |
| 54 format.setAnchorHref(link); \ | |
| 55 cursor.setCharFormat(format); \ | |
| 56 } | |
| 57 #define UNSET_FORMAT_HYPERLINK(format, cursor) \ | |
| 58 { \ | |
| 59 format.setAnchor(false); \ | |
| 60 format.setAnchorHref(""); \ | |
| 61 cursor.setCharFormat(format); \ | |
| 62 } | |
| 63 | |
| 64 AboutWindow::AboutWindow(QWidget* parent) : QDialog(parent) { | |
| 65 setWindowTitle(tr("About Minori")); | |
| 66 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); | |
| 67 setLayout(new QHBoxLayout); | |
| 68 | |
| 69 QPalette pal = QPalette(); | |
| 70 pal.setColor(QPalette::Window, pal.color(QPalette::Base)); | |
| 71 setPalette(pal); | |
| 72 setAutoFillBackground(true); | |
| 73 | |
| 74 QFont font; | |
| 75 QTextCharFormat format; | |
| 76 QTextBrowser* paragraph = new QTextBrowser(this); | |
| 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 | 81 QTextCursor cursor = paragraph->textCursor(); |
| 82 SET_TITLE_FONT(font, format, cursor); | |
| 83 SET_FONT_BOLD(font, format, cursor); | |
| 84 cursor.insertText("Minori"); | |
| 85 UNSET_FONT_BOLD(font, format, cursor); | |
| 86 cursor.insertText(" " MINORI_VERSION); | |
| 87 SET_PARAGRAPH_FONT(font, format, cursor); | |
| 88 cursor.insertBlock(); | |
| 89 cursor.insertBlock(); | |
| 90 SET_FONT_BOLD(font, format, cursor); | |
| 91 cursor.insertText(tr("Author:")); | |
| 92 UNSET_FONT_BOLD(font, format, cursor); | |
| 93 cursor.insertBlock(); | |
| 94 cursor.insertText(tr("Paper")); | |
| 95 cursor.insertBlock(); | |
| 96 cursor.insertBlock(); | |
| 97 SET_FONT_BOLD(font, format, cursor); | |
| 98 cursor.insertText(tr("Third party components:")); | |
| 99 UNSET_FONT_BOLD(font, format, cursor); | |
| 100 cursor.insertBlock(); | |
| 101 SET_FORMAT_HYPERLINK(format, cursor, "https://github.com/nlohmann/json"); | |
| 102 cursor.insertText(tr("JSON for Modern C++ ") + CONCAT_VERSION(NLOHMANN_JSON_VERSION_MAJOR, NLOHMANN_JSON_VERSION_MINOR, NLOHMANN_JSON_VERSION_PATCH)); | |
| 103 UNSET_FORMAT_HYPERLINK(format, cursor); | |
| 104 cursor.insertText(", "); | |
| 105 { | |
| 106 curl_version_info_data* data = curl_version_info(CURLVERSION_NOW); | |
| 107 SET_FORMAT_HYPERLINK(format, cursor, "https://curl.se/"); | |
| 108 cursor.insertText(tr("libcurl v") + data->version); | |
| 109 UNSET_FORMAT_HYPERLINK(format, cursor); | |
| 110 cursor.insertText(", "); | |
| 111 } | |
| 112 SET_FORMAT_HYPERLINK(format, cursor, "https://p.yusukekamiyamane.com/"); | |
| 113 cursor.insertText(tr("Fugue Icons ") + CONCAT_VERSION(3, 5, 6)); | |
| 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 | 123 cursor.insertBlock(); |
| 124 cursor.insertBlock(); | |
| 125 SET_FONT_BOLD(font, format, cursor); | |
| 126 cursor.insertText(tr("Links:")); | |
| 127 UNSET_FONT_BOLD(font, format, cursor); | |
| 128 cursor.insertBlock(); | |
| 129 layout()->addWidget(paragraph); | |
| 130 } |
