2018-06-26 14:09:39 +02:00
|
|
|
#include "AboutPage.hpp"
|
2018-01-12 23:09:05 +01:00
|
|
|
|
2018-07-04 18:48:53 +02:00
|
|
|
#include "debug/Log.hpp"
|
2018-06-26 14:09:39 +02:00
|
|
|
#include "util/LayoutCreator.hpp"
|
|
|
|
#include "util/RemoveScrollAreaBackground.hpp"
|
|
|
|
#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-07-04 18:48:53 +02:00
|
|
|
#include <QTextStream>
|
2018-01-13 00:04:47 +01:00
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
#define PIXMAP_WIDTH 500
|
|
|
|
|
2018-01-12 23:09:05 +01:00
|
|
|
namespace chatterino {
|
|
|
|
|
|
|
|
AboutPage::AboutPage()
|
2018-08-09 06:22:55 +02:00
|
|
|
: SettingsPage("About", ":/settings/about.svg")
|
2018-01-12 23:09:05 +01:00
|
|
|
{
|
2018-06-26 17:06:17 +02:00
|
|
|
LayoutCreator<AboutPage> layoutCreator(this);
|
2018-01-13 00:04:47 +01:00
|
|
|
|
2018-06-06 20:04:57 +02:00
|
|
|
auto scroll = layoutCreator.emplace<QScrollArea>();
|
|
|
|
auto widget = scroll.emplaceScrollAreaWidget();
|
2018-06-26 17:06:17 +02:00
|
|
|
removeScrollAreaBackground(scroll.getElement(), widget.getElement());
|
2018-06-06 20:04:57 +02:00
|
|
|
|
|
|
|
auto layout = widget.setLayoutType<QVBoxLayout>();
|
2018-01-13 00:04:47 +01:00
|
|
|
{
|
|
|
|
QPixmap pixmap;
|
2018-08-02 14:23:27 +02:00
|
|
|
pixmap.load(":/settings/aboutlogo.png");
|
2018-01-13 00:04:47 +01:00
|
|
|
|
2018-07-06 19:23:47 +02:00
|
|
|
auto logo = layout.emplace<QLabel>().assign(&this->logo_);
|
2018-01-13 00:04:47 +01:00
|
|
|
logo->setPixmap(pixmap);
|
2018-08-06 21:17:03 +02:00
|
|
|
logo->setFixedSize(PIXMAP_WIDTH,
|
|
|
|
PIXMAP_WIDTH * pixmap.height() / pixmap.width());
|
2018-01-13 00:04:47 +01:00
|
|
|
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>();
|
|
|
|
{
|
2018-08-06 21:17:03 +02:00
|
|
|
created->setText("Created by <a
|
|
|
|
href=\"https://github.com/fourtf\">fourtf</a><br>" "with big help from
|
|
|
|
pajlada."); created->setTextFormat(Qt::RichText);
|
2018-06-04 21:05:18 +02:00
|
|
|
created->setTextInteractionFlags(Qt::TextBrowserInteraction |
|
|
|
|
Qt::LinksAccessibleByKeyboard |
|
|
|
|
Qt::LinksAccessibleByKeyboard);
|
|
|
|
created->setOpenExternalLinks(true);
|
|
|
|
// created->setPalette(palette);
|
|
|
|
}
|
|
|
|
|
|
|
|
// auto github = xd.emplace<QLabel>();
|
|
|
|
// {
|
|
|
|
// github->setText(
|
2018-08-06 21:17:03 +02:00
|
|
|
// "<a
|
|
|
|
href=\"https://github.com/fourtf/chatterino2\">Chatterino on
|
2018-06-04 21:05:18 +02:00
|
|
|
// Github</a>");
|
|
|
|
// github->setTextFormat(Qt::RichText);
|
2018-08-06 21:17:03 +02:00
|
|
|
// github->setTextInteractionFlags(Qt::TextBrowserInteraction |
|
|
|
|
// Qt::LinksAccessibleByKeyboard |
|
|
|
|
// Qt::LinksAccessibleByKeyboard);
|
2018-06-04 21:05:18 +02:00
|
|
|
// github->setOpenExternalLinks(true);
|
|
|
|
// // github->setPalette(palette);
|
|
|
|
// }
|
|
|
|
}*/
|
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
auto licenses =
|
|
|
|
layout.emplace<QGroupBox>("Open source software used...");
|
2018-06-04 17:28:27 +02:00
|
|
|
{
|
|
|
|
auto form = licenses.emplace<QFormLayout>();
|
|
|
|
|
2018-06-22 12:34:33 +02:00
|
|
|
addLicense(form.getElement(), "Qt Framework", "https://www.qt.io",
|
|
|
|
":/licenses/qt_lgpl-3.0.txt");
|
|
|
|
addLicense(form.getElement(), "Boost", "https://www.boost.org/",
|
|
|
|
":/licenses/boost_boost.txt");
|
2018-08-06 21:17:03 +02:00
|
|
|
addLicense(form.getElement(), "Fmt", "http://fmtlib.net/",
|
|
|
|
":/licenses/fmt_bsd2.txt");
|
|
|
|
addLicense(form.getElement(), "LibCommuni",
|
|
|
|
"https://github.com/communi/libcommuni",
|
2018-06-04 17:28:27 +02:00
|
|
|
":/licenses/libcommuni_BSD3.txt");
|
2018-06-22 12:34:33 +02:00
|
|
|
addLicense(form.getElement(), "OpenSSL", "https://www.openssl.org/",
|
|
|
|
":/licenses/openssl.txt");
|
|
|
|
addLicense(form.getElement(), "RapidJson", "http://rapidjson.org/",
|
|
|
|
":/licenses/rapidjson.txt");
|
2018-08-06 21:17:03 +02:00
|
|
|
addLicense(form.getElement(), "Pajlada/Settings",
|
|
|
|
"https://github.com/pajlada/settings",
|
2018-06-04 17:28:27 +02:00
|
|
|
":/licenses/pajlada_settings.txt");
|
2018-08-06 21:17:03 +02:00
|
|
|
addLicense(form.getElement(), "Pajlada/Signals",
|
|
|
|
"https://github.com/pajlada/signals",
|
2018-06-04 17:28:27 +02:00
|
|
|
":/licenses/pajlada_signals.txt");
|
2018-08-06 21:17:03 +02:00
|
|
|
addLicense(form.getElement(), "Websocketpp",
|
|
|
|
"https://www.zaphoyd.com/websocketpp/",
|
2018-06-04 17:28:27 +02:00
|
|
|
":/licenses/websocketpp.txt");
|
|
|
|
}
|
2018-06-06 01:29:43 +02:00
|
|
|
|
|
|
|
auto attributions = layout.emplace<QGroupBox>("Attributions...");
|
|
|
|
{
|
|
|
|
auto l = attributions.emplace<QVBoxLayout>();
|
|
|
|
|
|
|
|
// clang-format off
|
2018-07-28 13:20:18 +02:00
|
|
|
l.emplace<QLabel>("EmojiOne 2 and 3 emojis provided by <a href=\"https://www.emojione.com/\">EmojiOne</a>")->setOpenExternalLinks(true);
|
|
|
|
l.emplace<QLabel>("Twemoji emojis provided by <a href=\"https://github.com/twitter/twemoji\">Twitter's Twemoji</a>")->setOpenExternalLinks(true);
|
|
|
|
l.emplace<QLabel>("Facebook emojis provided by <a href=\"https://facebook.com\">Facebook</a>")->setOpenExternalLinks(true);
|
|
|
|
l.emplace<QLabel>("Apple emojis provided by <a href=\"https://apple.com\">Apple</a>")->setOpenExternalLinks(true);
|
|
|
|
l.emplace<QLabel>("Google emojis provided by <a href=\"https://google.com\">Google</a>")->setOpenExternalLinks(true);
|
|
|
|
l.emplace<QLabel>("Messenger emojis provided by <a href=\"https://facebook.com\">Facebook</a>")->setOpenExternalLinks(true);
|
|
|
|
l.emplace<QLabel>("Emoji datasource provided by <a href=\"https://www.iamcal.com/\">Cal Henderson</a>")->setOpenExternalLinks(true);
|
2018-06-06 01:29:43 +02:00
|
|
|
// clang-format on
|
|
|
|
}
|
2018-07-04 18:48:53 +02:00
|
|
|
|
|
|
|
// Contributors
|
|
|
|
auto contributors = layout.emplace<QGroupBox>("Contributors");
|
|
|
|
{
|
|
|
|
auto l = contributors.emplace<QVBoxLayout>();
|
|
|
|
|
|
|
|
QFile contributorsFile(":/contributors.txt");
|
|
|
|
contributorsFile.open(QFile::ReadOnly);
|
|
|
|
|
|
|
|
QTextStream stream(&contributorsFile);
|
|
|
|
stream.setCodec("UTF-8");
|
|
|
|
|
|
|
|
QString line;
|
|
|
|
|
|
|
|
while (stream.readLineInto(&line)) {
|
|
|
|
if (line.isEmpty() || line.startsWith('#')) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList contributorParts = line.split("|");
|
|
|
|
|
|
|
|
if (contributorParts.size() != 4) {
|
|
|
|
Log("Missing parts in line '{}'", line);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString username = contributorParts[0].trimmed();
|
|
|
|
QString url = contributorParts[1].trimmed();
|
|
|
|
QString avatarUrl = contributorParts[2].trimmed();
|
|
|
|
QString role = contributorParts[3].trimmed();
|
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
auto *usernameLabel =
|
|
|
|
new QLabel("<a href=\"" + url + "\">" + username + "</a>");
|
2018-07-04 18:48:53 +02:00
|
|
|
usernameLabel->setOpenExternalLinks(true);
|
|
|
|
auto *roleLabel = new QLabel(role);
|
|
|
|
|
|
|
|
auto contributorBox2 = l.emplace<QHBoxLayout>();
|
|
|
|
|
|
|
|
const auto addAvatar = [&avatarUrl, &contributorBox2] {
|
|
|
|
if (!avatarUrl.isEmpty()) {
|
|
|
|
QPixmap avatarPixmap;
|
|
|
|
avatarPixmap.load(avatarUrl);
|
|
|
|
|
|
|
|
auto avatar = contributorBox2.emplace<QLabel>();
|
|
|
|
avatar->setPixmap(avatarPixmap);
|
|
|
|
avatar->setFixedSize(64, 64);
|
|
|
|
avatar->setScaledContents(true);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
const auto addLabels = [&contributorBox2, &usernameLabel,
|
|
|
|
&roleLabel] {
|
2018-07-04 18:48:53 +02:00
|
|
|
auto labelBox = new QVBoxLayout();
|
|
|
|
contributorBox2->addLayout(labelBox);
|
|
|
|
|
|
|
|
labelBox->addWidget(usernameLabel);
|
|
|
|
labelBox->addWidget(roleLabel);
|
|
|
|
};
|
|
|
|
|
|
|
|
addLabels();
|
|
|
|
addAvatar();
|
|
|
|
}
|
|
|
|
}
|
2018-01-13 00:04:47 +01:00
|
|
|
}
|
2018-04-20 00:15:57 +02:00
|
|
|
|
2018-08-09 06:22:55 +02:00
|
|
|
auto buildInfo = QStringList();
|
|
|
|
buildInfo += "Qt " QT_VERSION_STR;
|
|
|
|
#ifdef USEWINSDK
|
|
|
|
buildInfo += "Windows SDK";
|
|
|
|
#endif
|
|
|
|
#ifdef _MSC_FULL_VER
|
|
|
|
buildInfo += "MSVC " + QString::number(_MSC_FULL_VER, 10);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
auto buildText = QString("Built with " + buildInfo.join(", "));
|
|
|
|
layout.emplace<QLabel>(buildText);
|
|
|
|
|
2018-01-13 00:04:47 +01:00
|
|
|
layout->addStretch(1);
|
2018-01-12 23:09:05 +01:00
|
|
|
}
|
2018-04-03 02:55:32 +02:00
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
void AboutPage::addLicense(QFormLayout *form, const QString &name,
|
|
|
|
const QString &website, const QString &licenseLink)
|
2018-06-04 17:28:27 +02:00
|
|
|
{
|
|
|
|
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 chatterino
|