mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
changed notation
This commit is contained in:
parent
552e4c957a
commit
10e4a0f785
61 changed files with 1214 additions and 1051 deletions
|
@ -1,10 +1,10 @@
|
||||||
#include "account.h"
|
#include "account.h"
|
||||||
|
|
||||||
const Account *Account::m_anon = new Account("justinfan123", "", "");
|
Account Account::anon("justinfan123", "", "");
|
||||||
|
|
||||||
Account::Account(QString username, QString oauthToken, QString oauthClient)
|
Account::Account(QString username, QString oauthToken, QString oauthClient)
|
||||||
{
|
{
|
||||||
m_oauthClient = oauthClient;
|
this->oauthClient = oauthClient;
|
||||||
m_oauthToken = oauthToken;
|
this->oauthToken = oauthToken;
|
||||||
m_username = username;
|
this->username = username;
|
||||||
}
|
}
|
||||||
|
|
32
account.h
32
account.h
|
@ -1,49 +1,49 @@
|
||||||
#ifndef ACCOUNT_H
|
#ifndef ACCOUNT_H
|
||||||
#define ACCOUNT_H
|
#define ACCOUNT_H
|
||||||
|
|
||||||
#include "QString"
|
#include <QString>
|
||||||
|
|
||||||
class Account
|
class Account
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Account(QString username, QString oauthToken, QString oauthClient);
|
Account(QString getUsername, QString getOauthToken, QString getOauthClient);
|
||||||
|
|
||||||
static const Account *
|
static const Account *
|
||||||
anon()
|
getAnon()
|
||||||
{
|
{
|
||||||
return m_anon;
|
return &anon;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &
|
const QString &
|
||||||
username()
|
getUsername() const
|
||||||
{
|
{
|
||||||
return m_username;
|
return username;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &
|
const QString &
|
||||||
oauthToken()
|
getOauthToken() const
|
||||||
{
|
{
|
||||||
return m_oauthToken;
|
return oauthToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &
|
const QString &
|
||||||
oauthClient()
|
getOauthClient() const
|
||||||
{
|
{
|
||||||
return m_oauthClient;
|
return oauthClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isAnon()
|
isAnon() const
|
||||||
{
|
{
|
||||||
return m_username.startsWith("justinfan");
|
return username.startsWith("justinfan");
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const static Account *m_anon;
|
static Account anon;
|
||||||
|
|
||||||
QString m_username;
|
QString username;
|
||||||
QString m_oauthClient;
|
QString oauthClient;
|
||||||
QString m_oauthToken;
|
QString oauthToken;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ACCOUNT_H
|
#endif // ACCOUNT_H
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "appsettings.h"
|
#include "appsettings.h"
|
||||||
|
|
||||||
Word::Type AppSettings::m_wordTypeMask = Word::Default;
|
Word::Type AppSettings::wordTypeMask = Word::Default;
|
||||||
|
|
||||||
AppSettings::AppSettings()
|
AppSettings::AppSettings()
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,33 +7,34 @@ class AppSettings
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Word::Type
|
static Word::Type
|
||||||
wordTypeMask()
|
getWordTypeMask()
|
||||||
{
|
{
|
||||||
return m_wordTypeMask;
|
return wordTypeMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isIgnoredEmote(const QString &emote);
|
static bool isIgnoredEmote(const QString &emote);
|
||||||
|
|
||||||
static qreal
|
static qreal
|
||||||
emoteScale()
|
getEmoteScale()
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal
|
static qreal
|
||||||
badgeScale()
|
getBadgeScale()
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
scaleEmotesByLineHeight()
|
getScaleEmotesByLineHeight()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AppSettings();
|
AppSettings();
|
||||||
static Word::Type m_wordTypeMask;
|
static Word::Type wordTypeMask;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // APPSETTINGS_H
|
#endif // APPSETTINGS_H
|
||||||
|
|
32
channel.cpp
32
channel.cpp
|
@ -5,35 +5,35 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
Channel::Channel(const QString &channel)
|
Channel::Channel(const QString &channel)
|
||||||
: m_messages()
|
: messages()
|
||||||
, m_name((channel.length() > 0 && channel[0] == '#') ? channel.mid(1)
|
, name((channel.length() > 0 && channel[0] == '#') ? channel.mid(1)
|
||||||
: channel)
|
: channel)
|
||||||
, m_bttvChannelEmotes()
|
, bttvChannelEmotes()
|
||||||
, m_ffzChannelEmotes()
|
, ffzChannelEmotes()
|
||||||
, m_messageMutex()
|
, messageMutex()
|
||||||
, m_subLink("https://www.twitch.tv/" + m_name +
|
, subLink("https://www.twitch.tv/" + name +
|
||||||
"/subscribe?ref=in_chat_subscriber_link")
|
"/subscribe?ref=in_chat_subscriber_link")
|
||||||
, m_channelLink("https://twitch.tv/" + m_name)
|
, channelLink("https://twitch.tv/" + name)
|
||||||
, m_popoutPlayerLink("https://player.twitch.tv/?channel=" + m_name)
|
, popoutPlayerLink("https://player.twitch.tv/?channel=" + name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<std::shared_ptr<Message>>
|
QVector<std::shared_ptr<Message>>
|
||||||
Channel::getMessagesClone()
|
Channel::getMessagesClone()
|
||||||
{
|
{
|
||||||
m_messageMutex.lock();
|
this->messageMutex.lock();
|
||||||
QVector<std::shared_ptr<Message>> M(m_messages);
|
QVector<std::shared_ptr<Message>> M(this->messages);
|
||||||
M.detach();
|
M.detach();
|
||||||
m_messageMutex.unlock();
|
this->messageMutex.unlock();
|
||||||
return M;
|
return M;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Channel::addMessage(std::shared_ptr<Message> message)
|
Channel::addMessage(std::shared_ptr<Message> message)
|
||||||
{
|
{
|
||||||
m_messageMutex.lock();
|
this->messageMutex.lock();
|
||||||
m_messages.append(message);
|
this->messages.append(message);
|
||||||
m_messageMutex.unlock();
|
this->messageMutex.unlock();
|
||||||
|
|
||||||
Windows::repaintVisibleChatWidgets();
|
Windows::repaintVisibleChatWidgets();
|
||||||
}
|
}
|
||||||
|
|
75
channel.h
75
channel.h
|
@ -19,68 +19,69 @@ public:
|
||||||
|
|
||||||
// properties
|
// properties
|
||||||
const ConcurrentMap<QString, LazyLoadedImage *> &
|
const ConcurrentMap<QString, LazyLoadedImage *> &
|
||||||
bttvChannelEmotes() const
|
getBttvChannelEmotes() const
|
||||||
{
|
{
|
||||||
return m_bttvChannelEmotes;
|
return bttvChannelEmotes;
|
||||||
}
|
}
|
||||||
const ConcurrentMap<QString, LazyLoadedImage *> &
|
const ConcurrentMap<QString, LazyLoadedImage *> &
|
||||||
ffzChannelEmotes() const
|
getFfzChannelEmotes() const
|
||||||
{
|
{
|
||||||
return m_ffzChannelEmotes;
|
return ffzChannelEmotes;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QMutex &
|
const QMutex &
|
||||||
messageMutex() const
|
getMessageMutex() const
|
||||||
{
|
{
|
||||||
return m_messageMutex;
|
return messageMutex;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &
|
const QString &
|
||||||
name() const
|
getName() const
|
||||||
{
|
{
|
||||||
return m_name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
roomID() const
|
getRoomID() const
|
||||||
{
|
{
|
||||||
return m_roomID;
|
return roomID;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &
|
const QString &
|
||||||
subLink() const
|
getSubLink() const
|
||||||
{
|
{
|
||||||
return m_subLink;
|
return subLink;
|
||||||
}
|
}
|
||||||
const QString &
|
const QString &
|
||||||
channelLink() const
|
getChannelLink() const
|
||||||
{
|
{
|
||||||
return m_channelLink;
|
return channelLink;
|
||||||
}
|
}
|
||||||
const QString &
|
const QString &
|
||||||
popoutPlayerLink() const
|
getPopoutPlayerLink() const
|
||||||
{
|
{
|
||||||
return m_popoutPlayerLink;
|
return popoutPlayerLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isLive() const
|
getIsLive() const
|
||||||
{
|
{
|
||||||
return m_isLive;
|
return isLive;
|
||||||
}
|
}
|
||||||
int
|
int
|
||||||
streamViewerCount() const
|
getStreamViewerCount() const
|
||||||
{
|
{
|
||||||
return m_streamViewerCount;
|
return streamViewerCount;
|
||||||
}
|
}
|
||||||
const QString &
|
const QString &
|
||||||
streamStatus() const
|
getStreamStatus() const
|
||||||
{
|
{
|
||||||
return m_streamStatus;
|
return streamStatus;
|
||||||
}
|
}
|
||||||
const QString &
|
const QString &
|
||||||
streamGame() const
|
getStreamGame() const
|
||||||
{
|
{
|
||||||
return m_streamGame;
|
return streamGame;
|
||||||
}
|
}
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
|
@ -89,23 +90,23 @@ public:
|
||||||
QVector<std::shared_ptr<Message>> getMessagesClone();
|
QVector<std::shared_ptr<Message>> getMessagesClone();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVector<std::shared_ptr<Message>> m_messages;
|
QVector<std::shared_ptr<Message>> messages;
|
||||||
|
|
||||||
QString m_name;
|
QString name;
|
||||||
int m_roomID;
|
int roomID;
|
||||||
|
|
||||||
ConcurrentMap<QString, LazyLoadedImage *> m_bttvChannelEmotes;
|
ConcurrentMap<QString, LazyLoadedImage *> bttvChannelEmotes;
|
||||||
ConcurrentMap<QString, LazyLoadedImage *> m_ffzChannelEmotes;
|
ConcurrentMap<QString, LazyLoadedImage *> ffzChannelEmotes;
|
||||||
QMutex m_messageMutex;
|
QMutex messageMutex;
|
||||||
|
|
||||||
QString m_subLink;
|
QString subLink;
|
||||||
QString m_channelLink;
|
QString channelLink;
|
||||||
QString m_popoutPlayerLink;
|
QString popoutPlayerLink;
|
||||||
|
|
||||||
bool m_isLive;
|
bool isLive;
|
||||||
int m_streamViewerCount;
|
int streamViewerCount;
|
||||||
QString m_streamStatus;
|
QString streamStatus;
|
||||||
QString m_streamGame;
|
QString streamGame;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CHANNEL_H
|
#endif // CHANNEL_H
|
||||||
|
|
30
channels.cpp
30
channels.cpp
|
@ -1,22 +1,22 @@
|
||||||
#include "channels.h"
|
#include "channels.h"
|
||||||
#include "ircmanager.h"
|
#include "ircmanager.h"
|
||||||
|
|
||||||
Channel Channels::m_whispers(QString("/whispers"));
|
Channel Channels::whispers(QString("/whispers"));
|
||||||
Channel Channels::m_mentions(QString("/mentions"));
|
Channel Channels::mentions(QString("/mentions"));
|
||||||
Channel Channels::m_empty(QString(""));
|
Channel Channels::empty(QString(""));
|
||||||
|
|
||||||
QMap<QString, std::tuple<Channel *, int>> Channels::m_channels;
|
QMap<QString, std::tuple<Channel *, int>> Channels::channels;
|
||||||
|
|
||||||
Channel *
|
Channel *
|
||||||
Channels::addChannel(const QString &channel)
|
Channels::addChannel(const QString &channel)
|
||||||
{
|
{
|
||||||
QString c = channel.toLower();
|
QString c = channel.toLower();
|
||||||
|
|
||||||
auto a = m_channels.find(c);
|
auto a = Channels::channels.find(c);
|
||||||
|
|
||||||
if (a == m_channels.end()) {
|
if (a == Channels::channels.end()) {
|
||||||
auto _c = new Channel(c);
|
auto _c = new Channel(c);
|
||||||
m_channels.insert(c, std::tuple<Channel *, int>(_c, 1));
|
Channels::channels.insert(c, std::tuple<Channel *, int>(_c, 1));
|
||||||
|
|
||||||
IrcManager::joinChannel(c);
|
IrcManager::joinChannel(c);
|
||||||
|
|
||||||
|
@ -35,19 +35,19 @@ Channels::getChannel(const QString &channel)
|
||||||
|
|
||||||
if (channel.length() > 1 && channel.at(0) == '/') {
|
if (channel.length() > 1 && channel.at(0) == '/') {
|
||||||
if (c == "/whispers") {
|
if (c == "/whispers") {
|
||||||
return &m_whispers;
|
return &Channels::whispers;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c == "/mentions") {
|
if (c == "/mentions") {
|
||||||
return &m_mentions;
|
return &Channels::mentions;
|
||||||
}
|
}
|
||||||
|
|
||||||
return &m_empty;
|
return &Channels::empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto a = m_channels.find(c);
|
auto a = Channels::channels.find(c);
|
||||||
|
|
||||||
if (a == m_channels.end()) {
|
if (a == Channels::channels.end()) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,9 +63,9 @@ Channels::removeChannel(const QString &channel)
|
||||||
|
|
||||||
QString c = channel.toLower();
|
QString c = channel.toLower();
|
||||||
|
|
||||||
auto a = m_channels.find(c);
|
auto a = Channels::channels.find(c);
|
||||||
|
|
||||||
if (a == m_channels.end()) {
|
if (a == Channels::channels.end()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ Channels::removeChannel(const QString &channel)
|
||||||
|
|
||||||
if (std::get<1>(a.value()) == 0) {
|
if (std::get<1>(a.value()) == 0) {
|
||||||
IrcManager::partChannel(c);
|
IrcManager::partChannel(c);
|
||||||
m_channels.remove(c);
|
Channels::channels.remove(c);
|
||||||
delete std::get<0>(a.value());
|
delete std::get<0>(a.value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
16
channels.h
16
channels.h
|
@ -7,15 +7,15 @@ class Channels
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Channel *
|
static Channel *
|
||||||
whispers()
|
getWhispers()
|
||||||
{
|
{
|
||||||
return &m_whispers;
|
return &whispers;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Channel *
|
static Channel *
|
||||||
mentions()
|
getMentions()
|
||||||
{
|
{
|
||||||
return &m_whispers;
|
return &mentions;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Channel *addChannel(const QString &channel);
|
static Channel *addChannel(const QString &channel);
|
||||||
|
@ -27,11 +27,11 @@ private:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static Channel m_whispers;
|
static Channel whispers;
|
||||||
static Channel m_mentions;
|
static Channel mentions;
|
||||||
static Channel m_empty;
|
static Channel empty;
|
||||||
|
|
||||||
static QMap<QString, std::tuple<Channel *, int>> m_channels;
|
static QMap<QString, std::tuple<Channel *, int>> channels;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CHANNELS_H
|
#endif // CHANNELS_H
|
||||||
|
|
|
@ -10,19 +10,19 @@
|
||||||
|
|
||||||
ChatWidget::ChatWidget(QWidget *parent)
|
ChatWidget::ChatWidget(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, m_channel(NULL)
|
, channel(NULL)
|
||||||
, m_channelName(QString())
|
, channelName(QString())
|
||||||
, m_vbox(this)
|
, vbox(this)
|
||||||
, m_header(this)
|
, header(this)
|
||||||
, m_view(this)
|
, view(this)
|
||||||
, m_input()
|
, input()
|
||||||
{
|
{
|
||||||
m_vbox.setSpacing(0);
|
this->vbox.setSpacing(0);
|
||||||
m_vbox.setMargin(1);
|
this->vbox.setMargin(1);
|
||||||
|
|
||||||
m_vbox.addWidget(&m_header);
|
this->vbox.addWidget(&header);
|
||||||
m_vbox.addWidget(&m_view);
|
this->vbox.addWidget(&view);
|
||||||
m_vbox.addWidget(&m_input);
|
this->vbox.addWidget(&input);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatWidget::~ChatWidget()
|
ChatWidget::~ChatWidget()
|
||||||
|
@ -34,25 +34,26 @@ ChatWidget::setChannelName(const QString &name)
|
||||||
{
|
{
|
||||||
QString channel = name.trimmed();
|
QString channel = name.trimmed();
|
||||||
|
|
||||||
if (QString::compare(channel, m_channelName, Qt::CaseInsensitive) == 0) {
|
if (QString::compare(channel, this->channelName, Qt::CaseInsensitive) ==
|
||||||
m_channelName = channel;
|
0) {
|
||||||
m_header.updateChannelText();
|
this->channelName = channel;
|
||||||
|
this->header.updateChannelText();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_channelName = channel;
|
this->channelName = channel;
|
||||||
m_header.updateChannelText();
|
this->header.updateChannelText();
|
||||||
|
|
||||||
m_view.layoutMessages();
|
this->view.layoutMessages();
|
||||||
|
|
||||||
if (!m_channelName.isEmpty()) {
|
if (!this->channelName.isEmpty()) {
|
||||||
Channels::removeChannel(m_channelName);
|
Channels::removeChannel(this->channelName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channel.isEmpty()) {
|
if (channel.isEmpty()) {
|
||||||
m_channel = NULL;
|
this->channel = NULL;
|
||||||
} else {
|
} else {
|
||||||
m_channel = Channels::addChannel(channel);
|
this->channel = Channels::addChannel(channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,10 +62,10 @@ ChatWidget::showChangeChannelPopup()
|
||||||
{
|
{
|
||||||
TextInputDialog dialog(this);
|
TextInputDialog dialog(this);
|
||||||
|
|
||||||
dialog.setText(m_channelName);
|
dialog.setText(this->channelName);
|
||||||
|
|
||||||
if (dialog.exec() == QDialog::Accepted) {
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
setChannelName(dialog.text());
|
setChannelName(dialog.getText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,5 +74,5 @@ ChatWidget::paintEvent(QPaintEvent *)
|
||||||
{
|
{
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
|
||||||
painter.fillRect(rect(), ColorScheme::instance().ChatBackground);
|
painter.fillRect(this->rect(), ColorScheme::instance().ChatBackground);
|
||||||
}
|
}
|
||||||
|
|
33
chatwidget.h
33
chatwidget.h
|
@ -1,14 +1,15 @@
|
||||||
#ifndef CHATWIDGET_H
|
#ifndef CHATWIDGET_H
|
||||||
#define CHATWIDGET_H
|
#define CHATWIDGET_H
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
#include "QFont"
|
|
||||||
#include "QVBoxLayout"
|
|
||||||
#include "channel.h"
|
#include "channel.h"
|
||||||
#include "chatwidgetheader.h"
|
#include "chatwidgetheader.h"
|
||||||
#include "chatwidgetinput.h"
|
#include "chatwidgetinput.h"
|
||||||
#include "chatwidgetview.h"
|
#include "chatwidgetview.h"
|
||||||
|
|
||||||
|
#include <QFont>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
class ChatWidget : public QWidget
|
class ChatWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -18,21 +19,21 @@ public:
|
||||||
~ChatWidget();
|
~ChatWidget();
|
||||||
|
|
||||||
ChatWidgetView &
|
ChatWidgetView &
|
||||||
view()
|
getView()
|
||||||
{
|
{
|
||||||
return m_view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
Channel *
|
Channel *
|
||||||
channel() const
|
getChannel() const
|
||||||
{
|
{
|
||||||
return m_channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &
|
const QString &
|
||||||
channelName() const
|
getChannelName() const
|
||||||
{
|
{
|
||||||
return m_channelName;
|
return channelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setChannelName(const QString &name);
|
void setChannelName(const QString &name);
|
||||||
|
@ -43,14 +44,14 @@ protected:
|
||||||
void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
|
void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Channel *m_channel;
|
Channel *channel;
|
||||||
QString m_channelName;
|
QString channelName;
|
||||||
|
|
||||||
QFont m_font;
|
QFont font;
|
||||||
QVBoxLayout m_vbox;
|
QVBoxLayout vbox;
|
||||||
ChatWidgetHeader m_header;
|
ChatWidgetHeader header;
|
||||||
ChatWidgetView m_view;
|
ChatWidgetView view;
|
||||||
ChatWidgetInput m_input;
|
ChatWidgetInput input;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CHATWIDGET_H
|
#endif // CHATWIDGET_H
|
||||||
|
|
|
@ -10,61 +10,64 @@
|
||||||
|
|
||||||
ChatWidgetHeader::ChatWidgetHeader(ChatWidget *parent)
|
ChatWidgetHeader::ChatWidgetHeader(ChatWidget *parent)
|
||||||
: QWidget()
|
: QWidget()
|
||||||
, m_chatWidget(parent)
|
, chatWidget(parent)
|
||||||
, m_dragStart()
|
, dragStart()
|
||||||
, m_dragging(false)
|
, dragging(false)
|
||||||
, m_leftLabel()
|
, leftLabel()
|
||||||
, m_middleLabel()
|
, middleLabel()
|
||||||
, m_rightLabel()
|
, rightLabel()
|
||||||
, m_leftMenu(this)
|
, leftMenu(this)
|
||||||
, m_rightMenu(this)
|
, rightMenu(this)
|
||||||
{
|
{
|
||||||
setFixedHeight(32);
|
setFixedHeight(32);
|
||||||
|
|
||||||
updateColors();
|
updateColors();
|
||||||
updateChannelText();
|
updateChannelText();
|
||||||
|
|
||||||
setLayout(&m_hbox);
|
setLayout(&this->hbox);
|
||||||
m_hbox.setMargin(0);
|
this->hbox.setMargin(0);
|
||||||
m_hbox.addWidget(&m_leftLabel);
|
this->hbox.addWidget(&this->leftLabel);
|
||||||
m_hbox.addWidget(&m_middleLabel, 1);
|
this->hbox.addWidget(&this->middleLabel, 1);
|
||||||
m_hbox.addWidget(&m_rightLabel);
|
this->hbox.addWidget(&this->rightLabel);
|
||||||
|
|
||||||
// left
|
// left
|
||||||
m_leftLabel.label().setTextFormat(Qt::RichText);
|
this->leftLabel.getLabel().setTextFormat(Qt::RichText);
|
||||||
m_leftLabel.label().setText(
|
this->leftLabel.getLabel().setText(
|
||||||
"<img src=':/images/tool_moreCollapser_off16.png' />");
|
"<img src=':/images/tool_moreCollapser_off16.png' />");
|
||||||
|
|
||||||
QObject::connect(&m_leftLabel, &ChatWidgetHeaderButton::clicked, this,
|
QObject::connect(&this->leftLabel, &ChatWidgetHeaderButton::clicked, this,
|
||||||
&ChatWidgetHeader::leftButtonClicked);
|
&ChatWidgetHeader::leftButtonClicked);
|
||||||
|
|
||||||
m_leftMenu.addAction("Add new split", this, SLOT(menuAddSplit()),
|
this->leftMenu.addAction("Add new split", this, SLOT(menuAddSplit()),
|
||||||
QKeySequence(tr("Ctrl+T")));
|
QKeySequence(tr("Ctrl+T")));
|
||||||
m_leftMenu.addAction("Close split", this, SLOT(menuCloseSplit()),
|
this->leftMenu.addAction("Close split", this, SLOT(menuCloseSplit()),
|
||||||
QKeySequence(tr("Ctrl+W")));
|
QKeySequence(tr("Ctrl+W")));
|
||||||
m_leftMenu.addAction("Move split", this, SLOT(menuMoveSplit()));
|
this->leftMenu.addAction("Move split", this, SLOT(menuMoveSplit()));
|
||||||
m_leftMenu.addSeparator();
|
this->leftMenu.addSeparator();
|
||||||
m_leftMenu.addAction("Change channel", this, SLOT(menuChangeChannel()),
|
this->leftMenu.addAction("Change channel", this, SLOT(menuChangeChannel()),
|
||||||
QKeySequence(tr("Ctrl+R")));
|
QKeySequence(tr("Ctrl+R")));
|
||||||
m_leftMenu.addAction("Clear chat", this, SLOT(menuClearChat()));
|
this->leftMenu.addAction("Clear chat", this, SLOT(menuClearChat()));
|
||||||
m_leftMenu.addAction("Open channel", this, SLOT(menuOpenChannel()));
|
this->leftMenu.addAction("Open channel", this, SLOT(menuOpenChannel()));
|
||||||
m_leftMenu.addAction("Open pop-out player", this, SLOT(menuPopupPlayer()));
|
this->leftMenu.addAction("Open pop-out player", this,
|
||||||
m_leftMenu.addSeparator();
|
SLOT(menuPopupPlayer()));
|
||||||
m_leftMenu.addAction("Reload channel emotes", this,
|
this->leftMenu.addSeparator();
|
||||||
SLOT(menuReloadChannelEmotes()));
|
this->leftMenu.addAction("Reload channel emotes", this,
|
||||||
m_leftMenu.addAction("Manual reconnect", this, SLOT(menuManualReconnect()));
|
SLOT(menuReloadChannelEmotes()));
|
||||||
m_leftMenu.addSeparator();
|
this->leftMenu.addAction("Manual reconnect", this,
|
||||||
m_leftMenu.addAction("Show changelog", this, SLOT(menuShowChangelog()));
|
SLOT(menuManualReconnect()));
|
||||||
|
this->leftMenu.addSeparator();
|
||||||
|
this->leftMenu.addAction("Show changelog", this, SLOT(menuShowChangelog()));
|
||||||
|
|
||||||
// middle
|
// middle
|
||||||
m_middleLabel.setAlignment(Qt::AlignCenter);
|
this->middleLabel.setAlignment(Qt::AlignCenter);
|
||||||
QObject::connect(&m_middleLabel, SIGNAL(mouseDoubleClickEvent(QMouseEvent)), this,
|
QObject::connect(&this->middleLabel,
|
||||||
|
SIGNAL(mouseDoubleClickEvent(QMouseEvent)), this,
|
||||||
SLOT(mouseDoubleClickEvent));
|
SLOT(mouseDoubleClickEvent));
|
||||||
|
|
||||||
// right
|
// right
|
||||||
m_rightLabel.setMinimumWidth(height());
|
this->rightLabel.setMinimumWidth(height());
|
||||||
m_rightLabel.label().setTextFormat(Qt::RichText);
|
this->rightLabel.getLabel().setTextFormat(Qt::RichText);
|
||||||
m_rightLabel.label().setText("ayy");
|
this->rightLabel.getLabel().setText("ayy");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -73,17 +76,17 @@ ChatWidgetHeader::updateColors()
|
||||||
QPalette palette;
|
QPalette palette;
|
||||||
palette.setColor(QPalette::Foreground, ColorScheme::instance().Text);
|
palette.setColor(QPalette::Foreground, ColorScheme::instance().Text);
|
||||||
|
|
||||||
m_leftLabel.setPalette(palette);
|
this->leftLabel.setPalette(palette);
|
||||||
m_middleLabel.setPalette(palette);
|
this->middleLabel.setPalette(palette);
|
||||||
m_rightLabel.setPalette(palette);
|
this->rightLabel.setPalette(palette);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ChatWidgetHeader::updateChannelText()
|
ChatWidgetHeader::updateChannelText()
|
||||||
{
|
{
|
||||||
const QString &c = m_chatWidget->channelName();
|
const QString &c = this->chatWidget->getChannelName();
|
||||||
|
|
||||||
m_middleLabel.setText(c.isEmpty() ? "<no channel>" : c);
|
this->middleLabel.setText(c.isEmpty() ? "<no channel>" : c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -99,18 +102,18 @@ ChatWidgetHeader::paintEvent(QPaintEvent *)
|
||||||
void
|
void
|
||||||
ChatWidgetHeader::mousePressEvent(QMouseEvent *event)
|
ChatWidgetHeader::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
m_dragging = true;
|
this->dragging = true;
|
||||||
|
|
||||||
m_dragStart = event->pos();
|
this->dragStart = event->pos();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ChatWidgetHeader::mouseMoveEvent(QMouseEvent *event)
|
ChatWidgetHeader::mouseMoveEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (m_dragging) {
|
if (this->dragging) {
|
||||||
if (std::abs(m_dragStart.x() - event->pos().x()) > 12 ||
|
if (std::abs(this->dragStart.x() - event->pos().x()) > 12 ||
|
||||||
std::abs(m_dragStart.y() - event->pos().y()) > 12) {
|
std::abs(this->dragStart.y() - event->pos().y()) > 12) {
|
||||||
auto chatWidget = m_chatWidget;
|
auto chatWidget = this->chatWidget;
|
||||||
auto page = static_cast<NotebookPage *>(chatWidget->parentWidget());
|
auto page = static_cast<NotebookPage *>(chatWidget->parentWidget());
|
||||||
|
|
||||||
if (page != NULL) {
|
if (page != NULL) {
|
||||||
|
@ -144,15 +147,16 @@ void
|
||||||
ChatWidgetHeader::mouseDoubleClickEvent(QMouseEvent *event)
|
ChatWidgetHeader::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton) {
|
if (event->button() == Qt::LeftButton) {
|
||||||
chatWidget()->showChangeChannelPopup();
|
this->chatWidget->showChangeChannelPopup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ChatWidgetHeader::leftButtonClicked()
|
ChatWidgetHeader::leftButtonClicked()
|
||||||
{
|
{
|
||||||
m_leftMenu.move(m_leftLabel.mapToGlobal(QPoint(0, m_leftLabel.height())));
|
this->leftMenu.move(
|
||||||
m_leftMenu.show();
|
this->leftLabel.mapToGlobal(QPoint(0, this->leftLabel.height())));
|
||||||
|
this->leftMenu.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -175,7 +179,7 @@ ChatWidgetHeader::menuMoveSplit()
|
||||||
void
|
void
|
||||||
ChatWidgetHeader::menuChangeChannel()
|
ChatWidgetHeader::menuChangeChannel()
|
||||||
{
|
{
|
||||||
m_chatWidget->showChangeChannelPopup();
|
this->chatWidget->showChangeChannelPopup();
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
ChatWidgetHeader::menuClearChat()
|
ChatWidgetHeader::menuClearChat()
|
||||||
|
|
|
@ -22,9 +22,9 @@ public:
|
||||||
ChatWidgetHeader(ChatWidget *parent);
|
ChatWidgetHeader(ChatWidget *parent);
|
||||||
|
|
||||||
ChatWidget *
|
ChatWidget *
|
||||||
chatWidget()
|
getChatWidget()
|
||||||
{
|
{
|
||||||
return m_chatWidget;
|
return chatWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateColors();
|
void updateColors();
|
||||||
|
@ -37,19 +37,19 @@ protected:
|
||||||
void mouseDoubleClickEvent(QMouseEvent *event);
|
void mouseDoubleClickEvent(QMouseEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ChatWidget *m_chatWidget;
|
ChatWidget *chatWidget;
|
||||||
|
|
||||||
QPoint m_dragStart;
|
QPoint dragStart;
|
||||||
bool m_dragging;
|
bool dragging;
|
||||||
|
|
||||||
QHBoxLayout m_hbox;
|
QHBoxLayout hbox;
|
||||||
|
|
||||||
ChatWidgetHeaderButton m_leftLabel;
|
ChatWidgetHeaderButton leftLabel;
|
||||||
QLabel m_middleLabel;
|
QLabel middleLabel;
|
||||||
ChatWidgetHeaderButton m_rightLabel;
|
ChatWidgetHeaderButton rightLabel;
|
||||||
|
|
||||||
QMenu m_leftMenu;
|
QMenu leftMenu;
|
||||||
QMenu m_rightMenu;
|
QMenu rightMenu;
|
||||||
|
|
||||||
void leftButtonClicked();
|
void leftButtonClicked();
|
||||||
void rightButtonClicked();
|
void rightButtonClicked();
|
||||||
|
|
|
@ -7,21 +7,21 @@
|
||||||
ChatWidgetHeaderButton::ChatWidgetHeaderButton()
|
ChatWidgetHeaderButton::ChatWidgetHeaderButton()
|
||||||
: QWidget()
|
: QWidget()
|
||||||
, hbox()
|
, hbox()
|
||||||
, m_label()
|
, label()
|
||||||
, m_mouseOver(false)
|
, mouseOver(false)
|
||||||
, m_mouseDown(false)
|
, mouseDown(false)
|
||||||
{
|
{
|
||||||
setLayout(&hbox);
|
setLayout(&hbox);
|
||||||
|
|
||||||
hbox.setMargin(0);
|
hbox.setMargin(0);
|
||||||
hbox.addSpacing(6);
|
hbox.addSpacing(6);
|
||||||
hbox.addWidget(&m_label);
|
hbox.addWidget(&this->label);
|
||||||
hbox.addSpacing(6);
|
hbox.addSpacing(6);
|
||||||
|
|
||||||
QObject::connect(&m_label, &ChatWidgetHeaderButtonLabel::mouseUp, this,
|
QObject::connect(&this->label, &ChatWidgetHeaderButtonLabel::mouseUp, this,
|
||||||
&ChatWidgetHeaderButton::labelMouseUp);
|
&ChatWidgetHeaderButton::labelMouseUp);
|
||||||
QObject::connect(&m_label, &ChatWidgetHeaderButtonLabel::mouseDown, this,
|
QObject::connect(&this->label, &ChatWidgetHeaderButtonLabel::mouseDown,
|
||||||
&ChatWidgetHeaderButton::labelMouseDown);
|
this, &ChatWidgetHeaderButton::labelMouseDown);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -33,11 +33,11 @@ ChatWidgetHeaderButton::paintEvent(QPaintEvent *)
|
||||||
? QColor(0, 0, 0, 32)
|
? QColor(0, 0, 0, 32)
|
||||||
: QColor(255, 255, 255, 32));
|
: QColor(255, 255, 255, 32));
|
||||||
|
|
||||||
if (m_mouseDown) {
|
if (this->mouseDown) {
|
||||||
painter.fillRect(rect(), brush);
|
painter.fillRect(rect(), brush);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_mouseOver) {
|
if (this->mouseOver) {
|
||||||
painter.fillRect(rect(), brush);
|
painter.fillRect(rect(), brush);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ void
|
||||||
ChatWidgetHeaderButton::mousePressEvent(QMouseEvent *event)
|
ChatWidgetHeaderButton::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton) {
|
if (event->button() == Qt::LeftButton) {
|
||||||
m_mouseDown = true;
|
this->mouseDown = true;
|
||||||
|
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ void
|
||||||
ChatWidgetHeaderButton::mouseReleaseEvent(QMouseEvent *event)
|
ChatWidgetHeaderButton::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton) {
|
if (event->button() == Qt::LeftButton) {
|
||||||
m_mouseDown = false;
|
this->mouseDown = false;
|
||||||
|
|
||||||
repaint();
|
repaint();
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ ChatWidgetHeaderButton::mouseReleaseEvent(QMouseEvent *event)
|
||||||
void
|
void
|
||||||
ChatWidgetHeaderButton::enterEvent(QEvent *)
|
ChatWidgetHeaderButton::enterEvent(QEvent *)
|
||||||
{
|
{
|
||||||
m_mouseOver = true;
|
this->mouseOver = true;
|
||||||
|
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ ChatWidgetHeaderButton::enterEvent(QEvent *)
|
||||||
void
|
void
|
||||||
ChatWidgetHeaderButton::leaveEvent(QEvent *)
|
ChatWidgetHeaderButton::leaveEvent(QEvent *)
|
||||||
{
|
{
|
||||||
m_mouseOver = false;
|
this->mouseOver = false;
|
||||||
|
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ ChatWidgetHeaderButton::leaveEvent(QEvent *)
|
||||||
void
|
void
|
||||||
ChatWidgetHeaderButton::labelMouseUp()
|
ChatWidgetHeaderButton::labelMouseUp()
|
||||||
{
|
{
|
||||||
m_mouseDown = false;
|
this->mouseDown = false;
|
||||||
|
|
||||||
repaint();
|
repaint();
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ ChatWidgetHeaderButton::labelMouseUp()
|
||||||
void
|
void
|
||||||
ChatWidgetHeaderButton::labelMouseDown()
|
ChatWidgetHeaderButton::labelMouseDown()
|
||||||
{
|
{
|
||||||
m_mouseDown = true;
|
this->mouseDown = true;
|
||||||
|
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,9 @@ public:
|
||||||
ChatWidgetHeaderButton();
|
ChatWidgetHeaderButton();
|
||||||
|
|
||||||
ChatWidgetHeaderButtonLabel &
|
ChatWidgetHeaderButtonLabel &
|
||||||
label()
|
getLabel()
|
||||||
{
|
{
|
||||||
return m_label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -35,10 +35,10 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QHBoxLayout hbox;
|
QHBoxLayout hbox;
|
||||||
ChatWidgetHeaderButtonLabel m_label;
|
ChatWidgetHeaderButtonLabel label;
|
||||||
|
|
||||||
bool m_mouseOver;
|
bool mouseOver;
|
||||||
bool m_mouseDown;
|
bool mouseDown;
|
||||||
|
|
||||||
void labelMouseUp();
|
void labelMouseUp();
|
||||||
void labelMouseDown();
|
void labelMouseDown();
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
|
|
||||||
ChatWidgetView::ChatWidgetView(ChatWidget *parent)
|
ChatWidgetView::ChatWidgetView(ChatWidget *parent)
|
||||||
: QWidget()
|
: QWidget()
|
||||||
, m_chatWidget(parent)
|
, chatWidget(parent)
|
||||||
, m_scrollbar(this)
|
, scrollbar(this)
|
||||||
{
|
{
|
||||||
auto scroll = QScroller::scroller(this);
|
auto scroll = QScroller::scroller(this);
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ ChatWidgetView::ChatWidgetView(ChatWidget *parent)
|
||||||
bool
|
bool
|
||||||
ChatWidgetView::layoutMessages()
|
ChatWidgetView::layoutMessages()
|
||||||
{
|
{
|
||||||
auto c = m_chatWidget->channel();
|
auto c = this->chatWidget->getChannel();
|
||||||
|
|
||||||
if (c == NULL)
|
if (c == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
@ -42,8 +42,8 @@ ChatWidgetView::layoutMessages()
|
||||||
void
|
void
|
||||||
ChatWidgetView::resizeEvent(QResizeEvent *)
|
ChatWidgetView::resizeEvent(QResizeEvent *)
|
||||||
{
|
{
|
||||||
m_scrollbar.resize(m_scrollbar.width(), height());
|
this->scrollbar.resize(this->scrollbar.width(), height());
|
||||||
m_scrollbar.move(width() - m_scrollbar.width(), 0);
|
this->scrollbar.move(width() - this->scrollbar.width(), 0);
|
||||||
|
|
||||||
layoutMessages();
|
layoutMessages();
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ ChatWidgetView::paintEvent(QPaintEvent *)
|
||||||
|
|
||||||
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
|
|
||||||
auto c = m_chatWidget->channel();
|
auto c = this->chatWidget->getChannel();
|
||||||
|
|
||||||
QColor color;
|
QColor color;
|
||||||
|
|
||||||
|
@ -98,40 +98,50 @@ ChatWidgetView::paintEvent(QPaintEvent *)
|
||||||
|
|
||||||
auto messages = c->getMessagesClone();
|
auto messages = c->getMessagesClone();
|
||||||
|
|
||||||
int y = 0;
|
int start = this->scrollbar.getValue();
|
||||||
|
|
||||||
for (std::shared_ptr<Message> const &message : messages) {
|
if (start >= messages.length()) {
|
||||||
for (WordPart const &wordPart : message.get()->wordParts()) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int y = -(messages[start].get()->getHeight() *
|
||||||
|
(std::fmod(this->scrollbar.getValue(), 1)));
|
||||||
|
|
||||||
|
for (int i = start; i < messages.size(); ++i) {
|
||||||
|
Message *message = messages[i].get();
|
||||||
|
|
||||||
|
for (WordPart const &wordPart : message->getWordParts()) {
|
||||||
painter.setPen(QColor(255, 0, 0));
|
painter.setPen(QColor(255, 0, 0));
|
||||||
painter.drawRect(wordPart.x(), wordPart.y() + y, wordPart.width(),
|
painter.drawRect(wordPart.getX(), wordPart.getY() + y,
|
||||||
wordPart.height());
|
wordPart.getWidth(), wordPart.getHeight());
|
||||||
|
|
||||||
// image
|
// image
|
||||||
if (wordPart.word().isImage()) {
|
if (wordPart.getWord().isImage()) {
|
||||||
LazyLoadedImage &lli = wordPart.word().getImage();
|
LazyLoadedImage &lli = wordPart.getWord().getImage();
|
||||||
|
|
||||||
const QPixmap *image = lli.pixmap();
|
const QPixmap *image = lli.getPixmap();
|
||||||
|
|
||||||
if (image != NULL) {
|
if (image != NULL) {
|
||||||
painter.drawPixmap(
|
painter.drawPixmap(
|
||||||
QRect(wordPart.x(), wordPart.y() + y, wordPart.width(),
|
QRect(wordPart.getX(), wordPart.getY() + y,
|
||||||
wordPart.height()),
|
wordPart.getWidth(), wordPart.getHeight()),
|
||||||
*image);
|
*image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// text
|
// text
|
||||||
else {
|
else {
|
||||||
QColor color = wordPart.word().color();
|
QColor color = wordPart.getWord().getColor();
|
||||||
|
|
||||||
painter.setPen(color);
|
painter.setPen(color);
|
||||||
painter.setFont(wordPart.word().getFont());
|
painter.setFont(wordPart.getWord().getFont());
|
||||||
|
|
||||||
painter.drawText(
|
painter.drawText(
|
||||||
QRectF(wordPart.x(), wordPart.y() + y, 10000, 10000),
|
QRectF(wordPart.getX(), wordPart.getY() + y, 10000, 10000),
|
||||||
wordPart.text(), QTextOption(Qt::AlignLeft | Qt::AlignTop));
|
wordPart.getText(),
|
||||||
|
QTextOption(Qt::AlignLeft | Qt::AlignTop));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
y += message.get()->height();
|
y += message->getHeight();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#ifndef CHATVIEW_H
|
#ifndef CHATVIEW_H
|
||||||
#define CHATVIEW_H
|
#define CHATVIEW_H
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
#include "QPaintEvent"
|
|
||||||
#include "channel.h"
|
#include "channel.h"
|
||||||
#include "scrollbar.h"
|
#include "scrollbar.h"
|
||||||
|
|
||||||
|
#include <QPaintEvent>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
class ChatWidget;
|
class ChatWidget;
|
||||||
|
|
||||||
class ChatWidgetView : public QWidget
|
class ChatWidgetView : public QWidget
|
||||||
|
@ -20,12 +21,12 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *);
|
void resizeEvent(QResizeEvent *);
|
||||||
|
|
||||||
private:
|
|
||||||
ChatWidget *m_chatWidget;
|
|
||||||
|
|
||||||
ScrollBar m_scrollbar;
|
|
||||||
|
|
||||||
void paintEvent(QPaintEvent *);
|
void paintEvent(QPaintEvent *);
|
||||||
|
|
||||||
|
private:
|
||||||
|
ChatWidget *chatWidget;
|
||||||
|
|
||||||
|
ScrollBar scrollbar;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CHATVIEW_H
|
#endif // CHATVIEW_H
|
||||||
|
|
|
@ -50,22 +50,22 @@ ColorScheme::setColors(float hue, float multiplyer)
|
||||||
// fillLookupTableValues(0.65, 0.83, 0.5, 0.7);
|
// fillLookupTableValues(0.65, 0.83, 0.5, 0.7);
|
||||||
// fillLookupTableValues(0.83, 1, 0.7, 0.6);
|
// fillLookupTableValues(0.83, 1, 0.7, 0.6);
|
||||||
|
|
||||||
fillLookupTableValues(m_middleLookupTable, 0.000, 0.166, 0.66, 0.5);
|
fillLookupTableValues(this->middleLookupTable, 0.000, 0.166, 0.66, 0.5);
|
||||||
fillLookupTableValues(m_middleLookupTable, 0.166, 0.333, 0.5, 0.55);
|
fillLookupTableValues(this->middleLookupTable, 0.166, 0.333, 0.5, 0.55);
|
||||||
fillLookupTableValues(m_middleLookupTable, 0.333, 0.500, 0.55, 0.45);
|
fillLookupTableValues(this->middleLookupTable, 0.333, 0.500, 0.55, 0.45);
|
||||||
fillLookupTableValues(m_middleLookupTable, 0.500, 0.666, 0.45, 0.80);
|
fillLookupTableValues(this->middleLookupTable, 0.500, 0.666, 0.45, 0.80);
|
||||||
fillLookupTableValues(m_middleLookupTable, 0.666, 0.833, 0.80, 0.61);
|
fillLookupTableValues(this->middleLookupTable, 0.666, 0.833, 0.80, 0.61);
|
||||||
fillLookupTableValues(m_middleLookupTable, 0.833, 1.000, 0.61, 0.66);
|
fillLookupTableValues(this->middleLookupTable, 0.833, 1.000, 0.61, 0.66);
|
||||||
|
|
||||||
fillLookupTableValues(m_minLookupTable, 0.000, 0.166, 0.33, 0.23);
|
fillLookupTableValues(this->minLookupTable, 0.000, 0.166, 0.33, 0.23);
|
||||||
fillLookupTableValues(m_minLookupTable, 0.166, 0.333, 0.23, 0.27);
|
fillLookupTableValues(this->minLookupTable, 0.166, 0.333, 0.23, 0.27);
|
||||||
fillLookupTableValues(m_minLookupTable, 0.333, 0.500, 0.27, 0.23);
|
fillLookupTableValues(this->minLookupTable, 0.333, 0.500, 0.27, 0.23);
|
||||||
fillLookupTableValues(m_minLookupTable, 0.500, 0.666, 0.23, 0.50);
|
fillLookupTableValues(this->minLookupTable, 0.500, 0.666, 0.23, 0.50);
|
||||||
fillLookupTableValues(m_minLookupTable, 0.666, 0.833, 0.50, 0.30);
|
fillLookupTableValues(this->minLookupTable, 0.666, 0.833, 0.50, 0.30);
|
||||||
fillLookupTableValues(m_minLookupTable, 0.833, 1.000, 0.30, 0.33);
|
fillLookupTableValues(this->minLookupTable, 0.833, 1.000, 0.30, 0.33);
|
||||||
|
|
||||||
// for (int i = 0; i < LOOKUP_COLOR_COUNT; i++) {
|
// for (int i = 0; i < LOOKUP_COLOR_COUNT; i++) {
|
||||||
// qInfo(QString::number(m_middleLookupTable[i]).toStdString().c_str());
|
// qInfo(QString::number(this->middleLookupTable[i]).toStdString().c_str());
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ ColorScheme::normalizeColor(QColor &color)
|
||||||
{
|
{
|
||||||
// qreal l = color.lightnessF();
|
// qreal l = color.lightnessF();
|
||||||
// qreal s = color.saturationF();
|
// qreal s = color.saturationF();
|
||||||
// qreal x = m_colorLookupTable[std::max(0, color.hue())];
|
// qreal x = this->colorLookupTable[std::max(0, color.hue())];
|
||||||
// qreal newL = (l - 1) * x + 1;
|
// qreal newL = (l - 1) * x + 1;
|
||||||
|
|
||||||
// newL = s * newL + (1 - s) * l;
|
// newL = s * newL + (1 - s) * l;
|
||||||
|
@ -101,10 +101,10 @@ ColorScheme::normalizeColor(QColor &color)
|
||||||
qreal l = color.lightnessF();
|
qreal l = color.lightnessF();
|
||||||
qreal s = color.saturationF();
|
qreal s = color.saturationF();
|
||||||
int h = std::max(0, color.hue());
|
int h = std::max(0, color.hue());
|
||||||
qreal x = m_middleLookupTable[h];
|
qreal x = this->middleLookupTable[h];
|
||||||
x = s * 0.5 + (1 - s) * x;
|
x = s * 0.5 + (1 - s) * x;
|
||||||
|
|
||||||
qreal min = m_minLookupTable[h];
|
qreal min = this->minLookupTable[h];
|
||||||
min = (1 - s) * 0.5 + s * min;
|
min = (1 - s) * 0.5 + s * min;
|
||||||
|
|
||||||
qreal newL;
|
qreal newL;
|
||||||
|
|
|
@ -73,8 +73,8 @@ private:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal m_middleLookupTable[360] = {};
|
qreal middleLookupTable[360] = {};
|
||||||
qreal m_minLookupTable[360] = {};
|
qreal minLookupTable[360] = {};
|
||||||
|
|
||||||
void fillLookupTableValues(qreal (&array)[360], qreal from, qreal to,
|
void fillLookupTableValues(qreal (&array)[360], qreal from, qreal to,
|
||||||
qreal fromValue, qreal toValue);
|
qreal fromValue, qreal toValue);
|
||||||
|
|
48
emojis.cpp
48
emojis.cpp
|
@ -1,21 +1,17 @@
|
||||||
|
#include "emojis.h"
|
||||||
|
#include "emotes.h"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QStringBuilder>
|
#include <QStringBuilder>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
|
||||||
#include "emojis.h"
|
QRegularExpression Emojis::findShortCodesRegex(":([-+\\w]+):");
|
||||||
#include "emotes.h"
|
|
||||||
|
|
||||||
QRegularExpression *Emojis::findShortCodesRegex =
|
QMap<QString, Emojis::EmojiData> Emojis::shortCodeToEmoji;
|
||||||
new QRegularExpression(":([-+\\w]+):");
|
QMap<QString, QString> Emojis::emojiToShortCode;
|
||||||
|
QMap<QChar, QMap<QString, QString>> Emojis::firstEmojiChars;
|
||||||
|
|
||||||
QMap<QString, Emojis::EmojiData> *Emojis::shortCodeToEmoji =
|
ConcurrentMap<QString, LazyLoadedImage *> Emojis::imageCache;
|
||||||
new QMap<QString, Emojis::EmojiData>();
|
|
||||||
QMap<QString, QString> *Emojis::emojiToShortCode = new QMap<QString, QString>();
|
|
||||||
QMap<QChar, QMap<QString, QString>> *Emojis::firstEmojiChars =
|
|
||||||
new QMap<QChar, QMap<QString, QString>>();
|
|
||||||
|
|
||||||
ConcurrentMap<QString, LazyLoadedImage *> *Emojis::imageCache =
|
|
||||||
new ConcurrentMap<QString, LazyLoadedImage *>();
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
Emojis::replaceShortCodes(const QString &text)
|
Emojis::replaceShortCodes(const QString &text)
|
||||||
|
@ -32,9 +28,9 @@ Emojis::parseEmojis(std::vector<std::tuple<LazyLoadedImage *, QString>> &vector,
|
||||||
|
|
||||||
for (auto i = 0; i < text.length() - 1; i++) {
|
for (auto i = 0; i < text.length() - 1; i++) {
|
||||||
if (!text.at(i).isLowSurrogate()) {
|
if (!text.at(i).isLowSurrogate()) {
|
||||||
auto iter = firstEmojiChars->find(text.at(i));
|
auto iter = firstEmojiChars.find(text.at(i));
|
||||||
|
|
||||||
if (iter != firstEmojiChars->end()) {
|
if (iter != firstEmojiChars.end()) {
|
||||||
for (auto j = std::min(8, text.length() - i); j > 0; j--) {
|
for (auto j = std::min(8, text.length() - i); j > 0; j--) {
|
||||||
QString emojiString = text.mid(i, 2);
|
QString emojiString = text.mid(i, 2);
|
||||||
auto emojiIter = iter.value().find(emojiString);
|
auto emojiIter = iter.value().find(emojiString);
|
||||||
|
@ -51,11 +47,11 @@ Emojis::parseEmojis(std::vector<std::tuple<LazyLoadedImage *, QString>> &vector,
|
||||||
}
|
}
|
||||||
|
|
||||||
vector.push_back(std::tuple<LazyLoadedImage *, QString>(
|
vector.push_back(std::tuple<LazyLoadedImage *, QString>(
|
||||||
imageCache->getOrAdd(url,
|
imageCache.getOrAdd(url,
|
||||||
[&url] {
|
[&url] {
|
||||||
return new LazyLoadedImage(
|
return new LazyLoadedImage(
|
||||||
url, 0.35);
|
url, 0.35);
|
||||||
}),
|
}),
|
||||||
QString()));
|
QString()));
|
||||||
|
|
||||||
i += j - 1;
|
i += j - 1;
|
||||||
|
@ -104,23 +100,23 @@ Emojis::loadEmojis()
|
||||||
emotes[i++] = QString(item).toUInt(nullptr, 16);
|
emotes[i++] = QString(item).toUInt(nullptr, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
shortCodeToEmoji->insert(
|
shortCodeToEmoji.insert(
|
||||||
a.at(0), Emojis::EmojiData{QString::fromUcs4(emotes, i), a.at(1)});
|
a.at(0), Emojis::EmojiData{QString::fromUcs4(emotes, i), a.at(1)});
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto const &emoji : shortCodeToEmoji->toStdMap()) {
|
for (auto const &emoji : shortCodeToEmoji.toStdMap()) {
|
||||||
emojiToShortCode->insert(emoji.second.value, emoji.first);
|
emojiToShortCode.insert(emoji.second.value, emoji.first);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto const &emoji : shortCodeToEmoji->toStdMap()) {
|
for (auto const &emoji : shortCodeToEmoji.toStdMap()) {
|
||||||
auto iter = firstEmojiChars->find(emoji.first.at(0));
|
auto iter = firstEmojiChars.find(emoji.first.at(0));
|
||||||
|
|
||||||
if (iter != firstEmojiChars->end()) {
|
if (iter != firstEmojiChars.end()) {
|
||||||
iter.value().insert(emoji.second.value, emoji.second.value);
|
iter.value().insert(emoji.second.value, emoji.second.value);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
firstEmojiChars->insert(
|
firstEmojiChars.insert(
|
||||||
emoji.first.at(0),
|
emoji.first.at(0),
|
||||||
QMap<QString, QString>{{emoji.second.value, emoji.second.code}});
|
QMap<QString, QString>{{emoji.second.value, emoji.second.code}});
|
||||||
}
|
}
|
||||||
|
|
10
emojis.h
10
emojis.h
|
@ -26,13 +26,13 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QRegularExpression *findShortCodesRegex;
|
static QRegularExpression findShortCodesRegex;
|
||||||
|
|
||||||
static QMap<QString, EmojiData> *shortCodeToEmoji;
|
static QMap<QString, EmojiData> shortCodeToEmoji;
|
||||||
static QMap<QString, QString> *emojiToShortCode;
|
static QMap<QString, QString> emojiToShortCode;
|
||||||
static QMap<QChar, QMap<QString, QString>> *firstEmojiChars;
|
static QMap<QChar, QMap<QString, QString>> firstEmojiChars;
|
||||||
|
|
||||||
static ConcurrentMap<QString, LazyLoadedImage *> *imageCache;
|
static ConcurrentMap<QString, LazyLoadedImage *> imageCache;
|
||||||
|
|
||||||
Emojis()
|
Emojis()
|
||||||
{
|
{
|
||||||
|
|
37
emotes.cpp
37
emotes.cpp
|
@ -1,19 +1,19 @@
|
||||||
#include "emotes.h"
|
#include "emotes.h"
|
||||||
#include "resources.h"
|
#include "resources.h"
|
||||||
|
|
||||||
QString Emotes::m_twitchEmoteTemplate(
|
QString Emotes::twitchEmoteTemplate(
|
||||||
"https://static-cdn.jtvnw.net/emoticons/v1/{id}/{scale}.0");
|
"https://static-cdn.jtvnw.net/emoticons/v1/{id}/{scale}.0");
|
||||||
|
|
||||||
ConcurrentMap<QString, TwitchEmoteValue *> Emotes::m_twitchEmotes;
|
ConcurrentMap<QString, TwitchEmoteValue *> Emotes::twitchEmotes;
|
||||||
ConcurrentMap<QString, LazyLoadedImage *> Emotes::m_bttvEmotes;
|
ConcurrentMap<QString, LazyLoadedImage *> Emotes::bttvEmotes;
|
||||||
ConcurrentMap<QString, LazyLoadedImage *> Emotes::m_ffzEmotes;
|
ConcurrentMap<QString, LazyLoadedImage *> Emotes::ffzEmotes;
|
||||||
ConcurrentMap<QString, LazyLoadedImage *> Emotes::m_chatterinoEmotes;
|
ConcurrentMap<QString, LazyLoadedImage *> Emotes::chatterinoEmotes;
|
||||||
ConcurrentMap<QString, LazyLoadedImage *> Emotes::m_bttvChannelEmoteFromCaches;
|
ConcurrentMap<QString, LazyLoadedImage *> Emotes::bttvChannelEmoteFromCaches;
|
||||||
ConcurrentMap<QString, LazyLoadedImage *> Emotes::m_ffzChannelEmoteFromCaches;
|
ConcurrentMap<QString, LazyLoadedImage *> Emotes::ffzChannelEmoteFromCaches;
|
||||||
ConcurrentMap<long, LazyLoadedImage *> Emotes::m_twitchEmoteFromCache;
|
ConcurrentMap<long, LazyLoadedImage *> Emotes::twitchEmoteFromCache;
|
||||||
ConcurrentMap<QString, LazyLoadedImage *> Emotes::m_miscImageFromCache;
|
ConcurrentMap<QString, LazyLoadedImage *> Emotes::miscImageFromCache;
|
||||||
|
|
||||||
int Emotes::m_generation = 0;
|
int Emotes::generation = 0;
|
||||||
|
|
||||||
Emotes::Emotes()
|
Emotes::Emotes()
|
||||||
{
|
{
|
||||||
|
@ -22,10 +22,9 @@ Emotes::Emotes()
|
||||||
LazyLoadedImage *
|
LazyLoadedImage *
|
||||||
Emotes::getTwitchEmoteById(const QString &name, long id)
|
Emotes::getTwitchEmoteById(const QString &name, long id)
|
||||||
{
|
{
|
||||||
return m_twitchEmoteFromCache.getOrAdd(id, [&name, id] {
|
return Emotes::twitchEmoteFromCache.getOrAdd(id, [&name, id] {
|
||||||
qreal scale;
|
qreal scale;
|
||||||
QString url = getTwitchEmoteLink(id, scale);
|
QString url = getTwitchEmoteLink(id, scale);
|
||||||
|
|
||||||
return new LazyLoadedImage(url, scale, name, name + "\nTwitch Emote");
|
return new LazyLoadedImage(url, scale, name, name + "\nTwitch Emote");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -35,7 +34,7 @@ Emotes::getTwitchEmoteLink(long id, qreal &scale)
|
||||||
{
|
{
|
||||||
scale = .5;
|
scale = .5;
|
||||||
|
|
||||||
return m_twitchEmoteTemplate.replace("{id}", QString::number(id))
|
return Emotes::twitchEmoteTemplate.replace("{id}", QString::number(id))
|
||||||
.replace("{scale}", "2");
|
.replace("{scale}", "2");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,16 +49,16 @@ LazyLoadedImage *
|
||||||
Emotes::getCheerBadge(long long amount)
|
Emotes::getCheerBadge(long long amount)
|
||||||
{
|
{
|
||||||
if (amount >= 100000) {
|
if (amount >= 100000) {
|
||||||
return Resources::cheerBadge100000();
|
return Resources::getCheerBadge100000();
|
||||||
} else if (amount >= 10000) {
|
} else if (amount >= 10000) {
|
||||||
return Resources::cheerBadge10000();
|
return Resources::getCheerBadge10000();
|
||||||
} else if (amount >= 5000) {
|
} else if (amount >= 5000) {
|
||||||
return Resources::cheerBadge5000();
|
return Resources::getCheerBadge5000();
|
||||||
} else if (amount >= 1000) {
|
} else if (amount >= 1000) {
|
||||||
return Resources::cheerBadge1000();
|
return Resources::getCheerBadge1000();
|
||||||
} else if (amount >= 100) {
|
} else if (amount >= 100) {
|
||||||
return Resources::cheerBadge100();
|
return Resources::getCheerBadge100();
|
||||||
} else {
|
} else {
|
||||||
return Resources::cheerBadge1();
|
return Resources::getCheerBadge1();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
60
emotes.h
60
emotes.h
|
@ -11,51 +11,51 @@ class Emotes
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static ConcurrentMap<QString, TwitchEmoteValue *> &
|
static ConcurrentMap<QString, TwitchEmoteValue *> &
|
||||||
twitchEmotes()
|
getTwitchEmotes()
|
||||||
{
|
{
|
||||||
return m_twitchEmotes;
|
return twitchEmotes;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ConcurrentMap<QString, LazyLoadedImage *> &
|
static ConcurrentMap<QString, LazyLoadedImage *> &
|
||||||
bttvEmotes()
|
getBttvEmotes()
|
||||||
{
|
{
|
||||||
return m_bttvEmotes;
|
return bttvEmotes;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ConcurrentMap<QString, LazyLoadedImage *> &
|
static ConcurrentMap<QString, LazyLoadedImage *> &
|
||||||
ffzEmotes()
|
getFfzEmotes()
|
||||||
{
|
{
|
||||||
return m_ffzEmotes;
|
return ffzEmotes;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ConcurrentMap<QString, LazyLoadedImage *> &
|
static ConcurrentMap<QString, LazyLoadedImage *> &
|
||||||
chatterinoEmotes()
|
getChatterinoEmotes()
|
||||||
{
|
{
|
||||||
return m_chatterinoEmotes;
|
return chatterinoEmotes;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ConcurrentMap<QString, LazyLoadedImage *> &
|
static ConcurrentMap<QString, LazyLoadedImage *> &
|
||||||
bttvChannelEmoteFromCaches()
|
getBttvChannelEmoteFromCaches()
|
||||||
{
|
{
|
||||||
return m_bttvChannelEmoteFromCaches;
|
return bttvChannelEmoteFromCaches;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ConcurrentMap<QString, LazyLoadedImage *> &
|
static ConcurrentMap<QString, LazyLoadedImage *> &
|
||||||
ffzChannelEmoteFromCaches()
|
getFfzChannelEmoteFromCaches()
|
||||||
{
|
{
|
||||||
return m_ffzChannelEmoteFromCaches;
|
return ffzChannelEmoteFromCaches;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ConcurrentMap<long, LazyLoadedImage *> &
|
static ConcurrentMap<long, LazyLoadedImage *> &
|
||||||
twitchEmoteFromCache()
|
getTwitchEmoteFromCache()
|
||||||
{
|
{
|
||||||
return m_twitchEmoteFromCache;
|
return twitchEmoteFromCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ConcurrentMap<QString, LazyLoadedImage *> &
|
static ConcurrentMap<QString, LazyLoadedImage *> &
|
||||||
miscImageFromCache()
|
getMiscImageFromCache()
|
||||||
{
|
{
|
||||||
return m_miscImageFromCache;
|
return miscImageFromCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loadGlobalEmotes();
|
static void loadGlobalEmotes();
|
||||||
|
@ -67,36 +67,34 @@ public:
|
||||||
long int id);
|
long int id);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
generation()
|
getGeneration()
|
||||||
{
|
{
|
||||||
return m_generation;
|
return generation;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
incGeneration()
|
incGeneration()
|
||||||
{
|
{
|
||||||
m_generation++;
|
generation++;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Emotes();
|
Emotes();
|
||||||
|
|
||||||
static QString m_twitchEmoteTemplate;
|
static QString twitchEmoteTemplate;
|
||||||
|
|
||||||
static ConcurrentMap<QString, TwitchEmoteValue *> m_twitchEmotes;
|
static ConcurrentMap<QString, TwitchEmoteValue *> twitchEmotes;
|
||||||
static ConcurrentMap<QString, LazyLoadedImage *> m_bttvEmotes;
|
static ConcurrentMap<QString, LazyLoadedImage *> bttvEmotes;
|
||||||
static ConcurrentMap<QString, LazyLoadedImage *> m_ffzEmotes;
|
static ConcurrentMap<QString, LazyLoadedImage *> ffzEmotes;
|
||||||
static ConcurrentMap<QString, LazyLoadedImage *> m_chatterinoEmotes;
|
static ConcurrentMap<QString, LazyLoadedImage *> chatterinoEmotes;
|
||||||
static ConcurrentMap<QString, LazyLoadedImage *>
|
static ConcurrentMap<QString, LazyLoadedImage *> bttvChannelEmoteFromCaches;
|
||||||
m_bttvChannelEmoteFromCaches;
|
static ConcurrentMap<QString, LazyLoadedImage *> ffzChannelEmoteFromCaches;
|
||||||
static ConcurrentMap<QString, LazyLoadedImage *>
|
static ConcurrentMap<long, LazyLoadedImage *> twitchEmoteFromCache;
|
||||||
m_ffzChannelEmoteFromCaches;
|
static ConcurrentMap<QString, LazyLoadedImage *> miscImageFromCache;
|
||||||
static ConcurrentMap<long, LazyLoadedImage *> m_twitchEmoteFromCache;
|
|
||||||
static ConcurrentMap<QString, LazyLoadedImage *> m_miscImageFromCache;
|
|
||||||
|
|
||||||
static QString getTwitchEmoteLink(long id, qreal &scale);
|
static QString getTwitchEmoteLink(long id, qreal &scale);
|
||||||
|
|
||||||
static int m_generation;
|
static int generation;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EMOTES_H
|
#endif // EMOTES_H
|
||||||
|
|
|
@ -16,7 +16,7 @@ QFontMetrics *Fonts::metricsSmall = new QFontMetrics(*small);
|
||||||
QFontMetrics *Fonts::metricsLarge = new QFontMetrics(*large);
|
QFontMetrics *Fonts::metricsLarge = new QFontMetrics(*large);
|
||||||
QFontMetrics *Fonts::metricsVeryLarge = new QFontMetrics(*veryLarge);
|
QFontMetrics *Fonts::metricsVeryLarge = new QFontMetrics(*veryLarge);
|
||||||
|
|
||||||
int Fonts::m_generation = 0;
|
int Fonts::generation = 0;
|
||||||
|
|
||||||
Fonts::Fonts()
|
Fonts::Fonts()
|
||||||
{
|
{
|
||||||
|
|
8
fonts.h
8
fonts.h
|
@ -20,15 +20,15 @@ public:
|
||||||
static QFontMetrics &getFontMetrics(Type type);
|
static QFontMetrics &getFontMetrics(Type type);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
generation()
|
getGeneration()
|
||||||
{
|
{
|
||||||
return m_generation;
|
return generation;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
incGeneration()
|
incGeneration()
|
||||||
{
|
{
|
||||||
m_generation++;
|
generation++;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -48,7 +48,7 @@ private:
|
||||||
static QFontMetrics *metricsLarge;
|
static QFontMetrics *metricsLarge;
|
||||||
static QFontMetrics *metricsVeryLarge;
|
static QFontMetrics *metricsVeryLarge;
|
||||||
|
|
||||||
static int m_generation;
|
static int generation;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FONTS_H
|
#endif // FONTS_H
|
||||||
|
|
120
ircmanager.cpp
120
ircmanager.cpp
|
@ -13,14 +13,14 @@
|
||||||
#include <future>
|
#include <future>
|
||||||
|
|
||||||
Account *IrcManager::account = nullptr;
|
Account *IrcManager::account = nullptr;
|
||||||
IrcConnection *IrcManager::m_connection = NULL;
|
IrcConnection *IrcManager::connection = NULL;
|
||||||
QMutex IrcManager::m_connectionMutex;
|
QMutex IrcManager::connectionMutex;
|
||||||
long IrcManager::m_connectionIteration = 0;
|
long IrcManager::connectionGeneration = 0;
|
||||||
const QString IrcManager::defaultClientId = "7ue61iz46fz11y3cugd0l3tawb4taal";
|
const QString IrcManager::defaultClientId = "7ue61iz46fz11y3cugd0l3tawb4taal";
|
||||||
QNetworkAccessManager IrcManager::m_accessManager;
|
QNetworkAccessManager IrcManager::accessManager;
|
||||||
|
|
||||||
QMap<QString, bool> IrcManager::m_twitchBlockedUsers;
|
QMap<QString, bool> IrcManager::twitchBlockedUsers;
|
||||||
QMutex IrcManager::m_twitchBlockedUsersMutex;
|
QMutex IrcManager::twitchBlockedUsersMutex;
|
||||||
|
|
||||||
IrcManager::IrcManager()
|
IrcManager::IrcManager()
|
||||||
{
|
{
|
||||||
|
@ -37,9 +37,9 @@ IrcManager::connect()
|
||||||
void
|
void
|
||||||
IrcManager::beginConnecting()
|
IrcManager::beginConnecting()
|
||||||
{
|
{
|
||||||
IrcManager::account = const_cast<Account *>(Account::anon());
|
IrcManager::account = const_cast<Account *>(Account::getAnon());
|
||||||
|
|
||||||
int iteration = ++m_connectionIteration;
|
int generation = ++IrcManager::connectionGeneration;
|
||||||
|
|
||||||
auto c = new IrcConnection();
|
auto c = new IrcConnection();
|
||||||
|
|
||||||
|
@ -49,9 +49,9 @@ IrcManager::beginConnecting()
|
||||||
|
|
||||||
if (account->isAnon()) {
|
if (account->isAnon()) {
|
||||||
// fetch ignored users
|
// fetch ignored users
|
||||||
QString username = account->username();
|
QString username = account->getUsername();
|
||||||
QString oauthClient = account->oauthClient();
|
QString oauthClient = account->getOauthClient();
|
||||||
QString oauthToken = account->oauthToken();
|
QString oauthToken = account->getOauthToken();
|
||||||
|
|
||||||
{
|
{
|
||||||
QString nextLink = "https://api.twitch.tv/kraken/users/" +
|
QString nextLink = "https://api.twitch.tv/kraken/users/" +
|
||||||
|
@ -59,12 +59,12 @@ IrcManager::beginConnecting()
|
||||||
"&client_id=" + oauthClient;
|
"&client_id=" + oauthClient;
|
||||||
|
|
||||||
QNetworkRequest req(QUrl(nextLink + "&oauth_token=" + oauthToken));
|
QNetworkRequest req(QUrl(nextLink + "&oauth_token=" + oauthToken));
|
||||||
QNetworkReply *reply = m_accessManager.get(req);
|
QNetworkReply *reply = IrcManager::accessManager.get(req);
|
||||||
|
|
||||||
QObject::connect(reply, &QNetworkReply::finished, [=] {
|
QObject::connect(reply, &QNetworkReply::finished, [=] {
|
||||||
m_twitchBlockedUsersMutex.lock();
|
IrcManager::twitchBlockedUsersMutex.lock();
|
||||||
m_twitchBlockedUsers.clear();
|
IrcManager::twitchBlockedUsers.clear();
|
||||||
m_twitchBlockedUsersMutex.unlock();
|
IrcManager::twitchBlockedUsersMutex.unlock();
|
||||||
|
|
||||||
QByteArray data = reply->readAll();
|
QByteArray data = reply->readAll();
|
||||||
QJsonDocument jsonDoc(QJsonDocument::fromJson(data));
|
QJsonDocument jsonDoc(QJsonDocument::fromJson(data));
|
||||||
|
@ -75,15 +75,15 @@ IrcManager::beginConnecting()
|
||||||
|
|
||||||
auto blocks = root.value("blocks").toArray();
|
auto blocks = root.value("blocks").toArray();
|
||||||
|
|
||||||
m_twitchBlockedUsersMutex.lock();
|
IrcManager::twitchBlockedUsersMutex.lock();
|
||||||
for (QJsonValue block : blocks) {
|
for (QJsonValue block : blocks) {
|
||||||
QJsonObject user =
|
QJsonObject user =
|
||||||
block.toObject().value("user").toObject();
|
block.toObject().value("user").toObject();
|
||||||
// display_name
|
// display_name
|
||||||
m_twitchBlockedUsers.insert(
|
IrcManager::twitchBlockedUsers.insert(
|
||||||
user.value("name").toString().toLower(), true);
|
user.value("name").toString().toLower(), true);
|
||||||
}
|
}
|
||||||
m_twitchBlockedUsersMutex.unlock();
|
IrcManager::twitchBlockedUsersMutex.unlock();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ IrcManager::beginConnecting()
|
||||||
QNetworkRequest req(QUrl("https://api.twitch.tv/kraken/users/" +
|
QNetworkRequest req(QUrl("https://api.twitch.tv/kraken/users/" +
|
||||||
username + "/emotes?oauth_token=" +
|
username + "/emotes?oauth_token=" +
|
||||||
oauthToken + "&client_id=" + oauthClient));
|
oauthToken + "&client_id=" + oauthClient));
|
||||||
QNetworkReply *reply = m_accessManager.get(req);
|
QNetworkReply *reply = IrcManager::accessManager.get(req);
|
||||||
|
|
||||||
QObject::connect(reply, &QNetworkReply::finished, [=] {
|
QObject::connect(reply, &QNetworkReply::finished, [=] {
|
||||||
QByteArray data = reply->readAll();
|
QByteArray data = reply->readAll();
|
||||||
|
@ -104,15 +104,15 @@ IrcManager::beginConnecting()
|
||||||
|
|
||||||
auto blocks = root.value("blocks").toArray();
|
auto blocks = root.value("blocks").toArray();
|
||||||
|
|
||||||
m_twitchBlockedUsersMutex.lock();
|
IrcManager::twitchBlockedUsersMutex.lock();
|
||||||
for (QJsonValue block : blocks) {
|
for (QJsonValue block : blocks) {
|
||||||
QJsonObject user =
|
QJsonObject user =
|
||||||
block.toObject().value("user").toObject();
|
block.toObject().value("user").toObject();
|
||||||
// display_name
|
// display_name
|
||||||
m_twitchBlockedUsers.insert(
|
IrcManager::twitchBlockedUsers.insert(
|
||||||
user.value("name").toString().toLower(), true);
|
user.value("name").toString().toLower(), true);
|
||||||
}
|
}
|
||||||
m_twitchBlockedUsersMutex.unlock();
|
IrcManager::twitchBlockedUsersMutex.unlock();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,48 +129,48 @@ IrcManager::beginConnecting()
|
||||||
|
|
||||||
c->open();
|
c->open();
|
||||||
|
|
||||||
m_connectionMutex.lock();
|
IrcManager::connectionMutex.lock();
|
||||||
if (iteration == m_connectionIteration) {
|
if (generation == IrcManager::connectionGeneration) {
|
||||||
delete m_connection;
|
delete IrcManager::connection;
|
||||||
c->moveToThread(QCoreApplication::instance()->thread());
|
c->moveToThread(QCoreApplication::instance()->thread());
|
||||||
m_connection = c;
|
IrcManager::connection = c;
|
||||||
} else {
|
} else {
|
||||||
delete c;
|
delete c;
|
||||||
}
|
}
|
||||||
m_connectionMutex.unlock();
|
IrcManager::connectionMutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
IrcManager::disconnect()
|
IrcManager::disconnect()
|
||||||
{
|
{
|
||||||
m_connectionMutex.lock();
|
IrcManager::connectionMutex.lock();
|
||||||
|
|
||||||
if (m_connection != NULL) {
|
if (IrcManager::connection != NULL) {
|
||||||
delete m_connection;
|
delete IrcManager::connection;
|
||||||
m_connection = NULL;
|
IrcManager::connection = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_connectionMutex.unlock();
|
IrcManager::connectionMutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
IrcManager::joinChannel(const QString &channel)
|
IrcManager::joinChannel(const QString &channel)
|
||||||
{
|
{
|
||||||
m_connectionMutex.lock();
|
IrcManager::connectionMutex.lock();
|
||||||
if (m_connection != NULL) {
|
if (IrcManager::connection != NULL) {
|
||||||
m_connection->sendRaw("JOIN #" + channel);
|
IrcManager::connection->sendRaw("JOIN #" + channel);
|
||||||
}
|
}
|
||||||
m_connectionMutex.unlock();
|
IrcManager::connectionMutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
IrcManager::partChannel(const QString &channel)
|
IrcManager::partChannel(const QString &channel)
|
||||||
{
|
{
|
||||||
m_connectionMutex.lock();
|
IrcManager::connectionMutex.lock();
|
||||||
if (m_connection != NULL) {
|
if (IrcManager::connection != NULL) {
|
||||||
m_connection->sendRaw("PART #" + channel);
|
IrcManager::connection->sendRaw("PART #" + channel);
|
||||||
}
|
}
|
||||||
m_connectionMutex.unlock();
|
IrcManager::connectionMutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -204,34 +204,35 @@ IrcManager::privateMessageReceived(IrcPrivateMessage *message)
|
||||||
bool
|
bool
|
||||||
IrcManager::isTwitchBlockedUser(QString const &username)
|
IrcManager::isTwitchBlockedUser(QString const &username)
|
||||||
{
|
{
|
||||||
m_twitchBlockedUsersMutex.lock();
|
IrcManager::twitchBlockedUsersMutex.lock();
|
||||||
|
|
||||||
auto iterator = m_twitchBlockedUsers.find(username);
|
auto iterator = IrcManager::twitchBlockedUsers.find(username);
|
||||||
|
|
||||||
if (iterator == m_twitchBlockedUsers.end()) {
|
if (iterator == IrcManager::twitchBlockedUsers.end()) {
|
||||||
m_twitchBlockedUsersMutex.unlock();
|
IrcManager::twitchBlockedUsersMutex.unlock();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_twitchBlockedUsersMutex.unlock();
|
IrcManager::twitchBlockedUsersMutex.unlock();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
IrcManager::tryAddIgnoredUser(QString const &username, QString &errorMessage)
|
IrcManager::tryAddIgnoredUser(QString const &username, QString &errorMessage)
|
||||||
{
|
{
|
||||||
QUrl url("https://api.twitch.tv/kraken/users/" + account->username() +
|
QUrl url("https://api.twitch.tv/kraken/users/" + account->getUsername() +
|
||||||
"/blocks/" + username + "?oauth_token=" + account->oauthToken() +
|
"/blocks/" + username +
|
||||||
"&client_id=" + account->oauthClient());
|
"?oauth_token=" + account->getOauthToken() +
|
||||||
|
"&client_id=" + account->getOauthClient());
|
||||||
|
|
||||||
QNetworkRequest request(url);
|
QNetworkRequest request(url);
|
||||||
auto reply = m_accessManager.put(request, QByteArray());
|
auto reply = IrcManager::accessManager.put(request, QByteArray());
|
||||||
reply->waitForReadyRead(10000);
|
reply->waitForReadyRead(10000);
|
||||||
|
|
||||||
if (reply->error() == QNetworkReply::NoError) {
|
if (reply->error() == QNetworkReply::NoError) {
|
||||||
m_twitchBlockedUsersMutex.lock();
|
IrcManager::twitchBlockedUsersMutex.lock();
|
||||||
m_twitchBlockedUsers.insert(username, true);
|
IrcManager::twitchBlockedUsers.insert(username, true);
|
||||||
m_twitchBlockedUsersMutex.unlock();
|
IrcManager::twitchBlockedUsersMutex.unlock();
|
||||||
|
|
||||||
delete reply;
|
delete reply;
|
||||||
return true;
|
return true;
|
||||||
|
@ -254,18 +255,19 @@ IrcManager::addIgnoredUser(QString const &username)
|
||||||
bool
|
bool
|
||||||
IrcManager::tryRemoveIgnoredUser(QString const &username, QString &errorMessage)
|
IrcManager::tryRemoveIgnoredUser(QString const &username, QString &errorMessage)
|
||||||
{
|
{
|
||||||
QUrl url("https://api.twitch.tv/kraken/users/" + account->username() +
|
QUrl url("https://api.twitch.tv/kraken/users/" + account->getUsername() +
|
||||||
"/blocks/" + username + "?oauth_token=" + account->oauthToken() +
|
"/blocks/" + username +
|
||||||
"&client_id=" + account->oauthClient());
|
"?oauth_token=" + account->getOauthToken() +
|
||||||
|
"&client_id=" + account->getOauthClient());
|
||||||
|
|
||||||
QNetworkRequest request(url);
|
QNetworkRequest request(url);
|
||||||
auto reply = m_accessManager.deleteResource(request);
|
auto reply = IrcManager::accessManager.deleteResource(request);
|
||||||
reply->waitForReadyRead(10000);
|
reply->waitForReadyRead(10000);
|
||||||
|
|
||||||
if (reply->error() == QNetworkReply::NoError) {
|
if (reply->error() == QNetworkReply::NoError) {
|
||||||
m_twitchBlockedUsersMutex.lock();
|
IrcManager::twitchBlockedUsersMutex.lock();
|
||||||
m_twitchBlockedUsers.remove(username);
|
IrcManager::twitchBlockedUsers.remove(username);
|
||||||
m_twitchBlockedUsersMutex.unlock();
|
IrcManager::twitchBlockedUsersMutex.unlock();
|
||||||
|
|
||||||
delete reply;
|
delete reply;
|
||||||
return true;
|
return true;
|
||||||
|
|
16
ircmanager.h
16
ircmanager.h
|
@ -29,9 +29,9 @@ public:
|
||||||
static Account *account;
|
static Account *account;
|
||||||
|
|
||||||
static QNetworkAccessManager &
|
static QNetworkAccessManager &
|
||||||
accessManager()
|
getAccessManager()
|
||||||
{
|
{
|
||||||
return m_accessManager;
|
return accessManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void joinChannel(const QString &channel);
|
static void joinChannel(const QString &channel);
|
||||||
|
@ -41,16 +41,16 @@ public:
|
||||||
private:
|
private:
|
||||||
IrcManager();
|
IrcManager();
|
||||||
|
|
||||||
static QMap<QString, bool> m_twitchBlockedUsers;
|
static QMap<QString, bool> twitchBlockedUsers;
|
||||||
static QMutex m_twitchBlockedUsersMutex;
|
static QMutex twitchBlockedUsersMutex;
|
||||||
|
|
||||||
static QNetworkAccessManager m_accessManager;
|
static QNetworkAccessManager accessManager;
|
||||||
|
|
||||||
static void beginConnecting();
|
static void beginConnecting();
|
||||||
|
|
||||||
static IrcConnection *m_connection;
|
static IrcConnection *connection;
|
||||||
static QMutex m_connectionMutex;
|
static QMutex connectionMutex;
|
||||||
static long m_connectionIteration;
|
static long connectionGeneration;
|
||||||
|
|
||||||
static void messageReceived(IrcMessage *message);
|
static void messageReceived(IrcMessage *message);
|
||||||
static void privateMessageReceived(IrcPrivateMessage *message);
|
static void privateMessageReceived(IrcPrivateMessage *message);
|
||||||
|
|
|
@ -8,5 +8,5 @@ LambdaQRunnable::LambdaQRunnable(std::function<void()> action)
|
||||||
void
|
void
|
||||||
LambdaQRunnable::run()
|
LambdaQRunnable::run()
|
||||||
{
|
{
|
||||||
action();
|
this->action();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,30 +13,30 @@
|
||||||
LazyLoadedImage::LazyLoadedImage(const QString &url, qreal scale,
|
LazyLoadedImage::LazyLoadedImage(const QString &url, qreal scale,
|
||||||
const QString &name, const QString &tooltip,
|
const QString &name, const QString &tooltip,
|
||||||
const QMargins &margin, bool isHat)
|
const QMargins &margin, bool isHat)
|
||||||
: m_pixmap(NULL)
|
: pixmap(NULL)
|
||||||
, m_url(url)
|
, url(url)
|
||||||
, m_name(name)
|
, name(name)
|
||||||
, m_tooltip(tooltip)
|
, tooltip(tooltip)
|
||||||
, m_animated(false)
|
, animated(false)
|
||||||
, m_margin(margin)
|
, margin(margin)
|
||||||
, m_ishat(isHat)
|
, ishat(isHat)
|
||||||
, m_scale(scale)
|
, scale(scale)
|
||||||
, m_isLoading(false)
|
, isLoading(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
LazyLoadedImage::LazyLoadedImage(QPixmap *image, qreal scale,
|
LazyLoadedImage::LazyLoadedImage(QPixmap *image, qreal scale,
|
||||||
const QString &name, const QString &tooltip,
|
const QString &name, const QString &tooltip,
|
||||||
const QMargins &margin, bool isHat)
|
const QMargins &margin, bool isHat)
|
||||||
: m_pixmap(image)
|
: pixmap(image)
|
||||||
, m_url()
|
, url()
|
||||||
, m_name(name)
|
, name(name)
|
||||||
, m_tooltip(tooltip)
|
, tooltip(tooltip)
|
||||||
, m_animated(false)
|
, animated(false)
|
||||||
, m_margin(margin)
|
, margin(margin)
|
||||||
, m_ishat(isHat)
|
, ishat(isHat)
|
||||||
, m_scale(scale)
|
, scale(scale)
|
||||||
, m_isLoading(true)
|
, isLoading(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,10 +44,10 @@ void
|
||||||
LazyLoadedImage::loadImage()
|
LazyLoadedImage::loadImage()
|
||||||
{
|
{
|
||||||
// QThreadPool::globalInstance()->start(new LambdaQRunnable([=] {
|
// QThreadPool::globalInstance()->start(new LambdaQRunnable([=] {
|
||||||
QUrl url(m_url);
|
QUrl url(this->url);
|
||||||
QNetworkRequest request(url);
|
QNetworkRequest request(url);
|
||||||
|
|
||||||
QNetworkReply *reply = IrcManager::accessManager().get(request);
|
QNetworkReply *reply = IrcManager::getAccessManager().get(request);
|
||||||
|
|
||||||
QObject::connect(reply, &QNetworkReply::finished, [=] {
|
QObject::connect(reply, &QNetworkReply::finished, [=] {
|
||||||
QPixmap *pixmap = new QPixmap();
|
QPixmap *pixmap = new QPixmap();
|
||||||
|
@ -57,7 +57,7 @@ LazyLoadedImage::loadImage()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pixmap = pixmap;
|
this->pixmap = pixmap;
|
||||||
Emotes::incGeneration();
|
Emotes::incGeneration();
|
||||||
Windows::layoutVisibleChatWidgets();
|
Windows::layoutVisibleChatWidgets();
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,96 +7,100 @@
|
||||||
class LazyLoadedImage
|
class LazyLoadedImage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LazyLoadedImage(const QString &url, qreal scale = 1,
|
explicit LazyLoadedImage(const QString &url, qreal scale = 1,
|
||||||
const QString &name = "", const QString &tooltip = "",
|
const QString &getName = "",
|
||||||
const QMargins &margin = QMargins(), bool isHat = false);
|
const QString &getTooltip = "",
|
||||||
LazyLoadedImage(QPixmap *pixmap, qreal scale = 1, const QString &name = "",
|
const QMargins &getMargin = QMargins(),
|
||||||
const QString &tooltip = "",
|
bool getIsHat = false);
|
||||||
const QMargins &margin = QMargins(), bool isHat = false);
|
explicit LazyLoadedImage(QPixmap *pixmap, qreal scale = 1,
|
||||||
|
const QString &getName = "",
|
||||||
|
const QString &getTooltip = "",
|
||||||
|
const QMargins &getMargin = QMargins(),
|
||||||
|
bool getIsHat = false);
|
||||||
|
|
||||||
const QPixmap *
|
const QPixmap *
|
||||||
pixmap()
|
getPixmap()
|
||||||
{
|
{
|
||||||
if (!m_isLoading) {
|
if (!isLoading) {
|
||||||
m_isLoading = true;
|
isLoading = true;
|
||||||
|
|
||||||
loadImage();
|
loadImage();
|
||||||
}
|
}
|
||||||
return m_pixmap;
|
return pixmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal
|
qreal
|
||||||
scale() const
|
getScale() const
|
||||||
{
|
{
|
||||||
return m_scale;
|
return scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &
|
const QString &
|
||||||
url() const
|
getUrl() const
|
||||||
{
|
{
|
||||||
return m_url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &
|
const QString &
|
||||||
name() const
|
getName() const
|
||||||
{
|
{
|
||||||
return m_name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &
|
const QString &
|
||||||
tooltip() const
|
getTooltip() const
|
||||||
{
|
{
|
||||||
return m_tooltip;
|
return tooltip;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QMargins &
|
const QMargins &
|
||||||
margin() const
|
getMargin() const
|
||||||
{
|
{
|
||||||
return m_margin;
|
return margin;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
animated() const
|
getAnimated() const
|
||||||
{
|
{
|
||||||
return m_animated;
|
return animated;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isHat() const
|
getIsHat() const
|
||||||
{
|
{
|
||||||
return m_ishat;
|
return ishat;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
width() const
|
getWidth() const
|
||||||
{
|
{
|
||||||
if (m_pixmap == NULL) {
|
if (pixmap == NULL) {
|
||||||
return 16;
|
return 16;
|
||||||
}
|
}
|
||||||
return m_pixmap->width();
|
return pixmap->width();
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
height() const
|
getHeight() const
|
||||||
{
|
{
|
||||||
if (m_pixmap == NULL) {
|
if (pixmap == NULL) {
|
||||||
return 16;
|
return 16;
|
||||||
}
|
}
|
||||||
return m_pixmap->height();
|
return pixmap->height();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPixmap *m_pixmap;
|
QPixmap *pixmap;
|
||||||
|
|
||||||
QString m_url;
|
QString url;
|
||||||
QString m_name;
|
QString name;
|
||||||
QString m_tooltip;
|
QString tooltip;
|
||||||
bool m_animated;
|
bool animated;
|
||||||
QMargins m_margin;
|
QMargins margin;
|
||||||
bool m_ishat;
|
bool ishat;
|
||||||
qreal m_scale;
|
qreal scale;
|
||||||
|
|
||||||
bool m_isLoading;
|
bool isLoading;
|
||||||
|
|
||||||
void loadImage();
|
void loadImage();
|
||||||
};
|
};
|
||||||
|
|
8
link.cpp
8
link.cpp
|
@ -1,13 +1,13 @@
|
||||||
#include "link.h"
|
#include "link.h"
|
||||||
|
|
||||||
Link::Link()
|
Link::Link()
|
||||||
: m_type(None)
|
: type(None)
|
||||||
, m_value(QString())
|
, value(QString())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Link::Link(Type type, const QString &value)
|
Link::Link(Type type, const QString &value)
|
||||||
: m_type(type)
|
: type(type)
|
||||||
, m_value(value)
|
, value(value)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
18
link.h
18
link.h
|
@ -18,29 +18,29 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
Link();
|
Link();
|
||||||
Link(Type type, const QString &value);
|
Link(Type getType, const QString &getValue);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isValid()
|
getIsValid()
|
||||||
{
|
{
|
||||||
return m_type == None;
|
return type == None;
|
||||||
}
|
}
|
||||||
|
|
||||||
Type
|
Type
|
||||||
type()
|
getType()
|
||||||
{
|
{
|
||||||
return m_type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &
|
const QString &
|
||||||
value()
|
getValue()
|
||||||
{
|
{
|
||||||
return m_value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Type m_type;
|
Type type;
|
||||||
QString m_value;
|
QString value;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LINK_H
|
#endif // LINK_H
|
||||||
|
|
2
main.cpp
2
main.cpp
|
@ -19,7 +19,7 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
ColorScheme::instance().setColors(0, -0.8);
|
ColorScheme::instance().setColors(0, -0.8);
|
||||||
|
|
||||||
MainWindow &w = Windows::mainWindow();
|
MainWindow &w = Windows::getMainWindow();
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
IrcManager::connect();
|
IrcManager::connect();
|
||||||
|
|
|
@ -29,19 +29,19 @@ MainWindow::~MainWindow()
|
||||||
void
|
void
|
||||||
MainWindow::layoutVisibleChatWidgets(Channel *channel)
|
MainWindow::layoutVisibleChatWidgets(Channel *channel)
|
||||||
{
|
{
|
||||||
auto *page = notebook.selected();
|
auto *page = notebook.getSelectedPage();
|
||||||
|
|
||||||
if (page == NULL) {
|
if (page == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<ChatWidget *> &widgets = page->chatWidgets();
|
const std::vector<ChatWidget *> &widgets = page->getChatWidgets();
|
||||||
|
|
||||||
for (auto it = widgets.begin(); it != widgets.end(); ++it) {
|
for (auto it = widgets.begin(); it != widgets.end(); ++it) {
|
||||||
ChatWidget *widget = *it;
|
ChatWidget *widget = *it;
|
||||||
|
|
||||||
if (channel == NULL || channel == widget->channel()) {
|
if (channel == NULL || channel == widget->getChannel()) {
|
||||||
if (widget->view().layoutMessages()) {
|
if (widget->getView().layoutMessages()) {
|
||||||
widget->repaint();
|
widget->repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,19 +51,19 @@ MainWindow::layoutVisibleChatWidgets(Channel *channel)
|
||||||
void
|
void
|
||||||
MainWindow::repaintVisibleChatWidgets(Channel *channel)
|
MainWindow::repaintVisibleChatWidgets(Channel *channel)
|
||||||
{
|
{
|
||||||
auto *page = notebook.selected();
|
auto *page = notebook.getSelectedPage();
|
||||||
|
|
||||||
if (page == NULL) {
|
if (page == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<ChatWidget *> &widgets = page->chatWidgets();
|
const std::vector<ChatWidget *> &widgets = page->getChatWidgets();
|
||||||
|
|
||||||
for (auto it = widgets.begin(); it != widgets.end(); ++it) {
|
for (auto it = widgets.begin(); it != widgets.end(); ++it) {
|
||||||
ChatWidget *widget = *it;
|
ChatWidget *widget = *it;
|
||||||
|
|
||||||
if (channel == NULL || channel == widget->channel()) {
|
if (channel == NULL || channel == widget->getChannel()) {
|
||||||
widget->view().layoutMessages();
|
widget->getView().layoutMessages();
|
||||||
widget->repaint();
|
widget->repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
180
message.cpp
180
message.cpp
|
@ -23,16 +23,16 @@ QRegularExpression *Message::cheerRegex =
|
||||||
new QRegularExpression("cheer[1-9][0-9]*");
|
new QRegularExpression("cheer[1-9][0-9]*");
|
||||||
|
|
||||||
Message::Message(const QString &text)
|
Message::Message(const QString &text)
|
||||||
: m_wordParts(new std::vector<WordPart>())
|
: wordParts(new std::vector<WordPart>())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
|
Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
|
||||||
bool enablePingSound, bool isReceivedWhisper,
|
bool enablePingSound, bool isReceivedWhisper,
|
||||||
bool isSentWhisper, bool includeChannel)
|
bool isSentWhisper, bool includeChannel)
|
||||||
: m_wordParts(new std::vector<WordPart>())
|
: wordParts(new std::vector<WordPart>())
|
||||||
{
|
{
|
||||||
m_parseTime = std::chrono::system_clock::now();
|
this->parseTime = std::chrono::system_clock::now();
|
||||||
|
|
||||||
auto words = std::vector<Word>();
|
auto words = std::vector<Word>();
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
|
||||||
auto iterator = tags.find("id");
|
auto iterator = tags.find("id");
|
||||||
|
|
||||||
if (iterator != tags.end()) {
|
if (iterator != tags.end()) {
|
||||||
m_id = iterator.value().toString();
|
this->id = iterator.value().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// timestamps
|
// timestamps
|
||||||
|
@ -74,10 +74,10 @@ Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
|
||||||
static QString buttonBanTooltip("Ban user");
|
static QString buttonBanTooltip("Ban user");
|
||||||
static QString buttonTimeoutTooltip("Timeout user");
|
static QString buttonTimeoutTooltip("Timeout user");
|
||||||
|
|
||||||
words.push_back(Word(Resources::buttonBan(), Word::ButtonBan, QString(),
|
words.push_back(Word(Resources::getButtonBan(), Word::ButtonBan, QString(),
|
||||||
buttonBanTooltip,
|
buttonBanTooltip,
|
||||||
Link(Link::UserBan, ircMessage.account())));
|
Link(Link::UserBan, ircMessage.account())));
|
||||||
words.push_back(Word(Resources::buttonTimeout(), Word::ButtonTimeout,
|
words.push_back(Word(Resources::getButtonTimeout(), Word::ButtonTimeout,
|
||||||
QString(), buttonTimeoutTooltip,
|
QString(), buttonTimeoutTooltip,
|
||||||
Link(Link::UserTimeout, ircMessage.account())));
|
Link(Link::UserTimeout, ircMessage.account())));
|
||||||
|
|
||||||
|
@ -95,29 +95,32 @@ Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
|
||||||
Emotes::getCheerBadge(cheer), Word::BadgeCheer, QString(),
|
Emotes::getCheerBadge(cheer), Word::BadgeCheer, QString(),
|
||||||
QString("Twitch Cheer" + QString::number(cheer))));
|
QString("Twitch Cheer" + QString::number(cheer))));
|
||||||
} else if (badge == "staff/1") {
|
} else if (badge == "staff/1") {
|
||||||
words.push_back(Word(Resources::badgeStaff(), Word::BadgeStaff,
|
words.push_back(Word(Resources::getBadgeStaff(),
|
||||||
QString(), QString("Twitch Staff")));
|
Word::BadgeStaff, QString(),
|
||||||
|
QString("Twitch Staff")));
|
||||||
} else if (badge == "admin/1") {
|
} else if (badge == "admin/1") {
|
||||||
words.push_back(Word(Resources::badgeAdmin(), Word::BadgeAdmin,
|
words.push_back(Word(Resources::getBadgeAdmin(),
|
||||||
QString(), QString("Twitch Admin")));
|
Word::BadgeAdmin, QString(),
|
||||||
|
QString("Twitch Admin")));
|
||||||
} else if (badge == "global_mod/1") {
|
} else if (badge == "global_mod/1") {
|
||||||
words.push_back(Word(Resources::badgeGlobalmod(),
|
words.push_back(Word(Resources::getBadgeGlobalmod(),
|
||||||
Word::BadgeGlobalMod, QString(),
|
Word::BadgeGlobalMod, QString(),
|
||||||
QString("Global Moderator")));
|
QString("Global Moderator")));
|
||||||
} else if (badge == "moderator/1") {
|
} else if (badge == "moderator/1") {
|
||||||
// TODO: implement this xD
|
// TODO: implement this xD
|
||||||
words.push_back(Word(
|
words.push_back(Word(
|
||||||
Resources::badgeTurbo(), Word::BadgeModerator, QString(),
|
Resources::getBadgeTurbo(), Word::BadgeModerator, QString(),
|
||||||
QString("Channel Moderator"))); // custom badge
|
QString("Channel Moderator"))); // custom badge
|
||||||
} else if (badge == "turbo/1") {
|
} else if (badge == "turbo/1") {
|
||||||
words.push_back(Word(Resources::badgeStaff(), Word::BadgeTurbo,
|
words.push_back(Word(Resources::getBadgeStaff(),
|
||||||
QString(), QString("Turbo Subscriber")));
|
Word::BadgeTurbo, QString(),
|
||||||
|
QString("Turbo Subscriber")));
|
||||||
} else if (badge == "broadcaster/1") {
|
} else if (badge == "broadcaster/1") {
|
||||||
words.push_back(Word(Resources::badgeBroadcaster(),
|
words.push_back(Word(Resources::getBadgeBroadcaster(),
|
||||||
Word::BadgeBroadcaster, QString(),
|
Word::BadgeBroadcaster, QString(),
|
||||||
QString("Channel Broadcaster")));
|
QString("Channel Broadcaster")));
|
||||||
} else if (badge == "premium/1") {
|
} else if (badge == "premium/1") {
|
||||||
words.push_back(Word(Resources::badgePremium(),
|
words.push_back(Word(Resources::getBadgePremium(),
|
||||||
Word::BadgePremium, QString(),
|
Word::BadgePremium, QString(),
|
||||||
QString("Twitch Prime")));
|
QString("Twitch Prime")));
|
||||||
}
|
}
|
||||||
|
@ -134,21 +137,21 @@ Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
|
||||||
|
|
||||||
// channel name
|
// channel name
|
||||||
if (includeChannel) {
|
if (includeChannel) {
|
||||||
QString channelName("#" + channel.name());
|
QString channelName("#" + channel.getName());
|
||||||
words.push_back(Word(channelName, Word::Misc,
|
words.push_back(Word(
|
||||||
ColorScheme::instance().SystemMessageColor,
|
channelName, Word::Misc, ColorScheme::instance().SystemMessageColor,
|
||||||
QString(channelName), QString(),
|
QString(channelName), QString(),
|
||||||
Link(Link::Url, channel.name() + "\n" + m_id)));
|
Link(Link::Url, channel.getName() + "\n" + this->id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// username
|
// username
|
||||||
m_userName = ircMessage.account();
|
this->userName = ircMessage.account();
|
||||||
|
|
||||||
if (m_userName.isEmpty()) {
|
if (this->userName.isEmpty()) {
|
||||||
auto iterator = tags.find("login");
|
auto iterator = tags.find("login");
|
||||||
|
|
||||||
if (iterator != tags.end()) {
|
if (iterator != tags.end()) {
|
||||||
m_userName = iterator.value().toString();
|
this->userName = iterator.value().toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,11 +171,11 @@ Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
|
||||||
(hasLocalizedName ? (" (" + ircMessage.account() + ")") : QString());
|
(hasLocalizedName ? (" (" + ircMessage.account() + ")") : QString());
|
||||||
|
|
||||||
if (isSentWhisper) {
|
if (isSentWhisper) {
|
||||||
userDisplayString = IrcManager::account->username() + " -> ";
|
userDisplayString = IrcManager::account->getUsername() + " -> ";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isReceivedWhisper) {
|
if (isReceivedWhisper) {
|
||||||
userDisplayString += " -> " + IrcManager::account->username();
|
userDisplayString += " -> " + IrcManager::account->getUsername();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ircMessage.isAction()) {
|
if (!ircMessage.isAction()) {
|
||||||
|
@ -182,8 +185,8 @@ Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
|
||||||
words.push_back(Word(userDisplayString, Word::Username, usernameColor,
|
words.push_back(Word(userDisplayString, Word::Username, usernameColor,
|
||||||
userDisplayString, QString()));
|
userDisplayString, QString()));
|
||||||
|
|
||||||
// highlights
|
// highlights
|
||||||
// TODO: implement this xD
|
// TODO: implement this xD
|
||||||
|
|
||||||
// bits
|
// bits
|
||||||
QString bits = "";
|
QString bits = "";
|
||||||
|
@ -254,13 +257,13 @@ Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
|
||||||
currentTwitchEmote->first == i) {
|
currentTwitchEmote->first == i) {
|
||||||
words.push_back(Word(currentTwitchEmote->second,
|
words.push_back(Word(currentTwitchEmote->second,
|
||||||
Word::TwitchEmoteImage,
|
Word::TwitchEmoteImage,
|
||||||
currentTwitchEmote->second->name(),
|
currentTwitchEmote->second->getName(),
|
||||||
currentTwitchEmote->second->name() +
|
currentTwitchEmote->second->getName() +
|
||||||
QString("\nTwitch Emote")));
|
QString("\nTwitch Emote")));
|
||||||
words.push_back(Word(currentTwitchEmote->second->name(),
|
words.push_back(Word(currentTwitchEmote->second->getName(),
|
||||||
Word::TwitchEmoteText, textColor,
|
Word::TwitchEmoteText, textColor,
|
||||||
currentTwitchEmote->second->name(),
|
currentTwitchEmote->second->getName(),
|
||||||
currentTwitchEmote->second->name() +
|
currentTwitchEmote->second->getName() +
|
||||||
QString("\nTwitch Emote")));
|
QString("\nTwitch Emote")));
|
||||||
|
|
||||||
i += split.length() + 1;
|
i += split.length() + 1;
|
||||||
|
@ -313,12 +316,12 @@ Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
|
||||||
color + "/1");
|
color + "/1");
|
||||||
|
|
||||||
LazyLoadedImage *imageAnimated =
|
LazyLoadedImage *imageAnimated =
|
||||||
Emotes::miscImageFromCache().getOrAdd(
|
Emotes::getMiscImageFromCache().getOrAdd(
|
||||||
bitsLinkAnimated, [&bitsLinkAnimated] {
|
bitsLinkAnimated, [&bitsLinkAnimated] {
|
||||||
return new LazyLoadedImage(bitsLinkAnimated);
|
return new LazyLoadedImage(bitsLinkAnimated);
|
||||||
});
|
});
|
||||||
LazyLoadedImage *image =
|
LazyLoadedImage *image =
|
||||||
Emotes::miscImageFromCache().getOrAdd(
|
Emotes::getMiscImageFromCache().getOrAdd(
|
||||||
bitsLink, [&bitsLink] {
|
bitsLink, [&bitsLink] {
|
||||||
return new LazyLoadedImage(bitsLink);
|
return new LazyLoadedImage(bitsLink);
|
||||||
});
|
});
|
||||||
|
@ -354,15 +357,15 @@ Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
|
||||||
LazyLoadedImage *bttvEmote;
|
LazyLoadedImage *bttvEmote;
|
||||||
|
|
||||||
// TODO: Implement this (ignored emotes)
|
// TODO: Implement this (ignored emotes)
|
||||||
if (Emotes::bttvEmotes().tryGet(string, bttvEmote) ||
|
if (Emotes::getBttvEmotes().tryGet(string, bttvEmote) ||
|
||||||
channel.bttvChannelEmotes().tryGet(string, bttvEmote) ||
|
channel.getBttvChannelEmotes().tryGet(string, bttvEmote) ||
|
||||||
Emotes::ffzEmotes().tryGet(string, bttvEmote) ||
|
Emotes::getFfzEmotes().tryGet(string, bttvEmote) ||
|
||||||
channel.ffzChannelEmotes().tryGet(string, bttvEmote) ||
|
channel.getFfzChannelEmotes().tryGet(string, bttvEmote) ||
|
||||||
Emotes::chatterinoEmotes().tryGet(string, bttvEmote)) {
|
Emotes::getChatterinoEmotes().tryGet(string, bttvEmote)) {
|
||||||
words.push_back(Word(bttvEmote, Word::BttvEmoteImage,
|
words.push_back(Word(bttvEmote, Word::BttvEmoteImage,
|
||||||
bttvEmote->name(),
|
bttvEmote->getName(),
|
||||||
bttvEmote->tooltip(),
|
bttvEmote->getTooltip(),
|
||||||
Link(Link::Url, bttvEmote->url())));
|
Link(Link::Url, bttvEmote->getUrl())));
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -376,17 +379,17 @@ Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
|
||||||
} else { // is emoji
|
} else { // is emoji
|
||||||
static QString emojiTooltip("Emoji");
|
static QString emojiTooltip("Emoji");
|
||||||
|
|
||||||
words.push_back(
|
words.push_back(Word(image, Word::EmojiImage, image->getName(),
|
||||||
Word(image, Word::EmojiImage, image->name(), emojiTooltip));
|
emojiTooltip));
|
||||||
Word(image->name(), Word::EmojiText, textColor, image->name(),
|
Word(image->getName(), Word::EmojiText, textColor,
|
||||||
emojiTooltip);
|
image->getName(), emojiTooltip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
i += split.length() + 1;
|
i += split.length() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->m_words = words;
|
this->words = words;
|
||||||
|
|
||||||
// TODO: Implement this xD
|
// TODO: Implement this xD
|
||||||
// if (!isReceivedWhisper &&
|
// if (!isReceivedWhisper &&
|
||||||
|
@ -404,34 +407,35 @@ Message::layout(int width, bool enableEmoteMargins)
|
||||||
int mediumTextLineHeight = Fonts::getFontMetrics(Fonts::Medium).height();
|
int mediumTextLineHeight = Fonts::getFontMetrics(Fonts::Medium).height();
|
||||||
int spaceWidth = 4;
|
int spaceWidth = 4;
|
||||||
|
|
||||||
bool redraw = width != m_currentLayoutWidth || m_relayoutRequested;
|
bool redraw = width != this->currentLayoutWidth || this->relayoutRequested;
|
||||||
|
|
||||||
bool recalculateImages = m_emoteGeneration != Emotes::generation();
|
bool recalculateImages = this->emoteGeneration != Emotes::getGeneration();
|
||||||
bool recalculateText = m_fontGeneration != Fonts::generation();
|
bool recalculateText = this->fontGeneration != Fonts::getGeneration();
|
||||||
|
|
||||||
if (recalculateImages || recalculateText) {
|
if (recalculateImages || recalculateText) {
|
||||||
m_emoteGeneration = Emotes::generation();
|
this->emoteGeneration = Emotes::getGeneration();
|
||||||
m_fontGeneration = Fonts::generation();
|
this->fontGeneration = Fonts::getGeneration();
|
||||||
|
|
||||||
redraw = true;
|
redraw = true;
|
||||||
|
|
||||||
for (auto &word : m_words) {
|
for (auto &word : this->words) {
|
||||||
if (word.isImage()) {
|
if (word.isImage()) {
|
||||||
if (recalculateImages) {
|
if (recalculateImages) {
|
||||||
auto &image = word.getImage();
|
auto &image = word.getImage();
|
||||||
|
|
||||||
qreal w = image.width();
|
qreal w = image.getWidth();
|
||||||
qreal h = image.height();
|
qreal h = image.getHeight();
|
||||||
|
|
||||||
if (AppSettings::scaleEmotesByLineHeight()) {
|
if (AppSettings::getScaleEmotesByLineHeight()) {
|
||||||
word.setSize(
|
word.setSize(w * mediumTextLineHeight / h *
|
||||||
w * mediumTextLineHeight / h *
|
AppSettings::getEmoteScale(),
|
||||||
AppSettings::emoteScale(),
|
mediumTextLineHeight *
|
||||||
mediumTextLineHeight * AppSettings::emoteScale());
|
AppSettings::getEmoteScale());
|
||||||
} else {
|
} else {
|
||||||
word.setSize(
|
word.setSize(
|
||||||
w * image.scale() * AppSettings::emoteScale(),
|
w * image.getScale() * AppSettings::getEmoteScale(),
|
||||||
h * image.scale() * AppSettings::emoteScale());
|
h * image.getScale() *
|
||||||
|
AppSettings::getEmoteScale());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -463,32 +467,32 @@ Message::layout(int width, bool enableEmoteMargins)
|
||||||
for (int i = lineStart; i < parts->size(); i++) {
|
for (int i = lineStart; i < parts->size(); i++) {
|
||||||
WordPart &wordPart2 = parts->at(i);
|
WordPart &wordPart2 = parts->at(i);
|
||||||
|
|
||||||
wordPart2.setY(wordPart2.y() + lineHeight);
|
wordPart2.setY(wordPart2.getY() + lineHeight);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
int flags = AppSettings::wordTypeMask();
|
int flags = AppSettings::getWordTypeMask();
|
||||||
|
|
||||||
for (auto it = m_words.begin(); it != m_words.end(); ++it) {
|
for (auto it = this->words.begin(); it != this->words.end(); ++it) {
|
||||||
Word &word = *it;
|
Word &word = *it;
|
||||||
|
|
||||||
if ((word.type() & flags) == Word::None) {
|
if ((word.getType() & flags) == Word::None) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int xOffset = 0, yOffset = 0;
|
int xOffset = 0, yOffset = 0;
|
||||||
|
|
||||||
if (enableEmoteMargins) {
|
if (enableEmoteMargins) {
|
||||||
if (word.isImage() && word.getImage().isHat()) {
|
if (word.isImage() && word.getImage().getIsHat()) {
|
||||||
xOffset = -word.width() + 2;
|
xOffset = -word.getWidth() + 2;
|
||||||
} else {
|
} else {
|
||||||
xOffset = word.xOffset();
|
xOffset = word.getXOffset();
|
||||||
yOffset = word.yOffset();
|
yOffset = word.getYOffset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// word wrapping
|
// word wrapping
|
||||||
if (word.isText() && word.width() + MARGIN_LEFT > right) {
|
if (word.isText() && word.getWidth() + MARGIN_LEFT > right) {
|
||||||
alignParts();
|
alignParts();
|
||||||
|
|
||||||
y += lineHeight;
|
y += lineHeight;
|
||||||
|
@ -500,7 +504,7 @@ Message::layout(int width, bool enableEmoteMargins)
|
||||||
|
|
||||||
int width = 0;
|
int width = 0;
|
||||||
|
|
||||||
std::vector<short> &charWidths = word.characterWidthCache();
|
std::vector<short> &charWidths = word.getCharacterWidthCache();
|
||||||
|
|
||||||
if (charWidths.size() == 0) {
|
if (charWidths.size() == 0) {
|
||||||
charWidths.reserve(text.length());
|
charWidths.reserve(text.length());
|
||||||
|
@ -515,7 +519,7 @@ Message::layout(int width, bool enableEmoteMargins)
|
||||||
QString mid = text.mid(start, i - start - 1);
|
QString mid = text.mid(start, i - start - 1);
|
||||||
|
|
||||||
parts->push_back(WordPart(word, MARGIN_LEFT, y, width,
|
parts->push_back(WordPart(word, MARGIN_LEFT, y, width,
|
||||||
word.height(), mid, mid));
|
word.getHeight(), mid, mid));
|
||||||
|
|
||||||
y += metrics.height();
|
y += metrics.height();
|
||||||
|
|
||||||
|
@ -528,11 +532,11 @@ Message::layout(int width, bool enableEmoteMargins)
|
||||||
QString mid(text.mid(start));
|
QString mid(text.mid(start));
|
||||||
width = metrics.width(mid);
|
width = metrics.width(mid);
|
||||||
|
|
||||||
parts->push_back(WordPart(word, MARGIN_LEFT, y - word.height(),
|
parts->push_back(WordPart(word, MARGIN_LEFT, y - word.getHeight(),
|
||||||
width, word.height(), mid, mid));
|
width, word.getHeight(), mid, mid));
|
||||||
x = width + MARGIN_LEFT + spaceWidth;
|
x = width + MARGIN_LEFT + spaceWidth;
|
||||||
|
|
||||||
lineHeight = word.height();
|
lineHeight = word.getHeight();
|
||||||
|
|
||||||
lineStart = parts->size() - 1;
|
lineStart = parts->size() - 1;
|
||||||
|
|
||||||
|
@ -540,14 +544,14 @@ Message::layout(int width, bool enableEmoteMargins)
|
||||||
}
|
}
|
||||||
|
|
||||||
// fits in the line
|
// fits in the line
|
||||||
else if (first || x + word.width() + xOffset <= right) {
|
else if (first || x + word.getWidth() + xOffset <= right) {
|
||||||
parts->push_back(
|
parts->push_back(
|
||||||
WordPart(word, x, y - word.height(), word.copyText()));
|
WordPart(word, x, y - word.getHeight(), word.getCopyText()));
|
||||||
|
|
||||||
x += word.width() + xOffset;
|
x += word.getWidth() + xOffset;
|
||||||
x += spaceWidth;
|
x += spaceWidth;
|
||||||
|
|
||||||
lineHeight = std::max(word.height(), lineHeight);
|
lineHeight = std::max(word.getHeight(), lineHeight);
|
||||||
|
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
@ -558,25 +562,25 @@ Message::layout(int width, bool enableEmoteMargins)
|
||||||
|
|
||||||
y += lineHeight;
|
y += lineHeight;
|
||||||
|
|
||||||
parts->push_back(WordPart(word, MARGIN_LEFT, y - word.height(),
|
parts->push_back(WordPart(word, MARGIN_LEFT, y - word.getHeight(),
|
||||||
word.copyText()));
|
word.getCopyText()));
|
||||||
|
|
||||||
lineStart = parts->size() - 1;
|
lineStart = parts->size() - 1;
|
||||||
|
|
||||||
lineHeight = word.height();
|
lineHeight = word.getHeight();
|
||||||
|
|
||||||
x = word.width() + MARGIN_LEFT;
|
x = word.getWidth() + MARGIN_LEFT;
|
||||||
x += spaceWidth;
|
x += spaceWidth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
alignParts();
|
alignParts();
|
||||||
|
|
||||||
auto tmp = m_wordParts;
|
auto tmp = this->wordParts;
|
||||||
m_wordParts = parts;
|
this->wordParts = parts;
|
||||||
delete tmp;
|
delete tmp;
|
||||||
|
|
||||||
m_height = y + lineHeight;
|
this->height = y + lineHeight;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
76
message.h
76
message.h
|
@ -19,69 +19,69 @@ public:
|
||||||
|
|
||||||
~Message()
|
~Message()
|
||||||
{
|
{
|
||||||
if (m_wordParts != NULL) {
|
if (wordParts != NULL) {
|
||||||
delete m_wordParts;
|
delete wordParts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
canHighlightTab() const
|
getCanHighlightTab() const
|
||||||
{
|
{
|
||||||
return m_highlightTab;
|
return highlightTab;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &
|
const QString &
|
||||||
timeoutUser() const
|
getTimeoutUser() const
|
||||||
{
|
{
|
||||||
return m_timeoutUser;
|
return timeoutUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
timeoutCount() const
|
getTimeoutCount() const
|
||||||
{
|
{
|
||||||
return m_timeoutCount;
|
return timeoutCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &
|
const QString &
|
||||||
userName() const
|
getUserName() const
|
||||||
{
|
{
|
||||||
return m_userName;
|
return userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &
|
const QString &
|
||||||
displayName() const
|
getDisplayName() const
|
||||||
{
|
{
|
||||||
return m_displayName;
|
return displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<Word>
|
const std::vector<Word>
|
||||||
words() const
|
getWords() const
|
||||||
{
|
{
|
||||||
return m_words;
|
return words;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<WordPart>
|
const std::vector<WordPart>
|
||||||
wordParts() const
|
getWordParts() const
|
||||||
{
|
{
|
||||||
return *m_wordParts;
|
return *wordParts;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
disabled() const
|
getDisabled() const
|
||||||
{
|
{
|
||||||
return m_disabled;
|
return disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &
|
const QString &
|
||||||
id() const
|
getId() const
|
||||||
{
|
{
|
||||||
return m_id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
height() const
|
getHeight() const
|
||||||
{
|
{
|
||||||
return m_height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool layout(int width, bool enableEmoteMargins = true);
|
bool layout(int width, bool enableEmoteMargins = true);
|
||||||
|
@ -89,7 +89,7 @@ public:
|
||||||
void
|
void
|
||||||
requestRelayout()
|
requestRelayout()
|
||||||
{
|
{
|
||||||
m_relayoutRequested = true;
|
relayoutRequested = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -103,25 +103,25 @@ private:
|
||||||
|
|
||||||
static QRegularExpression *cheerRegex;
|
static QRegularExpression *cheerRegex;
|
||||||
|
|
||||||
bool m_highlightTab = false;
|
bool highlightTab = false;
|
||||||
QString m_timeoutUser = "";
|
QString timeoutUser = "";
|
||||||
int m_timeoutCount = 0;
|
int timeoutCount = 0;
|
||||||
bool m_disabled = false;
|
bool disabled = false;
|
||||||
std::chrono::time_point<std::chrono::system_clock> m_parseTime;
|
std::chrono::time_point<std::chrono::system_clock> parseTime;
|
||||||
|
|
||||||
QString m_userName = "";
|
QString userName = "";
|
||||||
QString m_displayName = "";
|
QString displayName = "";
|
||||||
QString m_id = "";
|
QString id = "";
|
||||||
|
|
||||||
int m_height = 0;
|
int height = 0;
|
||||||
|
|
||||||
std::vector<Word> m_words;
|
std::vector<Word> words;
|
||||||
std::vector<WordPart> *m_wordParts;
|
std::vector<WordPart> *wordParts;
|
||||||
|
|
||||||
long m_currentLayoutWidth = -1;
|
long currentLayoutWidth = -1;
|
||||||
bool m_relayoutRequested = true;
|
bool relayoutRequested = true;
|
||||||
int m_fontGeneration = -1;
|
int fontGeneration = -1;
|
||||||
int m_emoteGeneration = -1;
|
int emoteGeneration = -1;
|
||||||
|
|
||||||
static QString matchLink(const QString &string);
|
static QString matchLink(const QString &string);
|
||||||
|
|
||||||
|
|
46
notebook.cpp
46
notebook.cpp
|
@ -12,19 +12,19 @@
|
||||||
|
|
||||||
Notebook::Notebook(QWidget *parent)
|
Notebook::Notebook(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, m_addButton(this)
|
, addButton(this)
|
||||||
, m_settingsButton(this)
|
, settingsButton(this)
|
||||||
, m_userButton(this)
|
, userButton(this)
|
||||||
{
|
{
|
||||||
connect(&m_settingsButton, SIGNAL(clicked()), this,
|
connect(&this->settingsButton, SIGNAL(clicked()), this,
|
||||||
SLOT(settingsButtonClicked()));
|
SLOT(settingsButtonClicked()));
|
||||||
|
|
||||||
m_settingsButton.resize(24, 24);
|
this->settingsButton.resize(24, 24);
|
||||||
m_settingsButton.icon = NotebookButton::IconSettings;
|
this->settingsButton.icon = NotebookButton::IconSettings;
|
||||||
m_userButton.resize(24, 24);
|
this->userButton.resize(24, 24);
|
||||||
m_userButton.move(24, 0);
|
this->userButton.move(24, 0);
|
||||||
m_userButton.icon = NotebookButton::IconUser;
|
this->userButton.icon = NotebookButton::IconUser;
|
||||||
m_addButton.resize(24, 24);
|
this->addButton.resize(24, 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -41,11 +41,11 @@ Notebook::addPage()
|
||||||
auto tab = new NotebookTab(this);
|
auto tab = new NotebookTab(this);
|
||||||
auto page = new NotebookPage(this, tab);
|
auto page = new NotebookPage(this, tab);
|
||||||
|
|
||||||
if (m_pages.count() == 0) {
|
if (this->pages.count() == 0) {
|
||||||
select(page);
|
select(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->m_pages.append(page);
|
this->pages.append(page);
|
||||||
|
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ Notebook::addPage()
|
||||||
void
|
void
|
||||||
Notebook::select(NotebookPage *page)
|
Notebook::select(NotebookPage *page)
|
||||||
{
|
{
|
||||||
if (page == m_selected)
|
if (page == this->selectedPage)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (page != nullptr) {
|
if (page != nullptr) {
|
||||||
|
@ -61,12 +61,12 @@ Notebook::select(NotebookPage *page)
|
||||||
page->tab->setSelected(true);
|
page->tab->setSelected(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_selected != nullptr) {
|
if (this->selectedPage != nullptr) {
|
||||||
m_selected->setHidden(true);
|
this->selectedPage->setHidden(true);
|
||||||
m_selected->tab->setSelected(false);
|
this->selectedPage->tab->setSelected(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_selected = page;
|
this->selectedPage = page;
|
||||||
|
|
||||||
performLayout();
|
performLayout();
|
||||||
}
|
}
|
||||||
|
@ -78,11 +78,11 @@ Notebook::performLayout()
|
||||||
int tabHeight = 16;
|
int tabHeight = 16;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
|
||||||
for (auto &i : m_pages) {
|
for (auto &i : this->pages) {
|
||||||
tabHeight = i->tab->height();
|
tabHeight = i->tab->height();
|
||||||
|
|
||||||
if (!first &&
|
if (!first &&
|
||||||
(i == m_pages.last() ? tabHeight : 0) + x + i->tab->width() >
|
(i == this->pages.last() ? tabHeight : 0) + x + i->tab->width() >
|
||||||
width()) {
|
width()) {
|
||||||
y += i->tab->height();
|
y += i->tab->height();
|
||||||
i->tab->move(0, y);
|
i->tab->move(0, y);
|
||||||
|
@ -95,11 +95,11 @@ Notebook::performLayout()
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->m_addButton.move(x, y);
|
this->addButton.move(x, y);
|
||||||
|
|
||||||
if (m_selected != nullptr) {
|
if (this->selectedPage != nullptr) {
|
||||||
m_selected->move(0, y + tabHeight);
|
this->selectedPage->move(0, y + tabHeight);
|
||||||
m_selected->resize(width(), height() - y - tabHeight);
|
this->selectedPage->resize(width(), height() - y - tabHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
notebook.h
14
notebook.h
|
@ -21,9 +21,9 @@ public:
|
||||||
void select(NotebookPage *page);
|
void select(NotebookPage *page);
|
||||||
|
|
||||||
NotebookPage *
|
NotebookPage *
|
||||||
selected()
|
getSelectedPage()
|
||||||
{
|
{
|
||||||
return m_selected;
|
return selectedPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void performLayout();
|
void performLayout();
|
||||||
|
@ -37,13 +37,13 @@ public slots:
|
||||||
void settingsButtonClicked();
|
void settingsButtonClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<NotebookPage *> m_pages;
|
QList<NotebookPage *> pages;
|
||||||
|
|
||||||
NotebookButton m_addButton;
|
NotebookButton addButton;
|
||||||
NotebookButton m_settingsButton;
|
NotebookButton settingsButton;
|
||||||
NotebookButton m_userButton;
|
NotebookButton userButton;
|
||||||
|
|
||||||
NotebookPage *m_selected = nullptr;
|
NotebookPage *selectedPage = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NOTEBOOK_H
|
#endif // NOTEBOOK_H
|
||||||
|
|
|
@ -14,9 +14,9 @@ std::pair<int, int> NotebookPage::dropPosition = std::pair<int, int>(-1, -1);
|
||||||
|
|
||||||
NotebookPage::NotebookPage(QWidget *parent, NotebookTab *tab)
|
NotebookPage::NotebookPage(QWidget *parent, NotebookTab *tab)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, m_parentbox(this)
|
, parentbox(this)
|
||||||
, m_preview(this)
|
, preview(this)
|
||||||
, m_chatWidgets()
|
, chatWidgets()
|
||||||
{
|
{
|
||||||
this->tab = tab;
|
this->tab = tab;
|
||||||
tab->page = this;
|
tab->page = this;
|
||||||
|
@ -24,27 +24,28 @@ NotebookPage::NotebookPage(QWidget *parent, NotebookTab *tab)
|
||||||
setHidden(true);
|
setHidden(true);
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
m_parentbox.addSpacing(2);
|
this->parentbox.addSpacing(2);
|
||||||
m_parentbox.addLayout(&m_hbox);
|
this->parentbox.addLayout(&this->hbox);
|
||||||
m_parentbox.setMargin(0);
|
this->parentbox.setMargin(0);
|
||||||
|
|
||||||
m_hbox.setSpacing(1);
|
this->hbox.setSpacing(1);
|
||||||
m_hbox.setMargin(0);
|
this->hbox.setMargin(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<int, int>
|
std::pair<int, int>
|
||||||
NotebookPage::removeFromLayout(ChatWidget *widget)
|
NotebookPage::removeFromLayout(ChatWidget *widget)
|
||||||
{
|
{
|
||||||
for (auto it = m_chatWidgets.begin(); it != m_chatWidgets.end(); ++it) {
|
for (auto it = this->chatWidgets.begin(); it != this->chatWidgets.end();
|
||||||
|
++it) {
|
||||||
if (*it == widget) {
|
if (*it == widget) {
|
||||||
m_chatWidgets.erase(it);
|
this->chatWidgets.erase(it);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < m_hbox.count(); ++i) {
|
for (int i = 0; i < this->hbox.count(); ++i) {
|
||||||
auto vbox = static_cast<QVBoxLayout *>(m_hbox.itemAt(i));
|
auto vbox = static_cast<QVBoxLayout *>(this->hbox.itemAt(i));
|
||||||
|
|
||||||
for (int j = 0; j < vbox->count(); ++j) {
|
for (int j = 0; j < vbox->count(); ++j) {
|
||||||
if (vbox->itemAt(j)->widget() != widget)
|
if (vbox->itemAt(j)->widget() != widget)
|
||||||
|
@ -55,7 +56,7 @@ NotebookPage::removeFromLayout(ChatWidget *widget)
|
||||||
bool isLastItem = vbox->count() == 0;
|
bool isLastItem = vbox->count() == 0;
|
||||||
|
|
||||||
if (isLastItem) {
|
if (isLastItem) {
|
||||||
m_hbox.removeItem(vbox);
|
this->hbox.removeItem(vbox);
|
||||||
|
|
||||||
delete vbox;
|
delete vbox;
|
||||||
}
|
}
|
||||||
|
@ -72,14 +73,14 @@ NotebookPage::addToLayout(
|
||||||
ChatWidget *widget,
|
ChatWidget *widget,
|
||||||
std::pair<int, int> position = std::pair<int, int>(-1, -1))
|
std::pair<int, int> position = std::pair<int, int>(-1, -1))
|
||||||
{
|
{
|
||||||
m_chatWidgets.push_back(widget);
|
this->chatWidgets.push_back(widget);
|
||||||
|
|
||||||
// add vbox at the end
|
// add vbox at the end
|
||||||
if (position.first < 0 || position.first >= m_hbox.count()) {
|
if (position.first < 0 || position.first >= this->hbox.count()) {
|
||||||
auto vbox = new QVBoxLayout();
|
auto vbox = new QVBoxLayout();
|
||||||
vbox->addWidget(widget);
|
vbox->addWidget(widget);
|
||||||
|
|
||||||
m_hbox.addLayout(vbox);
|
this->hbox.addLayout(vbox);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,12 +89,12 @@ NotebookPage::addToLayout(
|
||||||
auto vbox = new QVBoxLayout();
|
auto vbox = new QVBoxLayout();
|
||||||
vbox->addWidget(widget);
|
vbox->addWidget(widget);
|
||||||
|
|
||||||
m_hbox.insertLayout(position.first, vbox);
|
this->hbox.insertLayout(position.first, vbox);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add to existing vbox
|
// add to existing vbox
|
||||||
auto vbox = static_cast<QVBoxLayout *>(m_hbox.itemAt(position.first));
|
auto vbox = static_cast<QVBoxLayout *>(this->hbox.itemAt(position.first));
|
||||||
|
|
||||||
vbox->insertWidget(std::max(0, std::min(vbox->count(), position.second)),
|
vbox->insertWidget(std::max(0, std::min(vbox->count(), position.second)),
|
||||||
widget);
|
widget);
|
||||||
|
@ -102,7 +103,7 @@ NotebookPage::addToLayout(
|
||||||
void
|
void
|
||||||
NotebookPage::enterEvent(QEvent *)
|
NotebookPage::enterEvent(QEvent *)
|
||||||
{
|
{
|
||||||
if (m_hbox.count() == 0) {
|
if (this->hbox.count() == 0) {
|
||||||
setCursor(QCursor(Qt::PointingHandCursor));
|
setCursor(QCursor(Qt::PointingHandCursor));
|
||||||
} else {
|
} else {
|
||||||
setCursor(QCursor(Qt::ArrowCursor));
|
setCursor(QCursor(Qt::ArrowCursor));
|
||||||
|
@ -117,7 +118,7 @@ NotebookPage::leaveEvent(QEvent *)
|
||||||
void
|
void
|
||||||
NotebookPage::mouseReleaseEvent(QMouseEvent *event)
|
NotebookPage::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (m_hbox.count() == 0 && event->button() == Qt::LeftButton) {
|
if (this->hbox.count() == 0 && event->button() == Qt::LeftButton) {
|
||||||
addToLayout(new ChatWidget(), std::pair<int, int>(-1, -1));
|
addToLayout(new ChatWidget(), std::pair<int, int>(-1, -1));
|
||||||
|
|
||||||
setCursor(QCursor(Qt::ArrowCursor));
|
setCursor(QCursor(Qt::ArrowCursor));
|
||||||
|
@ -131,27 +132,27 @@ NotebookPage::dragEnterEvent(QDragEnterEvent *event)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (isDraggingSplit) {
|
if (isDraggingSplit) {
|
||||||
m_dropRegions.clear();
|
this->dropRegions.clear();
|
||||||
|
|
||||||
if (m_hbox.count() == 0) {
|
if (this->hbox.count() == 0) {
|
||||||
m_dropRegions.push_back(
|
this->dropRegions.push_back(
|
||||||
DropRegion(rect(), std::pair<int, int>(-1, -1)));
|
DropRegion(rect(), std::pair<int, int>(-1, -1)));
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < m_hbox.count() + 1; ++i) {
|
for (int i = 0; i < this->hbox.count() + 1; ++i) {
|
||||||
m_dropRegions.push_back(DropRegion(
|
this->dropRegions.push_back(DropRegion(
|
||||||
QRect(((i * 4 - 1) * width() / m_hbox.count()) / 4, 0,
|
QRect(((i * 4 - 1) * width() / this->hbox.count()) / 4, 0,
|
||||||
width() / m_hbox.count() / 2, height()),
|
width() / this->hbox.count() / 2, height()),
|
||||||
std::pair<int, int>(i, -1)));
|
std::pair<int, int>(i, -1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < m_hbox.count(); ++i) {
|
for (int i = 0; i < this->hbox.count(); ++i) {
|
||||||
auto vbox = static_cast<QVBoxLayout *>(m_hbox.itemAt(i));
|
auto vbox = static_cast<QVBoxLayout *>(this->hbox.itemAt(i));
|
||||||
|
|
||||||
for (int j = 0; j < vbox->count() + 1; ++j) {
|
for (int j = 0; j < vbox->count() + 1; ++j) {
|
||||||
m_dropRegions.push_back(DropRegion(
|
this->dropRegions.push_back(DropRegion(
|
||||||
QRect(i * width() / m_hbox.count(),
|
QRect(i * width() / this->hbox.count(),
|
||||||
((j * 2 - 1) * height() / vbox->count()) / 2,
|
((j * 2 - 1) * height() / vbox->count()) / 2,
|
||||||
width() / m_hbox.count(),
|
width() / this->hbox.count(),
|
||||||
height() / vbox->count()),
|
height() / vbox->count()),
|
||||||
std::pair<int, int>(i, j)));
|
std::pair<int, int>(i, j)));
|
||||||
}
|
}
|
||||||
|
@ -173,20 +174,20 @@ NotebookPage::dragMoveEvent(QDragMoveEvent *event)
|
||||||
void
|
void
|
||||||
NotebookPage::setPreviewRect(QPoint mousePos)
|
NotebookPage::setPreviewRect(QPoint mousePos)
|
||||||
{
|
{
|
||||||
for (DropRegion region : m_dropRegions) {
|
for (DropRegion region : this->dropRegions) {
|
||||||
if (region.rect.contains(mousePos)) {
|
if (region.rect.contains(mousePos)) {
|
||||||
m_preview.setBounds(region.rect);
|
this->preview.setBounds(region.rect);
|
||||||
// m_preview.move(region.rect.x(), region.rect.y());
|
// this->preview.move(region.rect.x(), region.rect.y());
|
||||||
// m_preview.resize(region.rect.width(),
|
// this->preview.resize(region.rect.width(),
|
||||||
// region.rect.height());
|
// region.rect.height());
|
||||||
m_preview.show();
|
this->preview.show();
|
||||||
m_preview.raise();
|
this->preview.raise();
|
||||||
|
|
||||||
dropPosition = region.position;
|
dropPosition = region.position;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
m_preview.hide();
|
this->preview.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -194,7 +195,7 @@ NotebookPage::setPreviewRect(QPoint mousePos)
|
||||||
void
|
void
|
||||||
NotebookPage::dragLeaveEvent(QDragLeaveEvent *event)
|
NotebookPage::dragLeaveEvent(QDragLeaveEvent *event)
|
||||||
{
|
{
|
||||||
m_preview.hide();
|
this->preview.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -208,7 +209,7 @@ NotebookPage::dropEvent(QDropEvent *event)
|
||||||
addToLayout(NotebookPage::draggingSplit, dropPosition);
|
addToLayout(NotebookPage::draggingSplit, dropPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_preview.hide();
|
this->preview.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -216,7 +217,7 @@ NotebookPage::paintEvent(QPaintEvent *)
|
||||||
{
|
{
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
|
||||||
if (m_hbox.count() == 0) {
|
if (this->hbox.count() == 0) {
|
||||||
painter.fillRect(rect(), ColorScheme::instance().ChatBackground);
|
painter.fillRect(rect(), ColorScheme::instance().ChatBackground);
|
||||||
|
|
||||||
painter.fillRect(0, 0, width(), 2,
|
painter.fillRect(0, 0, width(), 2,
|
||||||
|
|
|
@ -24,9 +24,9 @@ public:
|
||||||
void addToLayout(ChatWidget *widget, std::pair<int, int> position);
|
void addToLayout(ChatWidget *widget, std::pair<int, int> position);
|
||||||
|
|
||||||
const std::vector<ChatWidget *> &
|
const std::vector<ChatWidget *> &
|
||||||
chatWidgets() const
|
getChatWidgets() const
|
||||||
{
|
{
|
||||||
return m_chatWidgets;
|
return chatWidgets;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isDraggingSplit;
|
static bool isDraggingSplit;
|
||||||
|
@ -56,13 +56,13 @@ protected:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
QVBoxLayout m_parentbox;
|
QVBoxLayout parentbox;
|
||||||
QHBoxLayout m_hbox;
|
QHBoxLayout hbox;
|
||||||
|
|
||||||
std::vector<ChatWidget *> m_chatWidgets;
|
std::vector<ChatWidget *> chatWidgets;
|
||||||
std::vector<DropRegion> m_dropRegions;
|
std::vector<DropRegion> dropRegions;
|
||||||
|
|
||||||
NotebookPageDropPreview m_preview;
|
NotebookPageDropPreview preview;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setPreviewRect(QPoint mousePos);
|
void setPreviewRect(QPoint mousePos);
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
NotebookPageDropPreview::NotebookPageDropPreview(QWidget *parent)
|
NotebookPageDropPreview::NotebookPageDropPreview(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, m_positionAnimation(this, "geometry")
|
, positionAnimation(this, "geometry")
|
||||||
, m_desiredGeometry()
|
, desiredGeometry()
|
||||||
{
|
{
|
||||||
setHidden(true);
|
setHidden(true);
|
||||||
}
|
}
|
||||||
|
@ -22,15 +22,15 @@ NotebookPageDropPreview::paintEvent(QPaintEvent *)
|
||||||
void
|
void
|
||||||
NotebookPageDropPreview::setBounds(const QRect &rect)
|
NotebookPageDropPreview::setBounds(const QRect &rect)
|
||||||
{
|
{
|
||||||
if (rect == m_desiredGeometry) {
|
if (rect == this->desiredGeometry) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_positionAnimation.stop();
|
this->positionAnimation.stop();
|
||||||
m_positionAnimation.setDuration(50);
|
this->positionAnimation.setDuration(50);
|
||||||
m_positionAnimation.setStartValue(geometry());
|
this->positionAnimation.setStartValue(geometry());
|
||||||
m_positionAnimation.setEndValue(rect);
|
this->positionAnimation.setEndValue(rect);
|
||||||
m_positionAnimation.start();
|
this->positionAnimation.start();
|
||||||
|
|
||||||
m_desiredGeometry = rect;
|
this->desiredGeometry = rect;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,8 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *);
|
void paintEvent(QPaintEvent *);
|
||||||
|
|
||||||
QPropertyAnimation m_positionAnimation;
|
QPropertyAnimation positionAnimation;
|
||||||
QRect m_desiredGeometry;
|
QRect desiredGeometry;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NOTEBOOKPAGEDROPPREVIEW_H
|
#endif // NOTEBOOKPAGEDROPPREVIEW_H
|
||||||
|
|
|
@ -6,12 +6,12 @@
|
||||||
|
|
||||||
NotebookTab::NotebookTab(Notebook *notebook)
|
NotebookTab::NotebookTab(Notebook *notebook)
|
||||||
: QWidget(notebook)
|
: QWidget(notebook)
|
||||||
, m_notebook(notebook)
|
, notebook(notebook)
|
||||||
, m_text("<no title>")
|
, text("<no title>")
|
||||||
, m_selected(false)
|
, selected(false)
|
||||||
, m_mouseOver(false)
|
, mouseOver(false)
|
||||||
, m_mouseDown(false)
|
, mouseDown(false)
|
||||||
, m_highlightStyle(HighlightNone)
|
, highlightStyle(HighlightNone)
|
||||||
{
|
{
|
||||||
calcSize();
|
calcSize();
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ NotebookTab::NotebookTab(Notebook *notebook)
|
||||||
void
|
void
|
||||||
NotebookTab::calcSize()
|
NotebookTab::calcSize()
|
||||||
{
|
{
|
||||||
resize(fontMetrics().width(m_text) + 8, 24);
|
resize(fontMetrics().width(this->text) + 8, 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -33,16 +33,16 @@ NotebookTab::paintEvent(QPaintEvent *)
|
||||||
|
|
||||||
auto colorScheme = ColorScheme::instance();
|
auto colorScheme = ColorScheme::instance();
|
||||||
|
|
||||||
if (m_selected) {
|
if (this->selected) {
|
||||||
painter.fillRect(rect(), colorScheme.TabSelectedBackground);
|
painter.fillRect(rect(), colorScheme.TabSelectedBackground);
|
||||||
fg = colorScheme.TabSelectedText;
|
fg = colorScheme.TabSelectedText;
|
||||||
} else if (m_mouseOver) {
|
} else if (this->mouseOver) {
|
||||||
painter.fillRect(rect(), colorScheme.TabHoverBackground);
|
painter.fillRect(rect(), colorScheme.TabHoverBackground);
|
||||||
fg = colorScheme.TabHoverText;
|
fg = colorScheme.TabHoverText;
|
||||||
} else if (m_highlightStyle == HighlightHighlighted) {
|
} else if (this->highlightStyle == HighlightHighlighted) {
|
||||||
painter.fillRect(rect(), colorScheme.TabHighlightedBackground);
|
painter.fillRect(rect(), colorScheme.TabHighlightedBackground);
|
||||||
fg = colorScheme.TabHighlightedText;
|
fg = colorScheme.TabHighlightedText;
|
||||||
} else if (m_highlightStyle == HighlightNewMessage) {
|
} else if (this->highlightStyle == HighlightNewMessage) {
|
||||||
painter.fillRect(rect(), colorScheme.TabNewMessageBackground);
|
painter.fillRect(rect(), colorScheme.TabNewMessageBackground);
|
||||||
fg = colorScheme.TabHighlightedText;
|
fg = colorScheme.TabHighlightedText;
|
||||||
} else {
|
} else {
|
||||||
|
@ -51,23 +51,23 @@ NotebookTab::paintEvent(QPaintEvent *)
|
||||||
}
|
}
|
||||||
|
|
||||||
painter.setPen(fg);
|
painter.setPen(fg);
|
||||||
painter.drawText(4, (height() + fontMetrics().height()) / 2, m_text);
|
painter.drawText(4, (height() + fontMetrics().height()) / 2, this->text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
NotebookTab::mousePressEvent(QMouseEvent *)
|
NotebookTab::mousePressEvent(QMouseEvent *)
|
||||||
{
|
{
|
||||||
m_mouseDown = true;
|
this->mouseDown = true;
|
||||||
|
|
||||||
repaint();
|
repaint();
|
||||||
|
|
||||||
m_notebook->select(page);
|
this->notebook->select(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
NotebookTab::mouseReleaseEvent(QMouseEvent *)
|
NotebookTab::mouseReleaseEvent(QMouseEvent *)
|
||||||
{
|
{
|
||||||
m_mouseDown = false;
|
this->mouseDown = false;
|
||||||
|
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ NotebookTab::mouseReleaseEvent(QMouseEvent *)
|
||||||
void
|
void
|
||||||
NotebookTab::enterEvent(QEvent *)
|
NotebookTab::enterEvent(QEvent *)
|
||||||
{
|
{
|
||||||
m_mouseOver = true;
|
this->mouseOver = true;
|
||||||
|
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ NotebookTab::enterEvent(QEvent *)
|
||||||
void
|
void
|
||||||
NotebookTab::leaveEvent(QEvent *)
|
NotebookTab::leaveEvent(QEvent *)
|
||||||
{
|
{
|
||||||
m_mouseOver = false;
|
this->mouseOver = false;
|
||||||
|
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
@ -91,5 +91,5 @@ NotebookTab::leaveEvent(QEvent *)
|
||||||
void
|
void
|
||||||
NotebookTab::dragEnterEvent(QDragEnterEvent *event)
|
NotebookTab::dragEnterEvent(QDragEnterEvent *event)
|
||||||
{
|
{
|
||||||
m_notebook->select(page);
|
this->notebook->select(page);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,47 +17,47 @@ public:
|
||||||
HighlightNewMessage
|
HighlightNewMessage
|
||||||
};
|
};
|
||||||
|
|
||||||
NotebookTab(Notebook *m_notebook);
|
NotebookTab(Notebook *notebook);
|
||||||
|
|
||||||
void calcSize();
|
void calcSize();
|
||||||
|
|
||||||
NotebookPage *page;
|
NotebookPage *page;
|
||||||
|
|
||||||
const QString &
|
const QString &
|
||||||
text() const
|
getText() const
|
||||||
{
|
{
|
||||||
return m_text;
|
return this->text;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
setText(const QString &text)
|
setText(const QString &text)
|
||||||
{
|
{
|
||||||
m_text = text;
|
this->text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
selected()
|
getSelected()
|
||||||
{
|
{
|
||||||
return m_selected;
|
return this->selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
setSelected(bool value)
|
setSelected(bool value)
|
||||||
{
|
{
|
||||||
m_selected = value;
|
this->selected = value;
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
HighlightStyle
|
HighlightStyle
|
||||||
highlightStyle() const
|
getHighlightStyle() const
|
||||||
{
|
{
|
||||||
return m_highlightStyle;
|
return this->highlightStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
setHighlightStyle(HighlightStyle style)
|
setHighlightStyle(HighlightStyle style)
|
||||||
{
|
{
|
||||||
m_highlightStyle = style;
|
this->highlightStyle = style;
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,14 +72,14 @@ protected:
|
||||||
void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE;
|
void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Notebook *m_notebook;
|
Notebook *notebook;
|
||||||
|
|
||||||
QString m_text;
|
QString text;
|
||||||
|
|
||||||
bool m_selected;
|
bool selected;
|
||||||
bool m_mouseOver;
|
bool mouseOver;
|
||||||
bool m_mouseDown;
|
bool mouseDown;
|
||||||
HighlightStyle m_highlightStyle;
|
HighlightStyle highlightStyle;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NOTEBOOKTAB_H
|
#endif // NOTEBOOKTAB_H
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
#include "resources.h"
|
#include "resources.h"
|
||||||
#include "QPixmap"
|
#include "QPixmap"
|
||||||
|
|
||||||
LazyLoadedImage *Resources::m_badgeStaff;
|
LazyLoadedImage *Resources::badgeStaff(NULL);
|
||||||
LazyLoadedImage *Resources::m_badgeAdmin;
|
LazyLoadedImage *Resources::badgeAdmin(NULL);
|
||||||
LazyLoadedImage *Resources::m_badgeModerator;
|
LazyLoadedImage *Resources::badgeModerator(NULL);
|
||||||
LazyLoadedImage *Resources::m_badgeGlobalmod;
|
LazyLoadedImage *Resources::badgeGlobalmod(NULL);
|
||||||
LazyLoadedImage *Resources::m_badgeTurbo;
|
LazyLoadedImage *Resources::badgeTurbo(NULL);
|
||||||
LazyLoadedImage *Resources::m_badgeBroadcaster;
|
LazyLoadedImage *Resources::badgeBroadcaster(NULL);
|
||||||
LazyLoadedImage *Resources::m_badgePremium;
|
LazyLoadedImage *Resources::badgePremium(NULL);
|
||||||
|
|
||||||
LazyLoadedImage *Resources::m_cheerBadge100000;
|
LazyLoadedImage *Resources::cheerBadge100000(NULL);
|
||||||
LazyLoadedImage *Resources::m_cheerBadge10000;
|
LazyLoadedImage *Resources::cheerBadge10000(NULL);
|
||||||
LazyLoadedImage *Resources::m_cheerBadge5000;
|
LazyLoadedImage *Resources::cheerBadge5000(NULL);
|
||||||
LazyLoadedImage *Resources::m_cheerBadge1000;
|
LazyLoadedImage *Resources::cheerBadge1000(NULL);
|
||||||
LazyLoadedImage *Resources::m_cheerBadge100;
|
LazyLoadedImage *Resources::cheerBadge100(NULL);
|
||||||
LazyLoadedImage *Resources::m_cheerBadge1;
|
LazyLoadedImage *Resources::cheerBadge1(NULL);
|
||||||
|
|
||||||
LazyLoadedImage *Resources::m_buttonBan;
|
LazyLoadedImage *Resources::buttonBan(NULL);
|
||||||
LazyLoadedImage *Resources::m_buttonTimeout;
|
LazyLoadedImage *Resources::buttonTimeout(NULL);
|
||||||
|
|
||||||
Resources::Resources()
|
Resources::Resources()
|
||||||
{
|
{
|
||||||
|
@ -27,30 +27,38 @@ void
|
||||||
Resources::load()
|
Resources::load()
|
||||||
{
|
{
|
||||||
// badges
|
// badges
|
||||||
m_badgeStaff = new LazyLoadedImage(new QPixmap(":/images/staff_bg.png"));
|
Resources::badgeStaff =
|
||||||
m_badgeAdmin = new LazyLoadedImage(new QPixmap(":/images/admin_bg.png"));
|
new LazyLoadedImage(new QPixmap(":/images/staff_bg.png"));
|
||||||
m_badgeModerator =
|
Resources::badgeAdmin =
|
||||||
|
new LazyLoadedImage(new QPixmap(":/images/admin_bg.png"));
|
||||||
|
Resources::badgeModerator =
|
||||||
new LazyLoadedImage(new QPixmap(":/images/moderator_bg.png"));
|
new LazyLoadedImage(new QPixmap(":/images/moderator_bg.png"));
|
||||||
m_badgeGlobalmod =
|
Resources::badgeGlobalmod =
|
||||||
new LazyLoadedImage(new QPixmap(":/images/globalmod_bg.png"));
|
new LazyLoadedImage(new QPixmap(":/images/globalmod_bg.png"));
|
||||||
m_badgeTurbo = new LazyLoadedImage(new QPixmap(":/images/turbo_bg.png"));
|
Resources::badgeTurbo =
|
||||||
m_badgeBroadcaster =
|
new LazyLoadedImage(new QPixmap(":/images/turbo_bg.png"));
|
||||||
|
Resources::badgeBroadcaster =
|
||||||
new LazyLoadedImage(new QPixmap(":/images/broadcaster_bg.png"));
|
new LazyLoadedImage(new QPixmap(":/images/broadcaster_bg.png"));
|
||||||
m_badgePremium =
|
Resources::badgePremium =
|
||||||
new LazyLoadedImage(new QPixmap(":/images/twitchprime_bg.png"));
|
new LazyLoadedImage(new QPixmap(":/images/twitchprime_bg.png"));
|
||||||
|
|
||||||
// cheer badges
|
// cheer badges
|
||||||
m_cheerBadge100000 =
|
Resources::cheerBadge100000 =
|
||||||
new LazyLoadedImage(new QPixmap(":/images/cheer100000"));
|
new LazyLoadedImage(new QPixmap(":/images/cheer100000"));
|
||||||
m_cheerBadge10000 = new LazyLoadedImage(new QPixmap(":/images/cheer10000"));
|
Resources::cheerBadge10000 =
|
||||||
m_cheerBadge5000 = new LazyLoadedImage(new QPixmap(":/images/cheer5000"));
|
new LazyLoadedImage(new QPixmap(":/images/cheer10000"));
|
||||||
m_cheerBadge1000 = new LazyLoadedImage(new QPixmap(":/images/cheer1000"));
|
Resources::cheerBadge5000 =
|
||||||
m_cheerBadge100 = new LazyLoadedImage(new QPixmap(":/images/cheer100"));
|
new LazyLoadedImage(new QPixmap(":/images/cheer5000"));
|
||||||
m_cheerBadge1 = new LazyLoadedImage(new QPixmap(":/images/cheer1"));
|
Resources::cheerBadge1000 =
|
||||||
|
new LazyLoadedImage(new QPixmap(":/images/cheer1000"));
|
||||||
|
Resources::cheerBadge100 =
|
||||||
|
new LazyLoadedImage(new QPixmap(":/images/cheer100"));
|
||||||
|
Resources::cheerBadge1 =
|
||||||
|
new LazyLoadedImage(new QPixmap(":/images/cheer1"));
|
||||||
|
|
||||||
// button
|
// button
|
||||||
m_buttonBan =
|
Resources::buttonBan =
|
||||||
new LazyLoadedImage(new QPixmap(":/images/button_ban.png"), 0.25);
|
new LazyLoadedImage(new QPixmap(":/images/button_ban.png"), 0.25);
|
||||||
m_buttonTimeout =
|
Resources::buttonTimeout =
|
||||||
new LazyLoadedImage(new QPixmap(":/images/button_timeout.png"), 0.25);
|
new LazyLoadedImage(new QPixmap(":/images/button_timeout.png"), 0.25);
|
||||||
}
|
}
|
||||||
|
|
90
resources.h
90
resources.h
|
@ -10,116 +10,116 @@ public:
|
||||||
|
|
||||||
// badges
|
// badges
|
||||||
static LazyLoadedImage *
|
static LazyLoadedImage *
|
||||||
badgeStaff()
|
getBadgeStaff()
|
||||||
{
|
{
|
||||||
return m_badgeStaff;
|
return badgeStaff;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LazyLoadedImage *
|
static LazyLoadedImage *
|
||||||
badgeAdmin()
|
getBadgeAdmin()
|
||||||
{
|
{
|
||||||
return m_badgeAdmin;
|
return badgeAdmin;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LazyLoadedImage *
|
static LazyLoadedImage *
|
||||||
badgeGlobalmod()
|
getBadgeGlobalmod()
|
||||||
{
|
{
|
||||||
return m_badgeGlobalmod;
|
return badgeGlobalmod;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LazyLoadedImage *
|
static LazyLoadedImage *
|
||||||
badgeModerator()
|
getBadgeModerator()
|
||||||
{
|
{
|
||||||
return m_badgeModerator;
|
return badgeModerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LazyLoadedImage *
|
static LazyLoadedImage *
|
||||||
badgeTurbo()
|
getBadgeTurbo()
|
||||||
{
|
{
|
||||||
return m_badgeTurbo;
|
return badgeTurbo;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LazyLoadedImage *
|
static LazyLoadedImage *
|
||||||
badgeBroadcaster()
|
getBadgeBroadcaster()
|
||||||
{
|
{
|
||||||
return m_badgeBroadcaster;
|
return badgeBroadcaster;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LazyLoadedImage *
|
static LazyLoadedImage *
|
||||||
badgePremium()
|
getBadgePremium()
|
||||||
{
|
{
|
||||||
return m_badgePremium;
|
return badgePremium;
|
||||||
}
|
}
|
||||||
|
|
||||||
// cheer badges
|
// cheer badges
|
||||||
static LazyLoadedImage *
|
static LazyLoadedImage *
|
||||||
cheerBadge100000()
|
getCheerBadge100000()
|
||||||
{
|
{
|
||||||
return m_cheerBadge100000;
|
return cheerBadge100000;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LazyLoadedImage *
|
static LazyLoadedImage *
|
||||||
cheerBadge10000()
|
getCheerBadge10000()
|
||||||
{
|
{
|
||||||
return m_cheerBadge10000;
|
return cheerBadge10000;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LazyLoadedImage *
|
static LazyLoadedImage *
|
||||||
cheerBadge5000()
|
getCheerBadge5000()
|
||||||
{
|
{
|
||||||
return m_cheerBadge5000;
|
return cheerBadge5000;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LazyLoadedImage *
|
static LazyLoadedImage *
|
||||||
cheerBadge1000()
|
getCheerBadge1000()
|
||||||
{
|
{
|
||||||
return m_cheerBadge1000;
|
return cheerBadge1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LazyLoadedImage *
|
static LazyLoadedImage *
|
||||||
cheerBadge100()
|
getCheerBadge100()
|
||||||
{
|
{
|
||||||
return m_cheerBadge100;
|
return cheerBadge100;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LazyLoadedImage *
|
static LazyLoadedImage *
|
||||||
cheerBadge1()
|
getCheerBadge1()
|
||||||
{
|
{
|
||||||
return m_cheerBadge1;
|
return cheerBadge1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LazyLoadedImage *
|
static LazyLoadedImage *
|
||||||
buttonBan()
|
getButtonBan()
|
||||||
{
|
{
|
||||||
return m_buttonBan;
|
return buttonBan;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LazyLoadedImage *
|
static LazyLoadedImage *
|
||||||
buttonTimeout()
|
getButtonTimeout()
|
||||||
{
|
{
|
||||||
return m_buttonTimeout;
|
return buttonTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Resources();
|
Resources();
|
||||||
|
|
||||||
static LazyLoadedImage *m_badgeStaff;
|
static LazyLoadedImage *badgeStaff;
|
||||||
static LazyLoadedImage *m_badgeAdmin;
|
static LazyLoadedImage *badgeAdmin;
|
||||||
static LazyLoadedImage *m_badgeGlobalmod;
|
static LazyLoadedImage *badgeGlobalmod;
|
||||||
static LazyLoadedImage *m_badgeModerator;
|
static LazyLoadedImage *badgeModerator;
|
||||||
static LazyLoadedImage *m_badgeTurbo;
|
static LazyLoadedImage *badgeTurbo;
|
||||||
static LazyLoadedImage *m_badgeBroadcaster;
|
static LazyLoadedImage *badgeBroadcaster;
|
||||||
static LazyLoadedImage *m_badgePremium;
|
static LazyLoadedImage *badgePremium;
|
||||||
|
|
||||||
static LazyLoadedImage *m_cheerBadge100000;
|
static LazyLoadedImage *cheerBadge100000;
|
||||||
static LazyLoadedImage *m_cheerBadge10000;
|
static LazyLoadedImage *cheerBadge10000;
|
||||||
static LazyLoadedImage *m_cheerBadge5000;
|
static LazyLoadedImage *cheerBadge5000;
|
||||||
static LazyLoadedImage *m_cheerBadge1000;
|
static LazyLoadedImage *cheerBadge1000;
|
||||||
static LazyLoadedImage *m_cheerBadge100;
|
static LazyLoadedImage *cheerBadge100;
|
||||||
static LazyLoadedImage *m_cheerBadge1;
|
static LazyLoadedImage *cheerBadge1;
|
||||||
|
|
||||||
static LazyLoadedImage *m_buttonBan;
|
static LazyLoadedImage *buttonBan;
|
||||||
static LazyLoadedImage *m_buttonTimeout;
|
static LazyLoadedImage *buttonTimeout;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RESOURCES_H
|
#endif // RESOURCES_H
|
||||||
|
|
|
@ -2,16 +2,25 @@
|
||||||
#include "QPainter"
|
#include "QPainter"
|
||||||
#include "colorscheme.h"
|
#include "colorscheme.h"
|
||||||
|
|
||||||
|
#define MIN_THUMB_HEIGHT 10
|
||||||
|
|
||||||
ScrollBar::ScrollBar(QWidget *widget)
|
ScrollBar::ScrollBar(QWidget *widget)
|
||||||
: QWidget(widget)
|
: QWidget(widget)
|
||||||
, mutex()
|
, mutex()
|
||||||
|
, highlights(NULL)
|
||||||
|
, thumbRect()
|
||||||
|
, maximum()
|
||||||
|
, minimum()
|
||||||
|
, largeChange()
|
||||||
|
, smallChange()
|
||||||
|
, value()
|
||||||
{
|
{
|
||||||
resize(16, 100);
|
resize(16, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollBar::~ScrollBar()
|
ScrollBar::~ScrollBar()
|
||||||
{
|
{
|
||||||
auto highlight = highlights;
|
auto highlight = this->highlights;
|
||||||
|
|
||||||
while (highlight != NULL) {
|
while (highlight != NULL) {
|
||||||
auto tmp = highlight->next;
|
auto tmp = highlight->next;
|
||||||
|
@ -23,15 +32,15 @@ ScrollBar::~ScrollBar()
|
||||||
void
|
void
|
||||||
ScrollBar::removeHighlightsWhere(std::function<bool(ScrollBarHighlight &)> func)
|
ScrollBar::removeHighlightsWhere(std::function<bool(ScrollBarHighlight &)> func)
|
||||||
{
|
{
|
||||||
mutex.lock();
|
this->mutex.lock();
|
||||||
|
|
||||||
ScrollBarHighlight *last = NULL;
|
ScrollBarHighlight *last = NULL;
|
||||||
ScrollBarHighlight *current = highlights;
|
ScrollBarHighlight *current = this->highlights;
|
||||||
|
|
||||||
while (current != NULL) {
|
while (current != NULL) {
|
||||||
if (func(*current)) {
|
if (func(*current)) {
|
||||||
if (last == NULL) {
|
if (last == NULL) {
|
||||||
highlights = current->next;
|
this->highlights = current->next;
|
||||||
} else {
|
} else {
|
||||||
last->next = current->next;
|
last->next = current->next;
|
||||||
}
|
}
|
||||||
|
@ -45,22 +54,22 @@ ScrollBar::removeHighlightsWhere(std::function<bool(ScrollBarHighlight &)> func)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex.unlock();
|
this->mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ScrollBar::addHighlight(ScrollBarHighlight *highlight)
|
ScrollBar::addHighlight(ScrollBarHighlight *highlight)
|
||||||
{
|
{
|
||||||
mutex.lock();
|
this->mutex.lock();
|
||||||
|
|
||||||
if (highlights == NULL) {
|
if (this->highlights == NULL) {
|
||||||
highlights = highlight;
|
this->highlights = highlight;
|
||||||
} else {
|
} else {
|
||||||
highlight->next = highlights->next;
|
highlight->next = this->highlights->next;
|
||||||
highlights->next = highlight;
|
this->highlights->next = highlight;
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex.unlock();
|
this->mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -69,7 +78,36 @@ ScrollBar::paintEvent(QPaintEvent *)
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
painter.fillRect(rect(), ColorScheme::instance().ScrollbarBG);
|
painter.fillRect(rect(), ColorScheme::instance().ScrollbarBG);
|
||||||
|
|
||||||
mutex.lock();
|
painter.fillRect(QRect(0, 0, width(), this->buttonHeight),
|
||||||
|
QColor(255, 0, 0));
|
||||||
|
painter.fillRect(
|
||||||
|
QRect(0, height() - this->buttonHeight, width(), this->buttonHeight),
|
||||||
|
QColor(255, 0, 0));
|
||||||
|
|
||||||
mutex.unlock();
|
ScrollBarHighlight *highlight = this->highlights;
|
||||||
|
|
||||||
|
this->mutex.lock();
|
||||||
|
|
||||||
|
// do {
|
||||||
|
// painter.fillRect();
|
||||||
|
// } while ((highlight = highlight->next()) != NULL);
|
||||||
|
|
||||||
|
this->mutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ScrollBar::updateScroll()
|
||||||
|
{
|
||||||
|
this->trackHeight = height() - this->buttonHeight - this->buttonHeight -
|
||||||
|
MIN_THUMB_HEIGHT - 1;
|
||||||
|
|
||||||
|
this->thumbRect =
|
||||||
|
QRect(0,
|
||||||
|
(int)(this->value / this->maximum * this->trackHeight) + 1 +
|
||||||
|
this->buttonHeight,
|
||||||
|
width(),
|
||||||
|
(int)(this->largeChange / this->maximum * this->trackHeight) +
|
||||||
|
MIN_THUMB_HEIGHT);
|
||||||
|
|
||||||
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
83
scrollbar.h
83
scrollbar.h
|
@ -17,12 +17,93 @@ public:
|
||||||
void removeHighlightsWhere(std::function<bool(ScrollBarHighlight &)> func);
|
void removeHighlightsWhere(std::function<bool(ScrollBarHighlight &)> func);
|
||||||
void addHighlight(ScrollBarHighlight *highlight);
|
void addHighlight(ScrollBarHighlight *highlight);
|
||||||
|
|
||||||
|
void
|
||||||
|
setMaximum(qreal value)
|
||||||
|
{
|
||||||
|
maximum = value;
|
||||||
|
|
||||||
|
updateScroll();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
setMinimum(qreal value)
|
||||||
|
{
|
||||||
|
minimum = value;
|
||||||
|
|
||||||
|
updateScroll();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
setLargeChange(qreal value)
|
||||||
|
{
|
||||||
|
largeChange = value;
|
||||||
|
|
||||||
|
updateScroll();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
setSmallChange(qreal value)
|
||||||
|
{
|
||||||
|
smallChange = value;
|
||||||
|
|
||||||
|
updateScroll();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
setValue(qreal value)
|
||||||
|
{
|
||||||
|
value = value;
|
||||||
|
|
||||||
|
updateScroll();
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal
|
||||||
|
getMaximum() const
|
||||||
|
{
|
||||||
|
return maximum;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal
|
||||||
|
getMinimum() const
|
||||||
|
{
|
||||||
|
return minimum;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal
|
||||||
|
getLargeChange() const
|
||||||
|
{
|
||||||
|
return largeChange;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal
|
||||||
|
getSmallChange() const
|
||||||
|
{
|
||||||
|
return smallChange;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal
|
||||||
|
getValue() const
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMutex mutex;
|
QMutex mutex;
|
||||||
ScrollBarHighlight *highlights = NULL;
|
ScrollBarHighlight *highlights;
|
||||||
void paintEvent(QPaintEvent *);
|
void paintEvent(QPaintEvent *);
|
||||||
|
|
||||||
|
int buttonHeight;
|
||||||
|
int trackHeight;
|
||||||
|
|
||||||
QRect thumbRect;
|
QRect thumbRect;
|
||||||
|
|
||||||
|
qreal maximum;
|
||||||
|
qreal minimum;
|
||||||
|
qreal largeChange;
|
||||||
|
qreal smallChange;
|
||||||
|
qreal value;
|
||||||
|
|
||||||
|
void updateScroll();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SCROLLBAR_H
|
#endif // SCROLLBAR_H
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
|
|
||||||
ScrollBarHighlight::ScrollBarHighlight(float position, int colorIndex,
|
ScrollBarHighlight::ScrollBarHighlight(float position, int colorIndex,
|
||||||
Style style, QString tag)
|
Style style, QString tag)
|
||||||
: m_position(position)
|
: position(position)
|
||||||
, m_colorIndex(std::max(
|
, colorIndex(std::max(
|
||||||
0, std::min(ColorScheme::instance().HighlightColorCount, colorIndex)))
|
0, std::min(ColorScheme::instance().HighlightColorCount, colorIndex)))
|
||||||
, m_style(style)
|
, style(style)
|
||||||
, m_tag(tag)
|
, tag(tag)
|
||||||
, next(NULL)
|
, next(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,40 +8,40 @@ class ScrollBarHighlight
|
||||||
public:
|
public:
|
||||||
enum Style { Default, Left, Right, SingleLine };
|
enum Style { Default, Left, Right, SingleLine };
|
||||||
|
|
||||||
ScrollBarHighlight(float position, int colorIndex, Style style = Default,
|
ScrollBarHighlight(float getPosition, int getColorIndex,
|
||||||
QString tag = "");
|
Style getStyle = Default, QString tag = "");
|
||||||
|
|
||||||
Style
|
Style
|
||||||
style()
|
getStyle()
|
||||||
{
|
{
|
||||||
return m_style;
|
return style;
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
position()
|
getPosition()
|
||||||
{
|
{
|
||||||
return m_position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
colorIndex()
|
getColorIndex()
|
||||||
{
|
{
|
||||||
return m_colorIndex;
|
return colorIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
getTag()
|
getTag()
|
||||||
{
|
{
|
||||||
return m_tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollBarHighlight *next;
|
ScrollBarHighlight *next;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Style m_style;
|
Style style;
|
||||||
float m_position;
|
float position;
|
||||||
int m_colorIndex;
|
int colorIndex;
|
||||||
QString m_tag;
|
QString tag;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SCROLLBARHIGHLIGHT_H
|
#endif // SCROLLBARHIGHLIGHT_H
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
#include "settingsdialog.h"
|
#include "settingsdialog.h"
|
||||||
#include "settingsdialogtab.h"
|
#include "settingsdialogtab.h"
|
||||||
|
|
||||||
#include "QComboBox"
|
#include <QComboBox>
|
||||||
#include "QFile"
|
#include <QFile>
|
||||||
#include "QFormLayout"
|
#include <QFormLayout>
|
||||||
#include "QGroupBox"
|
#include <QGroupBox>
|
||||||
#include "QLabel"
|
#include <QLabel>
|
||||||
#include "QPalette"
|
#include <QPalette>
|
||||||
#include "QResource"
|
#include <QResource>
|
||||||
|
|
||||||
SettingsDialog::SettingsDialog()
|
SettingsDialog::SettingsDialog()
|
||||||
{
|
{
|
||||||
|
@ -144,7 +144,7 @@ SettingsDialog::addTab(QLayout *layout, QString title, QString imageRes)
|
||||||
|
|
||||||
auto tab = new SettingsDialogTab(this, title, imageRes);
|
auto tab = new SettingsDialogTab(this, title, imageRes);
|
||||||
|
|
||||||
tab->widget = widget;
|
tab->setWidget(widget);
|
||||||
|
|
||||||
tabs.addWidget(tab, 0, Qt::AlignTop);
|
tabs.addWidget(tab, 0, Qt::AlignTop);
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ SettingsDialog::addTab(QLayout *layout, QString title, QString imageRes)
|
||||||
void
|
void
|
||||||
SettingsDialog::select(SettingsDialogTab *tab)
|
SettingsDialog::select(SettingsDialogTab *tab)
|
||||||
{
|
{
|
||||||
pageStack.setCurrentWidget(tab->widget);
|
pageStack.setCurrentWidget(tab->getWidget());
|
||||||
|
|
||||||
if (selectedTab != NULL) {
|
if (selectedTab != NULL) {
|
||||||
selectedTab->setSelected(false);
|
selectedTab->setSelected(false);
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
#ifndef SETTINGSDIALOG_H
|
#ifndef SETTINGSDIALOG_H
|
||||||
#define SETTINGSDIALOG_H
|
#define SETTINGSDIALOG_H
|
||||||
|
|
||||||
#include "QButtonGroup"
|
|
||||||
#include "QCheckBox"
|
|
||||||
#include "QDialogButtonBox"
|
|
||||||
#include "QHBoxLayout"
|
|
||||||
#include "QListView"
|
|
||||||
#include "QMainWindow"
|
|
||||||
#include "QPushButton"
|
|
||||||
#include "QStackedLayout"
|
|
||||||
#include "QVBoxLayout"
|
|
||||||
#include "QWidget"
|
|
||||||
#include "settingsdialogtab.h"
|
#include "settingsdialogtab.h"
|
||||||
|
|
||||||
|
#include <QButtonGroup>
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QListView>
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QStackedLayout>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
class SettingsDialog : public QWidget
|
class SettingsDialog : public QWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -9,8 +9,8 @@ class SettingsDialog;
|
||||||
class SettingsDialogTab : public QWidget
|
class SettingsDialogTab : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(
|
Q_PROPERTY(bool getSelected READ getSelected WRITE setSelected NOTIFY
|
||||||
bool selected READ selected WRITE setSelected NOTIFY selectedChanged)
|
selectedChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SettingsDialogTab(SettingsDialog *dialog, QString label, QString imageRes);
|
SettingsDialogTab(SettingsDialog *dialog, QString label, QString imageRes);
|
||||||
|
@ -18,20 +18,30 @@ public:
|
||||||
void
|
void
|
||||||
setSelected(bool selected)
|
setSelected(bool selected)
|
||||||
{
|
{
|
||||||
if (selected == m_selected)
|
if (selected == selected)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_selected = selected;
|
selected = selected;
|
||||||
emit selectedChanged(selected);
|
emit selectedChanged(selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
selected() const
|
getSelected() const
|
||||||
{
|
{
|
||||||
return m_selected;
|
return selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *widget;
|
QWidget *
|
||||||
|
getWidget()
|
||||||
|
{
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
setWidget(QWidget *widget)
|
||||||
|
{
|
||||||
|
this->widget = widget;
|
||||||
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void selectedChanged(bool);
|
void selectedChanged(bool);
|
||||||
|
@ -40,12 +50,13 @@ private:
|
||||||
void paintEvent(QPaintEvent *);
|
void paintEvent(QPaintEvent *);
|
||||||
void mouseReleaseEvent(QMouseEvent *event);
|
void mouseReleaseEvent(QMouseEvent *event);
|
||||||
|
|
||||||
|
QWidget *widget;
|
||||||
QString label;
|
QString label;
|
||||||
QImage image;
|
QImage image;
|
||||||
|
|
||||||
SettingsDialog *dialog = NULL;
|
SettingsDialog *dialog = NULL;
|
||||||
|
|
||||||
bool m_selected = false;
|
bool selected = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SETTINGSNOTEBOOKTAB_H
|
#endif // SETTINGSNOTEBOOKTAB_H
|
||||||
|
|
|
@ -3,21 +3,22 @@
|
||||||
|
|
||||||
TextInputDialog::TextInputDialog(QWidget *parent)
|
TextInputDialog::TextInputDialog(QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
, m_vbox(this)
|
, vbox(this)
|
||||||
, m_lineEdit()
|
, lineEdit()
|
||||||
, m_buttonBox()
|
, buttonBox()
|
||||||
, m_okButton("OK")
|
, okButton("OK")
|
||||||
, m_cancelButton("Cancel")
|
, cancelButton("Cancel")
|
||||||
{
|
{
|
||||||
m_vbox.addWidget(&m_lineEdit);
|
this->vbox.addWidget(&this->lineEdit);
|
||||||
m_vbox.addLayout(&m_buttonBox);
|
this->vbox.addLayout(&this->buttonBox);
|
||||||
m_buttonBox.addStretch(1);
|
this->buttonBox.addStretch(1);
|
||||||
m_buttonBox.addWidget(&m_okButton);
|
this->buttonBox.addWidget(&this->okButton);
|
||||||
m_buttonBox.addWidget(&m_cancelButton);
|
this->buttonBox.addWidget(&this->cancelButton);
|
||||||
|
|
||||||
QObject::connect(&m_okButton, SIGNAL(clicked()), this, SLOT(okButtonClicked()));
|
QObject::connect(&this->okButton, SIGNAL(clicked()), this,
|
||||||
QObject::connect(&m_cancelButton, SIGNAL(clicked()), this,
|
SLOT(okButtonClicked()));
|
||||||
SLOT(cancelButtonClicked()));
|
QObject::connect(&this->cancelButton, SIGNAL(clicked()), this,
|
||||||
|
SLOT(cancelButtonClicked()));
|
||||||
|
|
||||||
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
|
|
||||||
|
|
|
@ -16,23 +16,23 @@ public:
|
||||||
TextInputDialog(QWidget *parent = NULL);
|
TextInputDialog(QWidget *parent = NULL);
|
||||||
|
|
||||||
QString
|
QString
|
||||||
text() const
|
getText() const
|
||||||
{
|
{
|
||||||
return m_lineEdit.text();
|
return lineEdit.text();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
setText(const QString &text)
|
setText(const QString &text)
|
||||||
{
|
{
|
||||||
m_lineEdit.setText(text);
|
lineEdit.setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVBoxLayout m_vbox;
|
QVBoxLayout vbox;
|
||||||
QLineEdit m_lineEdit;
|
QLineEdit lineEdit;
|
||||||
QHBoxLayout m_buttonBox;
|
QHBoxLayout buttonBox;
|
||||||
QPushButton m_okButton;
|
QPushButton okButton;
|
||||||
QPushButton m_cancelButton;
|
QPushButton cancelButton;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void okButtonClicked();
|
void okButtonClicked();
|
||||||
|
|
|
@ -6,27 +6,27 @@
|
||||||
struct TwitchEmoteValue {
|
struct TwitchEmoteValue {
|
||||||
public:
|
public:
|
||||||
int
|
int
|
||||||
set()
|
getSet()
|
||||||
{
|
{
|
||||||
return m_set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
id()
|
getId()
|
||||||
{
|
{
|
||||||
return m_id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &
|
const QString &
|
||||||
channelName()
|
getChannelName()
|
||||||
{
|
{
|
||||||
return m_channelName;
|
return channelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_set;
|
int set;
|
||||||
int m_id;
|
int id;
|
||||||
QString m_channelName;
|
QString channelName;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TWITCHEMOTEVALUE_H
|
#endif // TWITCHEMOTEVALUE_H
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
|
|
||||||
QMutex Windows::m_windowMutex;
|
QMutex Windows::windowMutex;
|
||||||
|
|
||||||
MainWindow *Windows::m_mainWindow(NULL);
|
MainWindow *Windows::mainWindow(NULL);
|
||||||
|
|
||||||
void
|
void
|
||||||
Windows::layoutVisibleChatWidgets(Channel *channel)
|
Windows::layoutVisibleChatWidgets(Channel *channel)
|
||||||
{
|
{
|
||||||
m_mainWindow->layoutVisibleChatWidgets(channel);
|
Windows::mainWindow->layoutVisibleChatWidgets(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Windows::repaintVisibleChatWidgets(Channel *channel)
|
Windows::repaintVisibleChatWidgets(Channel *channel)
|
||||||
{
|
{
|
||||||
m_mainWindow->repaintVisibleChatWidgets(channel);
|
Windows::mainWindow->repaintVisibleChatWidgets(channel);
|
||||||
}
|
}
|
||||||
|
|
16
windows.h
16
windows.h
|
@ -12,15 +12,15 @@ public:
|
||||||
static void repaintVisibleChatWidgets(Channel *channel = NULL);
|
static void repaintVisibleChatWidgets(Channel *channel = NULL);
|
||||||
|
|
||||||
static MainWindow &
|
static MainWindow &
|
||||||
mainWindow()
|
getMainWindow()
|
||||||
{
|
{
|
||||||
m_windowMutex.lock();
|
windowMutex.lock();
|
||||||
if (m_mainWindow == NULL) {
|
if (mainWindow == NULL) {
|
||||||
m_mainWindow = new MainWindow();
|
mainWindow = new MainWindow();
|
||||||
}
|
}
|
||||||
m_windowMutex.unlock();
|
windowMutex.unlock();
|
||||||
|
|
||||||
return *m_mainWindow;
|
return *mainWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -28,9 +28,9 @@ private:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static QMutex m_windowMutex;
|
static QMutex windowMutex;
|
||||||
|
|
||||||
static MainWindow *m_mainWindow;
|
static MainWindow *mainWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WINDOWS_H
|
#endif // WINDOWS_H
|
||||||
|
|
38
word.cpp
38
word.cpp
|
@ -3,30 +3,30 @@
|
||||||
// Image word
|
// Image word
|
||||||
Word::Word(LazyLoadedImage *image, Type type, const QString ©text,
|
Word::Word(LazyLoadedImage *image, Type type, const QString ©text,
|
||||||
const QString &tooltip, const Link &link)
|
const QString &tooltip, const Link &link)
|
||||||
: m_image(image)
|
: image(image)
|
||||||
, m_text()
|
, text()
|
||||||
, m_color()
|
, color()
|
||||||
, m_isImage(true)
|
, _isImage(true)
|
||||||
, m_type(type)
|
, type(type)
|
||||||
, m_copyText(copytext)
|
, copyText(copytext)
|
||||||
, m_tooltip(tooltip)
|
, tooltip(tooltip)
|
||||||
, m_link(link)
|
, link(link)
|
||||||
, m_characterWidthCache()
|
, characterWidthCache()
|
||||||
{
|
{
|
||||||
image->width(); // professional segfault test
|
image->getWidth(); // professional segfault test
|
||||||
}
|
}
|
||||||
|
|
||||||
// Text word
|
// Text word
|
||||||
Word::Word(const QString &text, Type type, const QColor &color,
|
Word::Word(const QString &text, Type type, const QColor &color,
|
||||||
const QString ©text, const QString &tooltip, const Link &link)
|
const QString ©text, const QString &tooltip, const Link &link)
|
||||||
: m_image(NULL)
|
: image(NULL)
|
||||||
, m_text(text)
|
, text(text)
|
||||||
, m_color(color)
|
, color(color)
|
||||||
, m_isImage(false)
|
, _isImage(false)
|
||||||
, m_type(type)
|
, type(type)
|
||||||
, m_copyText(copytext)
|
, copyText(copytext)
|
||||||
, m_tooltip(tooltip)
|
, tooltip(tooltip)
|
||||||
, m_link(link)
|
, link(link)
|
||||||
, m_characterWidthCache()
|
, characterWidthCache()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
102
word.h
102
word.h
|
@ -63,148 +63,148 @@ public:
|
||||||
ButtonTimeout
|
ButtonTimeout
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit Word(LazyLoadedImage *m_image, Type type, const QString ©text,
|
explicit Word(LazyLoadedImage *image, Type getType, const QString ©text,
|
||||||
const QString &tooltip, const Link &link = Link());
|
const QString &getTooltip, const Link &getLink = Link());
|
||||||
explicit Word(const QString &m_text, Type type, const QColor &color,
|
explicit Word(const QString &text, Type getType, const QColor &getColor,
|
||||||
const QString ©text, const QString &tooltip,
|
const QString ©text, const QString &getTooltip,
|
||||||
const Link &link = Link());
|
const Link &getLink = Link());
|
||||||
|
|
||||||
LazyLoadedImage &
|
LazyLoadedImage &
|
||||||
getImage() const
|
getImage() const
|
||||||
{
|
{
|
||||||
return *m_image;
|
return *image;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &
|
const QString &
|
||||||
getText() const
|
getText() const
|
||||||
{
|
{
|
||||||
return m_text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
width() const
|
getWidth() const
|
||||||
{
|
{
|
||||||
return m_width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
height() const
|
getHeight() const
|
||||||
{
|
{
|
||||||
return m_height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
setSize(int width, int height)
|
setSize(int width, int height)
|
||||||
{
|
{
|
||||||
m_width = width;
|
width = width;
|
||||||
m_height = height;
|
height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isImage() const
|
isImage() const
|
||||||
{
|
{
|
||||||
return m_isImage;
|
return _isImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isText() const
|
isText() const
|
||||||
{
|
{
|
||||||
return !m_isImage;
|
return !_isImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &
|
const QString &
|
||||||
copyText() const
|
getCopyText() const
|
||||||
{
|
{
|
||||||
return m_copyText;
|
return copyText;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
hasTrailingSpace() const
|
hasTrailingSpace() const
|
||||||
{
|
{
|
||||||
return m_hasTrailingSpace;
|
return _hasTrailingSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFont &
|
QFont &
|
||||||
getFont() const
|
getFont() const
|
||||||
{
|
{
|
||||||
return Fonts::getFont(m_font);
|
return Fonts::getFont(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
QFontMetrics &
|
QFontMetrics &
|
||||||
getFontMetrics() const
|
getFontMetrics() const
|
||||||
{
|
{
|
||||||
return Fonts::getFontMetrics(m_font);
|
return Fonts::getFontMetrics(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
Type
|
Type
|
||||||
type() const
|
getType() const
|
||||||
{
|
{
|
||||||
return m_type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &
|
const QString &
|
||||||
tooltip() const
|
getTooltip() const
|
||||||
{
|
{
|
||||||
return m_tooltip;
|
return tooltip;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QColor &
|
const QColor &
|
||||||
color() const
|
getColor() const
|
||||||
{
|
{
|
||||||
return m_color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Link &
|
const Link &
|
||||||
link() const
|
getLink() const
|
||||||
{
|
{
|
||||||
return m_link;
|
return link;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
xOffset() const
|
getXOffset() const
|
||||||
{
|
{
|
||||||
return m_xOffset;
|
return xOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
yOffset() const
|
getYOffset() const
|
||||||
{
|
{
|
||||||
return m_yOffset;
|
return yOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
setOffset(int xOffset, int yOffset)
|
setOffset(int xOffset, int yOffset)
|
||||||
{
|
{
|
||||||
m_xOffset = std::max(0, xOffset);
|
xOffset = std::max(0, xOffset);
|
||||||
m_yOffset = std::max(0, yOffset);
|
yOffset = std::max(0, yOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<short> &
|
std::vector<short> &
|
||||||
characterWidthCache()
|
getCharacterWidthCache()
|
||||||
{
|
{
|
||||||
return m_characterWidthCache;
|
return characterWidthCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LazyLoadedImage *m_image;
|
LazyLoadedImage *image;
|
||||||
QString m_text;
|
QString text;
|
||||||
QColor m_color;
|
QColor color;
|
||||||
bool m_isImage;
|
bool _isImage;
|
||||||
|
|
||||||
Type m_type;
|
Type type;
|
||||||
QString m_copyText;
|
QString copyText;
|
||||||
QString m_tooltip;
|
QString tooltip;
|
||||||
|
|
||||||
int m_width = 16;
|
int width = 16;
|
||||||
int m_height = 16;
|
int height = 16;
|
||||||
int m_xOffset = 0;
|
int xOffset = 0;
|
||||||
int m_yOffset = 0;
|
int yOffset = 0;
|
||||||
|
|
||||||
bool m_hasTrailingSpace;
|
bool _hasTrailingSpace;
|
||||||
Fonts::Type m_font = Fonts::Medium;
|
Fonts::Type font = Fonts::Medium;
|
||||||
Link m_link;
|
Link link;
|
||||||
|
|
||||||
std::vector<short> m_characterWidthCache;
|
std::vector<short> characterWidthCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WORD_H
|
#endif // WORD_H
|
||||||
|
|
28
wordpart.cpp
28
wordpart.cpp
|
@ -4,13 +4,13 @@
|
||||||
WordPart::WordPart(Word &word, int x, int y, const QString ©Text,
|
WordPart::WordPart(Word &word, int x, int y, const QString ©Text,
|
||||||
bool allowTrailingSpace)
|
bool allowTrailingSpace)
|
||||||
: m_word(word)
|
: m_word(word)
|
||||||
, m_copyText(copyText)
|
, copyText(copyText)
|
||||||
, m_x(x)
|
, x(x)
|
||||||
, m_y(y)
|
, y(y)
|
||||||
, m_width(word.width())
|
, width(word.getWidth())
|
||||||
, m_height(word.height())
|
, height(word.getHeight())
|
||||||
, m_trailingSpace(word.hasTrailingSpace() & allowTrailingSpace)
|
, _trailingSpace(word.hasTrailingSpace() & allowTrailingSpace)
|
||||||
, m_text(word.isText() ? m_word.getText() : QString())
|
, text(word.isText() ? m_word.getText() : QString())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,12 +18,12 @@ WordPart::WordPart(Word &word, int x, int y, int width, int height,
|
||||||
const QString ©Text, const QString &customText,
|
const QString ©Text, const QString &customText,
|
||||||
bool allowTrailingSpace)
|
bool allowTrailingSpace)
|
||||||
: m_word(word)
|
: m_word(word)
|
||||||
, m_copyText(copyText)
|
, copyText(copyText)
|
||||||
, m_x(x)
|
, x(x)
|
||||||
, m_y(y)
|
, y(y)
|
||||||
, m_width(width)
|
, width(width)
|
||||||
, m_height(height)
|
, height(height)
|
||||||
, m_trailingSpace(word.hasTrailingSpace() & allowTrailingSpace)
|
, _trailingSpace(word.hasTrailingSpace() & allowTrailingSpace)
|
||||||
, m_text(customText)
|
, text(customText)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
66
wordpart.h
66
wordpart.h
|
@ -9,104 +9,104 @@ class Word;
|
||||||
class WordPart
|
class WordPart
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WordPart(Word &word, int x, int y, const QString ©Text,
|
WordPart(Word &getWord, int getX, int getY, const QString &getCopyText,
|
||||||
bool allowTrailingSpace = true);
|
bool allowTrailingSpace = true);
|
||||||
|
|
||||||
WordPart(Word &word, int x, int y, int width, int height,
|
WordPart(Word &getWord, int getX, int getY, int getWidth, int getHeight,
|
||||||
const QString ©Text, const QString &customText,
|
const QString &getCopyText, const QString &customText,
|
||||||
bool allowTrailingSpace = true);
|
bool allowTrailingSpace = true);
|
||||||
|
|
||||||
const Word &
|
const Word &
|
||||||
word() const
|
getWord() const
|
||||||
{
|
{
|
||||||
return m_word;
|
return m_word;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
width() const
|
getWidth() const
|
||||||
{
|
{
|
||||||
return m_width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
height() const
|
getHeight() const
|
||||||
{
|
{
|
||||||
return m_height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
x() const
|
getX() const
|
||||||
{
|
{
|
||||||
return m_x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
y() const
|
getY() const
|
||||||
{
|
{
|
||||||
return m_y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
setPosition(int x, int y)
|
setPosition(int x, int y)
|
||||||
{
|
{
|
||||||
m_x = x;
|
x = x;
|
||||||
m_y = y;
|
y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
setY(int y)
|
setY(int y)
|
||||||
{
|
{
|
||||||
m_y = y;
|
y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
right() const
|
getRight() const
|
||||||
{
|
{
|
||||||
return m_x + m_width;
|
return x + width;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
bottom() const
|
getBottom() const
|
||||||
{
|
{
|
||||||
return m_y + m_height;
|
return y + height;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect
|
QRect
|
||||||
rect() const
|
getRect() const
|
||||||
{
|
{
|
||||||
return QRect(m_x, m_y, m_width, m_height);
|
return QRect(x, y, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString
|
const QString
|
||||||
copyText() const
|
getCopyText() const
|
||||||
{
|
{
|
||||||
return m_copyText;
|
return copyText;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
hasTrailingSpace() const
|
hasTrailingSpace() const
|
||||||
{
|
{
|
||||||
return m_trailingSpace;
|
return _trailingSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &
|
const QString &
|
||||||
text() const
|
getText() const
|
||||||
{
|
{
|
||||||
return m_text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Word &m_word;
|
Word &m_word;
|
||||||
|
|
||||||
QString m_copyText;
|
QString copyText;
|
||||||
QString m_text;
|
QString text;
|
||||||
|
|
||||||
int m_x;
|
int x;
|
||||||
int m_y;
|
int y;
|
||||||
int m_width;
|
int width;
|
||||||
int m_height;
|
int height;
|
||||||
|
|
||||||
bool m_trailingSpace;
|
bool _trailingSpace;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WORDPART_H
|
#endif // WORDPART_H
|
||||||
|
|
Loading…
Reference in a new issue