juicy compiler error
This commit is contained in:
+236
-204
@@ -1,41 +1,49 @@
|
||||
#include "message.h"
|
||||
#include "qcolor.h"
|
||||
#include "colorscheme.h"
|
||||
#include "emotes.h"
|
||||
#include "emojis.h"
|
||||
#include "link.h"
|
||||
#include "appsettings.h"
|
||||
#include "ircmanager.h"
|
||||
#include "colorscheme.h"
|
||||
#include "emojis.h"
|
||||
#include "emotes.h"
|
||||
#include "fonts.h"
|
||||
#include "ircmanager.h"
|
||||
#include "link.h"
|
||||
#include "qcolor.h"
|
||||
|
||||
#include <ctime>
|
||||
#include <tuple>
|
||||
#include <list>
|
||||
#include <QStringList>
|
||||
#include <ctime>
|
||||
#include <list>
|
||||
#include <tuple>
|
||||
|
||||
#define MARGIN_LEFT 8
|
||||
#define MARGIN_RIGHT 8
|
||||
#define MARGIN_TOP 8
|
||||
#define MARGIN_BOTTOM 8
|
||||
|
||||
LazyLoadedImage* Message::badgeStaff = new LazyLoadedImage(new QImage(":/images/staff_bg.png"));
|
||||
LazyLoadedImage* Message::badgeAdmin = new LazyLoadedImage(new QImage(":/images/admin_bg.png"));
|
||||
LazyLoadedImage* Message::badgeModerator = new LazyLoadedImage(new QImage(":/images/moderator_bg.png"));
|
||||
LazyLoadedImage* Message::badgeGlobalmod = new LazyLoadedImage(new QImage(":/images/globalmod_bg.png"));
|
||||
LazyLoadedImage* Message::badgeTurbo = new LazyLoadedImage(new QImage(":/images/turbo_bg.png"));
|
||||
LazyLoadedImage* Message::badgeBroadcaster = new LazyLoadedImage(new QImage(":/images/broadcaster_bg.png"));
|
||||
LazyLoadedImage* Message::badgePremium = new LazyLoadedImage(new QImage(":/images/twitchprime_bg.png"));
|
||||
LazyLoadedImage *Message::badgeStaff =
|
||||
new LazyLoadedImage(new QImage(":/images/staff_bg.png"));
|
||||
LazyLoadedImage *Message::badgeAdmin =
|
||||
new LazyLoadedImage(new QImage(":/images/admin_bg.png"));
|
||||
LazyLoadedImage *Message::badgeModerator =
|
||||
new LazyLoadedImage(new QImage(":/images/moderator_bg.png"));
|
||||
LazyLoadedImage *Message::badgeGlobalmod =
|
||||
new LazyLoadedImage(new QImage(":/images/globalmod_bg.png"));
|
||||
LazyLoadedImage *Message::badgeTurbo =
|
||||
new LazyLoadedImage(new QImage(":/images/turbo_bg.png"));
|
||||
LazyLoadedImage *Message::badgeBroadcaster =
|
||||
new LazyLoadedImage(new QImage(":/images/broadcaster_bg.png"));
|
||||
LazyLoadedImage *Message::badgePremium =
|
||||
new LazyLoadedImage(new QImage(":/images/twitchprime_bg.png"));
|
||||
|
||||
QRegularExpression* Message::cheerRegex = new QRegularExpression("cheer[1-9][0-9]*");
|
||||
QRegularExpression *Message::cheerRegex =
|
||||
new QRegularExpression("cheer[1-9][0-9]*");
|
||||
|
||||
Message::Message(const QString &text)
|
||||
: m_wordParts(new std::list<WordPart>())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Message::Message(const IrcPrivateMessage& ircMessage, const Channel& channel, bool enablePingSound,
|
||||
bool isReceivedWhisper, bool isSentWhisper, bool includeChannel )
|
||||
Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
|
||||
bool enablePingSound, bool isReceivedWhisper,
|
||||
bool isSentWhisper, bool includeChannel)
|
||||
: m_wordParts(new std::list<WordPart>())
|
||||
{
|
||||
m_parseTime = std::chrono::system_clock::now();
|
||||
@@ -46,8 +54,7 @@ Message::Message(const IrcPrivateMessage& ircMessage, const Channel& channel, bo
|
||||
|
||||
auto iterator = tags.find("id");
|
||||
|
||||
if (iterator != tags.end())
|
||||
{
|
||||
if (iterator != tags.end()) {
|
||||
m_id = iterator.value().toString();
|
||||
}
|
||||
|
||||
@@ -55,9 +62,9 @@ Message::Message(const IrcPrivateMessage& ircMessage, const Channel& channel, bo
|
||||
iterator = tags.find("tmi-sent-ts");
|
||||
std::time_t time = std::time(NULL);
|
||||
|
||||
if (iterator != tags.end())
|
||||
{
|
||||
time = strtoll(iterator.value().toString().toStdString().c_str(), NULL, 10);
|
||||
if (iterator != tags.end()) {
|
||||
time = strtoll(iterator.value().toString().toStdString().c_str(), NULL,
|
||||
10);
|
||||
}
|
||||
|
||||
char timeStampBuffer[69];
|
||||
@@ -68,51 +75,50 @@ Message::Message(const IrcPrivateMessage& ircMessage, const Channel& channel, bo
|
||||
strftime(timeStampBuffer, 69, "%H:%M:%S", localtime(&time));
|
||||
QString timestampWithSeconds = QString(timeStampBuffer);
|
||||
|
||||
words.push_back(Word(timestamp, Word::TimestampNoSeconds, ColorScheme::instance().SystemMessageColor, QString(), QString()));
|
||||
words.push_back(Word(timestampWithSeconds, Word::TimestampWithSeconds, ColorScheme::instance().SystemMessageColor, QString(), QString()));
|
||||
words.push_back(Word(timestamp, Word::TimestampNoSeconds,
|
||||
ColorScheme::instance().SystemMessageColor, QString(),
|
||||
QString()));
|
||||
words.push_back(Word(timestampWithSeconds, Word::TimestampWithSeconds,
|
||||
ColorScheme::instance().SystemMessageColor, QString(),
|
||||
QString()));
|
||||
|
||||
// badges
|
||||
iterator = tags.find("badges");
|
||||
|
||||
if (iterator != tags.end())
|
||||
{
|
||||
if (iterator != tags.end()) {
|
||||
auto badges = iterator.value().toString().split(',');
|
||||
|
||||
for (QString badge : badges)
|
||||
{
|
||||
if (badge.startsWith("bits/"))
|
||||
{
|
||||
long long int cheer = strtoll(badge.mid(5).toStdString().c_str(), NULL, 10);
|
||||
words.push_back(Word(Emotes::getCheerBadge(cheer), Word::BadgeCheer, QString(), QString("Twitch Cheer" + QString::number(cheer))));
|
||||
}
|
||||
else if (badge == "staff/1")
|
||||
{
|
||||
words.push_back(Word(badgeStaff, Word::BadgeStaff, QString(), QString("Twitch Staff")));
|
||||
}
|
||||
else if (badge == "admin/1")
|
||||
{
|
||||
words.push_back(Word(badgeAdmin, Word::BadgeAdmin, QString(), QString("Twitch Admin")));
|
||||
}
|
||||
else if (badge == "global_mod/1")
|
||||
{
|
||||
words.push_back(Word(badgeGlobalmod, Word::BadgeGlobalMod, QString(), QString("Global Moderator")));
|
||||
}
|
||||
else if (badge == "moderator/1")
|
||||
{
|
||||
for (QString badge : badges) {
|
||||
if (badge.startsWith("bits/")) {
|
||||
long long int cheer =
|
||||
strtoll(badge.mid(5).toStdString().c_str(), NULL, 10);
|
||||
words.push_back(Word(
|
||||
Emotes::getCheerBadge(cheer), Word::BadgeCheer, QString(),
|
||||
QString("Twitch Cheer" + QString::number(cheer))));
|
||||
} else if (badge == "staff/1") {
|
||||
words.push_back(Word(badgeStaff, Word::BadgeStaff, QString(),
|
||||
QString("Twitch Staff")));
|
||||
} else if (badge == "admin/1") {
|
||||
words.push_back(Word(badgeAdmin, Word::BadgeAdmin, QString(),
|
||||
QString("Twitch Admin")));
|
||||
} else if (badge == "global_mod/1") {
|
||||
words.push_back(Word(badgeGlobalmod, Word::BadgeGlobalMod,
|
||||
QString(), QString("Global Moderator")));
|
||||
} else if (badge == "moderator/1") {
|
||||
#pragma message WARN("xD")
|
||||
words.push_back(Word(badgeTurbo, Word::BadgeModerator, QString(), QString("Channel Moderator"))); // custom badge
|
||||
}
|
||||
else if (badge == "turbo/1")
|
||||
{
|
||||
words.push_back(Word(badgeStaff, Word::BadgeTurbo, QString(), QString("Turbo Subscriber")));
|
||||
}
|
||||
else if (badge == "broadcaster/1")
|
||||
{
|
||||
words.push_back(Word(badgeBroadcaster, Word::BadgeBroadcaster, QString(), QString("Channel Broadcaster")));
|
||||
}
|
||||
else if (badge == "premium/1")
|
||||
{
|
||||
words.push_back(Word(badgePremium, Word::BadgePremium, QString(), QString("Twitch Prime")));
|
||||
words.push_back(
|
||||
Word(badgeTurbo, Word::BadgeModerator, QString(),
|
||||
QString("Channel Moderator"))); // custom badge
|
||||
} else if (badge == "turbo/1") {
|
||||
words.push_back(Word(badgeStaff, Word::BadgeTurbo, QString(),
|
||||
QString("Turbo Subscriber")));
|
||||
} else if (badge == "broadcaster/1") {
|
||||
words.push_back(Word(badgeBroadcaster, Word::BadgeBroadcaster,
|
||||
QString(),
|
||||
QString("Channel Broadcaster")));
|
||||
} else if (badge == "premium/1") {
|
||||
words.push_back(Word(badgePremium, Word::BadgePremium,
|
||||
QString(), QString("Twitch Prime")));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,27 +127,26 @@ Message::Message(const IrcPrivateMessage& ircMessage, const Channel& channel, bo
|
||||
QColor usernameColor = ColorScheme::instance().SystemMessageColor;
|
||||
|
||||
iterator = tags.find("color");
|
||||
if (iterator != tags.end())
|
||||
{
|
||||
usernameColor = QColor(iterator.value().toString());
|
||||
if (iterator != tags.end()) {
|
||||
usernameColor = QColor(iterator.value().toString());
|
||||
}
|
||||
|
||||
// channel name
|
||||
if (includeChannel)
|
||||
{
|
||||
if (includeChannel) {
|
||||
QString channelName("#" + channel.name());
|
||||
words.push_back(Word(channelName, Word::Misc, ColorScheme::instance().SystemMessageColor, QString(channelName), QString(), Link(Link::Url, channel.name() + "\n" + m_id)));
|
||||
words.push_back(Word(channelName, Word::Misc,
|
||||
ColorScheme::instance().SystemMessageColor,
|
||||
QString(channelName), QString(),
|
||||
Link(Link::Url, channel.name() + "\n" + m_id)));
|
||||
}
|
||||
|
||||
// username
|
||||
m_userName = ircMessage.account();
|
||||
|
||||
if (m_userName.isEmpty())
|
||||
{
|
||||
if (m_userName.isEmpty()) {
|
||||
auto iterator = tags.find("login");
|
||||
|
||||
if (iterator != tags.end())
|
||||
{
|
||||
if (iterator != tags.end()) {
|
||||
m_userName = iterator.value().toString();
|
||||
}
|
||||
}
|
||||
@@ -151,78 +156,81 @@ Message::Message(const IrcPrivateMessage& ircMessage, const Channel& channel, bo
|
||||
iterator = tags.find("display-name");
|
||||
if (iterator == tags.end()) {
|
||||
displayName = ircMessage.account();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
displayName = iterator.value().toString();
|
||||
}
|
||||
|
||||
bool hasLocalizedName = QString::compare(displayName, ircMessage.account()) == 0;
|
||||
QString userDisplayString = displayName + (hasLocalizedName ? (" (" + ircMessage.account() + ")") : QString());
|
||||
bool hasLocalizedName =
|
||||
QString::compare(displayName, ircMessage.account()) == 0;
|
||||
QString userDisplayString =
|
||||
displayName +
|
||||
(hasLocalizedName ? (" (" + ircMessage.account() + ")") : QString());
|
||||
|
||||
if (isSentWhisper)
|
||||
{
|
||||
if (isSentWhisper) {
|
||||
userDisplayString = IrcManager::account->username() + " -> ";
|
||||
}
|
||||
|
||||
if (isReceivedWhisper)
|
||||
{
|
||||
if (isReceivedWhisper) {
|
||||
userDisplayString += " -> " + IrcManager::account->username();
|
||||
}
|
||||
|
||||
if (!ircMessage.isAction())
|
||||
{
|
||||
if (!ircMessage.isAction()) {
|
||||
userDisplayString += ": ";
|
||||
}
|
||||
|
||||
words.push_back(Word(userDisplayString, Word::Username, usernameColor, userDisplayString, QString()));
|
||||
words.push_back(Word(userDisplayString, Word::Username, usernameColor,
|
||||
userDisplayString, QString()));
|
||||
|
||||
// highlights
|
||||
// highlights
|
||||
#pragma message WARN("xD")
|
||||
|
||||
// bits
|
||||
QString bits = "";
|
||||
|
||||
iterator = tags.find("bits");
|
||||
if (iterator != tags.end())
|
||||
{
|
||||
bits = iterator.value().toString();
|
||||
if (iterator != tags.end()) {
|
||||
bits = iterator.value().toString();
|
||||
}
|
||||
|
||||
// twitch emotes
|
||||
std::vector<std::pair<long int, LazyLoadedImage*>> twitchEmotes;
|
||||
std::vector<std::pair<long int, LazyLoadedImage *>> twitchEmotes;
|
||||
|
||||
iterator = tags.find("emotes");
|
||||
|
||||
if (iterator != tags.end())
|
||||
{
|
||||
if (iterator != tags.end()) {
|
||||
auto emotes = iterator.value().toString().split('/');
|
||||
|
||||
for (QString emote : emotes)
|
||||
{
|
||||
if (!emote.contains(':')) continue;
|
||||
for (QString emote : emotes) {
|
||||
if (!emote.contains(':'))
|
||||
continue;
|
||||
|
||||
QStringList parameters = emote.split(':');
|
||||
|
||||
if (parameters.length() < 2) continue;
|
||||
if (parameters.length() < 2)
|
||||
continue;
|
||||
|
||||
long int id = std::stol(parameters.at(0).toStdString(), NULL, 10);
|
||||
|
||||
QStringList occurences = parameters.at(1).split(',');
|
||||
|
||||
for (QString occurence : occurences)
|
||||
{
|
||||
for (QString occurence : occurences) {
|
||||
QStringList coords = occurence.split('-');
|
||||
|
||||
if (coords.length() < 2) continue;
|
||||
if (coords.length() < 2)
|
||||
continue;
|
||||
|
||||
long int start = std::stol(coords.at(0).toStdString(), NULL, 10);
|
||||
long int start =
|
||||
std::stol(coords.at(0).toStdString(), NULL, 10);
|
||||
long int end = std::stol(coords.at(1).toStdString(), NULL, 10);
|
||||
|
||||
if (start >= end || start < 0 || end > ircMessage.content().length()) continue;
|
||||
if (start >= end || start < 0 ||
|
||||
end > ircMessage.content().length())
|
||||
continue;
|
||||
|
||||
QString name = ircMessage.content().mid(start, end - start);
|
||||
|
||||
twitchEmotes.push_back(std::pair<long int, LazyLoadedImage*>(start, Emotes::getTwitchEmoteById(name, id)));
|
||||
twitchEmotes.push_back(std::pair<long int, LazyLoadedImage *>(
|
||||
start, Emotes::getTwitchEmoteById(name, id)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,21 +240,29 @@ Message::Message(const IrcPrivateMessage& ircMessage, const Channel& channel, bo
|
||||
auto currentTwitchEmote = twitchEmotes.begin();
|
||||
|
||||
// words
|
||||
QColor textColor = ircMessage.isAction() ? usernameColor : ColorScheme::instance().Text;
|
||||
QColor textColor =
|
||||
ircMessage.isAction() ? usernameColor : ColorScheme::instance().Text;
|
||||
|
||||
QStringList splits = ircMessage.content().split(' ');
|
||||
|
||||
long int i = 0;
|
||||
|
||||
for (QString split : splits)
|
||||
{
|
||||
for (QString split : splits) {
|
||||
// twitch emote
|
||||
if (currentTwitchEmote == twitchEmotes.end()) break;
|
||||
if (currentTwitchEmote == twitchEmotes.end())
|
||||
break;
|
||||
|
||||
if (currentTwitchEmote->first == i)
|
||||
{
|
||||
words.push_back(Word(currentTwitchEmote->second, Word::TwitchEmoteImage, currentTwitchEmote->second->name(), currentTwitchEmote->second->name() + QString("\nTwitch Emote")));
|
||||
words.push_back(Word(currentTwitchEmote->second->name(), Word::TwitchEmoteText, textColor, currentTwitchEmote->second->name(), currentTwitchEmote->second->name() + QString("\nTwitch Emote")));
|
||||
if (currentTwitchEmote->first == i) {
|
||||
words.push_back(Word(currentTwitchEmote->second,
|
||||
Word::TwitchEmoteImage,
|
||||
currentTwitchEmote->second->name(),
|
||||
currentTwitchEmote->second->name() +
|
||||
QString("\nTwitch Emote")));
|
||||
words.push_back(Word(currentTwitchEmote->second->name(),
|
||||
Word::TwitchEmoteText, textColor,
|
||||
currentTwitchEmote->second->name(),
|
||||
currentTwitchEmote->second->name() +
|
||||
QString("\nTwitch Emote")));
|
||||
|
||||
i += split.length() + 1;
|
||||
currentTwitchEmote = std::next(currentTwitchEmote);
|
||||
@@ -255,78 +271,99 @@ Message::Message(const IrcPrivateMessage& ircMessage, const Channel& channel, bo
|
||||
}
|
||||
|
||||
// split words
|
||||
std::vector<std::tuple<LazyLoadedImage*, QString>> parsed;
|
||||
std::vector<std::tuple<LazyLoadedImage *, QString>> parsed;
|
||||
|
||||
Emojis::parseEmojis(parsed, split);
|
||||
|
||||
for (const std::tuple<LazyLoadedImage*, QString>& tuple : parsed)
|
||||
{
|
||||
LazyLoadedImage* image = std::get<0>(tuple);
|
||||
if (image == NULL)
|
||||
{
|
||||
for (const std::tuple<LazyLoadedImage *, QString> &tuple : parsed) {
|
||||
LazyLoadedImage *image = std::get<0>(tuple);
|
||||
if (image == NULL) {
|
||||
QString string = std::get<1>(tuple);
|
||||
|
||||
// cheers
|
||||
if (!bits.isEmpty() && string.length() >= 6 && cheerRegex->match(string).isValid())
|
||||
{
|
||||
if (!bits.isEmpty() && string.length() >= 6 &&
|
||||
cheerRegex->match(string).isValid()) {
|
||||
auto cheer = string.mid(5).toInt();
|
||||
|
||||
QString color;
|
||||
|
||||
QColor bitsColor;
|
||||
|
||||
if (cheer >= 10000)
|
||||
{
|
||||
if (cheer >= 10000) {
|
||||
color = "red";
|
||||
bitsColor = QColor::fromHslF(0, 1, 0.5);
|
||||
}
|
||||
else if (cheer >= 5000)
|
||||
{
|
||||
} else if (cheer >= 5000) {
|
||||
color = "blue";
|
||||
bitsColor = QColor::fromHslF(0.61, 1, 0.4);
|
||||
}
|
||||
else if (cheer >= 1000)
|
||||
{
|
||||
} else if (cheer >= 1000) {
|
||||
color = "green";
|
||||
bitsColor = QColor::fromHslF(0.5, 1, 0.5);
|
||||
}
|
||||
else if (cheer >= 100)
|
||||
{
|
||||
} else if (cheer >= 100) {
|
||||
color = "purple";
|
||||
bitsColor = QColor::fromHslF(0.8, 1, 0.5);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
color = "gray";
|
||||
bitsColor = QColor::fromHslF(0.5f, 0.5f, 0.5f);
|
||||
}
|
||||
|
||||
QString bitsLinkAnimated = QString("http://static-cdn.jtvnw.net/bits/dark/animated/" + color + "/1");
|
||||
QString bitsLink = QString("http://static-cdn.jtvnw.net/bits/dark/static/" + color + "/1");
|
||||
QString bitsLinkAnimated = QString(
|
||||
"http://static-cdn.jtvnw.net/bits/dark/animated/" +
|
||||
color + "/1");
|
||||
QString bitsLink = QString(
|
||||
"http://static-cdn.jtvnw.net/bits/dark/static/" +
|
||||
color + "/1");
|
||||
|
||||
LazyLoadedImage* imageAnimated = Emotes::miscImageFromCache().getOrAdd(bitsLinkAnimated, [&bitsLinkAnimated]{ return new LazyLoadedImage(bitsLinkAnimated); });
|
||||
LazyLoadedImage* image = Emotes::miscImageFromCache().getOrAdd(bitsLink, [&bitsLink]{ return new LazyLoadedImage(bitsLink); });
|
||||
LazyLoadedImage *imageAnimated =
|
||||
Emotes::miscImageFromCache().getOrAdd(
|
||||
bitsLinkAnimated, [&bitsLinkAnimated] {
|
||||
return new LazyLoadedImage(bitsLinkAnimated);
|
||||
});
|
||||
LazyLoadedImage *image =
|
||||
Emotes::miscImageFromCache().getOrAdd(
|
||||
bitsLink, [&bitsLink] {
|
||||
return new LazyLoadedImage(bitsLink);
|
||||
});
|
||||
|
||||
words.push_back(Word(imageAnimated, Word::BitsAnimated, QString("cheer"), QString("Twitch Cheer"), Link(Link::Url, QString("https://blog.twitch.tv/introducing-cheering-celebrate-together-da62af41fac6"))));
|
||||
words.push_back(Word(image, Word::Bits, QString("cheer"), QString("Twitch Cheer"), Link(Link::Url, QString("https://blog.twitch.tv/introducing-cheering-celebrate-together-da62af41fac6"))));
|
||||
words.push_back(
|
||||
Word(imageAnimated, Word::BitsAnimated,
|
||||
QString("cheer"), QString("Twitch Cheer"),
|
||||
Link(Link::Url,
|
||||
QString("https://blog.twitch.tv/"
|
||||
"introducing-cheering-celebrate-"
|
||||
"together-da62af41fac6"))));
|
||||
words.push_back(
|
||||
Word(image, Word::Bits, QString("cheer"),
|
||||
QString("Twitch Cheer"),
|
||||
Link(Link::Url,
|
||||
QString("https://blog.twitch.tv/"
|
||||
"introducing-cheering-celebrate-"
|
||||
"together-da62af41fac6"))));
|
||||
|
||||
words.push_back(Word(QString("x" + string.mid(5)), Word::BitsAmount, bitsColor, QString(string.mid(5)), QString("Twitch Cheer"), Link(Link::Url, QString("https://blog.twitch.tv/introducing-cheering-celebrate-together-da62af41fac6"))));
|
||||
words.push_back(
|
||||
Word(QString("x" + string.mid(5)), Word::BitsAmount,
|
||||
bitsColor, QString(string.mid(5)),
|
||||
QString("Twitch Cheer"),
|
||||
Link(Link::Url,
|
||||
QString("https://blog.twitch.tv/"
|
||||
"introducing-cheering-celebrate-"
|
||||
"together-da62af41fac6"))));
|
||||
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
|
||||
// bttv / ffz emotes
|
||||
LazyLoadedImage* bttvEmote;
|
||||
LazyLoadedImage *bttvEmote;
|
||||
|
||||
#pragma message WARN( "xD ignored emotes")
|
||||
if (
|
||||
Emotes::bttvEmotes().tryGet(string, bttvEmote) ||
|
||||
channel.bttvChannelEmotes().tryGet(string, bttvEmote) ||
|
||||
Emotes::ffzEmotes().tryGet(string, bttvEmote) ||
|
||||
channel.ffzChannelEmotes().tryGet(string, bttvEmote) ||
|
||||
Emotes::chatterinoEmotes().tryGet(string, bttvEmote))
|
||||
{
|
||||
words.push_back(Word(bttvEmote, Word::BttvEmoteImage, bttvEmote->name(), bttvEmote->tooltip(), Link(Link::Url, bttvEmote->url())));
|
||||
#pragma message WARN("xD ignored emotes")
|
||||
if (Emotes::bttvEmotes().tryGet(string, bttvEmote) ||
|
||||
channel.bttvChannelEmotes().tryGet(string, bttvEmote) ||
|
||||
Emotes::ffzEmotes().tryGet(string, bttvEmote) ||
|
||||
channel.ffzChannelEmotes().tryGet(string, bttvEmote) ||
|
||||
Emotes::chatterinoEmotes().tryGet(string, bttvEmote)) {
|
||||
words.push_back(Word(bttvEmote, Word::BttvEmoteImage,
|
||||
bttvEmote->name(),
|
||||
bttvEmote->tooltip(),
|
||||
Link(Link::Url, bttvEmote->url())));
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -334,7 +371,9 @@ Message::Message(const IrcPrivateMessage& ircMessage, const Channel& channel, bo
|
||||
// actually just a word
|
||||
QString link = matchLink(string);
|
||||
|
||||
words.push_back(Word(string, Word::Text, textColor, string, QString(), link.isEmpty() ? Link() : Link(Link::Url, link)));
|
||||
words.push_back(
|
||||
Word(string, Word::Text, textColor, string, QString(),
|
||||
link.isEmpty() ? Link() : Link(Link::Url, link)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,16 +382,18 @@ Message::Message(const IrcPrivateMessage& ircMessage, const Channel& channel, bo
|
||||
|
||||
this->m_words = words;
|
||||
|
||||
#pragma message WARN("xD")
|
||||
// if (!isReceivedWhisper && AppSettings.HighlightIgnoredUsers.ContainsKey(Username))
|
||||
// {
|
||||
// HighlightTab = false;
|
||||
// }
|
||||
#pragma message WARN("xD")
|
||||
// if (!isReceivedWhisper &&
|
||||
// AppSettings.HighlightIgnoredUsers.ContainsKey(Username))
|
||||
// {
|
||||
// HighlightTab = false;
|
||||
// }
|
||||
}
|
||||
|
||||
//static void normalize
|
||||
// static void normalize
|
||||
|
||||
bool Message::layout(int width, bool enableEmoteMargins)
|
||||
bool
|
||||
Message::layout(int width, bool enableEmoteMargins)
|
||||
{
|
||||
width = width - (width % 2);
|
||||
|
||||
@@ -360,37 +401,33 @@ bool Message::layout(int width, bool enableEmoteMargins)
|
||||
|
||||
bool redraw = width != m_currentLayoutWidth || m_relayoutRequested;
|
||||
|
||||
if (m_recalculateImages || m_recalculateText)
|
||||
{
|
||||
if (m_recalculateImages || m_recalculateText) {
|
||||
redraw = true;
|
||||
|
||||
for (auto& word : m_words)
|
||||
{
|
||||
if (word.isImage())
|
||||
{
|
||||
if (m_recalculateImages)
|
||||
{
|
||||
auto& image = word.getImage();
|
||||
for (auto &word : m_words) {
|
||||
if (word.isImage()) {
|
||||
if (m_recalculateImages) {
|
||||
auto &image = word.getImage();
|
||||
|
||||
qreal w = image.width();
|
||||
qreal h = image.height();
|
||||
|
||||
if (AppSettings::scaleEmotesByLineHeight())
|
||||
{
|
||||
word.setSize(w * mediumTextLineHeight / h * AppSettings::emoteScale(), mediumTextLineHeight * AppSettings::emoteScale());
|
||||
}
|
||||
else
|
||||
{
|
||||
word.setSize(w * image.scale() * AppSettings::emoteScale(), h * image.scale() * AppSettings::emoteScale());
|
||||
if (AppSettings::scaleEmotesByLineHeight()) {
|
||||
word.setSize(
|
||||
w * mediumTextLineHeight / h *
|
||||
AppSettings::emoteScale(),
|
||||
mediumTextLineHeight * AppSettings::emoteScale());
|
||||
} else {
|
||||
word.setSize(
|
||||
w * image.scale() * AppSettings::emoteScale(),
|
||||
h * image.scale() * AppSettings::emoteScale());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_recalculateText)
|
||||
{
|
||||
QFontMetrics& metrics = word.getFontMetrics();
|
||||
word.setSize(metrics.width(word.getText()), metrics.height());
|
||||
} else {
|
||||
if (m_recalculateText) {
|
||||
QFontMetrics &metrics = word.getFontMetrics();
|
||||
word.setSize(metrics.width(word.getText()),
|
||||
metrics.height());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -399,32 +436,26 @@ bool Message::layout(int width, bool enableEmoteMargins)
|
||||
m_recalculateText = false;
|
||||
}
|
||||
|
||||
if (redraw)
|
||||
{
|
||||
if (redraw) {
|
||||
int x = MARGIN_LEFT;
|
||||
int y = MARGIN_TOP;
|
||||
|
||||
int right = width - MARGIN_RIGHT;
|
||||
|
||||
std::list<WordPart>* parts;
|
||||
std::list<WordPart> *parts = new std::list<WordPart>();
|
||||
|
||||
auto lineStart = m_wordParts->begin();
|
||||
int lineHeight = 0;
|
||||
|
||||
for (auto it = m_words.begin(); it != m_words.end(); ++it)
|
||||
{
|
||||
Word& word = *it;
|
||||
for (auto it = m_words.begin(); it != m_words.end(); ++it) {
|
||||
Word &word = *it;
|
||||
|
||||
int xOffset = 0, yOffset = 0;
|
||||
|
||||
if (enableEmoteMargins)
|
||||
{
|
||||
if (word.isImage() && word.getImage().isHat())
|
||||
{
|
||||
if (enableEmoteMargins) {
|
||||
if (word.isImage() && word.getImage().isHat()) {
|
||||
xOffset = -word.width() + 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
xOffset = word.xOffset();
|
||||
yOffset = word.yOffset();
|
||||
}
|
||||
@@ -432,18 +463,16 @@ bool Message::layout(int width, bool enableEmoteMargins)
|
||||
lineHeight = std::max(word.height(), lineHeight);
|
||||
}
|
||||
|
||||
if (x + word.width() + xOffset <= right)
|
||||
{
|
||||
parts->push_back(WordPart(word, x, y, QStringRef(&word.copyText())));
|
||||
if (x + word.width() + xOffset <= right) {
|
||||
parts->push_back(WordPart(word, x, y, word.copyText()));
|
||||
x += word.width() + xOffset;
|
||||
}
|
||||
// else if (word.isText() && word.getText().length() > 2)
|
||||
// {
|
||||
// else if (word.isText() && word.getText().length() > 2)
|
||||
// {
|
||||
|
||||
// }
|
||||
else
|
||||
{
|
||||
parts->push_back(WordPart(word, x, y, QStringRef(&word.copyText())));
|
||||
// }
|
||||
else {
|
||||
parts->push_back(WordPart(word, x, y, word.copyText()));
|
||||
|
||||
lineHeight = std::max(word.height(), lineHeight);
|
||||
}
|
||||
@@ -459,12 +488,15 @@ bool Message::layout(int width, bool enableEmoteMargins)
|
||||
return redraw;
|
||||
}
|
||||
|
||||
bool Message::sortTwitchEmotes(const std::pair<long int, LazyLoadedImage*>& a, const std::pair<long int, LazyLoadedImage*>& b)
|
||||
bool
|
||||
Message::sortTwitchEmotes(const std::pair<long int, LazyLoadedImage *> &a,
|
||||
const std::pair<long int, LazyLoadedImage *> &b)
|
||||
{
|
||||
return a.first < b.first;
|
||||
}
|
||||
|
||||
QString Message::matchLink(const QString &string)
|
||||
QString
|
||||
Message::matchLink(const QString &string)
|
||||
{
|
||||
#pragma message WARN("xD")
|
||||
return QString();
|
||||
|
||||
Reference in New Issue
Block a user