2019-09-08 22:27:57 +02:00
|
|
|
#include "AboutPage.hpp"
|
|
|
|
|
2019-09-16 18:37:32 +02:00
|
|
|
#include "common/Modes.hpp"
|
2020-11-21 16:20:10 +01:00
|
|
|
#include "common/QLogging.hpp"
|
2019-09-16 18:37:32 +02:00
|
|
|
#include "common/Version.hpp"
|
2019-09-08 22:27:57 +02:00
|
|
|
#include "util/LayoutCreator.hpp"
|
|
|
|
#include "util/RemoveScrollAreaBackground.hpp"
|
2020-10-31 16:42:48 +01:00
|
|
|
#include "widgets/BasePopup.hpp"
|
2019-09-08 22:27:57 +02:00
|
|
|
#include "widgets/helper/SignalLabel.hpp"
|
|
|
|
|
|
|
|
#include <QFormLayout>
|
|
|
|
#include <QGroupBox>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QTextEdit>
|
|
|
|
#include <QTextStream>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
#define PIXMAP_WIDTH 500
|
|
|
|
|
2021-07-25 16:19:01 +02:00
|
|
|
#define LINK_CHATTERINO_WIKI "https://wiki.chatterino.com"
|
|
|
|
#define LINK_DONATE "https://streamelements.com/fourtf/tip"
|
|
|
|
#define LINK_CHATTERINO_FEATURES "https://chatterino.com/#features"
|
|
|
|
#define LINK_CHATTERINO_DISCORD "https://discord.gg/7Y5AYhAK4z"
|
|
|
|
|
2019-09-08 22:27:57 +02:00
|
|
|
namespace chatterino {
|
|
|
|
|
|
|
|
AboutPage::AboutPage()
|
|
|
|
{
|
|
|
|
LayoutCreator<AboutPage> layoutCreator(this);
|
|
|
|
|
|
|
|
auto scroll = layoutCreator.emplace<QScrollArea>();
|
|
|
|
auto widget = scroll.emplaceScrollAreaWidget();
|
|
|
|
removeScrollAreaBackground(scroll.getElement(), widget.getElement());
|
|
|
|
|
|
|
|
auto layout = widget.setLayoutType<QVBoxLayout>();
|
|
|
|
{
|
|
|
|
QPixmap pixmap;
|
|
|
|
pixmap.load(":/settings/aboutlogo.png");
|
|
|
|
|
|
|
|
auto logo = layout.emplace<QLabel>().assign(&this->logo_);
|
|
|
|
logo->setPixmap(pixmap);
|
2020-04-19 21:05:40 +02:00
|
|
|
if (pixmap.width() != 0)
|
|
|
|
{
|
|
|
|
logo->setFixedSize(PIXMAP_WIDTH,
|
|
|
|
PIXMAP_WIDTH * pixmap.height() / pixmap.width());
|
|
|
|
}
|
2019-09-08 22:27:57 +02: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");
|
|
|
|
|
|
|
|
/*auto xd = layout.emplace<QGroupBox>("Created by...");
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
// }
|
|
|
|
}*/
|
|
|
|
|
2021-07-25 16:19:01 +02:00
|
|
|
// Version
|
2019-09-16 18:37:32 +02:00
|
|
|
auto versionInfo = layout.emplace<QGroupBox>("Version");
|
|
|
|
{
|
2019-10-07 22:42:34 +02:00
|
|
|
auto version = Version::instance();
|
2019-09-16 18:37:32 +02:00
|
|
|
QString text = QString("%1 (commit %2%3)")
|
2019-10-07 22:32:11 +02:00
|
|
|
.arg(version.fullVersion())
|
2019-09-16 18:37:32 +02:00
|
|
|
.arg("<a "
|
|
|
|
"href=\"https://github.com/Chatterino/"
|
|
|
|
"chatterino2/commit/" +
|
2019-10-07 22:32:11 +02:00
|
|
|
version.commitHash() + "\">" +
|
|
|
|
version.commitHash() + "</a>")
|
2019-10-07 22:42:34 +02:00
|
|
|
.arg(Modes::instance().isNightly
|
2019-10-07 22:32:11 +02:00
|
|
|
? ", " + version.dateOfBuild()
|
2019-09-26 00:51:05 +02:00
|
|
|
: "");
|
2019-09-16 18:37:32 +02:00
|
|
|
|
|
|
|
auto versionLabel = versionInfo.emplace<QLabel>(text);
|
|
|
|
versionLabel->setOpenExternalLinks(true);
|
|
|
|
versionLabel->setTextInteractionFlags(Qt::TextSelectableByMouse |
|
|
|
|
Qt::LinksAccessibleByMouse);
|
|
|
|
}
|
|
|
|
|
2021-07-25 16:19:01 +02:00
|
|
|
// About Chatterino
|
|
|
|
auto aboutChatterino = layout.emplace<QGroupBox>("About Chatterino...");
|
|
|
|
{
|
|
|
|
auto l = aboutChatterino.emplace<QVBoxLayout>();
|
|
|
|
|
|
|
|
// clang-format off
|
|
|
|
l.emplace<QLabel>("Chatterino Wiki can be found <a href=\"" LINK_CHATTERINO_WIKI "\">here</a>")->setOpenExternalLinks(true);
|
|
|
|
l.emplace<QLabel>("All about Chatterino's <a href=\"" LINK_CHATTERINO_FEATURES "\">features</a>")->setOpenExternalLinks(true);
|
|
|
|
l.emplace<QLabel>("Join the official Chatterino <a href=\"" LINK_CHATTERINO_DISCORD "\">Discord</a>")->setOpenExternalLinks(true);
|
|
|
|
// clang-format on
|
|
|
|
}
|
|
|
|
|
|
|
|
// Licenses
|
2019-09-08 22:27:57 +02:00
|
|
|
auto licenses =
|
|
|
|
layout.emplace<QGroupBox>("Open source software used...");
|
|
|
|
{
|
|
|
|
auto form = licenses.emplace<QFormLayout>();
|
|
|
|
|
|
|
|
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");
|
|
|
|
addLicense(form.getElement(), "LibCommuni",
|
|
|
|
"https://github.com/communi/libcommuni",
|
|
|
|
":/licenses/libcommuni_BSD3.txt");
|
|
|
|
addLicense(form.getElement(), "OpenSSL", "https://www.openssl.org/",
|
|
|
|
":/licenses/openssl.txt");
|
|
|
|
addLicense(form.getElement(), "RapidJson", "http://rapidjson.org/",
|
|
|
|
":/licenses/rapidjson.txt");
|
|
|
|
addLicense(form.getElement(), "Pajlada/Settings",
|
|
|
|
"https://github.com/pajlada/settings",
|
|
|
|
":/licenses/pajlada_settings.txt");
|
|
|
|
addLicense(form.getElement(), "Pajlada/Signals",
|
|
|
|
"https://github.com/pajlada/signals",
|
|
|
|
":/licenses/pajlada_signals.txt");
|
|
|
|
addLicense(form.getElement(), "Websocketpp",
|
|
|
|
"https://www.zaphoyd.com/websocketpp/",
|
|
|
|
":/licenses/websocketpp.txt");
|
2021-10-31 20:45:23 +01:00
|
|
|
#ifndef NO_QTKEYCHAIN
|
2019-09-18 13:03:16 +02:00
|
|
|
addLicense(form.getElement(), "QtKeychain",
|
|
|
|
"https://github.com/frankosterfeld/qtkeychain",
|
|
|
|
":/licenses/qtkeychain.txt");
|
2021-10-31 20:45:23 +01:00
|
|
|
#endif
|
2021-03-13 15:34:11 +01:00
|
|
|
addLicense(form.getElement(), "lrucache",
|
|
|
|
"https://github.com/lamerman/cpp-lru-cache",
|
|
|
|
":/licenses/lrucache.txt");
|
2019-09-08 22:27:57 +02:00
|
|
|
}
|
|
|
|
|
2021-07-25 16:19:01 +02:00
|
|
|
// Attributions
|
2019-09-08 22:27:57 +02:00
|
|
|
auto attributions = layout.emplace<QGroupBox>("Attributions...");
|
|
|
|
{
|
|
|
|
auto l = attributions.emplace<QVBoxLayout>();
|
|
|
|
|
|
|
|
// clang-format off
|
|
|
|
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>("Emoji datasource provided by <a href=\"https://www.iamcal.com/\">Cal Henderson</a>"
|
|
|
|
"(<a href=\"https://github.com/iamcal/emoji-data/blob/master/LICENSE\">show license</a>)")->setOpenExternalLinks(true);
|
|
|
|
// clang-format on
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
{
|
2020-11-21 16:20:10 +01:00
|
|
|
qCDebug(chatterinoWidget)
|
|
|
|
<< "Missing parts in line" << line;
|
2019-09-08 22:27:57 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString username = contributorParts[0].trimmed();
|
|
|
|
QString url = contributorParts[1].trimmed();
|
|
|
|
QString avatarUrl = contributorParts[2].trimmed();
|
|
|
|
QString role = contributorParts[3].trimmed();
|
|
|
|
|
|
|
|
auto *usernameLabel =
|
|
|
|
new QLabel("<a href=\"" + url + "\">" + username + "</a>");
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const auto addLabels = [&contributorBox2, &usernameLabel,
|
|
|
|
&roleLabel] {
|
|
|
|
auto labelBox = new QVBoxLayout();
|
|
|
|
contributorBox2->addLayout(labelBox);
|
|
|
|
|
|
|
|
labelBox->addWidget(usernameLabel);
|
|
|
|
labelBox->addWidget(roleLabel);
|
|
|
|
};
|
|
|
|
|
|
|
|
addLabels();
|
|
|
|
addAvatar();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
layout->addStretch(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
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 QLabel("<a href=\"" + licenseLink + "\">show license</a>");
|
2020-10-31 16:42:48 +01:00
|
|
|
QObject::connect(
|
|
|
|
b, &QLabel::linkActivated, [parent = this, name, licenseLink] {
|
|
|
|
auto window =
|
|
|
|
new BasePopup(BaseWindow::Flags::EnableCustomFrame, parent);
|
|
|
|
window->setWindowTitle("Chatterino - License for " + name);
|
|
|
|
window->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
auto layout = new QVBoxLayout();
|
|
|
|
auto *edit = new QTextEdit;
|
|
|
|
|
|
|
|
QFile file(licenseLink);
|
|
|
|
file.open(QIODevice::ReadOnly);
|
|
|
|
edit->setText(file.readAll());
|
|
|
|
edit->setReadOnly(true);
|
|
|
|
|
|
|
|
layout->addWidget(edit);
|
|
|
|
|
|
|
|
window->getLayoutContainer()->setLayout(layout);
|
|
|
|
window->show();
|
|
|
|
});
|
2019-09-08 22:27:57 +02:00
|
|
|
|
|
|
|
form->addRow(a, b);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace chatterino
|