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