Move polishcolor to a utils namespace and rename getusercolor

This commit is contained in:
James Graham
2023-07-31 19:44:16 +01:00
parent 648fff20f2
commit 9311052e39
5 changed files with 34 additions and 26 deletions

View File

@@ -16,6 +16,8 @@
#include <Kirigami/PlatformTheme>
#include "utils.h"
static const QStringList allowedTags = {
QStringLiteral("font"), QStringLiteral("del"), QStringLiteral("h1"), QStringLiteral("h2"), QStringLiteral("h3"), QStringLiteral("h4"),
QStringLiteral("h5"), QStringLiteral("h6"), QStringLiteral("blockquote"), QStringLiteral("p"), QStringLiteral("a"), QStringLiteral("ul"),
@@ -77,13 +79,6 @@ QString TextHandler::handleSendText()
return outputString;
}
static QColor polishColor(qreal hueF)
{
const auto lightness = static_cast<QGuiApplication *>(QGuiApplication::instance())->palette().color(QPalette::Active, QPalette::Window).lightnessF();
// https://github.com/quotient-im/libQuotient/wiki/User-color-coding-standard-draft-proposal
return QColor::fromHslF(hueF, 1, -0.7 * lightness + 0.9, 1);
}
QString TextHandler::handleRecieveRichText(Qt::TextFormat inputFormat, const NeoChatRoom *room, const Quotient::RoomEvent *event, bool stripNewlines)
{
m_pos = 0;
@@ -145,7 +140,7 @@ QString TextHandler::handleRecieveRichText(Qt::TextFormat inputFormat, const Neo
if (e->msgtype() == Quotient::MessageEventType::Emote) {
auto author = room->user(e->senderId());
QString emoteString = QStringLiteral("* <a href=\"https://matrix.to/#/") + e->senderId() + QStringLiteral("\" style=\"color:")
+ polishColor(author->hueF()).name() + QStringLiteral("\">") + author->displayname(room) + QStringLiteral("</a> ");
+ Utils::getUserColor(author->hueF()).name() + QStringLiteral("\">") + author->displayname(room) + QStringLiteral("</a> ");
if (outputString.startsWith(QStringLiteral("<p>"))) {
outputString.insert(3, emoteString);
} else {