mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
added words and message
This commit is contained in:
parent
7a7b714e78
commit
b7de109335
26
channel.cpp
26
channel.cpp
|
@ -1,4 +1,5 @@
|
|||
#include "channel.h"
|
||||
#include "message.h"
|
||||
|
||||
const Channel Channel::whispers = Channel(QString("/whispers"));
|
||||
const Channel Channel::mentions = Channel(QString("/mentions"));
|
||||
|
@ -7,12 +8,18 @@ QMap<QString, Channel*> Channel::channels = QMap<QString, Channel*>();
|
|||
|
||||
Channel::Channel(QString channel)
|
||||
{
|
||||
messageMutex = new QMutex();
|
||||
name = (channel.length() > 0 && channel[0] == '#') ? channel.mid(1) : channel;
|
||||
subLink = "https://www.twitch.tv/" + name + "/subscribe?ref=in_chat_subscriber_link";
|
||||
channelLink = "https://twitch.tv/" + name;
|
||||
popoutPlayerLink = "https://player.twitch.tv/?channel=" + name;
|
||||
}
|
||||
|
||||
//Channel::~Channel()
|
||||
//{
|
||||
//// delete messages;
|
||||
//}
|
||||
|
||||
Channel* Channel::addChannel(const QString &channel)
|
||||
{
|
||||
auto c = getChannel(channel);
|
||||
|
@ -42,10 +49,10 @@ Channel* Channel::getChannel(const QString &channel)
|
|||
auto a = channels.find(channel);
|
||||
|
||||
if (a == channels.end()) {
|
||||
return *a;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return a.value();
|
||||
}
|
||||
|
||||
void Channel::removeChannel(const QString &channel)
|
||||
|
@ -70,3 +77,18 @@ 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();
|
||||
auto M = new QVector<Message*>(*messages);
|
||||
messageMutex->unlock();
|
||||
return M;
|
||||
}
|
||||
|
||||
void Channel::addMessage(Message *message)
|
||||
{
|
||||
messageMutex->lock();
|
||||
// messages
|
||||
messageMutex->unlock();
|
||||
}
|
||||
|
|
13
channel.h
13
channel.h
|
@ -3,6 +3,10 @@
|
|||
|
||||
#include "QString"
|
||||
#include "QMap"
|
||||
#include "QMutex"
|
||||
#include "QVector"
|
||||
|
||||
class Message;
|
||||
|
||||
class Channel
|
||||
{
|
||||
|
@ -24,9 +28,16 @@ public:
|
|||
QString getStreamStatus();
|
||||
QString getStreamGame();
|
||||
|
||||
void addMessage(Message* message);
|
||||
// ~Channel();
|
||||
|
||||
QVector<Message*>* getMessagesClone();
|
||||
|
||||
private:
|
||||
Channel(QString channel);
|
||||
|
||||
QMutex* messageMutex;
|
||||
|
||||
static QMap<QString, Channel*> channels;
|
||||
|
||||
int referenceCount = 1;
|
||||
|
@ -35,6 +46,8 @@ private:
|
|||
|
||||
int roomID;
|
||||
|
||||
QVector<Message*>* messages = new QVector<Message*>();
|
||||
|
||||
QString subLink = "";
|
||||
QString channelLink = "";
|
||||
QString popoutPlayerLink = "";
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#-------------------------------------------------
|
||||
|
||||
QT += core gui network
|
||||
CONFIG += communi c++11
|
||||
CONFIG += communi
|
||||
COMMUNI += core model util
|
||||
|
||||
include(lib/libcommuni/src/src.pri)
|
||||
|
@ -50,7 +50,11 @@ SOURCES += main.cpp\
|
|||
account.cpp \
|
||||
emotes.cpp \
|
||||
lazyloadedimage.cpp \
|
||||
concurrentmap.cpp
|
||||
concurrentmap.cpp \
|
||||
message.cpp \
|
||||
word.cpp \
|
||||
link.cpp \
|
||||
fonts.cpp
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
chatwidget.h \
|
||||
|
@ -76,7 +80,11 @@ HEADERS += mainwindow.h \
|
|||
emotes.h \
|
||||
lazyloadedimage.h \
|
||||
twitchemotevalue.h \
|
||||
concurrentmap.h
|
||||
concurrentmap.h \
|
||||
message.h \
|
||||
word.h \
|
||||
link.h \
|
||||
fonts.h
|
||||
|
||||
FORMS += \
|
||||
dialog.ui
|
||||
|
|
|
@ -1,10 +1,17 @@
|
|||
#include "chatwidgetview.h"
|
||||
#include "QScroller"
|
||||
#include "QPainter"
|
||||
|
||||
ChatWidgetView::ChatWidgetView()
|
||||
: QWidget(),
|
||||
scrollbar(this)
|
||||
scrollbar(this),
|
||||
m_channel(NULL)
|
||||
{
|
||||
auto scroll = QScroller::scroller(this);
|
||||
|
||||
scroll->scrollTo(QPointF(0, 100));
|
||||
|
||||
m_channel = Channel::getChannel("ian678");
|
||||
}
|
||||
|
||||
void ChatWidgetView::resizeEvent(QResizeEvent *)
|
||||
|
@ -12,3 +19,16 @@ void ChatWidgetView::resizeEvent(QResizeEvent *)
|
|||
scrollbar.resize(scrollbar.width(), height());
|
||||
scrollbar.move(width() - scrollbar.width(), 0);
|
||||
}
|
||||
|
||||
void ChatWidgetView::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
auto c = channel();
|
||||
|
||||
if (c == NULL) return;
|
||||
|
||||
auto M = c->getMessagesClone();
|
||||
|
||||
delete M;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include <QWidget>
|
||||
#include "scrollbar.h"
|
||||
#include "QPaintEvent"
|
||||
#include "channel.h"
|
||||
|
||||
class ChatWidgetView : public QWidget
|
||||
{
|
||||
|
@ -11,11 +13,18 @@ class ChatWidgetView : public QWidget
|
|||
public:
|
||||
ChatWidgetView();
|
||||
|
||||
Channel* channel() {
|
||||
return m_channel;
|
||||
}
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
private:
|
||||
ScrollBar scrollbar;
|
||||
Channel* m_channel;
|
||||
|
||||
void paintEvent(QPaintEvent *);
|
||||
};
|
||||
|
||||
#endif // CHATVIEW_H
|
||||
|
|
|
@ -7,6 +7,8 @@ void ColorScheme::setColors(float hue, float multiplyer)
|
|||
{
|
||||
IsLightTheme = multiplyer > 0;
|
||||
|
||||
SystemMessageColor = QColor(140, 127, 127);
|
||||
|
||||
auto isLightTheme = IsLightTheme;
|
||||
|
||||
auto getColor = [isLightTheme, multiplyer] (qreal h, qreal s, qreal l, qreal a = 1.0)
|
||||
|
|
|
@ -9,6 +9,8 @@ class ColorScheme
|
|||
public:
|
||||
bool IsLightTheme;
|
||||
|
||||
QColor SystemMessageColor;
|
||||
|
||||
QColor DropPreviewBackground;
|
||||
|
||||
QColor TooltipBackground;
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
TValue getOrAdd(const TKey &name, function<TValue ()> addLambda) {
|
||||
TValue getOrAdd(const TKey &name, std::function<TValue ()> addLambda) {
|
||||
mutex->lock();
|
||||
auto a = map->find(name);
|
||||
if (a == map->end()) {
|
||||
|
|
52
emotes.cpp
52
emotes.cpp
|
@ -9,24 +9,42 @@ ConcurrentMap<QString, LazyLoadedImage* >* Emotes::m_fFzChannelEmoteFromCaches
|
|||
ConcurrentMap<int, LazyLoadedImage* >* Emotes::m_twitchEmoteFromCache = new ConcurrentMap<int, LazyLoadedImage* >();
|
||||
ConcurrentMap<int, LazyLoadedImage* >* Emotes::m_miscImageFromCache = new ConcurrentMap<int, LazyLoadedImage* >();
|
||||
|
||||
//QMutex* Emotes::mutexBttvEmote = new QMutex();
|
||||
//QMap<QString, LazyLoadedImage*>* Emotes::mapBttvEmote = new QMap<QString, LazyLoadedImage*>();
|
||||
|
||||
//LazyLoadedImage* Emotes::getBttvEmote(const QString &name) {
|
||||
// mutexBttvEmote->lock();
|
||||
// auto a = mapBttvEmote->find(name);
|
||||
// if (a == mapBttvEmote->end()) {
|
||||
// mutexBttvEmote->unlock();
|
||||
// return NULL;
|
||||
// }
|
||||
// mutexBttvEmote->unlock();
|
||||
// return a.value();
|
||||
//}
|
||||
|
||||
//void
|
||||
|
||||
|
||||
Emotes::Emotes()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
LazyLoadedImage* Emotes::getCheerImage(long long amount, bool animated)
|
||||
{
|
||||
#warning "xD"
|
||||
// object image;
|
||||
|
||||
// if (cheer >= 100000)
|
||||
// {
|
||||
// image = GuiEngine.Current.GetImage(ImageType.Cheer100000);
|
||||
// }
|
||||
// else if (cheer >= 10000)
|
||||
// {
|
||||
// image = GuiEngine.Current.GetImage(ImageType.Cheer10000);
|
||||
// }
|
||||
// else if (cheer >= 5000)
|
||||
// {
|
||||
// image = GuiEngine.Current.GetImage(ImageType.Cheer5000);
|
||||
// }
|
||||
// else if (cheer >= 1000)
|
||||
// {
|
||||
// image = GuiEngine.Current.GetImage(ImageType.Cheer1000);
|
||||
// }
|
||||
// else if (cheer >= 100)
|
||||
// {
|
||||
// image = GuiEngine.Current.GetImage(ImageType.Cheer100);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// image = GuiEngine.Current.GetImage(ImageType.Cheer1);
|
||||
// }
|
||||
|
||||
// words.Add(new Word { Type = SpanType.Image, Value = image, Tooltip = "Twitch Cheer " + cheer });
|
||||
|
||||
return new LazyLoadedImage("");
|
||||
}
|
||||
|
|
4
emotes.h
4
emotes.h
|
@ -19,6 +19,10 @@ public:
|
|||
static ConcurrentMap<int, LazyLoadedImage* >& twitchEmoteFromCache() { return *m_twitchEmoteFromCache ; }
|
||||
static ConcurrentMap<int, LazyLoadedImage* >& miscImageFromCache() { return *m_miscImageFromCache ; }
|
||||
|
||||
static void loadGlobalEmotes();
|
||||
|
||||
static LazyLoadedImage* getCheerImage(long long int amount, bool animated);
|
||||
|
||||
private:
|
||||
Emotes();
|
||||
|
||||
|
|
27
fonts.cpp
Normal file
27
fonts.cpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
#include "fonts.h"
|
||||
|
||||
#define DEFAULT_FONT "Arial"
|
||||
|
||||
QFont* Fonts::medium = new QFont(DEFAULT_FONT);
|
||||
QFont* Fonts::mediumBold = new QFont(DEFAULT_FONT);
|
||||
QFont* Fonts::mediumItalic = new QFont(DEFAULT_FONT);
|
||||
QFont* Fonts::small = new QFont(DEFAULT_FONT);
|
||||
QFont* Fonts::large = new QFont(DEFAULT_FONT);
|
||||
QFont* Fonts::veryLarge = new QFont(DEFAULT_FONT);
|
||||
|
||||
Fonts::Fonts()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QFont& Fonts::getFont(Type type)
|
||||
{
|
||||
if (type == Medium ) return *medium ;
|
||||
if (type == MediumBold ) return *mediumBold ;
|
||||
if (type == MediumItalic) return *mediumItalic;
|
||||
if (type == Small ) return *small ;
|
||||
if (type == Large ) return *large ;
|
||||
if (type == VeryLarge ) return *veryLarge ;
|
||||
|
||||
return *medium;
|
||||
}
|
31
fonts.h
Normal file
31
fonts.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
#ifndef FONTS_H
|
||||
#define FONTS_H
|
||||
|
||||
#include "QFont"
|
||||
|
||||
class Fonts
|
||||
{
|
||||
public:
|
||||
enum Type : char {
|
||||
Medium,
|
||||
MediumBold,
|
||||
MediumItalic,
|
||||
Small,
|
||||
Large,
|
||||
VeryLarge
|
||||
};
|
||||
|
||||
static QFont& getFont(Type type);
|
||||
|
||||
private:
|
||||
Fonts();
|
||||
|
||||
static QFont* medium;
|
||||
static QFont* mediumBold;
|
||||
static QFont* mediumItalic;
|
||||
static QFont* small;
|
||||
static QFont* large;
|
||||
static QFont* veryLarge;
|
||||
};
|
||||
|
||||
#endif // FONTS_H
|
BIN
images/admin_bg.png
Normal file
BIN
images/admin_bg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 439 B |
BIN
images/broadcaster_bg.png
Normal file
BIN
images/broadcaster_bg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 191 B |
BIN
images/globalmod_bg.png
Normal file
BIN
images/globalmod_bg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 397 B |
BIN
images/moderator_bg.png
Normal file
BIN
images/moderator_bg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 376 B |
BIN
images/staff_bg.png
Normal file
BIN
images/staff_bg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 269 B |
BIN
images/turbo_bg.png
Normal file
BIN
images/turbo_bg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 257 B |
|
@ -8,8 +8,9 @@
|
|||
#include "QJsonDocument"
|
||||
#include "QJsonObject"
|
||||
#include "QJsonArray"
|
||||
#include "channel.h"
|
||||
|
||||
Account* IrcManager::account = NULL;
|
||||
Account* IrcManager::account = const_cast<Account*>(Account::anon());
|
||||
IrcConnection* IrcManager::connection = NULL;
|
||||
QMutex* IrcManager::connectionMutex = new QMutex();
|
||||
long IrcManager::connectionIteration = 0;
|
||||
|
@ -113,6 +114,7 @@ void IrcManager::beginConnecting()
|
|||
c->setNickName("justinfan123");
|
||||
c->setRealName("justinfan123");
|
||||
c->sendRaw("JOIN #fourtf");
|
||||
c->sendRaw("JOIN #ian678");
|
||||
|
||||
c->sendCommand(IrcCommand::createCapability("REQ", "twitch.tv/commands"));
|
||||
c->sendCommand(IrcCommand::createCapability("REQ", "twitch.tv/tags"));
|
||||
|
@ -147,12 +149,19 @@ void IrcManager::messageReceived(IrcMessage *message)
|
|||
{
|
||||
qInfo(message->command().toStdString().c_str());
|
||||
|
||||
// if (message->command() == "")
|
||||
// if (message->command() == "")
|
||||
}
|
||||
|
||||
void IrcManager::privateMessageReceived(IrcPrivateMessage *message)
|
||||
{
|
||||
qInfo(message->content().toStdString().c_str());
|
||||
|
||||
qInfo(message->target().toStdString().c_str());
|
||||
auto c = Channel::getChannel(message->target().mid(1));
|
||||
|
||||
if (c != NULL) {
|
||||
c->addMessage(new Message(*message, *c));
|
||||
}
|
||||
}
|
||||
|
||||
bool IrcManager::isTwitchBlockedUser(QString const &username)
|
||||
|
@ -198,7 +207,7 @@ bool IrcManager::tryAddIgnoredUser(QString const &username, QString& errorMessag
|
|||
void IrcManager::addIgnoredUser(QString const &username)
|
||||
{
|
||||
QString errorMessage;
|
||||
if (tryAddIgnoredUser(username, errorMessage)) {
|
||||
if (!tryAddIgnoredUser(username, errorMessage)) {
|
||||
#warning "xD"
|
||||
}
|
||||
}
|
||||
|
@ -231,7 +240,7 @@ bool IrcManager::tryRemoveIgnoredUser(QString const &username, QString& errorMes
|
|||
void IrcManager::removeIgnoredUser(QString const &username)
|
||||
{
|
||||
QString errorMessage;
|
||||
if (tryRemoveIgnoredUser(username, errorMessage)) {
|
||||
if (!tryRemoveIgnoredUser(username, errorMessage)) {
|
||||
#warning "xD"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "QMap"
|
||||
#include "account.h"
|
||||
#include "qnetworkaccessmanager.h"
|
||||
#include "message.h"
|
||||
|
||||
class IrcManager
|
||||
{
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
#include "lazyloadedimage.h"
|
||||
|
||||
LazyLoadedImage::LazyLoadedImage()
|
||||
LazyLoadedImage::LazyLoadedImage(QString url)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
LazyLoadedImage::LazyLoadedImage(QImage *image)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,21 @@
|
|||
#ifndef LAZYLOADEDIMAGE_H
|
||||
#define LAZYLOADEDIMAGE_H
|
||||
|
||||
#include "QString"
|
||||
#include "QImage"
|
||||
|
||||
class LazyLoadedImage
|
||||
{
|
||||
public:
|
||||
LazyLoadedImage();
|
||||
LazyLoadedImage(QString url);
|
||||
LazyLoadedImage(QImage* image);
|
||||
|
||||
QImage* image() {
|
||||
return m_image;
|
||||
}
|
||||
|
||||
private:
|
||||
QImage* m_image = NULL;
|
||||
};
|
||||
|
||||
#endif // LAZYLOADEDIMAGE_H
|
||||
#endif // LAZYLOADEDIMAGE_H
|
||||
|
|
11
link.h
Normal file
11
link.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
#ifndef LINK_H
|
||||
#define LINK_H
|
||||
|
||||
|
||||
class Link
|
||||
{
|
||||
public:
|
||||
Link();
|
||||
};
|
||||
|
||||
#endif // LINK_H
|
3
main.cpp
3
main.cpp
|
@ -12,6 +12,9 @@ int main(int argc, char *argv[])
|
|||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
Channel::addChannel("ian678");
|
||||
Channel::addChannel("fourtf");
|
||||
|
||||
IrcManager::connect();
|
||||
|
||||
return a.exec();
|
||||
|
|
183
message.cpp
Normal file
183
message.cpp
Normal file
|
@ -0,0 +1,183 @@
|
|||
#include "message.h"
|
||||
#include "qcolor.h"
|
||||
#include "colorscheme.h"
|
||||
#include "emotes.h"
|
||||
|
||||
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"));
|
||||
|
||||
Message::Message(const QString &text)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Message::Message(const IrcPrivateMessage& ircMessage, const Channel& Channel)
|
||||
{
|
||||
m_parseTime = std::chrono::system_clock::now();
|
||||
|
||||
auto words = new QList<Word>();
|
||||
|
||||
// timestamps
|
||||
iterator = ircMessage.tags().find("tmi-sent-ts");
|
||||
time_t time = std::time(NULL);
|
||||
|
||||
if (iterator != ircMessage.tags().end())
|
||||
{
|
||||
time = strtoll(iterator.value().toString().toStdString().c_str(), NULL, 10);
|
||||
}
|
||||
|
||||
char timeStampBuffer[69];
|
||||
|
||||
strftime(timeStampBuffer, 69, "%H:%M", localtime(&time));
|
||||
QString timestamp = QString(timeStampBuffer);
|
||||
|
||||
strftime(timeStampBuffer, 69, "%H:%M:%S", localtime(&time));
|
||||
QString timestampWithSeconds = QString(timeStampBuffer);
|
||||
|
||||
words->append(new Word(timestamp, Word::TimestampNoSeconds));
|
||||
words->append(new Word(timestampWithSeconds, Word::TimestampWithSeconds));
|
||||
|
||||
// username
|
||||
m_userName = ircMessage.account();
|
||||
|
||||
if (m_userName.isEmpty())
|
||||
{
|
||||
auto iterator = ircMessage.tags().find("login");
|
||||
|
||||
if (iterator != ircMessage.tags().end())
|
||||
{
|
||||
m_userName = iterator.value().toString();
|
||||
}
|
||||
}
|
||||
|
||||
// display name
|
||||
QString displayName;
|
||||
|
||||
auto iterator = ircMessage.tags().find("display-name");
|
||||
if (iterator == ircMessage.tags().end()) {
|
||||
displayName = m_userName;
|
||||
}
|
||||
else {
|
||||
displayName = iterator.value().toString();
|
||||
}
|
||||
|
||||
// highlights
|
||||
#warning "xD"
|
||||
|
||||
// color
|
||||
QColor usernameColor = ColorScheme::getInstance().SystemMessageColor;
|
||||
|
||||
iterator = ircMessage.tags().find("color");
|
||||
if (iterator != ircMessage.tags().end())
|
||||
{
|
||||
usernameColor = QColor(iterator.value().toString());
|
||||
}
|
||||
|
||||
// bits
|
||||
QString bits = "";
|
||||
|
||||
iterator = ircMessage.tags().find("bits");
|
||||
if (iterator != ircMessage.tags().end())
|
||||
{
|
||||
bits = iterator.value().toString();
|
||||
}
|
||||
|
||||
// badges
|
||||
iterator = ircMessage.tags().find("badges");
|
||||
|
||||
if (iterator != ircMessage.tags().end())
|
||||
{
|
||||
auto badges = iterator.value().toString().split(',');
|
||||
|
||||
for (QString badge : badges)
|
||||
{
|
||||
if (badge.startsWith("bits/"))
|
||||
{
|
||||
|
||||
}
|
||||
else if (badge == "staff/1")
|
||||
{
|
||||
QString a("");
|
||||
QString b("Twitch Staff");
|
||||
words->append(*new Word(badgeStaff, Word::BadgeStaff, a, b));
|
||||
}
|
||||
// else if (badge == "admin/1")
|
||||
// {
|
||||
// words->append(*new Word(badgeAdmin, Word::BadgeAdmin, "", "Twitch Admin"));
|
||||
// }
|
||||
// else if (badge == "global_mod/1")
|
||||
// {
|
||||
// words->append(*new Word(badgeGlobalmod, Word::BadgeGlobalMod, "", "Global Moderator"));
|
||||
// }
|
||||
// else if (badge == "moderator/1")
|
||||
// {
|
||||
//#warning "xD"
|
||||
// words->append(*new Word(badgeTurbo, Word::BadgeModerator, "", "Channel Moderator")); // custom badge
|
||||
// }
|
||||
// else if (badge == "turbo/1")
|
||||
// {
|
||||
// words->append(*new Word(badgeStaff, Word::BadgeTurbo, "", "Turbo Subscriber"));
|
||||
// }
|
||||
// else if (badge == "broadcaster/1")
|
||||
// {
|
||||
// words->append(*new Word(badgeBroadcaster, Word::BadgeBroadcaster, "", "Channel Broadcaster"));
|
||||
// }
|
||||
// else if (badge == "premium/1")
|
||||
// {
|
||||
// words->append(*new Word(badgeTwitchPrime, Word::BadgePremium, "", "Twitch Prime"));
|
||||
// }
|
||||
|
||||
|
||||
// case "staff/1":
|
||||
// Badges |= MessageBadges.Staff;
|
||||
// words.Add(new Word { Type = SpanType.Image, Value = GuiEngine.Current.GetImage(ImageType.BadgeStaff), Tooltip = });
|
||||
// break;
|
||||
// case "admin/1":
|
||||
// Badges |= MessageBadges.Admin;
|
||||
// words.Add(new Word { Type = SpanType.Image, Value = GuiEngine.Current.GetImage(ImageType.BadgeAdmin), Tooltip = "Twitch Admin" });
|
||||
// break;
|
||||
// case "global_mod/1":
|
||||
// Badges |= MessageBadges.GlobalMod;
|
||||
// words.Add(new Word { Type = SpanType.Image, Value = GuiEngine.Current.GetImage(ImageType.BadgeGlobalmod), Tooltip = "Global Moderator" });
|
||||
// break;
|
||||
// case "moderator/1":
|
||||
// Badges |= MessageBadges.Mod;
|
||||
// if (channel.ModeratorBadge == null)
|
||||
// {
|
||||
// words.Add(new Word { Type = SpanType.Image, Value = GuiEngine.Current.GetImage(ImageType.BadgeModerator), Tooltip = "Channel Moderator" });
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// words.Add(new Word { Type = SpanType.LazyLoadedImage, Value = channel.ModeratorBadge, Tooltip = channel.ModeratorBadge.Tooltip });
|
||||
// }
|
||||
// break;
|
||||
// case "turbo/1":
|
||||
// Badges |= MessageBadges.Turbo;
|
||||
// words.Add(new Word { Type = SpanType.Image, Value = GuiEngine.Current.GetImage(ImageType.BadgeTurbo), Tooltip = "Turbo Subscriber" });
|
||||
// break;
|
||||
// case "broadcaster/1":
|
||||
// Badges |= MessageBadges.Broadcaster;
|
||||
// words.Add(new Word { Type = SpanType.Image, Value = GuiEngine.Current.GetImage(ImageType.BadgeBroadcaster), Tooltip = "Channel Broadcaster" });
|
||||
// break;
|
||||
// case "premium/1":
|
||||
// Badges |= MessageBadges.Broadcaster;
|
||||
// words.Add(new Word { Type = SpanType.Image, Value = GuiEngine.Current.GetImage(ImageType.BadgeTwitchPrime), Tooltip = "Twitch Prime" });
|
||||
// break;
|
||||
|
||||
|
||||
// long long int cheer = strtoll(badge.mid(5).toStdString().c_str(), NULL, 10);
|
||||
|
||||
// auto image = Emotes::getCheerImage(cheer, false);
|
||||
// auto imageAnimated = Emotes::getCheerImage(cheer, true);
|
||||
|
||||
// words->append(*new Word(image, Word::Bits));
|
||||
// words->append(*new Word(imageAnimated, Word::BitsAnimated));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
40
message.cpp.xT5964
Normal file
40
message.cpp.xT5964
Normal file
|
@ -0,0 +1,40 @@
|
|||
#include "message.h"
|
||||
#include "qcolor.h"
|
||||
#include "colorscheme.h"
|
||||
|
||||
Message::Message(const QString &text)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Message::Message(const IrcPrivateMessage& ircMessage, const Channel& Channel)
|
||||
{
|
||||
m_parseTime = std::chrono::system_clock::now();
|
||||
|
||||
auto words = new QList<Word>();
|
||||
|
||||
// username
|
||||
m_userName = ircMessage.account();
|
||||
|
||||
if (m_userName.isEmpty())
|
||||
{
|
||||
auto iterator = ircMessage.tags().find("login");
|
||||
|
||||
if (iterator != ircMessage.tags().end())
|
||||
{
|
||||
m_userName = iterator.value().toString();
|
||||
}
|
||||
}
|
||||
|
||||
// highlights
|
||||
#warning "xD"
|
||||
|
||||
// color
|
||||
QColor usernameColor = ColorScheme::SystemMessageColor;
|
||||
|
||||
auto iterator = ircMessage.tags().find("color");
|
||||
if (iterator != ircMessage.tags().end())
|
||||
{
|
||||
usernameColor = QColor(iterator.value().toString());
|
||||
}
|
||||
}
|
75
message.h
Normal file
75
message.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
#ifndef MESSAGE_H
|
||||
#define MESSAGE_H
|
||||
|
||||
#include "IrcMessage"
|
||||
#include "word.h"
|
||||
#include "chrono"
|
||||
#include "channel.h"
|
||||
|
||||
class Message
|
||||
{
|
||||
public:
|
||||
// enum Badges : char {
|
||||
// None = 0,
|
||||
// Mod = 1,
|
||||
// Turbo = 2,
|
||||
// Sub = 4,
|
||||
// Staff = 8,
|
||||
// GlobalMod = 16,
|
||||
// Admin = 32,
|
||||
// Broadcaster = 64,
|
||||
// };
|
||||
|
||||
Message(const QString& text);
|
||||
Message(const IrcPrivateMessage& ircMessage, const Channel& Channel);
|
||||
|
||||
bool canHighlightTab() {
|
||||
return m_highlightTab;
|
||||
}
|
||||
|
||||
QString timeoutUser() {
|
||||
return m_timeoutUser;
|
||||
}
|
||||
|
||||
int timeoutCount() {
|
||||
return m_timeoutCount;
|
||||
}
|
||||
|
||||
QString userName() {
|
||||
return m_userName;
|
||||
}
|
||||
|
||||
QString displayName() {
|
||||
return m_displayName;
|
||||
}
|
||||
|
||||
QList<Word> words() {
|
||||
return m_words;
|
||||
}
|
||||
|
||||
bool disabled() {
|
||||
return m_disabled;
|
||||
}
|
||||
|
||||
private:
|
||||
static LazyLoadedImage* badgeStaff;
|
||||
static LazyLoadedImage* badgeAdmin;
|
||||
static LazyLoadedImage* badgeGlobalmod;
|
||||
static LazyLoadedImage* badgeModerator;
|
||||
static LazyLoadedImage* badgeTurbo;
|
||||
static LazyLoadedImage* badgeBroadcaster;
|
||||
static LazyLoadedImage* badgePremium;
|
||||
|
||||
bool m_highlightTab = false;
|
||||
QString m_timeoutUser = "";
|
||||
int m_timeoutCount = 0;
|
||||
bool m_disabled = false;
|
||||
std::chrono::time_point<std::chrono::system_clock> m_parseTime;
|
||||
|
||||
QString m_userName = "";
|
||||
QString m_displayName = "";
|
||||
|
||||
QList<Word> m_words;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_H
|
|
@ -18,5 +18,11 @@
|
|||
<file>images/tool_moreCollapser_off16.png</file>
|
||||
<file>images/twitchprime_bg.png</file>
|
||||
<file>qss/settings.qss</file>
|
||||
<file>images/admin_bg.png</file>
|
||||
<file>images/broadcaster_bg.png</file>
|
||||
<file>images/globalmod_bg.png</file>
|
||||
<file>images/moderator_bg.png</file>
|
||||
<file>images/staff_bg.png</file>
|
||||
<file>images/turbo_bg.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
27
word.cpp
Normal file
27
word.cpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
#include "word.h"
|
||||
|
||||
Word::Word(LazyLoadedImage* image, Type type, const QString& copytext, const QString& tooltip)
|
||||
{
|
||||
this->image = image;
|
||||
this->text = NULL;
|
||||
m_isImage = true;
|
||||
m_type = type;
|
||||
m_copyText = new QString(copytext);
|
||||
m_tooltip = new QString(tooltip);
|
||||
}
|
||||
|
||||
Word::Word(const QString& text, Type type, const QString& copytext, const QString& tooltip)
|
||||
{
|
||||
this->image = NULL;
|
||||
this->text = new QString(text);
|
||||
m_isImage = false;
|
||||
m_type = type;
|
||||
m_copyText = new QString(copytext);
|
||||
m_tooltip = new QString(tooltip);
|
||||
}
|
||||
|
||||
Word::~Word()
|
||||
{
|
||||
delete m_copyText;
|
||||
delete m_tooltip;
|
||||
}
|
116
word.h
Normal file
116
word.h
Normal file
|
@ -0,0 +1,116 @@
|
|||
#ifndef WORD_H
|
||||
#define WORD_H
|
||||
|
||||
#include "lazyloadedimage.h"
|
||||
#include "QString"
|
||||
#include "fonts.h"
|
||||
#include "QRect"
|
||||
|
||||
class Word
|
||||
{
|
||||
public:
|
||||
enum Type : long int {
|
||||
None = 0,
|
||||
Misc = 1,
|
||||
Text = 2,
|
||||
|
||||
TimestampNoSeconds = 4,
|
||||
TimestampWithSeconds = 8,
|
||||
|
||||
TwitchEmoteImage = 0x10,
|
||||
TwitchEmoteText = 0x20,
|
||||
BttvEmoteImage = 0x40,
|
||||
BttvEmoteText = 0x80,
|
||||
BttvGifEmoteImage = 0x100,
|
||||
BttvGifEmoteText = 0x200,
|
||||
FfzEmoteImage = 0x400,
|
||||
FfzEmoteText = 0x800,
|
||||
|
||||
Bits = 0x1000,
|
||||
BitsAnimated = 0x2000,
|
||||
|
||||
BadgeStaff = 0x4000,
|
||||
BadgeAdmin = 0x8000,
|
||||
BadgeGlobalMod = 0x10000,
|
||||
BadgeModerator = 0x20000,
|
||||
BadgeTurbo = 0x40000,
|
||||
BadgeBroadcaster = 0x80000,
|
||||
BadgePremium = 0x100000,
|
||||
BadgeChatterino = 0x200000,
|
||||
BadgeBits = 0x400000,
|
||||
};
|
||||
|
||||
Word(LazyLoadedImage* image, Type type, const QString& copytext, const QString& tooltip = "");
|
||||
Word(const QString& text, Type type, const QString& copytext, const QString& tooltip = "");
|
||||
|
||||
~Word();
|
||||
|
||||
LazyLoadedImage& getImage() {
|
||||
return *image;
|
||||
}
|
||||
|
||||
QString& getText() {
|
||||
return *text;
|
||||
}
|
||||
|
||||
int width() {
|
||||
return m_width;
|
||||
}
|
||||
|
||||
int height() {
|
||||
return m_height;
|
||||
}
|
||||
|
||||
int x() {
|
||||
return m_x;
|
||||
}
|
||||
|
||||
int y() {
|
||||
return m_y;
|
||||
}
|
||||
|
||||
QRect rect() {
|
||||
return QRect(m_x, m_y, m_width, m_height);
|
||||
}
|
||||
|
||||
bool isImage() {
|
||||
return m_isImage;
|
||||
}
|
||||
|
||||
QString* copyText() {
|
||||
return m_copyText;
|
||||
}
|
||||
|
||||
bool hasTrailingSpace() {
|
||||
return m_hasTrailingSpace;
|
||||
}
|
||||
|
||||
QFont& getFont() {
|
||||
return Fonts::getFont(m_font);
|
||||
}
|
||||
|
||||
Type type() {
|
||||
return m_type;
|
||||
}
|
||||
|
||||
QString& tooltip() {
|
||||
return *m_tooltip;
|
||||
}
|
||||
|
||||
private:
|
||||
LazyLoadedImage* image;
|
||||
QString* text;
|
||||
bool m_isImage;
|
||||
|
||||
Type m_type;
|
||||
QString* m_copyText;
|
||||
QString* m_tooltip;
|
||||
int m_x;
|
||||
int m_y;
|
||||
int m_width;
|
||||
int m_height;
|
||||
bool m_hasTrailingSpace;
|
||||
Fonts::Type m_font = Fonts::Medium;
|
||||
};
|
||||
|
||||
#endif // WORD_H
|
Loading…
Reference in a new issue