mirror-chatterino2/src/widgets/settingspages/aboutpage.cpp

114 lines
4.6 KiB
C++
Raw Normal View History

2018-01-12 23:09:05 +01:00
#include "aboutpage.hpp"
2018-01-16 00:26:04 +01:00
#include "util/layoutcreator.hpp"
2018-06-04 17:28:27 +02:00
#include "widgets/helper/signallabel.hpp"
2018-01-13 00:04:47 +01:00
2018-06-04 17:28:27 +02:00
#include <QFormLayout>
#include <QGroupBox>
2018-01-13 00:04:47 +01:00
#include <QLabel>
2018-06-04 17:28:27 +02:00
#include <QTextEdit>
2018-01-13 00:04:47 +01:00
#include <QVBoxLayout>
#define PIXMAP_WIDTH 500
2018-01-12 23:09:05 +01:00
namespace chatterino {
namespace widgets {
namespace settingspages {
AboutPage::AboutPage()
: SettingsPage("About", ":/images/about.svg")
{
2018-01-13 00:04:47 +01:00
util::LayoutCreator<AboutPage> layoutCreator(this);
2018-01-13 02:00:02 +01:00
auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
2018-01-13 00:04:47 +01:00
{
QPixmap pixmap;
pixmap.load(":/images/aboutlogo.png");
auto logo = layout.emplace<QLabel>().assign(&this->logo);
logo->setPixmap(pixmap);
logo->setFixedSize(PIXMAP_WIDTH, PIXMAP_WIDTH * pixmap.height() / pixmap.width());
logo->setScaledContents(true);
// this does nothing
// QPalette palette;
// palette.setColor(QPalette::Text, Qt::white);
// palette.setColor(QPalette::Link, "#a5cdff");
// palette.setColor(QPalette::LinkVisited, "#a5cdff");
2018-06-04 21:05:18 +02:00
/*auto xd = layout.emplace<QGroupBox>("Created by...");
2018-06-04 17:28:27 +02:00
{
2018-06-04 21:05:18 +02:00
auto created = xd.emplace<QLabel>();
{
created->setText("Created by <a href=\"https://github.com/fourtf\">fourtf</a><br>"
"with big help from pajlada.");
created->setTextFormat(Qt::RichText);
created->setTextInteractionFlags(Qt::TextBrowserInteraction |
Qt::LinksAccessibleByKeyboard |
Qt::LinksAccessibleByKeyboard);
created->setOpenExternalLinks(true);
// created->setPalette(palette);
}
// auto github = xd.emplace<QLabel>();
// {
// github->setText(
// "<a href=\"https://github.com/fourtf/chatterino2\">Chatterino on
// Github</a>");
// github->setTextFormat(Qt::RichText);
// github->setTextInteractionFlags(Qt::TextBrowserInteraction |
// Qt::LinksAccessibleByKeyboard |
// Qt::LinksAccessibleByKeyboard);
// github->setOpenExternalLinks(true);
// // github->setPalette(palette);
// }
}*/
auto licenses = layout.emplace<QGroupBox>("Open source software used...");
2018-06-04 17:28:27 +02:00
{
auto form = licenses.emplace<QFormLayout>();
addLicense(*form, "Qt Framework", "https://www.qt.io", ":/licenses/qt_lgpl-3.0.txt");
addLicense(*form, "Boost", "https://www.boost.org/", ":/licenses/boost_boost.txt");
addLicense(*form, "Fmt", "http://fmtlib.net/", ":/licenses/fmt_bsd2.txt");
addLicense(*form, "LibCommuni", "https://github.com/communi/libcommuni",
":/licenses/libcommuni_BSD3.txt");
addLicense(*form, "OpenSSL", "https://www.openssl.org/", ":/licenses/openssl.txt");
addLicense(*form, "RapidJson", "http://rapidjson.org/", ":/licenses/rapidjson.txt");
addLicense(*form, "Pajlada/Settings", "https://github.com/pajlada/settings",
":/licenses/pajlada_settings.txt");
addLicense(*form, "Pajlada/Signals", "https://github.com/pajlada/signals",
":/licenses/pajlada_signals.txt");
addLicense(*form, "Websocketpp", "https://www.zaphoyd.com/websocketpp/",
":/licenses/websocketpp.txt");
}
2018-01-13 00:04:47 +01:00
}
2018-04-20 00:15:57 +02:00
2018-01-13 00:04:47 +01:00
layout->addStretch(1);
2018-01-12 23:09:05 +01:00
}
2018-06-04 17:28:27 +02:00
void AboutPage::addLicense(QFormLayout *form, const QString &name, const QString &website,
const QString &licenseLink)
{
auto *a = new QLabel("<a href=\"" + website + "\">" + name + "</a>");
a->setOpenExternalLinks(true);
auto *b = new SignalLabel();
b->setText("<a href=\"" + licenseLink + "\">show license</a>");
2018-06-04 21:05:18 +02:00
b->setCursor(Qt::PointingHandCursor);
2018-06-04 17:28:27 +02:00
QObject::connect(b, &SignalLabel::mouseUp, [licenseLink] {
auto *edit = new QTextEdit;
QFile file(licenseLink);
file.open(QIODevice::ReadOnly);
edit->setText(file.readAll());
edit->setReadOnly(true);
edit->show();
});
form->addRow(a, b);
}
2018-01-12 23:09:05 +01:00
} // namespace settingspages
} // namespace widgets
} // namespace chatterino