Mercurial > minori
diff src/gui/dialog/about.cc @ 81:9b2b41f83a5e
boring: mass rename to cc
because this is a very unix-y project, it makes more sense to use the
'cc' extension
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Mon, 23 Oct 2023 12:07:27 -0400 |
parents | src/gui/dialog/about.cpp@6f7385bd334c |
children | 27455104ea37 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/gui/dialog/about.cc Mon Oct 23 12:07:27 2023 -0400 @@ -0,0 +1,137 @@ +#include "gui/dialog/about.h" +#include "core/json.h" +#include "core/version.h" +#include "gui/widgets/text.h" +#include "pugixml.hpp" +#include <QFont> +#include <QHBoxLayout> +#include <QTextBrowser> +#include <QTextCharFormat> +#include <QTextCursor> +#include <curl/curl.h> + +#define CONCAT_VERSION_NX(major, minor, patch) ("v" #major "." #minor "." #patch) + +#define CONCAT_VERSION(major, minor, patch) CONCAT_VERSION_NX(major, minor, patch) + +#define SET_TITLE_FONT(font, format, cursor) \ + { \ + QFont fnt; \ + fnt.setPixelSize(16); \ + format.setFont(fnt); \ + cursor.setCharFormat(format); \ + } + +#define SET_PARAGRAPH_FONT(font, format, cursor) \ + { \ + QFont fnt; \ + fnt.setPixelSize(12); \ + format.setFont(fnt); \ + cursor.setCharFormat(format); \ + } + +#define SET_FONT_BOLD(font, format, cursor) \ + { \ + font = cursor.charFormat().font(); \ + font.setBold(true); \ + format.setFont(font); \ + cursor.setCharFormat(format); \ + } + +#define UNSET_FONT_BOLD(font, format, cursor) \ + { \ + font = cursor.charFormat().font(); \ + font.setBold(false); \ + format.setFont(font); \ + cursor.setCharFormat(format); \ + } + +#define SET_FORMAT_HYPERLINK(format, cursor, link) \ + { \ + font = cursor.charFormat().font(); \ + font.setUnderline(true); \ + format.setFont(font); \ + format.setAnchor(true); \ + format.setAnchorHref(link); \ + cursor.setCharFormat(format); \ + } +#define UNSET_FORMAT_HYPERLINK(format, cursor) \ + { \ + font = cursor.charFormat().font(); \ + font.setUnderline(false); \ + format.setFont(font); \ + format.setAnchor(false); \ + format.setAnchorHref(""); \ + cursor.setCharFormat(format); \ + } + +AboutWindow::AboutWindow(QWidget* parent) : QDialog(parent) { + setWindowTitle(tr("About Minori")); + setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); + QHBoxLayout* layout = new QHBoxLayout(this); + + QPalette pal = QPalette(); + pal.setColor(QPalette::Window, pal.color(QPalette::Base)); + setPalette(pal); + setAutoFillBackground(true); + + QFont font; + QTextCharFormat format; + QTextBrowser* paragraph = new QTextBrowser(this); + paragraph->setOpenExternalLinks(true); + paragraph->setFrameShape(QFrame::NoFrame); + paragraph->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + paragraph->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + QTextCursor cursor = paragraph->textCursor(); + SET_TITLE_FONT(font, format, cursor); + SET_FONT_BOLD(font, format, cursor); + cursor.insertText("Minori"); + UNSET_FONT_BOLD(font, format, cursor); + cursor.insertText(" " MINORI_VERSION); + SET_PARAGRAPH_FONT(font, format, cursor); + cursor.insertBlock(); + cursor.insertBlock(); + SET_FONT_BOLD(font, format, cursor); + cursor.insertText(tr("Author:")); + UNSET_FONT_BOLD(font, format, cursor); + cursor.insertBlock(); + cursor.insertText(tr("Paper")); + cursor.insertBlock(); + cursor.insertBlock(); + SET_FONT_BOLD(font, format, cursor); + cursor.insertText(tr("Third party components:")); + UNSET_FONT_BOLD(font, format, cursor); + cursor.insertBlock(); + SET_FORMAT_HYPERLINK(format, cursor, "https://github.com/nlohmann/json"); + cursor.insertText(tr("JSON for Modern C++ ") + CONCAT_VERSION(NLOHMANN_JSON_VERSION_MAJOR, + NLOHMANN_JSON_VERSION_MINOR, + NLOHMANN_JSON_VERSION_PATCH)); + UNSET_FORMAT_HYPERLINK(format, cursor); + cursor.insertText(", "); + { + curl_version_info_data* data = curl_version_info(CURLVERSION_NOW); + SET_FORMAT_HYPERLINK(format, cursor, "https://curl.se/"); + cursor.insertText(tr("libcurl v") + data->version); + UNSET_FORMAT_HYPERLINK(format, cursor); + cursor.insertText(", "); + } + SET_FORMAT_HYPERLINK(format, cursor, "https://p.yusukekamiyamane.com/"); + cursor.insertText(tr("Fugue Icons ") + CONCAT_VERSION(3, 5, 6)); + UNSET_FORMAT_HYPERLINK(format, cursor); + cursor.insertText(", "); + SET_FORMAT_HYPERLINK(format, cursor, "https://pugixml.org/"); + cursor.insertText(tr("pugixml v") + QString::number(PUGIXML_VERSION / 1000) + "." + + QString::number(PUGIXML_VERSION / 10 % 100) + "." + QString::number(PUGIXML_VERSION % 10)); + UNSET_FORMAT_HYPERLINK(format, cursor); + cursor.insertText(", "); + SET_FORMAT_HYPERLINK(format, cursor, "https://github.com/erengy/anitomy"); + cursor.insertText(tr("Anitomy")); + UNSET_FORMAT_HYPERLINK(format, cursor); + cursor.insertBlock(); + cursor.insertBlock(); + SET_FONT_BOLD(font, format, cursor); + cursor.insertText(tr("Links:")); + UNSET_FONT_BOLD(font, format, cursor); + cursor.insertBlock(); + layout->addWidget(paragraph); +}