mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
added messages
This commit is contained in:
parent
82bc101bb8
commit
a8c2b1151f
42
channel.cpp
42
channel.cpp
|
@ -1,24 +1,23 @@
|
||||||
#include "channel.h"
|
#include "channel.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
|
|
||||||
const Channel Channel::whispers = Channel(QString("/whispers"));
|
Channel Channel::whispers = Channel(QString("/whispers"));
|
||||||
const Channel Channel::mentions = Channel(QString("/mentions"));
|
Channel Channel::mentions = Channel(QString("/mentions"));
|
||||||
|
|
||||||
QMap<QString, Channel*> Channel::channels = QMap<QString, Channel*>();
|
QMap<QString, Channel*> Channel::channels = QMap<QString, Channel*>();
|
||||||
|
|
||||||
Channel::Channel(QString channel)
|
Channel::Channel(QString channel)
|
||||||
: m_name((channel.length() > 0 && channel[0] == '#') ? channel.mid(1) : channel)
|
: m_name((channel.length() > 0 && channel[0] == '#') ? channel.mid(1) : channel)
|
||||||
|
, m_bttvChannelEmotes()
|
||||||
|
, m_ffzChannelEmotes()
|
||||||
|
, m_messages()
|
||||||
|
, m_messageMutex()
|
||||||
|
, m_subLink("https://www.twitch.tv/" + m_name + "/subscribe?ref=in_chat_subscriber_link")
|
||||||
|
, m_channelLink("https://twitch.tv/" + m_name)
|
||||||
|
, m_popoutPlayerLink("https://player.twitch.tv/?channel=" + m_name)
|
||||||
{
|
{
|
||||||
messageMutex = new QMutex();
|
|
||||||
subLink = "https://www.twitch.tv/" + m_name + "/subscribe?ref=in_chat_subscriber_link";
|
|
||||||
channelLink = "https://twitch.tv/" + m_name;
|
|
||||||
popoutPlayerLink = "https://player.twitch.tv/?channel=" + m_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Channel::~Channel()
|
}
|
||||||
//{
|
|
||||||
//// delete messages;
|
|
||||||
//}
|
|
||||||
|
|
||||||
Channel* Channel::addChannel(const QString &channel)
|
Channel* Channel::addChannel(const QString &channel)
|
||||||
{
|
{
|
||||||
|
@ -69,26 +68,17 @@ void Channel::removeChannel(const QString &channel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Channel::getSubLink() { return subLink ; }
|
QVector<Message*> Channel::getMessagesClone()
|
||||||
QString Channel::getChannelLink() { return channelLink ; }
|
|
||||||
QString Channel::getPopoutPlayerLink() { return popoutPlayerLink ; }
|
|
||||||
|
|
||||||
bool Channel::getIsLive() { return isLive ; }
|
|
||||||
int Channel::getStreamViewerCount() { return streamViewerCount; }
|
|
||||||
QString Channel::getStreamStatus() { return streamStatus ; }
|
|
||||||
QString Channel::getStreamGame() { return streamGame ; }
|
|
||||||
|
|
||||||
QVector<Message*>* Channel::getMessagesClone()
|
|
||||||
{
|
{
|
||||||
messageMutex->lock();
|
m_messageMutex.lock();
|
||||||
auto M = new QVector<Message*>(*messages);
|
QVector M = QVector<Message*>(*m_messages);
|
||||||
messageMutex->unlock();
|
m_messageMutex.unlock();
|
||||||
return M;
|
return M;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Channel::addMessage(Message *message)
|
void Channel::addMessage(Message *message)
|
||||||
{
|
{
|
||||||
messageMutex->lock();
|
m_messageMutex.lock();
|
||||||
// messages
|
// messages
|
||||||
messageMutex->unlock();
|
m_messageMutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
79
channel.h
79
channel.h
|
@ -1,64 +1,79 @@
|
||||||
#ifndef CHANNEL_H
|
#ifndef CHANNEL_H
|
||||||
#define CHANNEL_H
|
#define CHANNEL_H
|
||||||
|
|
||||||
#include "QString"
|
#include "concurrentmap.h"
|
||||||
#include "QMap"
|
#include "lazyloadedimage.h"
|
||||||
#include "QMutex"
|
|
||||||
#include "QVector"
|
#include <QString>
|
||||||
|
#include <QMap>
|
||||||
|
#include <QMutex>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
class Message;
|
class Message;
|
||||||
|
|
||||||
class Channel
|
class Channel
|
||||||
{
|
{
|
||||||
|
// static
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const Channel whispers;
|
static Channel whispers;
|
||||||
static const Channel mentions;
|
static Channel mentions;
|
||||||
|
|
||||||
static Channel* addChannel(const QString &channel);
|
static Channel* addChannel(const QString &channel);
|
||||||
static Channel* getChannel(const QString &channel);
|
static Channel* getChannel(const QString &channel);
|
||||||
static void removeChannel(const QString &channel);
|
static void removeChannel(const QString &channel);
|
||||||
|
|
||||||
QString getSubLink();
|
private:
|
||||||
QString getChannelLink();
|
static QMap<QString, Channel*> channels;
|
||||||
QString getPopoutPlayerLink();
|
|
||||||
|
|
||||||
bool getIsLive();
|
// members
|
||||||
int getStreamViewerCount();
|
|
||||||
QString getStreamStatus();
|
|
||||||
QString getStreamGame();
|
|
||||||
|
|
||||||
const QString& name() const {
|
public:
|
||||||
return m_name;
|
// properties
|
||||||
}
|
const ConcurrentMap<QString, LazyLoadedImage*>& bttvChannelEmotes() const { return m_bttvChannelEmotes; }
|
||||||
|
const ConcurrentMap<QString, LazyLoadedImage*>& ffzChannelEmotes() const { return m_ffzChannelEmotes; }
|
||||||
|
|
||||||
|
const QMutex& messageMutex() const { return m_messageMutex; }
|
||||||
|
|
||||||
|
const QString& name() const { return m_name; }
|
||||||
|
int roomID() const { return m_roomID; }
|
||||||
|
|
||||||
|
const QString& subLink() const { return m_subLink; }
|
||||||
|
const QString& channelLink() const { return m_channelLink; }
|
||||||
|
const QString& popoutPlayerLink() const { return m_popoutPlayerLink; }
|
||||||
|
|
||||||
|
bool isLive() const { return m_isLive; }
|
||||||
|
int streamViewerCount() const { return m_streamViewerCount; }
|
||||||
|
const QString& streamStatus() const { return m_streamStatus; }
|
||||||
|
const QString& streamGame() const { return m_streamGame; }
|
||||||
|
|
||||||
|
// methods
|
||||||
void addMessage(Message* message);
|
void addMessage(Message* message);
|
||||||
// ~Channel();
|
|
||||||
|
|
||||||
QVector<Message*>* getMessagesClone();
|
QVector<Message*> getMessagesClone();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Channel(QString channel);
|
Channel(QString channel);
|
||||||
|
|
||||||
QMutex* messageMutex;
|
ConcurrentMap<QString, LazyLoadedImage*> m_bttvChannelEmotes;
|
||||||
|
ConcurrentMap<QString, LazyLoadedImage*> m_ffzChannelEmotes;
|
||||||
|
QMutex m_messageMutex;
|
||||||
|
|
||||||
static QMap<QString, Channel*> channels;
|
int m_referenceCount = 0;
|
||||||
|
|
||||||
int referenceCount = 1;
|
QVector<Message*> m_messages;
|
||||||
|
|
||||||
QString m_name;
|
QString m_name;
|
||||||
|
int m_roomID;
|
||||||
|
|
||||||
int roomID;
|
QString m_subLink;
|
||||||
|
QString m_channelLink;
|
||||||
|
QString m_popoutPlayerLink;
|
||||||
|
|
||||||
QVector<Message*>* messages = new QVector<Message*>();
|
bool m_isLive;
|
||||||
|
int m_streamViewerCount;
|
||||||
QString subLink = "";
|
QString m_streamStatus;
|
||||||
QString channelLink = "";
|
QString m_streamGame;
|
||||||
QString popoutPlayerLink = "";
|
|
||||||
|
|
||||||
bool isLive = false;
|
|
||||||
int streamViewerCount = 0;
|
|
||||||
QString streamStatus = "";
|
|
||||||
QString streamGame = "";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CHANNEL_H
|
#endif // CHANNEL_H
|
||||||
|
|
|
@ -30,5 +30,5 @@ void ChatWidgetView::paintEvent(QPaintEvent *)
|
||||||
|
|
||||||
auto M = c->getMessagesClone();
|
auto M = c->getMessagesClone();
|
||||||
|
|
||||||
delete M;
|
|
||||||
}
|
}
|
||||||
|
|
1820
emojidata.txt
Normal file
1820
emojidata.txt
Normal file
File diff suppressed because it is too large
Load diff
1931
emojis.cpp
1931
emojis.cpp
File diff suppressed because it is too large
Load diff
18
emojis.h
18
emojis.h
|
@ -4,22 +4,34 @@
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "lazyloadedimage.h"
|
#include "lazyloadedimage.h"
|
||||||
#include "concurrentmap.h"
|
#include "concurrentmap.h"
|
||||||
|
|
||||||
class Emojis
|
class Emojis
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::vector<std::tuple<LazyLoadedImage*, QString>> parseEmotes(const QString& value);
|
static void parseEmojis(std::vector<std::tuple<LazyLoadedImage*, QString>>& vector, const QString& text);
|
||||||
|
|
||||||
static void initEmojis();
|
static void initEmojis();
|
||||||
|
|
||||||
|
static QString replaceShortCodes(const QString& text);
|
||||||
|
|
||||||
|
struct EmojiData {
|
||||||
|
QString value;
|
||||||
|
QString code;
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static QRegularExpression* findShortCodesRegex;
|
static QRegularExpression* findShortCodesRegex;
|
||||||
|
|
||||||
static QMap<QString, QString>* shortCodeToEmoji;
|
static QMap<QString, EmojiData>* shortCodeToEmoji;
|
||||||
static QMap<QString, QString>* emojiToShortCode;
|
static QMap<QString, QString>* emojiToShortCode;
|
||||||
static QMap<QChar, QMap<QString, LazyLoadedImage*>>* firstEmojiChars;
|
static QMap<QChar, QMap<QString, QString>>* firstEmojiChars;
|
||||||
|
|
||||||
|
static ConcurrentMap<QString, LazyLoadedImage*>* imageCache;
|
||||||
|
|
||||||
Emojis() {}
|
Emojis() {}
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,9 +5,9 @@ ConcurrentMap<QString, LazyLoadedImage* >* Emotes::m_bttvEmotes
|
||||||
ConcurrentMap<QString, LazyLoadedImage* >* Emotes::m_ffzEmotes = new ConcurrentMap<QString, LazyLoadedImage* >();
|
ConcurrentMap<QString, LazyLoadedImage* >* Emotes::m_ffzEmotes = new ConcurrentMap<QString, LazyLoadedImage* >();
|
||||||
ConcurrentMap<QString, LazyLoadedImage* >* Emotes::m_chatterinoEmotes = new ConcurrentMap<QString, LazyLoadedImage* >();
|
ConcurrentMap<QString, LazyLoadedImage* >* Emotes::m_chatterinoEmotes = new ConcurrentMap<QString, LazyLoadedImage* >();
|
||||||
ConcurrentMap<QString, LazyLoadedImage* >* Emotes::m_bttvChannelEmoteFromCaches = new ConcurrentMap<QString, LazyLoadedImage* >();
|
ConcurrentMap<QString, LazyLoadedImage* >* Emotes::m_bttvChannelEmoteFromCaches = new ConcurrentMap<QString, LazyLoadedImage* >();
|
||||||
ConcurrentMap<QString, LazyLoadedImage* >* Emotes::m_fFzChannelEmoteFromCaches = new ConcurrentMap<QString, LazyLoadedImage* >();
|
ConcurrentMap<QString, LazyLoadedImage* >* Emotes::m_ffzChannelEmoteFromCaches = new ConcurrentMap<QString, LazyLoadedImage* >();
|
||||||
ConcurrentMap<int, LazyLoadedImage* >* Emotes::m_twitchEmoteFromCache = new ConcurrentMap<int, LazyLoadedImage* >();
|
ConcurrentMap<int, LazyLoadedImage* >* Emotes::m_twitchEmoteFromCache = new ConcurrentMap<int, LazyLoadedImage* >();
|
||||||
ConcurrentMap<int, LazyLoadedImage* >* Emotes::m_miscImageFromCache = new ConcurrentMap<int, LazyLoadedImage* >();
|
ConcurrentMap<QString, LazyLoadedImage* >* Emotes::m_miscImageFromCache = new ConcurrentMap<QString, LazyLoadedImage* >();
|
||||||
|
|
||||||
LazyLoadedImage* Emotes::m_cheerBadge100000 = new LazyLoadedImage(new QImage(":/cheer100000"));
|
LazyLoadedImage* Emotes::m_cheerBadge100000 = new LazyLoadedImage(new QImage(":/cheer100000"));
|
||||||
LazyLoadedImage* Emotes::m_cheerBadge10000 = new LazyLoadedImage(new QImage(":/cheer10000"));
|
LazyLoadedImage* Emotes::m_cheerBadge10000 = new LazyLoadedImage(new QImage(":/cheer10000"));
|
||||||
|
|
8
emotes.h
8
emotes.h
|
@ -15,9 +15,9 @@ public:
|
||||||
static ConcurrentMap<QString, LazyLoadedImage* >& ffzEmotes() { return *m_ffzEmotes ; }
|
static ConcurrentMap<QString, LazyLoadedImage* >& ffzEmotes() { return *m_ffzEmotes ; }
|
||||||
static ConcurrentMap<QString, LazyLoadedImage* >& chatterinoEmotes() { return *m_chatterinoEmotes ; }
|
static ConcurrentMap<QString, LazyLoadedImage* >& chatterinoEmotes() { return *m_chatterinoEmotes ; }
|
||||||
static ConcurrentMap<QString, LazyLoadedImage* >& bttvChannelEmoteFromCaches() { return *m_bttvChannelEmoteFromCaches; }
|
static ConcurrentMap<QString, LazyLoadedImage* >& bttvChannelEmoteFromCaches() { return *m_bttvChannelEmoteFromCaches; }
|
||||||
static ConcurrentMap<QString, LazyLoadedImage* >& fFzChannelEmoteFromCaches() { return *m_fFzChannelEmoteFromCaches ; }
|
static ConcurrentMap<QString, LazyLoadedImage* >& ffzChannelEmoteFromCaches() { return *m_ffzChannelEmoteFromCaches ; }
|
||||||
static ConcurrentMap<int, LazyLoadedImage* >& twitchEmoteFromCache() { return *m_twitchEmoteFromCache ; }
|
static ConcurrentMap<int, LazyLoadedImage* >& twitchEmoteFromCache() { return *m_twitchEmoteFromCache ; }
|
||||||
static ConcurrentMap<int, LazyLoadedImage* >& miscImageFromCache() { return *m_miscImageFromCache ; }
|
static ConcurrentMap<QString, LazyLoadedImage* >& miscImageFromCache() { return *m_miscImageFromCache ; }
|
||||||
|
|
||||||
static void loadGlobalEmotes();
|
static void loadGlobalEmotes();
|
||||||
|
|
||||||
|
@ -34,9 +34,9 @@ private:
|
||||||
static ConcurrentMap<QString, LazyLoadedImage* >* m_ffzEmotes;
|
static ConcurrentMap<QString, LazyLoadedImage* >* m_ffzEmotes;
|
||||||
static ConcurrentMap<QString, LazyLoadedImage* >* m_chatterinoEmotes;
|
static ConcurrentMap<QString, LazyLoadedImage* >* m_chatterinoEmotes;
|
||||||
static ConcurrentMap<QString, LazyLoadedImage* >* m_bttvChannelEmoteFromCaches;
|
static ConcurrentMap<QString, LazyLoadedImage* >* m_bttvChannelEmoteFromCaches;
|
||||||
static ConcurrentMap<QString, LazyLoadedImage* >* m_fFzChannelEmoteFromCaches;
|
static ConcurrentMap<QString, LazyLoadedImage* >* m_ffzChannelEmoteFromCaches;
|
||||||
static ConcurrentMap<int, LazyLoadedImage* >* m_twitchEmoteFromCache;
|
static ConcurrentMap<int, LazyLoadedImage* >* m_twitchEmoteFromCache;
|
||||||
static ConcurrentMap<int, LazyLoadedImage* >* m_miscImageFromCache;
|
static ConcurrentMap<QString, LazyLoadedImage* >* m_miscImageFromCache;
|
||||||
|
|
||||||
static LazyLoadedImage* m_cheerBadge100000;
|
static LazyLoadedImage* m_cheerBadge100000;
|
||||||
static LazyLoadedImage* m_cheerBadge10000 ;
|
static LazyLoadedImage* m_cheerBadge10000 ;
|
||||||
|
|
1
main.cpp
1
main.cpp
|
@ -3,6 +3,7 @@
|
||||||
#include "colorscheme.h"
|
#include "colorscheme.h"
|
||||||
#include "ircmanager.h"
|
#include "ircmanager.h"
|
||||||
#include "emojis.h"
|
#include "emojis.h"
|
||||||
|
#include <QClipboard>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
122
message.cpp
122
message.cpp
|
@ -2,8 +2,13 @@
|
||||||
#include "qcolor.h"
|
#include "qcolor.h"
|
||||||
#include "colorscheme.h"
|
#include "colorscheme.h"
|
||||||
#include "emotes.h"
|
#include "emotes.h"
|
||||||
|
#include "emojis.h"
|
||||||
|
#include "link.h"
|
||||||
|
#include "appsettings.h"
|
||||||
|
#include "ircmanager.h"
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
#include <tuple>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
LazyLoadedImage* Message::badgeStaff = new LazyLoadedImage(new QImage(":/images/staff_bg.png"));
|
LazyLoadedImage* Message::badgeStaff = new LazyLoadedImage(new QImage(":/images/staff_bg.png"));
|
||||||
|
@ -14,6 +19,8 @@ LazyLoadedImage* Message::badgeTurbo = new LazyLoadedImage(new QImage(":/i
|
||||||
LazyLoadedImage* Message::badgeBroadcaster = new LazyLoadedImage(new QImage(":/images/broadcaster_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::badgePremium = new LazyLoadedImage(new QImage(":/images/twitchprime_bg.png"));
|
||||||
|
|
||||||
|
QRegularExpression* Message::cheerRegex = new QRegularExpression("cheer[1-9][0-9]*");
|
||||||
|
|
||||||
Message::Message(const QString &text)
|
Message::Message(const QString &text)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -112,7 +119,7 @@ Message::Message(const IrcPrivateMessage& ircMessage, const Channel& channel, bo
|
||||||
if (includeChannel)
|
if (includeChannel)
|
||||||
{
|
{
|
||||||
QString channelName("#" + channel.name());
|
QString channelName("#" + channel.name());
|
||||||
words->append(Word(channelName, Word::Misc, ColorScheme::instance().SystemMessageColor, QString(channelName), QString(), Link(Link::ShowMessage, channel.name() + "\n" + m_id)));
|
words->append(Word(channelName, Word::Misc, ColorScheme::instance().SystemMessageColor, QString(channelName), QString(), Link(Link::Url, channel.name() + "\n" + m_id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// username
|
// username
|
||||||
|
@ -141,6 +148,21 @@ Message::Message(const IrcPrivateMessage& ircMessage, const Channel& channel, bo
|
||||||
bool hasLocalizedName = QString::compare(displayName, ircMessage.account()) == 0;
|
bool hasLocalizedName = QString::compare(displayName, ircMessage.account()) == 0;
|
||||||
QString userDisplayString = displayName + (hasLocalizedName ? (" (" + ircMessage.account() + ")") : QString());
|
QString userDisplayString = displayName + (hasLocalizedName ? (" (" + ircMessage.account() + ")") : QString());
|
||||||
|
|
||||||
|
if (isSentWhisper)
|
||||||
|
{
|
||||||
|
userDisplayString = IrcManager::account->username() + " -> ";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isReceivedWhisper)
|
||||||
|
{
|
||||||
|
userDisplayString += " -> " + IrcManager::account->username();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ircMessage.isAction())
|
||||||
|
{
|
||||||
|
userDisplayString += ": ";
|
||||||
|
}
|
||||||
|
|
||||||
words->append(Word(userDisplayString, Word::Username, usernameColor, userDisplayString, QString()));
|
words->append(Word(userDisplayString, Word::Username, usernameColor, userDisplayString, QString()));
|
||||||
|
|
||||||
// highlights
|
// highlights
|
||||||
|
@ -222,10 +244,108 @@ Message::Message(const IrcPrivateMessage& ircMessage, const Channel& channel, bo
|
||||||
}
|
}
|
||||||
|
|
||||||
// split words
|
// split words
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
QString string = std::get<1>(tuple);
|
||||||
|
|
||||||
|
// cheers
|
||||||
|
if (!bits.isEmpty() && string.length() >= 6 && cheerRegex->match(string).isValid())
|
||||||
|
{
|
||||||
|
auto cheer = string.mid(5).toInt();
|
||||||
|
|
||||||
|
QString color;
|
||||||
|
|
||||||
|
QColor bitsColor;
|
||||||
|
|
||||||
|
if (cheer >= 10000)
|
||||||
|
{
|
||||||
|
color = "red";
|
||||||
|
bitsColor = QColor::fromHslF(0, 1, 0.5);
|
||||||
}
|
}
|
||||||
|
else if (cheer >= 5000)
|
||||||
|
{
|
||||||
|
color = "blue";
|
||||||
|
bitsColor = QColor::fromHslF(0.61, 1, 0.4);
|
||||||
|
}
|
||||||
|
else if (cheer >= 1000)
|
||||||
|
{
|
||||||
|
color = "green";
|
||||||
|
bitsColor = QColor::fromHslF(0.5, 1, 0.5);
|
||||||
|
}
|
||||||
|
else if (cheer >= 100)
|
||||||
|
{
|
||||||
|
color = "purple";
|
||||||
|
bitsColor = QColor::fromHslF(0.8, 1, 0.5);
|
||||||
|
}
|
||||||
|
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");
|
||||||
|
|
||||||
|
LazyLoadedImage* imageAnimated = Emotes::miscImageFromCache().getOrAdd(bitsLinkAnimated, [&bitsLinkAnimated]{ return new LazyLoadedImage(bitsLinkAnimated); });
|
||||||
|
LazyLoadedImage* image = Emotes::miscImageFromCache().getOrAdd(bitsLink, [&bitsLink]{ return new LazyLoadedImage(bitsLink); });
|
||||||
|
|
||||||
|
words->append(Word(imageAnimated, Word::BitsAnimated, QString("cheer"), QString("Twitch Cheer"), Link(Link::Url, QString("https://blog.twitch.tv/introducing-cheering-celebrate-together-da62af41fac6"))));
|
||||||
|
words->append(Word(image, Word::Bits, QString("cheer"), QString("Twitch Cheer"), Link(Link::Url, QString("https://blog.twitch.tv/introducing-cheering-celebrate-together-da62af41fac6"))));
|
||||||
|
|
||||||
|
words->append(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;
|
||||||
|
|
||||||
|
// bttv / ffz emotes
|
||||||
|
LazyLoadedImage* bttvEmote;
|
||||||
|
|
||||||
|
if (
|
||||||
|
#warning "xD ignored emotes"
|
||||||
|
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->append(Word(bttvEmote, Word::BttvEmoteImage, bttvEmote->name(), bttvEmote->tooltip(), Link(Link::Url, bttvEmote->url())));
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// actually just a word
|
||||||
|
QString link = matchLink(string);
|
||||||
|
|
||||||
|
words->append(Word(string, Word::Text, textColor, string, QString(), link.isEmpty() ? Link() : Link(Link::Url, link)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
i += split.length() + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->words() = words;
|
||||||
|
|
||||||
|
#warning "xD"
|
||||||
|
// if (!isReceivedWhisper && AppSettings.HighlightIgnoredUsers.ContainsKey(Username))
|
||||||
|
// {
|
||||||
|
// HighlightTab = false;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
return a.first < b.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Message::matchLink(const QString &string)
|
||||||
|
{
|
||||||
|
#warning "xD"
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
20
message.h
20
message.h
|
@ -24,35 +24,35 @@ public:
|
||||||
Message(const IrcPrivateMessage& ircMessage, const Channel& Channel, bool enablePingSound = true,
|
Message(const IrcPrivateMessage& ircMessage, const Channel& Channel, bool enablePingSound = true,
|
||||||
bool isReceivedWhisper = false, bool isSentWhisper = false, bool includeChannel = false);
|
bool isReceivedWhisper = false, bool isSentWhisper = false, bool includeChannel = false);
|
||||||
|
|
||||||
bool canHighlightTab() {
|
bool canHighlightTab() const {
|
||||||
return m_highlightTab;
|
return m_highlightTab;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString& timeoutUser() {
|
const QString& timeoutUser() const {
|
||||||
return m_timeoutUser;
|
return m_timeoutUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
int timeoutCount() {
|
int timeoutCount() const {
|
||||||
return m_timeoutCount;
|
return m_timeoutCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString& userName() {
|
const QString& userName() const {
|
||||||
return m_userName;
|
return m_userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString& displayName() {
|
const QString& displayName() const {
|
||||||
return m_displayName;
|
return m_displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Word> words() {
|
QList<Word> words() const {
|
||||||
return m_words;
|
return m_words;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool disabled() {
|
bool disabled() const {
|
||||||
return m_disabled;
|
return m_disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString& id() {
|
const QString& id() const {
|
||||||
return m_id;
|
return m_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,6 +65,8 @@ private:
|
||||||
static LazyLoadedImage* badgeBroadcaster;
|
static LazyLoadedImage* badgeBroadcaster;
|
||||||
static LazyLoadedImage* badgePremium;
|
static LazyLoadedImage* badgePremium;
|
||||||
|
|
||||||
|
static QRegularExpression* cheerRegex;
|
||||||
|
|
||||||
bool m_highlightTab = false;
|
bool m_highlightTab = false;
|
||||||
QString m_timeoutUser = "";
|
QString m_timeoutUser = "";
|
||||||
int m_timeoutCount = 0;
|
int m_timeoutCount = 0;
|
||||||
|
@ -77,6 +79,8 @@ private:
|
||||||
|
|
||||||
QList<Word> m_words;
|
QList<Word> m_words;
|
||||||
|
|
||||||
|
static QString matchLink(const QString& string);
|
||||||
|
|
||||||
static bool sortTwitchEmotes(const std::pair<long int, LazyLoadedImage*>& a, const std::pair<long int, LazyLoadedImage*>& b);
|
static bool sortTwitchEmotes(const std::pair<long int, LazyLoadedImage*>& a, const std::pair<long int, LazyLoadedImage*>& b);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -24,5 +24,6 @@
|
||||||
<file>images/moderator_bg.png</file>
|
<file>images/moderator_bg.png</file>
|
||||||
<file>images/staff_bg.png</file>
|
<file>images/staff_bg.png</file>
|
||||||
<file>images/turbo_bg.png</file>
|
<file>images/turbo_bg.png</file>
|
||||||
|
<file>emojidata.txt</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
41
word.h
41
word.h
|
@ -51,70 +51,79 @@ public:
|
||||||
| BadgeCheer,
|
| BadgeCheer,
|
||||||
|
|
||||||
Username = 0x800000,
|
Username = 0x800000,
|
||||||
|
BitsAmount = 0x1000000,
|
||||||
|
|
||||||
Default = TimestampNoSeconds | Badges | Username | Bits | FfzEmoteImage | BttvEmoteImage | BttvGifEmoteImage | TwitchEmoteImage
|
Default = TimestampNoSeconds | Badges | Username | Bits | FfzEmoteImage | BttvEmoteImage | BttvGifEmoteImage | TwitchEmoteImage | BitsAmount
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit Word(LazyLoadedImage* m_image, Type type, const QString& copytext, const QString& tooltip, const Link& link = Link());
|
explicit Word(LazyLoadedImage* m_image, Type type, const QString& copytext, const QString& tooltip, const Link& link = Link());
|
||||||
explicit Word(const QString& m_text, Type type, const QColor& color, const QString& copytext, const QString& tooltip, const Link& link = Link());
|
explicit Word(const QString& m_text, Type type, const QColor& color, const QString& copytext, const QString& tooltip, const Link& link = Link());
|
||||||
|
|
||||||
LazyLoadedImage& getImage() {
|
LazyLoadedImage& getImage() const {
|
||||||
return *m_image;
|
return *m_image;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString& getText() {
|
const QString& getText() const {
|
||||||
return m_text;
|
return m_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
int width() {
|
int width() const {
|
||||||
return m_width;
|
return m_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
int height() {
|
int height() const {
|
||||||
return m_height;
|
return m_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
int x() {
|
int x() const {
|
||||||
return m_x;
|
return m_x;
|
||||||
}
|
}
|
||||||
|
|
||||||
int y() {
|
int y() const {
|
||||||
return m_y;
|
return m_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect rect() {
|
int right() const {
|
||||||
|
return m_x + m_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
int bottom() const {
|
||||||
|
return m_y + m_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
QRect rect() const {
|
||||||
return QRect(m_x, m_y, m_width, m_height);
|
return QRect(m_x, m_y, m_width, m_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isImage() {
|
bool isImage() const {
|
||||||
return m_isImage;
|
return m_isImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString& copyText() {
|
const QString& copyText() const {
|
||||||
return m_copyText;
|
return m_copyText;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasTrailingSpace() {
|
bool hasTrailingSpace() const {
|
||||||
return m_hasTrailingSpace;
|
return m_hasTrailingSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFont& getFont() {
|
QFont& getFont() const {
|
||||||
return Fonts::getFont(m_font);
|
return Fonts::getFont(m_font);
|
||||||
}
|
}
|
||||||
|
|
||||||
Type type() {
|
Type type() const {
|
||||||
return m_type;
|
return m_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString& tooltip() {
|
const QString& tooltip() const {
|
||||||
return m_tooltip;
|
return m_tooltip;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QColor& color() {
|
const QColor& color() const {
|
||||||
return m_color;
|
return m_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Link& link() {
|
const Link& link() const {
|
||||||
return m_link;
|
return m_link;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue