added words and message
This commit is contained in:
+24
-2
@@ -1,4 +1,5 @@
|
|||||||
#include "channel.h"
|
#include "channel.h"
|
||||||
|
#include "message.h"
|
||||||
|
|
||||||
const Channel Channel::whispers = Channel(QString("/whispers"));
|
const Channel Channel::whispers = Channel(QString("/whispers"));
|
||||||
const Channel Channel::mentions = Channel(QString("/mentions"));
|
const Channel Channel::mentions = Channel(QString("/mentions"));
|
||||||
@@ -7,12 +8,18 @@ QMap<QString, Channel*> Channel::channels = QMap<QString, Channel*>();
|
|||||||
|
|
||||||
Channel::Channel(QString channel)
|
Channel::Channel(QString channel)
|
||||||
{
|
{
|
||||||
|
messageMutex = new QMutex();
|
||||||
name = (channel.length() > 0 && channel[0] == '#') ? channel.mid(1) : channel;
|
name = (channel.length() > 0 && channel[0] == '#') ? channel.mid(1) : channel;
|
||||||
subLink = "https://www.twitch.tv/" + name + "/subscribe?ref=in_chat_subscriber_link";
|
subLink = "https://www.twitch.tv/" + name + "/subscribe?ref=in_chat_subscriber_link";
|
||||||
channelLink = "https://twitch.tv/" + name;
|
channelLink = "https://twitch.tv/" + name;
|
||||||
popoutPlayerLink = "https://player.twitch.tv/?channel=" + name;
|
popoutPlayerLink = "https://player.twitch.tv/?channel=" + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Channel::~Channel()
|
||||||
|
//{
|
||||||
|
//// delete messages;
|
||||||
|
//}
|
||||||
|
|
||||||
Channel* Channel::addChannel(const QString &channel)
|
Channel* Channel::addChannel(const QString &channel)
|
||||||
{
|
{
|
||||||
auto c = getChannel(channel);
|
auto c = getChannel(channel);
|
||||||
@@ -42,10 +49,10 @@ Channel* Channel::getChannel(const QString &channel)
|
|||||||
auto a = channels.find(channel);
|
auto a = channels.find(channel);
|
||||||
|
|
||||||
if (a == channels.end()) {
|
if (a == channels.end()) {
|
||||||
return *a;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return a.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Channel::removeChannel(const QString &channel)
|
void Channel::removeChannel(const QString &channel)
|
||||||
@@ -70,3 +77,18 @@ bool Channel::getIsLive() { return isLive ; }
|
|||||||
int Channel::getStreamViewerCount() { return streamViewerCount; }
|
int Channel::getStreamViewerCount() { return streamViewerCount; }
|
||||||
QString Channel::getStreamStatus() { return streamStatus ; }
|
QString Channel::getStreamStatus() { return streamStatus ; }
|
||||||
QString Channel::getStreamGame() { return streamGame ; }
|
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();
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,6 +3,10 @@
|
|||||||
|
|
||||||
#include "QString"
|
#include "QString"
|
||||||
#include "QMap"
|
#include "QMap"
|
||||||
|
#include "QMutex"
|
||||||
|
#include "QVector"
|
||||||
|
|
||||||
|
class Message;
|
||||||
|
|
||||||
class Channel
|
class Channel
|
||||||
{
|
{
|
||||||
@@ -24,9 +28,16 @@ public:
|
|||||||
QString getStreamStatus();
|
QString getStreamStatus();
|
||||||
QString getStreamGame();
|
QString getStreamGame();
|
||||||
|
|
||||||
|
void addMessage(Message* message);
|
||||||
|
// ~Channel();
|
||||||
|
|
||||||
|
QVector<Message*>* getMessagesClone();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Channel(QString channel);
|
Channel(QString channel);
|
||||||
|
|
||||||
|
QMutex* messageMutex;
|
||||||
|
|
||||||
static QMap<QString, Channel*> channels;
|
static QMap<QString, Channel*> channels;
|
||||||
|
|
||||||
int referenceCount = 1;
|
int referenceCount = 1;
|
||||||
@@ -35,6 +46,8 @@ private:
|
|||||||
|
|
||||||
int roomID;
|
int roomID;
|
||||||
|
|
||||||
|
QVector<Message*>* messages = new QVector<Message*>();
|
||||||
|
|
||||||
QString subLink = "";
|
QString subLink = "";
|
||||||
QString channelLink = "";
|
QString channelLink = "";
|
||||||
QString popoutPlayerLink = "";
|
QString popoutPlayerLink = "";
|
||||||
|
|||||||
+11
-3
@@ -5,7 +5,7 @@
|
|||||||
#-------------------------------------------------
|
#-------------------------------------------------
|
||||||
|
|
||||||
QT += core gui network
|
QT += core gui network
|
||||||
CONFIG += communi c++11
|
CONFIG += communi
|
||||||
COMMUNI += core model util
|
COMMUNI += core model util
|
||||||
|
|
||||||
include(lib/libcommuni/src/src.pri)
|
include(lib/libcommuni/src/src.pri)
|
||||||
@@ -50,7 +50,11 @@ SOURCES += main.cpp\
|
|||||||
account.cpp \
|
account.cpp \
|
||||||
emotes.cpp \
|
emotes.cpp \
|
||||||
lazyloadedimage.cpp \
|
lazyloadedimage.cpp \
|
||||||
concurrentmap.cpp
|
concurrentmap.cpp \
|
||||||
|
message.cpp \
|
||||||
|
word.cpp \
|
||||||
|
link.cpp \
|
||||||
|
fonts.cpp
|
||||||
|
|
||||||
HEADERS += mainwindow.h \
|
HEADERS += mainwindow.h \
|
||||||
chatwidget.h \
|
chatwidget.h \
|
||||||
@@ -76,7 +80,11 @@ HEADERS += mainwindow.h \
|
|||||||
emotes.h \
|
emotes.h \
|
||||||
lazyloadedimage.h \
|
lazyloadedimage.h \
|
||||||
twitchemotevalue.h \
|
twitchemotevalue.h \
|
||||||
concurrentmap.h
|
concurrentmap.h \
|
||||||
|
message.h \
|
||||||
|
word.h \
|
||||||
|
link.h \
|
||||||
|
fonts.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
dialog.ui
|
dialog.ui
|
||||||
|
|||||||
+21
-1
@@ -1,10 +1,17 @@
|
|||||||
#include "chatwidgetview.h"
|
#include "chatwidgetview.h"
|
||||||
|
#include "QScroller"
|
||||||
|
#include "QPainter"
|
||||||
|
|
||||||
ChatWidgetView::ChatWidgetView()
|
ChatWidgetView::ChatWidgetView()
|
||||||
: QWidget(),
|
: 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 *)
|
void ChatWidgetView::resizeEvent(QResizeEvent *)
|
||||||
@@ -12,3 +19,16 @@ void ChatWidgetView::resizeEvent(QResizeEvent *)
|
|||||||
scrollbar.resize(scrollbar.width(), height());
|
scrollbar.resize(scrollbar.width(), height());
|
||||||
scrollbar.move(width() - scrollbar.width(), 0);
|
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 <QWidget>
|
||||||
#include "scrollbar.h"
|
#include "scrollbar.h"
|
||||||
|
#include "QPaintEvent"
|
||||||
|
#include "channel.h"
|
||||||
|
|
||||||
class ChatWidgetView : public QWidget
|
class ChatWidgetView : public QWidget
|
||||||
{
|
{
|
||||||
@@ -11,11 +13,18 @@ class ChatWidgetView : public QWidget
|
|||||||
public:
|
public:
|
||||||
ChatWidgetView();
|
ChatWidgetView();
|
||||||
|
|
||||||
|
Channel* channel() {
|
||||||
|
return m_channel;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *);
|
void resizeEvent(QResizeEvent *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ScrollBar scrollbar;
|
ScrollBar scrollbar;
|
||||||
|
Channel* m_channel;
|
||||||
|
|
||||||
|
void paintEvent(QPaintEvent *);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CHATVIEW_H
|
#endif // CHATVIEW_H
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ void ColorScheme::setColors(float hue, float multiplyer)
|
|||||||
{
|
{
|
||||||
IsLightTheme = multiplyer > 0;
|
IsLightTheme = multiplyer > 0;
|
||||||
|
|
||||||
|
SystemMessageColor = QColor(140, 127, 127);
|
||||||
|
|
||||||
auto isLightTheme = IsLightTheme;
|
auto isLightTheme = IsLightTheme;
|
||||||
|
|
||||||
auto getColor = [isLightTheme, multiplyer] (qreal h, qreal s, qreal l, qreal a = 1.0)
|
auto getColor = [isLightTheme, multiplyer] (qreal h, qreal s, qreal l, qreal a = 1.0)
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ class ColorScheme
|
|||||||
public:
|
public:
|
||||||
bool IsLightTheme;
|
bool IsLightTheme;
|
||||||
|
|
||||||
|
QColor SystemMessageColor;
|
||||||
|
|
||||||
QColor DropPreviewBackground;
|
QColor DropPreviewBackground;
|
||||||
|
|
||||||
QColor TooltipBackground;
|
QColor TooltipBackground;
|
||||||
|
|||||||
+1
-1
@@ -27,7 +27,7 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TValue getOrAdd(const TKey &name, function<TValue ()> addLambda) {
|
TValue getOrAdd(const TKey &name, std::function<TValue ()> addLambda) {
|
||||||
mutex->lock();
|
mutex->lock();
|
||||||
auto a = map->find(name);
|
auto a = map->find(name);
|
||||||
if (a == map->end()) {
|
if (a == map->end()) {
|
||||||
|
|||||||
+35
-17
@@ -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_twitchEmoteFromCache = new ConcurrentMap<int, LazyLoadedImage* >();
|
||||||
ConcurrentMap<int, LazyLoadedImage* >* Emotes::m_miscImageFromCache = 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()
|
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("");
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,6 +19,10 @@ public:
|
|||||||
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<int, LazyLoadedImage* >& miscImageFromCache() { return *m_miscImageFromCache ; }
|
||||||
|
|
||||||
|
static void loadGlobalEmotes();
|
||||||
|
|
||||||
|
static LazyLoadedImage* getCheerImage(long long int amount, bool animated);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Emotes();
|
Emotes();
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 439 B |
Binary file not shown.
|
After Width: | Height: | Size: 191 B |
Binary file not shown.
|
After Width: | Height: | Size: 397 B |
Binary file not shown.
|
After Width: | Height: | Size: 376 B |
Binary file not shown.
|
After Width: | Height: | Size: 269 B |
Binary file not shown.
|
After Width: | Height: | Size: 257 B |
+13
-4
@@ -8,8 +8,9 @@
|
|||||||
#include "QJsonDocument"
|
#include "QJsonDocument"
|
||||||
#include "QJsonObject"
|
#include "QJsonObject"
|
||||||
#include "QJsonArray"
|
#include "QJsonArray"
|
||||||
|
#include "channel.h"
|
||||||
|
|
||||||
Account* IrcManager::account = NULL;
|
Account* IrcManager::account = const_cast<Account*>(Account::anon());
|
||||||
IrcConnection* IrcManager::connection = NULL;
|
IrcConnection* IrcManager::connection = NULL;
|
||||||
QMutex* IrcManager::connectionMutex = new QMutex();
|
QMutex* IrcManager::connectionMutex = new QMutex();
|
||||||
long IrcManager::connectionIteration = 0;
|
long IrcManager::connectionIteration = 0;
|
||||||
@@ -113,6 +114,7 @@ void IrcManager::beginConnecting()
|
|||||||
c->setNickName("justinfan123");
|
c->setNickName("justinfan123");
|
||||||
c->setRealName("justinfan123");
|
c->setRealName("justinfan123");
|
||||||
c->sendRaw("JOIN #fourtf");
|
c->sendRaw("JOIN #fourtf");
|
||||||
|
c->sendRaw("JOIN #ian678");
|
||||||
|
|
||||||
c->sendCommand(IrcCommand::createCapability("REQ", "twitch.tv/commands"));
|
c->sendCommand(IrcCommand::createCapability("REQ", "twitch.tv/commands"));
|
||||||
c->sendCommand(IrcCommand::createCapability("REQ", "twitch.tv/tags"));
|
c->sendCommand(IrcCommand::createCapability("REQ", "twitch.tv/tags"));
|
||||||
@@ -147,12 +149,19 @@ void IrcManager::messageReceived(IrcMessage *message)
|
|||||||
{
|
{
|
||||||
qInfo(message->command().toStdString().c_str());
|
qInfo(message->command().toStdString().c_str());
|
||||||
|
|
||||||
// if (message->command() == "")
|
// if (message->command() == "")
|
||||||
}
|
}
|
||||||
|
|
||||||
void IrcManager::privateMessageReceived(IrcPrivateMessage *message)
|
void IrcManager::privateMessageReceived(IrcPrivateMessage *message)
|
||||||
{
|
{
|
||||||
qInfo(message->content().toStdString().c_str());
|
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)
|
bool IrcManager::isTwitchBlockedUser(QString const &username)
|
||||||
@@ -198,7 +207,7 @@ bool IrcManager::tryAddIgnoredUser(QString const &username, QString& errorMessag
|
|||||||
void IrcManager::addIgnoredUser(QString const &username)
|
void IrcManager::addIgnoredUser(QString const &username)
|
||||||
{
|
{
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
if (tryAddIgnoredUser(username, errorMessage)) {
|
if (!tryAddIgnoredUser(username, errorMessage)) {
|
||||||
#warning "xD"
|
#warning "xD"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -231,7 +240,7 @@ bool IrcManager::tryRemoveIgnoredUser(QString const &username, QString& errorMes
|
|||||||
void IrcManager::removeIgnoredUser(QString const &username)
|
void IrcManager::removeIgnoredUser(QString const &username)
|
||||||
{
|
{
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
if (tryRemoveIgnoredUser(username, errorMessage)) {
|
if (!tryRemoveIgnoredUser(username, errorMessage)) {
|
||||||
#warning "xD"
|
#warning "xD"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "QMap"
|
#include "QMap"
|
||||||
#include "account.h"
|
#include "account.h"
|
||||||
#include "qnetworkaccessmanager.h"
|
#include "qnetworkaccessmanager.h"
|
||||||
|
#include "message.h"
|
||||||
|
|
||||||
class IrcManager
|
class IrcManager
|
||||||
{
|
{
|
||||||
|
|||||||
+6
-1
@@ -1,6 +1,11 @@
|
|||||||
#include "lazyloadedimage.h"
|
#include "lazyloadedimage.h"
|
||||||
|
|
||||||
LazyLoadedImage::LazyLoadedImage()
|
LazyLoadedImage::LazyLoadedImage(QString url)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
LazyLoadedImage::LazyLoadedImage(QImage *image)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-2
@@ -1,11 +1,21 @@
|
|||||||
#ifndef LAZYLOADEDIMAGE_H
|
#ifndef LAZYLOADEDIMAGE_H
|
||||||
#define LAZYLOADEDIMAGE_H
|
#define LAZYLOADEDIMAGE_H
|
||||||
|
|
||||||
|
#include "QString"
|
||||||
|
#include "QImage"
|
||||||
|
|
||||||
class LazyLoadedImage
|
class LazyLoadedImage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LazyLoadedImage();
|
LazyLoadedImage(QString url);
|
||||||
|
LazyLoadedImage(QImage* image);
|
||||||
|
|
||||||
|
QImage* image() {
|
||||||
|
return m_image;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QImage* m_image = NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LAZYLOADEDIMAGE_H
|
#endif // LAZYLOADEDIMAGE_H
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#ifndef LINK_H
|
||||||
|
#define LINK_H
|
||||||
|
|
||||||
|
|
||||||
|
class Link
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Link();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LINK_H
|
||||||
@@ -12,6 +12,9 @@ int main(int argc, char *argv[])
|
|||||||
MainWindow w;
|
MainWindow w;
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
|
Channel::addChannel("ian678");
|
||||||
|
Channel::addChannel("fourtf");
|
||||||
|
|
||||||
IrcManager::connect();
|
IrcManager::connect();
|
||||||
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
|
|||||||
+183
@@ -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));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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/tool_moreCollapser_off16.png</file>
|
||||||
<file>images/twitchprime_bg.png</file>
|
<file>images/twitchprime_bg.png</file>
|
||||||
<file>qss/settings.qss</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>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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
|
||||||
Reference in New Issue
Block a user