refactor: About page (#5287)
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "util/RemoveScrollAreaBackground.hpp"
|
||||
#include "widgets/BasePopup.hpp"
|
||||
#include "widgets/helper/SignalLabel.hpp"
|
||||
#include "widgets/layout/FlowLayout.hpp"
|
||||
|
||||
#include <QFile>
|
||||
#include <QFormLayout>
|
||||
@@ -54,6 +55,7 @@ AboutPage::AboutPage()
|
||||
|
||||
auto label = vbox.emplace<QLabel>(version.buildString() + "<br>" +
|
||||
version.runningString());
|
||||
label->setWordWrap(true);
|
||||
label->setOpenExternalLinks(true);
|
||||
label->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||
}
|
||||
@@ -137,15 +139,15 @@ AboutPage::AboutPage()
|
||||
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>"
|
||||
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 contributors = layout.emplace<QGroupBox>("People");
|
||||
{
|
||||
auto l = contributors.emplace<QVBoxLayout>();
|
||||
auto l = contributors.emplace<FlowLayout>();
|
||||
|
||||
QFile contributorsFile(":/contributors.txt");
|
||||
contributorsFile.open(QFile::ReadOnly);
|
||||
@@ -166,11 +168,24 @@ AboutPage::AboutPage()
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line.startsWith(u"@header"))
|
||||
{
|
||||
if (l->count() != 0)
|
||||
{
|
||||
l->addLinebreak(20);
|
||||
}
|
||||
auto *label = new QLabel(QStringLiteral("<h1>%1</h1>")
|
||||
.arg(line.mid(8).trimmed()));
|
||||
l->addWidget(label);
|
||||
l->addLinebreak(8);
|
||||
continue;
|
||||
}
|
||||
|
||||
QStringList contributorParts = line.split("|");
|
||||
|
||||
if (contributorParts.size() != 4)
|
||||
if (contributorParts.size() != 3)
|
||||
{
|
||||
qCDebug(chatterinoWidget)
|
||||
qCWarning(chatterinoWidget)
|
||||
<< "Missing parts in line" << line;
|
||||
continue;
|
||||
}
|
||||
@@ -178,39 +193,42 @@ AboutPage::AboutPage()
|
||||
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);
|
||||
usernameLabel->setToolTip(url);
|
||||
|
||||
auto contributorBox2 = l.emplace<QHBoxLayout>();
|
||||
auto contributorBox2 = l.emplace<QVBoxLayout>();
|
||||
|
||||
const auto addAvatar = [&avatarUrl, &contributorBox2] {
|
||||
if (!avatarUrl.isEmpty())
|
||||
const auto addAvatar = [&] {
|
||||
auto *avatar = new QLabel();
|
||||
QPixmap avatarPixmap;
|
||||
if (avatarUrl.isEmpty())
|
||||
{
|
||||
QPixmap avatarPixmap;
|
||||
avatarPixmap.load(avatarUrl);
|
||||
|
||||
auto avatar = contributorBox2.emplace<QLabel>();
|
||||
avatar->setPixmap(avatarPixmap);
|
||||
avatar->setFixedSize(64, 64);
|
||||
avatar->setScaledContents(true);
|
||||
// TODO: or anon.png
|
||||
avatarPixmap.load(":/avatars/anon.png");
|
||||
}
|
||||
else
|
||||
{
|
||||
avatarPixmap.load(avatarUrl);
|
||||
}
|
||||
|
||||
avatar->setPixmap(avatarPixmap);
|
||||
avatar->setFixedSize(64, 64);
|
||||
avatar->setScaledContents(true);
|
||||
contributorBox2->addWidget(avatar, 0, Qt::AlignCenter);
|
||||
};
|
||||
|
||||
const auto addLabels = [&contributorBox2, &usernameLabel,
|
||||
&roleLabel] {
|
||||
const auto addLabels = [&] {
|
||||
auto *labelBox = new QVBoxLayout();
|
||||
contributorBox2->addLayout(labelBox);
|
||||
|
||||
labelBox->addWidget(usernameLabel);
|
||||
labelBox->addWidget(roleLabel);
|
||||
labelBox->addWidget(usernameLabel, 0, Qt::AlignCenter);
|
||||
};
|
||||
|
||||
addLabels();
|
||||
addAvatar();
|
||||
addLabels();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user