changed notation

This commit is contained in:
fourtf 2017-01-18 04:33:30 +01:00
parent 552e4c957a
commit 10e4a0f785
61 changed files with 1214 additions and 1051 deletions

View file

@ -1,10 +1,10 @@
#include "account.h"
const Account *Account::m_anon = new Account("justinfan123", "", "");
Account Account::anon("justinfan123", "", "");
Account::Account(QString username, QString oauthToken, QString oauthClient)
{
m_oauthClient = oauthClient;
m_oauthToken = oauthToken;
m_username = username;
this->oauthClient = oauthClient;
this->oauthToken = oauthToken;
this->username = username;
}

View file

@ -1,49 +1,49 @@
#ifndef ACCOUNT_H
#define ACCOUNT_H
#include "QString"
#include <QString>
class Account
{
public:
Account(QString username, QString oauthToken, QString oauthClient);
Account(QString getUsername, QString getOauthToken, QString getOauthClient);
static const Account *
anon()
getAnon()
{
return m_anon;
return &anon;
}
const QString &
username()
getUsername() const
{
return m_username;
return username;
}
const QString &
oauthToken()
getOauthToken() const
{
return m_oauthToken;
return oauthToken;
}
const QString &
oauthClient()
getOauthClient() const
{
return m_oauthClient;
return oauthClient;
}
bool
isAnon()
isAnon() const
{
return m_username.startsWith("justinfan");
return username.startsWith("justinfan");
}
private:
const static Account *m_anon;
static Account anon;
QString m_username;
QString m_oauthClient;
QString m_oauthToken;
QString username;
QString oauthClient;
QString oauthToken;
};
#endif // ACCOUNT_H

View file

@ -1,6 +1,6 @@
#include "appsettings.h"
Word::Type AppSettings::m_wordTypeMask = Word::Default;
Word::Type AppSettings::wordTypeMask = Word::Default;
AppSettings::AppSettings()
{

View file

@ -7,33 +7,34 @@ class AppSettings
{
public:
static Word::Type
wordTypeMask()
getWordTypeMask()
{
return m_wordTypeMask;
return wordTypeMask;
}
static bool isIgnoredEmote(const QString &emote);
static qreal
emoteScale()
getEmoteScale()
{
return 1;
}
static qreal
badgeScale()
getBadgeScale()
{
return 1;
}
static bool
scaleEmotesByLineHeight()
getScaleEmotesByLineHeight()
{
return false;
}
private:
AppSettings();
static Word::Type m_wordTypeMask;
static Word::Type wordTypeMask;
};
#endif // APPSETTINGS_H

View file

@ -5,35 +5,35 @@
#include <memory>
Channel::Channel(const QString &channel)
: m_messages()
, m_name((channel.length() > 0 && channel[0] == '#') ? channel.mid(1)
: channel)
, m_bttvChannelEmotes()
, m_ffzChannelEmotes()
, m_messageMutex()
, m_subLink("https://www.twitch.tv/" + m_name +
"/subscribe?ref=in_chat_subscriber_link")
, m_channelLink("https://twitch.tv/" + m_name)
, m_popoutPlayerLink("https://player.twitch.tv/?channel=" + m_name)
: messages()
, name((channel.length() > 0 && channel[0] == '#') ? channel.mid(1)
: channel)
, bttvChannelEmotes()
, ffzChannelEmotes()
, messageMutex()
, subLink("https://www.twitch.tv/" + name +
"/subscribe?ref=in_chat_subscriber_link")
, channelLink("https://twitch.tv/" + name)
, popoutPlayerLink("https://player.twitch.tv/?channel=" + name)
{
}
QVector<std::shared_ptr<Message>>
Channel::getMessagesClone()
{
m_messageMutex.lock();
QVector<std::shared_ptr<Message>> M(m_messages);
this->messageMutex.lock();
QVector<std::shared_ptr<Message>> M(this->messages);
M.detach();
m_messageMutex.unlock();
this->messageMutex.unlock();
return M;
}
void
Channel::addMessage(std::shared_ptr<Message> message)
{
m_messageMutex.lock();
m_messages.append(message);
m_messageMutex.unlock();
this->messageMutex.lock();
this->messages.append(message);
this->messageMutex.unlock();
Windows::repaintVisibleChatWidgets();
}

View file

@ -19,68 +19,69 @@ public:
// properties
const ConcurrentMap<QString, LazyLoadedImage *> &
bttvChannelEmotes() const
getBttvChannelEmotes() const
{
return m_bttvChannelEmotes;
return bttvChannelEmotes;
}
const ConcurrentMap<QString, LazyLoadedImage *> &
ffzChannelEmotes() const
getFfzChannelEmotes() const
{
return m_ffzChannelEmotes;
return ffzChannelEmotes;
}
const QMutex &
messageMutex() const
getMessageMutex() const
{
return m_messageMutex;
return messageMutex;
}
const QString &
name() const
getName() const
{
return m_name;
return name;
}
int
roomID() const
getRoomID() const
{
return m_roomID;
return roomID;
}
const QString &
subLink() const
getSubLink() const
{
return m_subLink;
return subLink;
}
const QString &
channelLink() const
getChannelLink() const
{
return m_channelLink;
return channelLink;
}
const QString &
popoutPlayerLink() const
getPopoutPlayerLink() const
{
return m_popoutPlayerLink;
return popoutPlayerLink;
}
bool
isLive() const
getIsLive() const
{
return m_isLive;
return isLive;
}
int
streamViewerCount() const
getStreamViewerCount() const
{
return m_streamViewerCount;
return streamViewerCount;
}
const QString &
streamStatus() const
getStreamStatus() const
{
return m_streamStatus;
return streamStatus;
}
const QString &
streamGame() const
getStreamGame() const
{
return m_streamGame;
return streamGame;
}
// methods
@ -89,23 +90,23 @@ public:
QVector<std::shared_ptr<Message>> getMessagesClone();
private:
QVector<std::shared_ptr<Message>> m_messages;
QVector<std::shared_ptr<Message>> messages;
QString m_name;
int m_roomID;
QString name;
int roomID;
ConcurrentMap<QString, LazyLoadedImage *> m_bttvChannelEmotes;
ConcurrentMap<QString, LazyLoadedImage *> m_ffzChannelEmotes;
QMutex m_messageMutex;
ConcurrentMap<QString, LazyLoadedImage *> bttvChannelEmotes;
ConcurrentMap<QString, LazyLoadedImage *> ffzChannelEmotes;
QMutex messageMutex;
QString m_subLink;
QString m_channelLink;
QString m_popoutPlayerLink;
QString subLink;
QString channelLink;
QString popoutPlayerLink;
bool m_isLive;
int m_streamViewerCount;
QString m_streamStatus;
QString m_streamGame;
bool isLive;
int streamViewerCount;
QString streamStatus;
QString streamGame;
};
#endif // CHANNEL_H

View file

@ -1,22 +1,22 @@
#include "channels.h"
#include "ircmanager.h"
Channel Channels::m_whispers(QString("/whispers"));
Channel Channels::m_mentions(QString("/mentions"));
Channel Channels::m_empty(QString(""));
Channel Channels::whispers(QString("/whispers"));
Channel Channels::mentions(QString("/mentions"));
Channel Channels::empty(QString(""));
QMap<QString, std::tuple<Channel *, int>> Channels::m_channels;
QMap<QString, std::tuple<Channel *, int>> Channels::channels;
Channel *
Channels::addChannel(const QString &channel)
{
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);
m_channels.insert(c, std::tuple<Channel *, int>(_c, 1));
Channels::channels.insert(c, std::tuple<Channel *, int>(_c, 1));
IrcManager::joinChannel(c);
@ -35,19 +35,19 @@ Channels::getChannel(const QString &channel)
if (channel.length() > 1 && channel.at(0) == '/') {
if (c == "/whispers") {
return &m_whispers;
return &Channels::whispers;
}
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;
}
@ -63,9 +63,9 @@ Channels::removeChannel(const QString &channel)
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;
}
@ -73,7 +73,7 @@ Channels::removeChannel(const QString &channel)
if (std::get<1>(a.value()) == 0) {
IrcManager::partChannel(c);
m_channels.remove(c);
Channels::channels.remove(c);
delete std::get<0>(a.value());
}
}

View file

@ -7,15 +7,15 @@ class Channels
{
public:
static Channel *
whispers()
getWhispers()
{
return &m_whispers;
return &whispers;
}
static Channel *
mentions()
getMentions()
{
return &m_whispers;
return &mentions;
}
static Channel *addChannel(const QString &channel);
@ -27,11 +27,11 @@ private:
{
}
static Channel m_whispers;
static Channel m_mentions;
static Channel m_empty;
static Channel whispers;
static Channel mentions;
static Channel empty;
static QMap<QString, std::tuple<Channel *, int>> m_channels;
static QMap<QString, std::tuple<Channel *, int>> channels;
};
#endif // CHANNELS_H

View file

@ -10,19 +10,19 @@
ChatWidget::ChatWidget(QWidget *parent)
: QWidget(parent)
, m_channel(NULL)
, m_channelName(QString())
, m_vbox(this)
, m_header(this)
, m_view(this)
, m_input()
, channel(NULL)
, channelName(QString())
, vbox(this)
, header(this)
, view(this)
, input()
{
m_vbox.setSpacing(0);
m_vbox.setMargin(1);
this->vbox.setSpacing(0);
this->vbox.setMargin(1);
m_vbox.addWidget(&m_header);
m_vbox.addWidget(&m_view);
m_vbox.addWidget(&m_input);
this->vbox.addWidget(&header);
this->vbox.addWidget(&view);
this->vbox.addWidget(&input);
}
ChatWidget::~ChatWidget()
@ -34,25 +34,26 @@ ChatWidget::setChannelName(const QString &name)
{
QString channel = name.trimmed();
if (QString::compare(channel, m_channelName, Qt::CaseInsensitive) == 0) {
m_channelName = channel;
m_header.updateChannelText();
if (QString::compare(channel, this->channelName, Qt::CaseInsensitive) ==
0) {
this->channelName = channel;
this->header.updateChannelText();
return;
}
m_channelName = channel;
m_header.updateChannelText();
this->channelName = channel;
this->header.updateChannelText();
m_view.layoutMessages();
this->view.layoutMessages();
if (!m_channelName.isEmpty()) {
Channels::removeChannel(m_channelName);
if (!this->channelName.isEmpty()) {
Channels::removeChannel(this->channelName);
}
if (channel.isEmpty()) {
m_channel = NULL;
this->channel = NULL;
} else {
m_channel = Channels::addChannel(channel);
this->channel = Channels::addChannel(channel);
}
}
@ -61,10 +62,10 @@ ChatWidget::showChangeChannelPopup()
{
TextInputDialog dialog(this);
dialog.setText(m_channelName);
dialog.setText(this->channelName);
if (dialog.exec() == QDialog::Accepted) {
setChannelName(dialog.text());
setChannelName(dialog.getText());
}
}
@ -73,5 +74,5 @@ ChatWidget::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.fillRect(rect(), ColorScheme::instance().ChatBackground);
painter.fillRect(this->rect(), ColorScheme::instance().ChatBackground);
}

View file

@ -1,14 +1,15 @@
#ifndef CHATWIDGET_H
#define CHATWIDGET_H
#include <QWidget>
#include "QFont"
#include "QVBoxLayout"
#include "channel.h"
#include "chatwidgetheader.h"
#include "chatwidgetinput.h"
#include "chatwidgetview.h"
#include <QFont>
#include <QVBoxLayout>
#include <QWidget>
class ChatWidget : public QWidget
{
Q_OBJECT
@ -18,21 +19,21 @@ public:
~ChatWidget();
ChatWidgetView &
view()
getView()
{
return m_view;
return view;
}
Channel *
channel() const
getChannel() const
{
return m_channel;
return channel;
}
const QString &
channelName() const
getChannelName() const
{
return m_channelName;
return channelName;
}
void setChannelName(const QString &name);
@ -43,14 +44,14 @@ protected:
void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
private:
Channel *m_channel;
QString m_channelName;
Channel *channel;
QString channelName;
QFont m_font;
QVBoxLayout m_vbox;
ChatWidgetHeader m_header;
ChatWidgetView m_view;
ChatWidgetInput m_input;
QFont font;
QVBoxLayout vbox;
ChatWidgetHeader header;
ChatWidgetView view;
ChatWidgetInput input;
};
#endif // CHATWIDGET_H

View file

@ -10,61 +10,64 @@
ChatWidgetHeader::ChatWidgetHeader(ChatWidget *parent)
: QWidget()
, m_chatWidget(parent)
, m_dragStart()
, m_dragging(false)
, m_leftLabel()
, m_middleLabel()
, m_rightLabel()
, m_leftMenu(this)
, m_rightMenu(this)
, chatWidget(parent)
, dragStart()
, dragging(false)
, leftLabel()
, middleLabel()
, rightLabel()
, leftMenu(this)
, rightMenu(this)
{
setFixedHeight(32);
updateColors();
updateChannelText();
setLayout(&m_hbox);
m_hbox.setMargin(0);
m_hbox.addWidget(&m_leftLabel);
m_hbox.addWidget(&m_middleLabel, 1);
m_hbox.addWidget(&m_rightLabel);
setLayout(&this->hbox);
this->hbox.setMargin(0);
this->hbox.addWidget(&this->leftLabel);
this->hbox.addWidget(&this->middleLabel, 1);
this->hbox.addWidget(&this->rightLabel);
// left
m_leftLabel.label().setTextFormat(Qt::RichText);
m_leftLabel.label().setText(
this->leftLabel.getLabel().setTextFormat(Qt::RichText);
this->leftLabel.getLabel().setText(
"<img src=':/images/tool_moreCollapser_off16.png' />");
QObject::connect(&m_leftLabel, &ChatWidgetHeaderButton::clicked, this,
QObject::connect(&this->leftLabel, &ChatWidgetHeaderButton::clicked, this,
&ChatWidgetHeader::leftButtonClicked);
m_leftMenu.addAction("Add new split", this, SLOT(menuAddSplit()),
QKeySequence(tr("Ctrl+T")));
m_leftMenu.addAction("Close split", this, SLOT(menuCloseSplit()),
QKeySequence(tr("Ctrl+W")));
m_leftMenu.addAction("Move split", this, SLOT(menuMoveSplit()));
m_leftMenu.addSeparator();
m_leftMenu.addAction("Change channel", this, SLOT(menuChangeChannel()),
QKeySequence(tr("Ctrl+R")));
m_leftMenu.addAction("Clear chat", this, SLOT(menuClearChat()));
m_leftMenu.addAction("Open channel", this, SLOT(menuOpenChannel()));
m_leftMenu.addAction("Open pop-out player", this, SLOT(menuPopupPlayer()));
m_leftMenu.addSeparator();
m_leftMenu.addAction("Reload channel emotes", this,
SLOT(menuReloadChannelEmotes()));
m_leftMenu.addAction("Manual reconnect", this, SLOT(menuManualReconnect()));
m_leftMenu.addSeparator();
m_leftMenu.addAction("Show changelog", this, SLOT(menuShowChangelog()));
this->leftMenu.addAction("Add new split", this, SLOT(menuAddSplit()),
QKeySequence(tr("Ctrl+T")));
this->leftMenu.addAction("Close split", this, SLOT(menuCloseSplit()),
QKeySequence(tr("Ctrl+W")));
this->leftMenu.addAction("Move split", this, SLOT(menuMoveSplit()));
this->leftMenu.addSeparator();
this->leftMenu.addAction("Change channel", this, SLOT(menuChangeChannel()),
QKeySequence(tr("Ctrl+R")));
this->leftMenu.addAction("Clear chat", this, SLOT(menuClearChat()));
this->leftMenu.addAction("Open channel", this, SLOT(menuOpenChannel()));
this->leftMenu.addAction("Open pop-out player", this,
SLOT(menuPopupPlayer()));
this->leftMenu.addSeparator();
this->leftMenu.addAction("Reload channel emotes", this,
SLOT(menuReloadChannelEmotes()));
this->leftMenu.addAction("Manual reconnect", this,
SLOT(menuManualReconnect()));
this->leftMenu.addSeparator();
this->leftMenu.addAction("Show changelog", this, SLOT(menuShowChangelog()));
// middle
m_middleLabel.setAlignment(Qt::AlignCenter);
QObject::connect(&m_middleLabel, SIGNAL(mouseDoubleClickEvent(QMouseEvent)), this,
this->middleLabel.setAlignment(Qt::AlignCenter);
QObject::connect(&this->middleLabel,
SIGNAL(mouseDoubleClickEvent(QMouseEvent)), this,
SLOT(mouseDoubleClickEvent));
// right
m_rightLabel.setMinimumWidth(height());
m_rightLabel.label().setTextFormat(Qt::RichText);
m_rightLabel.label().setText("ayy");
this->rightLabel.setMinimumWidth(height());
this->rightLabel.getLabel().setTextFormat(Qt::RichText);
this->rightLabel.getLabel().setText("ayy");
}
void
@ -73,17 +76,17 @@ ChatWidgetHeader::updateColors()
QPalette palette;
palette.setColor(QPalette::Foreground, ColorScheme::instance().Text);
m_leftLabel.setPalette(palette);
m_middleLabel.setPalette(palette);
m_rightLabel.setPalette(palette);
this->leftLabel.setPalette(palette);
this->middleLabel.setPalette(palette);
this->rightLabel.setPalette(palette);
}
void
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
@ -99,18 +102,18 @@ ChatWidgetHeader::paintEvent(QPaintEvent *)
void
ChatWidgetHeader::mousePressEvent(QMouseEvent *event)
{
m_dragging = true;
this->dragging = true;
m_dragStart = event->pos();
this->dragStart = event->pos();
}
void
ChatWidgetHeader::mouseMoveEvent(QMouseEvent *event)
{
if (m_dragging) {
if (std::abs(m_dragStart.x() - event->pos().x()) > 12 ||
std::abs(m_dragStart.y() - event->pos().y()) > 12) {
auto chatWidget = m_chatWidget;
if (this->dragging) {
if (std::abs(this->dragStart.x() - event->pos().x()) > 12 ||
std::abs(this->dragStart.y() - event->pos().y()) > 12) {
auto chatWidget = this->chatWidget;
auto page = static_cast<NotebookPage *>(chatWidget->parentWidget());
if (page != NULL) {
@ -144,15 +147,16 @@ void
ChatWidgetHeader::mouseDoubleClickEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
chatWidget()->showChangeChannelPopup();
this->chatWidget->showChangeChannelPopup();
}
}
void
ChatWidgetHeader::leftButtonClicked()
{
m_leftMenu.move(m_leftLabel.mapToGlobal(QPoint(0, m_leftLabel.height())));
m_leftMenu.show();
this->leftMenu.move(
this->leftLabel.mapToGlobal(QPoint(0, this->leftLabel.height())));
this->leftMenu.show();
}
void
@ -175,7 +179,7 @@ ChatWidgetHeader::menuMoveSplit()
void
ChatWidgetHeader::menuChangeChannel()
{
m_chatWidget->showChangeChannelPopup();
this->chatWidget->showChangeChannelPopup();
}
void
ChatWidgetHeader::menuClearChat()

View file

@ -22,9 +22,9 @@ public:
ChatWidgetHeader(ChatWidget *parent);
ChatWidget *
chatWidget()
getChatWidget()
{
return m_chatWidget;
return chatWidget;
}
void updateColors();
@ -37,19 +37,19 @@ protected:
void mouseDoubleClickEvent(QMouseEvent *event);
private:
ChatWidget *m_chatWidget;
ChatWidget *chatWidget;
QPoint m_dragStart;
bool m_dragging;
QPoint dragStart;
bool dragging;
QHBoxLayout m_hbox;
QHBoxLayout hbox;
ChatWidgetHeaderButton m_leftLabel;
QLabel m_middleLabel;
ChatWidgetHeaderButton m_rightLabel;
ChatWidgetHeaderButton leftLabel;
QLabel middleLabel;
ChatWidgetHeaderButton rightLabel;
QMenu m_leftMenu;
QMenu m_rightMenu;
QMenu leftMenu;
QMenu rightMenu;
void leftButtonClicked();
void rightButtonClicked();

View file

@ -7,21 +7,21 @@
ChatWidgetHeaderButton::ChatWidgetHeaderButton()
: QWidget()
, hbox()
, m_label()
, m_mouseOver(false)
, m_mouseDown(false)
, label()
, mouseOver(false)
, mouseDown(false)
{
setLayout(&hbox);
hbox.setMargin(0);
hbox.addSpacing(6);
hbox.addWidget(&m_label);
hbox.addWidget(&this->label);
hbox.addSpacing(6);
QObject::connect(&m_label, &ChatWidgetHeaderButtonLabel::mouseUp, this,
QObject::connect(&this->label, &ChatWidgetHeaderButtonLabel::mouseUp, this,
&ChatWidgetHeaderButton::labelMouseUp);
QObject::connect(&m_label, &ChatWidgetHeaderButtonLabel::mouseDown, this,
&ChatWidgetHeaderButton::labelMouseDown);
QObject::connect(&this->label, &ChatWidgetHeaderButtonLabel::mouseDown,
this, &ChatWidgetHeaderButton::labelMouseDown);
}
void
@ -33,11 +33,11 @@ ChatWidgetHeaderButton::paintEvent(QPaintEvent *)
? QColor(0, 0, 0, 32)
: QColor(255, 255, 255, 32));
if (m_mouseDown) {
if (this->mouseDown) {
painter.fillRect(rect(), brush);
}
if (m_mouseOver) {
if (this->mouseOver) {
painter.fillRect(rect(), brush);
}
}
@ -46,7 +46,7 @@ void
ChatWidgetHeaderButton::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
m_mouseDown = true;
this->mouseDown = true;
repaint();
}
@ -56,7 +56,7 @@ void
ChatWidgetHeaderButton::mouseReleaseEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
m_mouseDown = false;
this->mouseDown = false;
repaint();
@ -67,7 +67,7 @@ ChatWidgetHeaderButton::mouseReleaseEvent(QMouseEvent *event)
void
ChatWidgetHeaderButton::enterEvent(QEvent *)
{
m_mouseOver = true;
this->mouseOver = true;
repaint();
}
@ -75,7 +75,7 @@ ChatWidgetHeaderButton::enterEvent(QEvent *)
void
ChatWidgetHeaderButton::leaveEvent(QEvent *)
{
m_mouseOver = false;
this->mouseOver = false;
repaint();
}
@ -83,7 +83,7 @@ ChatWidgetHeaderButton::leaveEvent(QEvent *)
void
ChatWidgetHeaderButton::labelMouseUp()
{
m_mouseDown = false;
this->mouseDown = false;
repaint();
@ -93,7 +93,7 @@ ChatWidgetHeaderButton::labelMouseUp()
void
ChatWidgetHeaderButton::labelMouseDown()
{
m_mouseDown = true;
this->mouseDown = true;
repaint();
}

View file

@ -16,9 +16,9 @@ public:
ChatWidgetHeaderButton();
ChatWidgetHeaderButtonLabel &
label()
getLabel()
{
return m_label;
return label;
}
signals:
@ -35,10 +35,10 @@ protected:
private:
QHBoxLayout hbox;
ChatWidgetHeaderButtonLabel m_label;
ChatWidgetHeaderButtonLabel label;
bool m_mouseOver;
bool m_mouseDown;
bool mouseOver;
bool mouseDown;
void labelMouseUp();
void labelMouseDown();

View file

@ -12,8 +12,8 @@
ChatWidgetView::ChatWidgetView(ChatWidget *parent)
: QWidget()
, m_chatWidget(parent)
, m_scrollbar(this)
, chatWidget(parent)
, scrollbar(this)
{
auto scroll = QScroller::scroller(this);
@ -23,7 +23,7 @@ ChatWidgetView::ChatWidgetView(ChatWidget *parent)
bool
ChatWidgetView::layoutMessages()
{
auto c = m_chatWidget->channel();
auto c = this->chatWidget->getChannel();
if (c == NULL)
return false;
@ -42,8 +42,8 @@ ChatWidgetView::layoutMessages()
void
ChatWidgetView::resizeEvent(QResizeEvent *)
{
m_scrollbar.resize(m_scrollbar.width(), height());
m_scrollbar.move(width() - m_scrollbar.width(), 0);
this->scrollbar.resize(this->scrollbar.width(), height());
this->scrollbar.move(width() - this->scrollbar.width(), 0);
layoutMessages();
}
@ -55,7 +55,7 @@ ChatWidgetView::paintEvent(QPaintEvent *)
painter.setRenderHint(QPainter::SmoothPixmapTransform);
auto c = m_chatWidget->channel();
auto c = this->chatWidget->getChannel();
QColor color;
@ -98,40 +98,50 @@ ChatWidgetView::paintEvent(QPaintEvent *)
auto messages = c->getMessagesClone();
int y = 0;
int start = this->scrollbar.getValue();
for (std::shared_ptr<Message> const &message : messages) {
for (WordPart const &wordPart : message.get()->wordParts()) {
if (start >= messages.length()) {
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.drawRect(wordPart.x(), wordPart.y() + y, wordPart.width(),
wordPart.height());
painter.drawRect(wordPart.getX(), wordPart.getY() + y,
wordPart.getWidth(), wordPart.getHeight());
// image
if (wordPart.word().isImage()) {
LazyLoadedImage &lli = wordPart.word().getImage();
if (wordPart.getWord().isImage()) {
LazyLoadedImage &lli = wordPart.getWord().getImage();
const QPixmap *image = lli.pixmap();
const QPixmap *image = lli.getPixmap();
if (image != NULL) {
painter.drawPixmap(
QRect(wordPart.x(), wordPart.y() + y, wordPart.width(),
wordPart.height()),
QRect(wordPart.getX(), wordPart.getY() + y,
wordPart.getWidth(), wordPart.getHeight()),
*image);
}
}
// text
else {
QColor color = wordPart.word().color();
QColor color = wordPart.getWord().getColor();
painter.setPen(color);
painter.setFont(wordPart.word().getFont());
painter.setFont(wordPart.getWord().getFont());
painter.drawText(
QRectF(wordPart.x(), wordPart.y() + y, 10000, 10000),
wordPart.text(), QTextOption(Qt::AlignLeft | Qt::AlignTop));
QRectF(wordPart.getX(), wordPart.getY() + y, 10000, 10000),
wordPart.getText(),
QTextOption(Qt::AlignLeft | Qt::AlignTop));
}
}
y += message.get()->height();
y += message->getHeight();
}
}

View file

@ -1,11 +1,12 @@
#ifndef CHATVIEW_H
#define CHATVIEW_H
#include <QWidget>
#include "QPaintEvent"
#include "channel.h"
#include "scrollbar.h"
#include <QPaintEvent>
#include <QWidget>
class ChatWidget;
class ChatWidgetView : public QWidget
@ -20,12 +21,12 @@ public:
protected:
void resizeEvent(QResizeEvent *);
private:
ChatWidget *m_chatWidget;
ScrollBar m_scrollbar;
void paintEvent(QPaintEvent *);
private:
ChatWidget *chatWidget;
ScrollBar scrollbar;
};
#endif // CHATVIEW_H

View file

@ -50,22 +50,22 @@ ColorScheme::setColors(float hue, float multiplyer)
// fillLookupTableValues(0.65, 0.83, 0.5, 0.7);
// fillLookupTableValues(0.83, 1, 0.7, 0.6);
fillLookupTableValues(m_middleLookupTable, 0.000, 0.166, 0.66, 0.5);
fillLookupTableValues(m_middleLookupTable, 0.166, 0.333, 0.5, 0.55);
fillLookupTableValues(m_middleLookupTable, 0.333, 0.500, 0.55, 0.45);
fillLookupTableValues(m_middleLookupTable, 0.500, 0.666, 0.45, 0.80);
fillLookupTableValues(m_middleLookupTable, 0.666, 0.833, 0.80, 0.61);
fillLookupTableValues(m_middleLookupTable, 0.833, 1.000, 0.61, 0.66);
fillLookupTableValues(this->middleLookupTable, 0.000, 0.166, 0.66, 0.5);
fillLookupTableValues(this->middleLookupTable, 0.166, 0.333, 0.5, 0.55);
fillLookupTableValues(this->middleLookupTable, 0.333, 0.500, 0.55, 0.45);
fillLookupTableValues(this->middleLookupTable, 0.500, 0.666, 0.45, 0.80);
fillLookupTableValues(this->middleLookupTable, 0.666, 0.833, 0.80, 0.61);
fillLookupTableValues(this->middleLookupTable, 0.833, 1.000, 0.61, 0.66);
fillLookupTableValues(m_minLookupTable, 0.000, 0.166, 0.33, 0.23);
fillLookupTableValues(m_minLookupTable, 0.166, 0.333, 0.23, 0.27);
fillLookupTableValues(m_minLookupTable, 0.333, 0.500, 0.27, 0.23);
fillLookupTableValues(m_minLookupTable, 0.500, 0.666, 0.23, 0.50);
fillLookupTableValues(m_minLookupTable, 0.666, 0.833, 0.50, 0.30);
fillLookupTableValues(m_minLookupTable, 0.833, 1.000, 0.30, 0.33);
fillLookupTableValues(this->minLookupTable, 0.000, 0.166, 0.33, 0.23);
fillLookupTableValues(this->minLookupTable, 0.166, 0.333, 0.23, 0.27);
fillLookupTableValues(this->minLookupTable, 0.333, 0.500, 0.27, 0.23);
fillLookupTableValues(this->minLookupTable, 0.500, 0.666, 0.23, 0.50);
fillLookupTableValues(this->minLookupTable, 0.666, 0.833, 0.50, 0.30);
fillLookupTableValues(this->minLookupTable, 0.833, 1.000, 0.30, 0.33);
// 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 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;
// newL = s * newL + (1 - s) * l;
@ -101,10 +101,10 @@ ColorScheme::normalizeColor(QColor &color)
qreal l = color.lightnessF();
qreal s = color.saturationF();
int h = std::max(0, color.hue());
qreal x = m_middleLookupTable[h];
qreal x = this->middleLookupTable[h];
x = s * 0.5 + (1 - s) * x;
qreal min = m_minLookupTable[h];
qreal min = this->minLookupTable[h];
min = (1 - s) * 0.5 + s * min;
qreal newL;

View file

@ -73,8 +73,8 @@ private:
{
}
qreal m_middleLookupTable[360] = {};
qreal m_minLookupTable[360] = {};
qreal middleLookupTable[360] = {};
qreal minLookupTable[360] = {};
void fillLookupTableValues(qreal (&array)[360], qreal from, qreal to,
qreal fromValue, qreal toValue);

View file

@ -1,21 +1,17 @@
#include "emojis.h"
#include "emotes.h"
#include <QFile>
#include <QStringBuilder>
#include <QTextStream>
#include "emojis.h"
#include "emotes.h"
QRegularExpression Emojis::findShortCodesRegex(":([-+\\w]+):");
QRegularExpression *Emojis::findShortCodesRegex =
new QRegularExpression(":([-+\\w]+):");
QMap<QString, Emojis::EmojiData> Emojis::shortCodeToEmoji;
QMap<QString, QString> Emojis::emojiToShortCode;
QMap<QChar, QMap<QString, QString>> Emojis::firstEmojiChars;
QMap<QString, Emojis::EmojiData> *Emojis::shortCodeToEmoji =
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 *>();
ConcurrentMap<QString, LazyLoadedImage *> Emojis::imageCache;
QString
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++) {
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--) {
QString emojiString = text.mid(i, 2);
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>(
imageCache->getOrAdd(url,
[&url] {
return new LazyLoadedImage(
url, 0.35);
}),
imageCache.getOrAdd(url,
[&url] {
return new LazyLoadedImage(
url, 0.35);
}),
QString()));
i += j - 1;
@ -104,23 +100,23 @@ Emojis::loadEmojis()
emotes[i++] = QString(item).toUInt(nullptr, 16);
}
shortCodeToEmoji->insert(
shortCodeToEmoji.insert(
a.at(0), Emojis::EmojiData{QString::fromUcs4(emotes, i), a.at(1)});
}
for (auto const &emoji : shortCodeToEmoji->toStdMap()) {
emojiToShortCode->insert(emoji.second.value, emoji.first);
for (auto const &emoji : shortCodeToEmoji.toStdMap()) {
emojiToShortCode.insert(emoji.second.value, emoji.first);
}
for (auto const &emoji : shortCodeToEmoji->toStdMap()) {
auto iter = firstEmojiChars->find(emoji.first.at(0));
for (auto const &emoji : shortCodeToEmoji.toStdMap()) {
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);
continue;
}
firstEmojiChars->insert(
firstEmojiChars.insert(
emoji.first.at(0),
QMap<QString, QString>{{emoji.second.value, emoji.second.code}});
}

View file

@ -26,13 +26,13 @@ public:
};
private:
static QRegularExpression *findShortCodesRegex;
static QRegularExpression findShortCodesRegex;
static QMap<QString, EmojiData> *shortCodeToEmoji;
static QMap<QString, QString> *emojiToShortCode;
static QMap<QChar, QMap<QString, QString>> *firstEmojiChars;
static QMap<QString, EmojiData> shortCodeToEmoji;
static QMap<QString, QString> emojiToShortCode;
static QMap<QChar, QMap<QString, QString>> firstEmojiChars;
static ConcurrentMap<QString, LazyLoadedImage *> *imageCache;
static ConcurrentMap<QString, LazyLoadedImage *> imageCache;
Emojis()
{

View file

@ -1,19 +1,19 @@
#include "emotes.h"
#include "resources.h"
QString Emotes::m_twitchEmoteTemplate(
QString Emotes::twitchEmoteTemplate(
"https://static-cdn.jtvnw.net/emoticons/v1/{id}/{scale}.0");
ConcurrentMap<QString, TwitchEmoteValue *> Emotes::m_twitchEmotes;
ConcurrentMap<QString, LazyLoadedImage *> Emotes::m_bttvEmotes;
ConcurrentMap<QString, LazyLoadedImage *> Emotes::m_ffzEmotes;
ConcurrentMap<QString, LazyLoadedImage *> Emotes::m_chatterinoEmotes;
ConcurrentMap<QString, LazyLoadedImage *> Emotes::m_bttvChannelEmoteFromCaches;
ConcurrentMap<QString, LazyLoadedImage *> Emotes::m_ffzChannelEmoteFromCaches;
ConcurrentMap<long, LazyLoadedImage *> Emotes::m_twitchEmoteFromCache;
ConcurrentMap<QString, LazyLoadedImage *> Emotes::m_miscImageFromCache;
ConcurrentMap<QString, TwitchEmoteValue *> Emotes::twitchEmotes;
ConcurrentMap<QString, LazyLoadedImage *> Emotes::bttvEmotes;
ConcurrentMap<QString, LazyLoadedImage *> Emotes::ffzEmotes;
ConcurrentMap<QString, LazyLoadedImage *> Emotes::chatterinoEmotes;
ConcurrentMap<QString, LazyLoadedImage *> Emotes::bttvChannelEmoteFromCaches;
ConcurrentMap<QString, LazyLoadedImage *> Emotes::ffzChannelEmoteFromCaches;
ConcurrentMap<long, LazyLoadedImage *> Emotes::twitchEmoteFromCache;
ConcurrentMap<QString, LazyLoadedImage *> Emotes::miscImageFromCache;
int Emotes::m_generation = 0;
int Emotes::generation = 0;
Emotes::Emotes()
{
@ -22,10 +22,9 @@ Emotes::Emotes()
LazyLoadedImage *
Emotes::getTwitchEmoteById(const QString &name, long id)
{
return m_twitchEmoteFromCache.getOrAdd(id, [&name, id] {
return Emotes::twitchEmoteFromCache.getOrAdd(id, [&name, id] {
qreal scale;
QString url = getTwitchEmoteLink(id, scale);
return new LazyLoadedImage(url, scale, name, name + "\nTwitch Emote");
});
}
@ -35,7 +34,7 @@ Emotes::getTwitchEmoteLink(long id, qreal &scale)
{
scale = .5;
return m_twitchEmoteTemplate.replace("{id}", QString::number(id))
return Emotes::twitchEmoteTemplate.replace("{id}", QString::number(id))
.replace("{scale}", "2");
}
@ -50,16 +49,16 @@ LazyLoadedImage *
Emotes::getCheerBadge(long long amount)
{
if (amount >= 100000) {
return Resources::cheerBadge100000();
return Resources::getCheerBadge100000();
} else if (amount >= 10000) {
return Resources::cheerBadge10000();
return Resources::getCheerBadge10000();
} else if (amount >= 5000) {
return Resources::cheerBadge5000();
return Resources::getCheerBadge5000();
} else if (amount >= 1000) {
return Resources::cheerBadge1000();
return Resources::getCheerBadge1000();
} else if (amount >= 100) {
return Resources::cheerBadge100();
return Resources::getCheerBadge100();
} else {
return Resources::cheerBadge1();
return Resources::getCheerBadge1();
}
}

View file

@ -11,51 +11,51 @@ class Emotes
{
public:
static ConcurrentMap<QString, TwitchEmoteValue *> &
twitchEmotes()
getTwitchEmotes()
{
return m_twitchEmotes;
return twitchEmotes;
}
static ConcurrentMap<QString, LazyLoadedImage *> &
bttvEmotes()
getBttvEmotes()
{
return m_bttvEmotes;
return bttvEmotes;
}
static ConcurrentMap<QString, LazyLoadedImage *> &
ffzEmotes()
getFfzEmotes()
{
return m_ffzEmotes;
return ffzEmotes;
}
static ConcurrentMap<QString, LazyLoadedImage *> &
chatterinoEmotes()
getChatterinoEmotes()
{
return m_chatterinoEmotes;
return chatterinoEmotes;
}
static ConcurrentMap<QString, LazyLoadedImage *> &
bttvChannelEmoteFromCaches()
getBttvChannelEmoteFromCaches()
{
return m_bttvChannelEmoteFromCaches;
return bttvChannelEmoteFromCaches;
}
static ConcurrentMap<QString, LazyLoadedImage *> &
ffzChannelEmoteFromCaches()
getFfzChannelEmoteFromCaches()
{
return m_ffzChannelEmoteFromCaches;
return ffzChannelEmoteFromCaches;
}
static ConcurrentMap<long, LazyLoadedImage *> &
twitchEmoteFromCache()
getTwitchEmoteFromCache()
{
return m_twitchEmoteFromCache;
return twitchEmoteFromCache;
}
static ConcurrentMap<QString, LazyLoadedImage *> &
miscImageFromCache()
getMiscImageFromCache()
{
return m_miscImageFromCache;
return miscImageFromCache;
}
static void loadGlobalEmotes();
@ -67,36 +67,34 @@ public:
long int id);
static int
generation()
getGeneration()
{
return m_generation;
return generation;
}
static void
incGeneration()
{
m_generation++;
generation++;
}
private:
Emotes();
static QString m_twitchEmoteTemplate;
static QString twitchEmoteTemplate;
static ConcurrentMap<QString, TwitchEmoteValue *> m_twitchEmotes;
static ConcurrentMap<QString, LazyLoadedImage *> m_bttvEmotes;
static ConcurrentMap<QString, LazyLoadedImage *> m_ffzEmotes;
static ConcurrentMap<QString, LazyLoadedImage *> m_chatterinoEmotes;
static ConcurrentMap<QString, LazyLoadedImage *>
m_bttvChannelEmoteFromCaches;
static ConcurrentMap<QString, LazyLoadedImage *>
m_ffzChannelEmoteFromCaches;
static ConcurrentMap<long, LazyLoadedImage *> m_twitchEmoteFromCache;
static ConcurrentMap<QString, LazyLoadedImage *> m_miscImageFromCache;
static ConcurrentMap<QString, TwitchEmoteValue *> twitchEmotes;
static ConcurrentMap<QString, LazyLoadedImage *> bttvEmotes;
static ConcurrentMap<QString, LazyLoadedImage *> ffzEmotes;
static ConcurrentMap<QString, LazyLoadedImage *> chatterinoEmotes;
static ConcurrentMap<QString, LazyLoadedImage *> bttvChannelEmoteFromCaches;
static ConcurrentMap<QString, LazyLoadedImage *> ffzChannelEmoteFromCaches;
static ConcurrentMap<long, LazyLoadedImage *> twitchEmoteFromCache;
static ConcurrentMap<QString, LazyLoadedImage *> miscImageFromCache;
static QString getTwitchEmoteLink(long id, qreal &scale);
static int m_generation;
static int generation;
};
#endif // EMOTES_H

View file

@ -16,7 +16,7 @@ QFontMetrics *Fonts::metricsSmall = new QFontMetrics(*small);
QFontMetrics *Fonts::metricsLarge = new QFontMetrics(*large);
QFontMetrics *Fonts::metricsVeryLarge = new QFontMetrics(*veryLarge);
int Fonts::m_generation = 0;
int Fonts::generation = 0;
Fonts::Fonts()
{

View file

@ -20,15 +20,15 @@ public:
static QFontMetrics &getFontMetrics(Type type);
static int
generation()
getGeneration()
{
return m_generation;
return generation;
}
static void
incGeneration()
{
m_generation++;
generation++;
}
private:
@ -48,7 +48,7 @@ private:
static QFontMetrics *metricsLarge;
static QFontMetrics *metricsVeryLarge;
static int m_generation;
static int generation;
};
#endif // FONTS_H

View file

@ -13,14 +13,14 @@
#include <future>
Account *IrcManager::account = nullptr;
IrcConnection *IrcManager::m_connection = NULL;
QMutex IrcManager::m_connectionMutex;
long IrcManager::m_connectionIteration = 0;
IrcConnection *IrcManager::connection = NULL;
QMutex IrcManager::connectionMutex;
long IrcManager::connectionGeneration = 0;
const QString IrcManager::defaultClientId = "7ue61iz46fz11y3cugd0l3tawb4taal";
QNetworkAccessManager IrcManager::m_accessManager;
QNetworkAccessManager IrcManager::accessManager;
QMap<QString, bool> IrcManager::m_twitchBlockedUsers;
QMutex IrcManager::m_twitchBlockedUsersMutex;
QMap<QString, bool> IrcManager::twitchBlockedUsers;
QMutex IrcManager::twitchBlockedUsersMutex;
IrcManager::IrcManager()
{
@ -37,9 +37,9 @@ IrcManager::connect()
void
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();
@ -49,9 +49,9 @@ IrcManager::beginConnecting()
if (account->isAnon()) {
// fetch ignored users
QString username = account->username();
QString oauthClient = account->oauthClient();
QString oauthToken = account->oauthToken();
QString username = account->getUsername();
QString oauthClient = account->getOauthClient();
QString oauthToken = account->getOauthToken();
{
QString nextLink = "https://api.twitch.tv/kraken/users/" +
@ -59,12 +59,12 @@ IrcManager::beginConnecting()
"&client_id=" + oauthClient;
QNetworkRequest req(QUrl(nextLink + "&oauth_token=" + oauthToken));
QNetworkReply *reply = m_accessManager.get(req);
QNetworkReply *reply = IrcManager::accessManager.get(req);
QObject::connect(reply, &QNetworkReply::finished, [=] {
m_twitchBlockedUsersMutex.lock();
m_twitchBlockedUsers.clear();
m_twitchBlockedUsersMutex.unlock();
IrcManager::twitchBlockedUsersMutex.lock();
IrcManager::twitchBlockedUsers.clear();
IrcManager::twitchBlockedUsersMutex.unlock();
QByteArray data = reply->readAll();
QJsonDocument jsonDoc(QJsonDocument::fromJson(data));
@ -75,15 +75,15 @@ IrcManager::beginConnecting()
auto blocks = root.value("blocks").toArray();
m_twitchBlockedUsersMutex.lock();
IrcManager::twitchBlockedUsersMutex.lock();
for (QJsonValue block : blocks) {
QJsonObject user =
block.toObject().value("user").toObject();
// display_name
m_twitchBlockedUsers.insert(
IrcManager::twitchBlockedUsers.insert(
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/" +
username + "/emotes?oauth_token=" +
oauthToken + "&client_id=" + oauthClient));
QNetworkReply *reply = m_accessManager.get(req);
QNetworkReply *reply = IrcManager::accessManager.get(req);
QObject::connect(reply, &QNetworkReply::finished, [=] {
QByteArray data = reply->readAll();
@ -104,15 +104,15 @@ IrcManager::beginConnecting()
auto blocks = root.value("blocks").toArray();
m_twitchBlockedUsersMutex.lock();
IrcManager::twitchBlockedUsersMutex.lock();
for (QJsonValue block : blocks) {
QJsonObject user =
block.toObject().value("user").toObject();
// display_name
m_twitchBlockedUsers.insert(
IrcManager::twitchBlockedUsers.insert(
user.value("name").toString().toLower(), true);
}
m_twitchBlockedUsersMutex.unlock();
IrcManager::twitchBlockedUsersMutex.unlock();
});
}
}
@ -129,48 +129,48 @@ IrcManager::beginConnecting()
c->open();
m_connectionMutex.lock();
if (iteration == m_connectionIteration) {
delete m_connection;
IrcManager::connectionMutex.lock();
if (generation == IrcManager::connectionGeneration) {
delete IrcManager::connection;
c->moveToThread(QCoreApplication::instance()->thread());
m_connection = c;
IrcManager::connection = c;
} else {
delete c;
}
m_connectionMutex.unlock();
IrcManager::connectionMutex.unlock();
}
void
IrcManager::disconnect()
{
m_connectionMutex.lock();
IrcManager::connectionMutex.lock();
if (m_connection != NULL) {
delete m_connection;
m_connection = NULL;
if (IrcManager::connection != NULL) {
delete IrcManager::connection;
IrcManager::connection = NULL;
}
m_connectionMutex.unlock();
IrcManager::connectionMutex.unlock();
}
void
IrcManager::joinChannel(const QString &channel)
{
m_connectionMutex.lock();
if (m_connection != NULL) {
m_connection->sendRaw("JOIN #" + channel);
IrcManager::connectionMutex.lock();
if (IrcManager::connection != NULL) {
IrcManager::connection->sendRaw("JOIN #" + channel);
}
m_connectionMutex.unlock();
IrcManager::connectionMutex.unlock();
}
void
IrcManager::partChannel(const QString &channel)
{
m_connectionMutex.lock();
if (m_connection != NULL) {
m_connection->sendRaw("PART #" + channel);
IrcManager::connectionMutex.lock();
if (IrcManager::connection != NULL) {
IrcManager::connection->sendRaw("PART #" + channel);
}
m_connectionMutex.unlock();
IrcManager::connectionMutex.unlock();
}
void
@ -204,34 +204,35 @@ IrcManager::privateMessageReceived(IrcPrivateMessage *message)
bool
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()) {
m_twitchBlockedUsersMutex.unlock();
if (iterator == IrcManager::twitchBlockedUsers.end()) {
IrcManager::twitchBlockedUsersMutex.unlock();
return false;
}
m_twitchBlockedUsersMutex.unlock();
IrcManager::twitchBlockedUsersMutex.unlock();
return true;
}
bool
IrcManager::tryAddIgnoredUser(QString const &username, QString &errorMessage)
{
QUrl url("https://api.twitch.tv/kraken/users/" + account->username() +
"/blocks/" + username + "?oauth_token=" + account->oauthToken() +
"&client_id=" + account->oauthClient());
QUrl url("https://api.twitch.tv/kraken/users/" + account->getUsername() +
"/blocks/" + username +
"?oauth_token=" + account->getOauthToken() +
"&client_id=" + account->getOauthClient());
QNetworkRequest request(url);
auto reply = m_accessManager.put(request, QByteArray());
auto reply = IrcManager::accessManager.put(request, QByteArray());
reply->waitForReadyRead(10000);
if (reply->error() == QNetworkReply::NoError) {
m_twitchBlockedUsersMutex.lock();
m_twitchBlockedUsers.insert(username, true);
m_twitchBlockedUsersMutex.unlock();
IrcManager::twitchBlockedUsersMutex.lock();
IrcManager::twitchBlockedUsers.insert(username, true);
IrcManager::twitchBlockedUsersMutex.unlock();
delete reply;
return true;
@ -254,18 +255,19 @@ IrcManager::addIgnoredUser(QString const &username)
bool
IrcManager::tryRemoveIgnoredUser(QString const &username, QString &errorMessage)
{
QUrl url("https://api.twitch.tv/kraken/users/" + account->username() +
"/blocks/" + username + "?oauth_token=" + account->oauthToken() +
"&client_id=" + account->oauthClient());
QUrl url("https://api.twitch.tv/kraken/users/" + account->getUsername() +
"/blocks/" + username +
"?oauth_token=" + account->getOauthToken() +
"&client_id=" + account->getOauthClient());
QNetworkRequest request(url);
auto reply = m_accessManager.deleteResource(request);
auto reply = IrcManager::accessManager.deleteResource(request);
reply->waitForReadyRead(10000);
if (reply->error() == QNetworkReply::NoError) {
m_twitchBlockedUsersMutex.lock();
m_twitchBlockedUsers.remove(username);
m_twitchBlockedUsersMutex.unlock();
IrcManager::twitchBlockedUsersMutex.lock();
IrcManager::twitchBlockedUsers.remove(username);
IrcManager::twitchBlockedUsersMutex.unlock();
delete reply;
return true;

View file

@ -29,9 +29,9 @@ public:
static Account *account;
static QNetworkAccessManager &
accessManager()
getAccessManager()
{
return m_accessManager;
return accessManager;
}
static void joinChannel(const QString &channel);
@ -41,16 +41,16 @@ public:
private:
IrcManager();
static QMap<QString, bool> m_twitchBlockedUsers;
static QMutex m_twitchBlockedUsersMutex;
static QMap<QString, bool> twitchBlockedUsers;
static QMutex twitchBlockedUsersMutex;
static QNetworkAccessManager m_accessManager;
static QNetworkAccessManager accessManager;
static void beginConnecting();
static IrcConnection *m_connection;
static QMutex m_connectionMutex;
static long m_connectionIteration;
static IrcConnection *connection;
static QMutex connectionMutex;
static long connectionGeneration;
static void messageReceived(IrcMessage *message);
static void privateMessageReceived(IrcPrivateMessage *message);

View file

@ -8,5 +8,5 @@ LambdaQRunnable::LambdaQRunnable(std::function<void()> action)
void
LambdaQRunnable::run()
{
action();
this->action();
}

View file

@ -13,30 +13,30 @@
LazyLoadedImage::LazyLoadedImage(const QString &url, qreal scale,
const QString &name, const QString &tooltip,
const QMargins &margin, bool isHat)
: m_pixmap(NULL)
, m_url(url)
, m_name(name)
, m_tooltip(tooltip)
, m_animated(false)
, m_margin(margin)
, m_ishat(isHat)
, m_scale(scale)
, m_isLoading(false)
: pixmap(NULL)
, url(url)
, name(name)
, tooltip(tooltip)
, animated(false)
, margin(margin)
, ishat(isHat)
, scale(scale)
, isLoading(false)
{
}
LazyLoadedImage::LazyLoadedImage(QPixmap *image, qreal scale,
const QString &name, const QString &tooltip,
const QMargins &margin, bool isHat)
: m_pixmap(image)
, m_url()
, m_name(name)
, m_tooltip(tooltip)
, m_animated(false)
, m_margin(margin)
, m_ishat(isHat)
, m_scale(scale)
, m_isLoading(true)
: pixmap(image)
, url()
, name(name)
, tooltip(tooltip)
, animated(false)
, margin(margin)
, ishat(isHat)
, scale(scale)
, isLoading(true)
{
}
@ -44,10 +44,10 @@ void
LazyLoadedImage::loadImage()
{
// QThreadPool::globalInstance()->start(new LambdaQRunnable([=] {
QUrl url(m_url);
QUrl url(this->url);
QNetworkRequest request(url);
QNetworkReply *reply = IrcManager::accessManager().get(request);
QNetworkReply *reply = IrcManager::getAccessManager().get(request);
QObject::connect(reply, &QNetworkReply::finished, [=] {
QPixmap *pixmap = new QPixmap();
@ -57,7 +57,7 @@ LazyLoadedImage::loadImage()
return;
}
m_pixmap = pixmap;
this->pixmap = pixmap;
Emotes::incGeneration();
Windows::layoutVisibleChatWidgets();
});

View file

@ -7,96 +7,100 @@
class LazyLoadedImage
{
public:
LazyLoadedImage(const QString &url, qreal scale = 1,
const QString &name = "", const QString &tooltip = "",
const QMargins &margin = QMargins(), bool isHat = false);
LazyLoadedImage(QPixmap *pixmap, qreal scale = 1, const QString &name = "",
const QString &tooltip = "",
const QMargins &margin = QMargins(), bool isHat = false);
explicit LazyLoadedImage(const QString &url, qreal scale = 1,
const QString &getName = "",
const QString &getTooltip = "",
const QMargins &getMargin = QMargins(),
bool getIsHat = false);
explicit LazyLoadedImage(QPixmap *pixmap, qreal scale = 1,
const QString &getName = "",
const QString &getTooltip = "",
const QMargins &getMargin = QMargins(),
bool getIsHat = false);
const QPixmap *
pixmap()
getPixmap()
{
if (!m_isLoading) {
m_isLoading = true;
if (!isLoading) {
isLoading = true;
loadImage();
}
return m_pixmap;
return pixmap;
}
qreal
scale() const
getScale() const
{
return m_scale;
return scale;
}
const QString &
url() const
getUrl() const
{
return m_url;
return url;
}
const QString &
name() const
getName() const
{
return m_name;
return name;
}
const QString &
tooltip() const
getTooltip() const
{
return m_tooltip;
return tooltip;
}
const QMargins &
margin() const
getMargin() const
{
return m_margin;
return margin;
}
bool
animated() const
getAnimated() const
{
return m_animated;
return animated;
}
bool
isHat() const
getIsHat() const
{
return m_ishat;
return ishat;
}
int
width() const
getWidth() const
{
if (m_pixmap == NULL) {
if (pixmap == NULL) {
return 16;
}
return m_pixmap->width();
return pixmap->width();
}
int
height() const
getHeight() const
{
if (m_pixmap == NULL) {
if (pixmap == NULL) {
return 16;
}
return m_pixmap->height();
return pixmap->height();
}
private:
QPixmap *m_pixmap;
QPixmap *pixmap;
QString m_url;
QString m_name;
QString m_tooltip;
bool m_animated;
QMargins m_margin;
bool m_ishat;
qreal m_scale;
QString url;
QString name;
QString tooltip;
bool animated;
QMargins margin;
bool ishat;
qreal scale;
bool m_isLoading;
bool isLoading;
void loadImage();
};

View file

@ -1,13 +1,13 @@
#include "link.h"
Link::Link()
: m_type(None)
, m_value(QString())
: type(None)
, value(QString())
{
}
Link::Link(Type type, const QString &value)
: m_type(type)
, m_value(value)
: type(type)
, value(value)
{
}

18
link.h
View file

@ -18,29 +18,29 @@ public:
};
Link();
Link(Type type, const QString &value);
Link(Type getType, const QString &getValue);
bool
isValid()
getIsValid()
{
return m_type == None;
return type == None;
}
Type
type()
getType()
{
return m_type;
return type;
}
const QString &
value()
getValue()
{
return m_value;
return value;
}
private:
Type m_type;
QString m_value;
Type type;
QString value;
};
#endif // LINK_H

View file

@ -19,7 +19,7 @@ main(int argc, char *argv[])
ColorScheme::instance().setColors(0, -0.8);
MainWindow &w = Windows::mainWindow();
MainWindow &w = Windows::getMainWindow();
w.show();
IrcManager::connect();

View file

@ -29,19 +29,19 @@ MainWindow::~MainWindow()
void
MainWindow::layoutVisibleChatWidgets(Channel *channel)
{
auto *page = notebook.selected();
auto *page = notebook.getSelectedPage();
if (page == NULL) {
return;
}
const std::vector<ChatWidget *> &widgets = page->chatWidgets();
const std::vector<ChatWidget *> &widgets = page->getChatWidgets();
for (auto it = widgets.begin(); it != widgets.end(); ++it) {
ChatWidget *widget = *it;
if (channel == NULL || channel == widget->channel()) {
if (widget->view().layoutMessages()) {
if (channel == NULL || channel == widget->getChannel()) {
if (widget->getView().layoutMessages()) {
widget->repaint();
}
}
@ -51,19 +51,19 @@ MainWindow::layoutVisibleChatWidgets(Channel *channel)
void
MainWindow::repaintVisibleChatWidgets(Channel *channel)
{
auto *page = notebook.selected();
auto *page = notebook.getSelectedPage();
if (page == NULL) {
return;
}
const std::vector<ChatWidget *> &widgets = page->chatWidgets();
const std::vector<ChatWidget *> &widgets = page->getChatWidgets();
for (auto it = widgets.begin(); it != widgets.end(); ++it) {
ChatWidget *widget = *it;
if (channel == NULL || channel == widget->channel()) {
widget->view().layoutMessages();
if (channel == NULL || channel == widget->getChannel()) {
widget->getView().layoutMessages();
widget->repaint();
}
}

View file

@ -23,16 +23,16 @@ QRegularExpression *Message::cheerRegex =
new QRegularExpression("cheer[1-9][0-9]*");
Message::Message(const QString &text)
: m_wordParts(new std::vector<WordPart>())
: wordParts(new std::vector<WordPart>())
{
}
Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
bool enablePingSound, bool isReceivedWhisper,
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>();
@ -41,7 +41,7 @@ Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
auto iterator = tags.find("id");
if (iterator != tags.end()) {
m_id = iterator.value().toString();
this->id = iterator.value().toString();
}
// timestamps
@ -74,10 +74,10 @@ Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
static QString buttonBanTooltip("Ban 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,
Link(Link::UserBan, ircMessage.account())));
words.push_back(Word(Resources::buttonTimeout(), Word::ButtonTimeout,
words.push_back(Word(Resources::getButtonTimeout(), Word::ButtonTimeout,
QString(), buttonTimeoutTooltip,
Link(Link::UserTimeout, ircMessage.account())));
@ -95,29 +95,32 @@ Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
Emotes::getCheerBadge(cheer), Word::BadgeCheer, QString(),
QString("Twitch Cheer" + QString::number(cheer))));
} else if (badge == "staff/1") {
words.push_back(Word(Resources::badgeStaff(), Word::BadgeStaff,
QString(), QString("Twitch Staff")));
words.push_back(Word(Resources::getBadgeStaff(),
Word::BadgeStaff, QString(),
QString("Twitch Staff")));
} else if (badge == "admin/1") {
words.push_back(Word(Resources::badgeAdmin(), Word::BadgeAdmin,
QString(), QString("Twitch Admin")));
words.push_back(Word(Resources::getBadgeAdmin(),
Word::BadgeAdmin, QString(),
QString("Twitch Admin")));
} else if (badge == "global_mod/1") {
words.push_back(Word(Resources::badgeGlobalmod(),
words.push_back(Word(Resources::getBadgeGlobalmod(),
Word::BadgeGlobalMod, QString(),
QString("Global Moderator")));
} else if (badge == "moderator/1") {
// TODO: implement this xD
words.push_back(Word(
Resources::badgeTurbo(), Word::BadgeModerator, QString(),
Resources::getBadgeTurbo(), Word::BadgeModerator, QString(),
QString("Channel Moderator"))); // custom badge
} else if (badge == "turbo/1") {
words.push_back(Word(Resources::badgeStaff(), Word::BadgeTurbo,
QString(), QString("Turbo Subscriber")));
words.push_back(Word(Resources::getBadgeStaff(),
Word::BadgeTurbo, QString(),
QString("Turbo Subscriber")));
} else if (badge == "broadcaster/1") {
words.push_back(Word(Resources::badgeBroadcaster(),
words.push_back(Word(Resources::getBadgeBroadcaster(),
Word::BadgeBroadcaster, QString(),
QString("Channel Broadcaster")));
} else if (badge == "premium/1") {
words.push_back(Word(Resources::badgePremium(),
words.push_back(Word(Resources::getBadgePremium(),
Word::BadgePremium, QString(),
QString("Twitch Prime")));
}
@ -134,21 +137,21 @@ Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
// channel name
if (includeChannel) {
QString channelName("#" + channel.name());
words.push_back(Word(channelName, Word::Misc,
ColorScheme::instance().SystemMessageColor,
QString(channelName), QString(),
Link(Link::Url, channel.name() + "\n" + m_id)));
QString channelName("#" + channel.getName());
words.push_back(Word(
channelName, Word::Misc, ColorScheme::instance().SystemMessageColor,
QString(channelName), QString(),
Link(Link::Url, channel.getName() + "\n" + this->id)));
}
// username
m_userName = ircMessage.account();
this->userName = ircMessage.account();
if (m_userName.isEmpty()) {
if (this->userName.isEmpty()) {
auto iterator = tags.find("login");
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());
if (isSentWhisper) {
userDisplayString = IrcManager::account->username() + " -> ";
userDisplayString = IrcManager::account->getUsername() + " -> ";
}
if (isReceivedWhisper) {
userDisplayString += " -> " + IrcManager::account->username();
userDisplayString += " -> " + IrcManager::account->getUsername();
}
if (!ircMessage.isAction()) {
@ -182,8 +185,8 @@ Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
words.push_back(Word(userDisplayString, Word::Username, usernameColor,
userDisplayString, QString()));
// highlights
// TODO: implement this xD
// highlights
// TODO: implement this xD
// bits
QString bits = "";
@ -254,13 +257,13 @@ Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
currentTwitchEmote->first == i) {
words.push_back(Word(currentTwitchEmote->second,
Word::TwitchEmoteImage,
currentTwitchEmote->second->name(),
currentTwitchEmote->second->name() +
currentTwitchEmote->second->getName(),
currentTwitchEmote->second->getName() +
QString("\nTwitch Emote")));
words.push_back(Word(currentTwitchEmote->second->name(),
words.push_back(Word(currentTwitchEmote->second->getName(),
Word::TwitchEmoteText, textColor,
currentTwitchEmote->second->name(),
currentTwitchEmote->second->name() +
currentTwitchEmote->second->getName(),
currentTwitchEmote->second->getName() +
QString("\nTwitch Emote")));
i += split.length() + 1;
@ -313,12 +316,12 @@ Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
color + "/1");
LazyLoadedImage *imageAnimated =
Emotes::miscImageFromCache().getOrAdd(
Emotes::getMiscImageFromCache().getOrAdd(
bitsLinkAnimated, [&bitsLinkAnimated] {
return new LazyLoadedImage(bitsLinkAnimated);
});
LazyLoadedImage *image =
Emotes::miscImageFromCache().getOrAdd(
Emotes::getMiscImageFromCache().getOrAdd(
bitsLink, [&bitsLink] {
return new LazyLoadedImage(bitsLink);
});
@ -354,15 +357,15 @@ Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
LazyLoadedImage *bttvEmote;
// TODO: Implement this (ignored emotes)
if (Emotes::bttvEmotes().tryGet(string, bttvEmote) ||
channel.bttvChannelEmotes().tryGet(string, bttvEmote) ||
Emotes::ffzEmotes().tryGet(string, bttvEmote) ||
channel.ffzChannelEmotes().tryGet(string, bttvEmote) ||
Emotes::chatterinoEmotes().tryGet(string, bttvEmote)) {
if (Emotes::getBttvEmotes().tryGet(string, bttvEmote) ||
channel.getBttvChannelEmotes().tryGet(string, bttvEmote) ||
Emotes::getFfzEmotes().tryGet(string, bttvEmote) ||
channel.getFfzChannelEmotes().tryGet(string, bttvEmote) ||
Emotes::getChatterinoEmotes().tryGet(string, bttvEmote)) {
words.push_back(Word(bttvEmote, Word::BttvEmoteImage,
bttvEmote->name(),
bttvEmote->tooltip(),
Link(Link::Url, bttvEmote->url())));
bttvEmote->getName(),
bttvEmote->getTooltip(),
Link(Link::Url, bttvEmote->getUrl())));
continue;
}
@ -376,17 +379,17 @@ Message::Message(const IrcPrivateMessage &ircMessage, const Channel &channel,
} else { // is emoji
static QString emojiTooltip("Emoji");
words.push_back(
Word(image, Word::EmojiImage, image->name(), emojiTooltip));
Word(image->name(), Word::EmojiText, textColor, image->name(),
emojiTooltip);
words.push_back(Word(image, Word::EmojiImage, image->getName(),
emojiTooltip));
Word(image->getName(), Word::EmojiText, textColor,
image->getName(), emojiTooltip);
}
}
i += split.length() + 1;
}
this->m_words = words;
this->words = words;
// TODO: Implement this xD
// if (!isReceivedWhisper &&
@ -404,34 +407,35 @@ Message::layout(int width, bool enableEmoteMargins)
int mediumTextLineHeight = Fonts::getFontMetrics(Fonts::Medium).height();
int spaceWidth = 4;
bool redraw = width != m_currentLayoutWidth || m_relayoutRequested;
bool redraw = width != this->currentLayoutWidth || this->relayoutRequested;
bool recalculateImages = m_emoteGeneration != Emotes::generation();
bool recalculateText = m_fontGeneration != Fonts::generation();
bool recalculateImages = this->emoteGeneration != Emotes::getGeneration();
bool recalculateText = this->fontGeneration != Fonts::getGeneration();
if (recalculateImages || recalculateText) {
m_emoteGeneration = Emotes::generation();
m_fontGeneration = Fonts::generation();
this->emoteGeneration = Emotes::getGeneration();
this->fontGeneration = Fonts::getGeneration();
redraw = true;
for (auto &word : m_words) {
for (auto &word : this->words) {
if (word.isImage()) {
if (recalculateImages) {
auto &image = word.getImage();
qreal w = image.width();
qreal h = image.height();
qreal w = image.getWidth();
qreal h = image.getHeight();
if (AppSettings::scaleEmotesByLineHeight()) {
word.setSize(
w * mediumTextLineHeight / h *
AppSettings::emoteScale(),
mediumTextLineHeight * AppSettings::emoteScale());
if (AppSettings::getScaleEmotesByLineHeight()) {
word.setSize(w * mediumTextLineHeight / h *
AppSettings::getEmoteScale(),
mediumTextLineHeight *
AppSettings::getEmoteScale());
} else {
word.setSize(
w * image.scale() * AppSettings::emoteScale(),
h * image.scale() * AppSettings::emoteScale());
w * image.getScale() * AppSettings::getEmoteScale(),
h * image.getScale() *
AppSettings::getEmoteScale());
}
}
} else {
@ -463,32 +467,32 @@ Message::layout(int width, bool enableEmoteMargins)
for (int i = lineStart; i < parts->size(); 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;
if ((word.type() & flags) == Word::None) {
if ((word.getType() & flags) == Word::None) {
continue;
}
int xOffset = 0, yOffset = 0;
if (enableEmoteMargins) {
if (word.isImage() && word.getImage().isHat()) {
xOffset = -word.width() + 2;
if (word.isImage() && word.getImage().getIsHat()) {
xOffset = -word.getWidth() + 2;
} else {
xOffset = word.xOffset();
yOffset = word.yOffset();
xOffset = word.getXOffset();
yOffset = word.getYOffset();
}
}
// word wrapping
if (word.isText() && word.width() + MARGIN_LEFT > right) {
if (word.isText() && word.getWidth() + MARGIN_LEFT > right) {
alignParts();
y += lineHeight;
@ -500,7 +504,7 @@ Message::layout(int width, bool enableEmoteMargins)
int width = 0;
std::vector<short> &charWidths = word.characterWidthCache();
std::vector<short> &charWidths = word.getCharacterWidthCache();
if (charWidths.size() == 0) {
charWidths.reserve(text.length());
@ -515,7 +519,7 @@ Message::layout(int width, bool enableEmoteMargins)
QString mid = text.mid(start, i - start - 1);
parts->push_back(WordPart(word, MARGIN_LEFT, y, width,
word.height(), mid, mid));
word.getHeight(), mid, mid));
y += metrics.height();
@ -528,11 +532,11 @@ Message::layout(int width, bool enableEmoteMargins)
QString mid(text.mid(start));
width = metrics.width(mid);
parts->push_back(WordPart(word, MARGIN_LEFT, y - word.height(),
width, word.height(), mid, mid));
parts->push_back(WordPart(word, MARGIN_LEFT, y - word.getHeight(),
width, word.getHeight(), mid, mid));
x = width + MARGIN_LEFT + spaceWidth;
lineHeight = word.height();
lineHeight = word.getHeight();
lineStart = parts->size() - 1;
@ -540,14 +544,14 @@ Message::layout(int width, bool enableEmoteMargins)
}
// fits in the line
else if (first || x + word.width() + xOffset <= right) {
else if (first || x + word.getWidth() + xOffset <= right) {
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;
lineHeight = std::max(word.height(), lineHeight);
lineHeight = std::max(word.getHeight(), lineHeight);
first = false;
}
@ -558,25 +562,25 @@ Message::layout(int width, bool enableEmoteMargins)
y += lineHeight;
parts->push_back(WordPart(word, MARGIN_LEFT, y - word.height(),
word.copyText()));
parts->push_back(WordPart(word, MARGIN_LEFT, y - word.getHeight(),
word.getCopyText()));
lineStart = parts->size() - 1;
lineHeight = word.height();
lineHeight = word.getHeight();
x = word.width() + MARGIN_LEFT;
x = word.getWidth() + MARGIN_LEFT;
x += spaceWidth;
}
}
alignParts();
auto tmp = m_wordParts;
m_wordParts = parts;
auto tmp = this->wordParts;
this->wordParts = parts;
delete tmp;
m_height = y + lineHeight;
this->height = y + lineHeight;
return true;
}

View file

@ -19,69 +19,69 @@ public:
~Message()
{
if (m_wordParts != NULL) {
delete m_wordParts;
if (wordParts != NULL) {
delete wordParts;
}
}
bool
canHighlightTab() const
getCanHighlightTab() const
{
return m_highlightTab;
return highlightTab;
}
const QString &
timeoutUser() const
getTimeoutUser() const
{
return m_timeoutUser;
return timeoutUser;
}
int
timeoutCount() const
getTimeoutCount() const
{
return m_timeoutCount;
return timeoutCount;
}
const QString &
userName() const
getUserName() const
{
return m_userName;
return userName;
}
const QString &
displayName() const
getDisplayName() const
{
return m_displayName;
return displayName;
}
const std::vector<Word>
words() const
getWords() const
{
return m_words;
return words;
}
const std::vector<WordPart>
wordParts() const
getWordParts() const
{
return *m_wordParts;
return *wordParts;
}
bool
disabled() const
getDisabled() const
{
return m_disabled;
return disabled;
}
const QString &
id() const
getId() const
{
return m_id;
return id;
}
int
height() const
getHeight() const
{
return m_height;
return height;
}
bool layout(int width, bool enableEmoteMargins = true);
@ -89,7 +89,7 @@ public:
void
requestRelayout()
{
m_relayoutRequested = true;
relayoutRequested = true;
}
private:
@ -103,25 +103,25 @@ private:
static QRegularExpression *cheerRegex;
bool m_highlightTab = false;
QString m_timeoutUser = "";
int m_timeoutCount = 0;
bool m_disabled = false;
std::chrono::time_point<std::chrono::system_clock> m_parseTime;
bool highlightTab = false;
QString timeoutUser = "";
int timeoutCount = 0;
bool disabled = false;
std::chrono::time_point<std::chrono::system_clock> parseTime;
QString m_userName = "";
QString m_displayName = "";
QString m_id = "";
QString userName = "";
QString displayName = "";
QString id = "";
int m_height = 0;
int height = 0;
std::vector<Word> m_words;
std::vector<WordPart> *m_wordParts;
std::vector<Word> words;
std::vector<WordPart> *wordParts;
long m_currentLayoutWidth = -1;
bool m_relayoutRequested = true;
int m_fontGeneration = -1;
int m_emoteGeneration = -1;
long currentLayoutWidth = -1;
bool relayoutRequested = true;
int fontGeneration = -1;
int emoteGeneration = -1;
static QString matchLink(const QString &string);

View file

@ -12,19 +12,19 @@
Notebook::Notebook(QWidget *parent)
: QWidget(parent)
, m_addButton(this)
, m_settingsButton(this)
, m_userButton(this)
, addButton(this)
, settingsButton(this)
, userButton(this)
{
connect(&m_settingsButton, SIGNAL(clicked()), this,
connect(&this->settingsButton, SIGNAL(clicked()), this,
SLOT(settingsButtonClicked()));
m_settingsButton.resize(24, 24);
m_settingsButton.icon = NotebookButton::IconSettings;
m_userButton.resize(24, 24);
m_userButton.move(24, 0);
m_userButton.icon = NotebookButton::IconUser;
m_addButton.resize(24, 24);
this->settingsButton.resize(24, 24);
this->settingsButton.icon = NotebookButton::IconSettings;
this->userButton.resize(24, 24);
this->userButton.move(24, 0);
this->userButton.icon = NotebookButton::IconUser;
this->addButton.resize(24, 24);
}
void
@ -41,11 +41,11 @@ Notebook::addPage()
auto tab = new NotebookTab(this);
auto page = new NotebookPage(this, tab);
if (m_pages.count() == 0) {
if (this->pages.count() == 0) {
select(page);
}
this->m_pages.append(page);
this->pages.append(page);
return page;
}
@ -53,7 +53,7 @@ Notebook::addPage()
void
Notebook::select(NotebookPage *page)
{
if (page == m_selected)
if (page == this->selectedPage)
return;
if (page != nullptr) {
@ -61,12 +61,12 @@ Notebook::select(NotebookPage *page)
page->tab->setSelected(true);
}
if (m_selected != nullptr) {
m_selected->setHidden(true);
m_selected->tab->setSelected(false);
if (this->selectedPage != nullptr) {
this->selectedPage->setHidden(true);
this->selectedPage->tab->setSelected(false);
}
m_selected = page;
this->selectedPage = page;
performLayout();
}
@ -78,11 +78,11 @@ Notebook::performLayout()
int tabHeight = 16;
bool first = true;
for (auto &i : m_pages) {
for (auto &i : this->pages) {
tabHeight = i->tab->height();
if (!first &&
(i == m_pages.last() ? tabHeight : 0) + x + i->tab->width() >
(i == this->pages.last() ? tabHeight : 0) + x + i->tab->width() >
width()) {
y += i->tab->height();
i->tab->move(0, y);
@ -95,11 +95,11 @@ Notebook::performLayout()
first = false;
}
this->m_addButton.move(x, y);
this->addButton.move(x, y);
if (m_selected != nullptr) {
m_selected->move(0, y + tabHeight);
m_selected->resize(width(), height() - y - tabHeight);
if (this->selectedPage != nullptr) {
this->selectedPage->move(0, y + tabHeight);
this->selectedPage->resize(width(), height() - y - tabHeight);
}
}

View file

@ -21,9 +21,9 @@ public:
void select(NotebookPage *page);
NotebookPage *
selected()
getSelectedPage()
{
return m_selected;
return selectedPage;
}
void performLayout();
@ -37,13 +37,13 @@ public slots:
void settingsButtonClicked();
private:
QList<NotebookPage *> m_pages;
QList<NotebookPage *> pages;
NotebookButton m_addButton;
NotebookButton m_settingsButton;
NotebookButton m_userButton;
NotebookButton addButton;
NotebookButton settingsButton;
NotebookButton userButton;
NotebookPage *m_selected = nullptr;
NotebookPage *selectedPage = nullptr;
};
#endif // NOTEBOOK_H

View file

@ -14,9 +14,9 @@ std::pair<int, int> NotebookPage::dropPosition = std::pair<int, int>(-1, -1);
NotebookPage::NotebookPage(QWidget *parent, NotebookTab *tab)
: QWidget(parent)
, m_parentbox(this)
, m_preview(this)
, m_chatWidgets()
, parentbox(this)
, preview(this)
, chatWidgets()
{
this->tab = tab;
tab->page = this;
@ -24,27 +24,28 @@ NotebookPage::NotebookPage(QWidget *parent, NotebookTab *tab)
setHidden(true);
setAcceptDrops(true);
m_parentbox.addSpacing(2);
m_parentbox.addLayout(&m_hbox);
m_parentbox.setMargin(0);
this->parentbox.addSpacing(2);
this->parentbox.addLayout(&this->hbox);
this->parentbox.setMargin(0);
m_hbox.setSpacing(1);
m_hbox.setMargin(0);
this->hbox.setSpacing(1);
this->hbox.setMargin(0);
}
std::pair<int, int>
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) {
m_chatWidgets.erase(it);
this->chatWidgets.erase(it);
break;
}
}
for (int i = 0; i < m_hbox.count(); ++i) {
auto vbox = static_cast<QVBoxLayout *>(m_hbox.itemAt(i));
for (int i = 0; i < this->hbox.count(); ++i) {
auto vbox = static_cast<QVBoxLayout *>(this->hbox.itemAt(i));
for (int j = 0; j < vbox->count(); ++j) {
if (vbox->itemAt(j)->widget() != widget)
@ -55,7 +56,7 @@ NotebookPage::removeFromLayout(ChatWidget *widget)
bool isLastItem = vbox->count() == 0;
if (isLastItem) {
m_hbox.removeItem(vbox);
this->hbox.removeItem(vbox);
delete vbox;
}
@ -72,14 +73,14 @@ NotebookPage::addToLayout(
ChatWidget *widget,
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
if (position.first < 0 || position.first >= m_hbox.count()) {
if (position.first < 0 || position.first >= this->hbox.count()) {
auto vbox = new QVBoxLayout();
vbox->addWidget(widget);
m_hbox.addLayout(vbox);
this->hbox.addLayout(vbox);
return;
}
@ -88,12 +89,12 @@ NotebookPage::addToLayout(
auto vbox = new QVBoxLayout();
vbox->addWidget(widget);
m_hbox.insertLayout(position.first, vbox);
this->hbox.insertLayout(position.first, vbox);
return;
}
// 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)),
widget);
@ -102,7 +103,7 @@ NotebookPage::addToLayout(
void
NotebookPage::enterEvent(QEvent *)
{
if (m_hbox.count() == 0) {
if (this->hbox.count() == 0) {
setCursor(QCursor(Qt::PointingHandCursor));
} else {
setCursor(QCursor(Qt::ArrowCursor));
@ -117,7 +118,7 @@ NotebookPage::leaveEvent(QEvent *)
void
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));
setCursor(QCursor(Qt::ArrowCursor));
@ -131,27 +132,27 @@ NotebookPage::dragEnterEvent(QDragEnterEvent *event)
return;
if (isDraggingSplit) {
m_dropRegions.clear();
this->dropRegions.clear();
if (m_hbox.count() == 0) {
m_dropRegions.push_back(
if (this->hbox.count() == 0) {
this->dropRegions.push_back(
DropRegion(rect(), std::pair<int, int>(-1, -1)));
} else {
for (int i = 0; i < m_hbox.count() + 1; ++i) {
m_dropRegions.push_back(DropRegion(
QRect(((i * 4 - 1) * width() / m_hbox.count()) / 4, 0,
width() / m_hbox.count() / 2, height()),
for (int i = 0; i < this->hbox.count() + 1; ++i) {
this->dropRegions.push_back(DropRegion(
QRect(((i * 4 - 1) * width() / this->hbox.count()) / 4, 0,
width() / this->hbox.count() / 2, height()),
std::pair<int, int>(i, -1)));
}
for (int i = 0; i < m_hbox.count(); ++i) {
auto vbox = static_cast<QVBoxLayout *>(m_hbox.itemAt(i));
for (int i = 0; i < this->hbox.count(); ++i) {
auto vbox = static_cast<QVBoxLayout *>(this->hbox.itemAt(i));
for (int j = 0; j < vbox->count() + 1; ++j) {
m_dropRegions.push_back(DropRegion(
QRect(i * width() / m_hbox.count(),
this->dropRegions.push_back(DropRegion(
QRect(i * width() / this->hbox.count(),
((j * 2 - 1) * height() / vbox->count()) / 2,
width() / m_hbox.count(),
width() / this->hbox.count(),
height() / vbox->count()),
std::pair<int, int>(i, j)));
}
@ -173,20 +174,20 @@ NotebookPage::dragMoveEvent(QDragMoveEvent *event)
void
NotebookPage::setPreviewRect(QPoint mousePos)
{
for (DropRegion region : m_dropRegions) {
for (DropRegion region : this->dropRegions) {
if (region.rect.contains(mousePos)) {
m_preview.setBounds(region.rect);
// m_preview.move(region.rect.x(), region.rect.y());
// m_preview.resize(region.rect.width(),
this->preview.setBounds(region.rect);
// this->preview.move(region.rect.x(), region.rect.y());
// this->preview.resize(region.rect.width(),
// region.rect.height());
m_preview.show();
m_preview.raise();
this->preview.show();
this->preview.raise();
dropPosition = region.position;
return;
} else {
m_preview.hide();
this->preview.hide();
}
}
}
@ -194,7 +195,7 @@ NotebookPage::setPreviewRect(QPoint mousePos)
void
NotebookPage::dragLeaveEvent(QDragLeaveEvent *event)
{
m_preview.hide();
this->preview.hide();
}
void
@ -208,7 +209,7 @@ NotebookPage::dropEvent(QDropEvent *event)
addToLayout(NotebookPage::draggingSplit, dropPosition);
}
m_preview.hide();
this->preview.hide();
}
void
@ -216,7 +217,7 @@ NotebookPage::paintEvent(QPaintEvent *)
{
QPainter painter(this);
if (m_hbox.count() == 0) {
if (this->hbox.count() == 0) {
painter.fillRect(rect(), ColorScheme::instance().ChatBackground);
painter.fillRect(0, 0, width(), 2,

View file

@ -24,9 +24,9 @@ public:
void addToLayout(ChatWidget *widget, std::pair<int, int> position);
const std::vector<ChatWidget *> &
chatWidgets() const
getChatWidgets() const
{
return m_chatWidgets;
return chatWidgets;
}
static bool isDraggingSplit;
@ -56,13 +56,13 @@ protected:
}
};
QVBoxLayout m_parentbox;
QHBoxLayout m_hbox;
QVBoxLayout parentbox;
QHBoxLayout hbox;
std::vector<ChatWidget *> m_chatWidgets;
std::vector<DropRegion> m_dropRegions;
std::vector<ChatWidget *> chatWidgets;
std::vector<DropRegion> dropRegions;
NotebookPageDropPreview m_preview;
NotebookPageDropPreview preview;
private:
void setPreviewRect(QPoint mousePos);

View file

@ -4,8 +4,8 @@
NotebookPageDropPreview::NotebookPageDropPreview(QWidget *parent)
: QWidget(parent)
, m_positionAnimation(this, "geometry")
, m_desiredGeometry()
, positionAnimation(this, "geometry")
, desiredGeometry()
{
setHidden(true);
}
@ -22,15 +22,15 @@ NotebookPageDropPreview::paintEvent(QPaintEvent *)
void
NotebookPageDropPreview::setBounds(const QRect &rect)
{
if (rect == m_desiredGeometry) {
if (rect == this->desiredGeometry) {
return;
}
m_positionAnimation.stop();
m_positionAnimation.setDuration(50);
m_positionAnimation.setStartValue(geometry());
m_positionAnimation.setEndValue(rect);
m_positionAnimation.start();
this->positionAnimation.stop();
this->positionAnimation.setDuration(50);
this->positionAnimation.setStartValue(geometry());
this->positionAnimation.setEndValue(rect);
this->positionAnimation.start();
m_desiredGeometry = rect;
this->desiredGeometry = rect;
}

View file

@ -14,8 +14,8 @@ public:
protected:
void paintEvent(QPaintEvent *);
QPropertyAnimation m_positionAnimation;
QRect m_desiredGeometry;
QPropertyAnimation positionAnimation;
QRect desiredGeometry;
};
#endif // NOTEBOOKPAGEDROPPREVIEW_H

View file

@ -6,12 +6,12 @@
NotebookTab::NotebookTab(Notebook *notebook)
: QWidget(notebook)
, m_notebook(notebook)
, m_text("<no title>")
, m_selected(false)
, m_mouseOver(false)
, m_mouseDown(false)
, m_highlightStyle(HighlightNone)
, notebook(notebook)
, text("<no title>")
, selected(false)
, mouseOver(false)
, mouseDown(false)
, highlightStyle(HighlightNone)
{
calcSize();
@ -21,7 +21,7 @@ NotebookTab::NotebookTab(Notebook *notebook)
void
NotebookTab::calcSize()
{
resize(fontMetrics().width(m_text) + 8, 24);
resize(fontMetrics().width(this->text) + 8, 24);
}
void
@ -33,16 +33,16 @@ NotebookTab::paintEvent(QPaintEvent *)
auto colorScheme = ColorScheme::instance();
if (m_selected) {
if (this->selected) {
painter.fillRect(rect(), colorScheme.TabSelectedBackground);
fg = colorScheme.TabSelectedText;
} else if (m_mouseOver) {
} else if (this->mouseOver) {
painter.fillRect(rect(), colorScheme.TabHoverBackground);
fg = colorScheme.TabHoverText;
} else if (m_highlightStyle == HighlightHighlighted) {
} else if (this->highlightStyle == HighlightHighlighted) {
painter.fillRect(rect(), colorScheme.TabHighlightedBackground);
fg = colorScheme.TabHighlightedText;
} else if (m_highlightStyle == HighlightNewMessage) {
} else if (this->highlightStyle == HighlightNewMessage) {
painter.fillRect(rect(), colorScheme.TabNewMessageBackground);
fg = colorScheme.TabHighlightedText;
} else {
@ -51,23 +51,23 @@ NotebookTab::paintEvent(QPaintEvent *)
}
painter.setPen(fg);
painter.drawText(4, (height() + fontMetrics().height()) / 2, m_text);
painter.drawText(4, (height() + fontMetrics().height()) / 2, this->text);
}
void
NotebookTab::mousePressEvent(QMouseEvent *)
{
m_mouseDown = true;
this->mouseDown = true;
repaint();
m_notebook->select(page);
this->notebook->select(page);
}
void
NotebookTab::mouseReleaseEvent(QMouseEvent *)
{
m_mouseDown = false;
this->mouseDown = false;
repaint();
}
@ -75,7 +75,7 @@ NotebookTab::mouseReleaseEvent(QMouseEvent *)
void
NotebookTab::enterEvent(QEvent *)
{
m_mouseOver = true;
this->mouseOver = true;
repaint();
}
@ -83,7 +83,7 @@ NotebookTab::enterEvent(QEvent *)
void
NotebookTab::leaveEvent(QEvent *)
{
m_mouseOver = false;
this->mouseOver = false;
repaint();
}
@ -91,5 +91,5 @@ NotebookTab::leaveEvent(QEvent *)
void
NotebookTab::dragEnterEvent(QDragEnterEvent *event)
{
m_notebook->select(page);
this->notebook->select(page);
}

View file

@ -17,47 +17,47 @@ public:
HighlightNewMessage
};
NotebookTab(Notebook *m_notebook);
NotebookTab(Notebook *notebook);
void calcSize();
NotebookPage *page;
const QString &
text() const
getText() const
{
return m_text;
return this->text;
}
void
setText(const QString &text)
{
m_text = text;
this->text = text;
}
bool
selected()
getSelected()
{
return m_selected;
return this->selected;
}
void
setSelected(bool value)
{
m_selected = value;
this->selected = value;
repaint();
}
HighlightStyle
highlightStyle() const
getHighlightStyle() const
{
return m_highlightStyle;
return this->highlightStyle;
}
void
setHighlightStyle(HighlightStyle style)
{
m_highlightStyle = style;
this->highlightStyle = style;
repaint();
}
@ -72,14 +72,14 @@ protected:
void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE;
private:
Notebook *m_notebook;
Notebook *notebook;
QString m_text;
QString text;
bool m_selected;
bool m_mouseOver;
bool m_mouseDown;
HighlightStyle m_highlightStyle;
bool selected;
bool mouseOver;
bool mouseDown;
HighlightStyle highlightStyle;
};
#endif // NOTEBOOKTAB_H

View file

@ -1,23 +1,23 @@
#include "resources.h"
#include "QPixmap"
LazyLoadedImage *Resources::m_badgeStaff;
LazyLoadedImage *Resources::m_badgeAdmin;
LazyLoadedImage *Resources::m_badgeModerator;
LazyLoadedImage *Resources::m_badgeGlobalmod;
LazyLoadedImage *Resources::m_badgeTurbo;
LazyLoadedImage *Resources::m_badgeBroadcaster;
LazyLoadedImage *Resources::m_badgePremium;
LazyLoadedImage *Resources::badgeStaff(NULL);
LazyLoadedImage *Resources::badgeAdmin(NULL);
LazyLoadedImage *Resources::badgeModerator(NULL);
LazyLoadedImage *Resources::badgeGlobalmod(NULL);
LazyLoadedImage *Resources::badgeTurbo(NULL);
LazyLoadedImage *Resources::badgeBroadcaster(NULL);
LazyLoadedImage *Resources::badgePremium(NULL);
LazyLoadedImage *Resources::m_cheerBadge100000;
LazyLoadedImage *Resources::m_cheerBadge10000;
LazyLoadedImage *Resources::m_cheerBadge5000;
LazyLoadedImage *Resources::m_cheerBadge1000;
LazyLoadedImage *Resources::m_cheerBadge100;
LazyLoadedImage *Resources::m_cheerBadge1;
LazyLoadedImage *Resources::cheerBadge100000(NULL);
LazyLoadedImage *Resources::cheerBadge10000(NULL);
LazyLoadedImage *Resources::cheerBadge5000(NULL);
LazyLoadedImage *Resources::cheerBadge1000(NULL);
LazyLoadedImage *Resources::cheerBadge100(NULL);
LazyLoadedImage *Resources::cheerBadge1(NULL);
LazyLoadedImage *Resources::m_buttonBan;
LazyLoadedImage *Resources::m_buttonTimeout;
LazyLoadedImage *Resources::buttonBan(NULL);
LazyLoadedImage *Resources::buttonTimeout(NULL);
Resources::Resources()
{
@ -27,30 +27,38 @@ void
Resources::load()
{
// badges
m_badgeStaff = new LazyLoadedImage(new QPixmap(":/images/staff_bg.png"));
m_badgeAdmin = new LazyLoadedImage(new QPixmap(":/images/admin_bg.png"));
m_badgeModerator =
Resources::badgeStaff =
new LazyLoadedImage(new QPixmap(":/images/staff_bg.png"));
Resources::badgeAdmin =
new LazyLoadedImage(new QPixmap(":/images/admin_bg.png"));
Resources::badgeModerator =
new LazyLoadedImage(new QPixmap(":/images/moderator_bg.png"));
m_badgeGlobalmod =
Resources::badgeGlobalmod =
new LazyLoadedImage(new QPixmap(":/images/globalmod_bg.png"));
m_badgeTurbo = new LazyLoadedImage(new QPixmap(":/images/turbo_bg.png"));
m_badgeBroadcaster =
Resources::badgeTurbo =
new LazyLoadedImage(new QPixmap(":/images/turbo_bg.png"));
Resources::badgeBroadcaster =
new LazyLoadedImage(new QPixmap(":/images/broadcaster_bg.png"));
m_badgePremium =
Resources::badgePremium =
new LazyLoadedImage(new QPixmap(":/images/twitchprime_bg.png"));
// cheer badges
m_cheerBadge100000 =
Resources::cheerBadge100000 =
new LazyLoadedImage(new QPixmap(":/images/cheer100000"));
m_cheerBadge10000 = new LazyLoadedImage(new QPixmap(":/images/cheer10000"));
m_cheerBadge5000 = new LazyLoadedImage(new QPixmap(":/images/cheer5000"));
m_cheerBadge1000 = new LazyLoadedImage(new QPixmap(":/images/cheer1000"));
m_cheerBadge100 = new LazyLoadedImage(new QPixmap(":/images/cheer100"));
m_cheerBadge1 = new LazyLoadedImage(new QPixmap(":/images/cheer1"));
Resources::cheerBadge10000 =
new LazyLoadedImage(new QPixmap(":/images/cheer10000"));
Resources::cheerBadge5000 =
new LazyLoadedImage(new QPixmap(":/images/cheer5000"));
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
m_buttonBan =
Resources::buttonBan =
new LazyLoadedImage(new QPixmap(":/images/button_ban.png"), 0.25);
m_buttonTimeout =
Resources::buttonTimeout =
new LazyLoadedImage(new QPixmap(":/images/button_timeout.png"), 0.25);
}

View file

@ -10,116 +10,116 @@ public:
// badges
static LazyLoadedImage *
badgeStaff()
getBadgeStaff()
{
return m_badgeStaff;
return badgeStaff;
}
static LazyLoadedImage *
badgeAdmin()
getBadgeAdmin()
{
return m_badgeAdmin;
return badgeAdmin;
}
static LazyLoadedImage *
badgeGlobalmod()
getBadgeGlobalmod()
{
return m_badgeGlobalmod;
return badgeGlobalmod;
}
static LazyLoadedImage *
badgeModerator()
getBadgeModerator()
{
return m_badgeModerator;
return badgeModerator;
}
static LazyLoadedImage *
badgeTurbo()
getBadgeTurbo()
{
return m_badgeTurbo;
return badgeTurbo;
}
static LazyLoadedImage *
badgeBroadcaster()
getBadgeBroadcaster()
{
return m_badgeBroadcaster;
return badgeBroadcaster;
}
static LazyLoadedImage *
badgePremium()
getBadgePremium()
{
return m_badgePremium;
return badgePremium;
}
// cheer badges
static LazyLoadedImage *
cheerBadge100000()
getCheerBadge100000()
{
return m_cheerBadge100000;
return cheerBadge100000;
}
static LazyLoadedImage *
cheerBadge10000()
getCheerBadge10000()
{
return m_cheerBadge10000;
return cheerBadge10000;
}
static LazyLoadedImage *
cheerBadge5000()
getCheerBadge5000()
{
return m_cheerBadge5000;
return cheerBadge5000;
}
static LazyLoadedImage *
cheerBadge1000()
getCheerBadge1000()
{
return m_cheerBadge1000;
return cheerBadge1000;
}
static LazyLoadedImage *
cheerBadge100()
getCheerBadge100()
{
return m_cheerBadge100;
return cheerBadge100;
}
static LazyLoadedImage *
cheerBadge1()
getCheerBadge1()
{
return m_cheerBadge1;
return cheerBadge1;
}
static LazyLoadedImage *
buttonBan()
getButtonBan()
{
return m_buttonBan;
return buttonBan;
}
static LazyLoadedImage *
buttonTimeout()
getButtonTimeout()
{
return m_buttonTimeout;
return buttonTimeout;
}
private:
Resources();
static LazyLoadedImage *m_badgeStaff;
static LazyLoadedImage *m_badgeAdmin;
static LazyLoadedImage *m_badgeGlobalmod;
static LazyLoadedImage *m_badgeModerator;
static LazyLoadedImage *m_badgeTurbo;
static LazyLoadedImage *m_badgeBroadcaster;
static LazyLoadedImage *m_badgePremium;
static LazyLoadedImage *badgeStaff;
static LazyLoadedImage *badgeAdmin;
static LazyLoadedImage *badgeGlobalmod;
static LazyLoadedImage *badgeModerator;
static LazyLoadedImage *badgeTurbo;
static LazyLoadedImage *badgeBroadcaster;
static LazyLoadedImage *badgePremium;
static LazyLoadedImage *m_cheerBadge100000;
static LazyLoadedImage *m_cheerBadge10000;
static LazyLoadedImage *m_cheerBadge5000;
static LazyLoadedImage *m_cheerBadge1000;
static LazyLoadedImage *m_cheerBadge100;
static LazyLoadedImage *m_cheerBadge1;
static LazyLoadedImage *cheerBadge100000;
static LazyLoadedImage *cheerBadge10000;
static LazyLoadedImage *cheerBadge5000;
static LazyLoadedImage *cheerBadge1000;
static LazyLoadedImage *cheerBadge100;
static LazyLoadedImage *cheerBadge1;
static LazyLoadedImage *m_buttonBan;
static LazyLoadedImage *m_buttonTimeout;
static LazyLoadedImage *buttonBan;
static LazyLoadedImage *buttonTimeout;
};
#endif // RESOURCES_H

View file

@ -2,16 +2,25 @@
#include "QPainter"
#include "colorscheme.h"
#define MIN_THUMB_HEIGHT 10
ScrollBar::ScrollBar(QWidget *widget)
: QWidget(widget)
, mutex()
, highlights(NULL)
, thumbRect()
, maximum()
, minimum()
, largeChange()
, smallChange()
, value()
{
resize(16, 100);
}
ScrollBar::~ScrollBar()
{
auto highlight = highlights;
auto highlight = this->highlights;
while (highlight != NULL) {
auto tmp = highlight->next;
@ -23,15 +32,15 @@ ScrollBar::~ScrollBar()
void
ScrollBar::removeHighlightsWhere(std::function<bool(ScrollBarHighlight &)> func)
{
mutex.lock();
this->mutex.lock();
ScrollBarHighlight *last = NULL;
ScrollBarHighlight *current = highlights;
ScrollBarHighlight *current = this->highlights;
while (current != NULL) {
if (func(*current)) {
if (last == NULL) {
highlights = current->next;
this->highlights = current->next;
} else {
last->next = current->next;
}
@ -45,22 +54,22 @@ ScrollBar::removeHighlightsWhere(std::function<bool(ScrollBarHighlight &)> func)
}
}
mutex.unlock();
this->mutex.unlock();
}
void
ScrollBar::addHighlight(ScrollBarHighlight *highlight)
{
mutex.lock();
this->mutex.lock();
if (highlights == NULL) {
highlights = highlight;
if (this->highlights == NULL) {
this->highlights = highlight;
} else {
highlight->next = highlights->next;
highlights->next = highlight;
highlight->next = this->highlights->next;
this->highlights->next = highlight;
}
mutex.unlock();
this->mutex.unlock();
}
void
@ -69,7 +78,36 @@ ScrollBar::paintEvent(QPaintEvent *)
QPainter painter(this);
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();
}

View file

@ -17,12 +17,93 @@ public:
void removeHighlightsWhere(std::function<bool(ScrollBarHighlight &)> func);
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:
QMutex mutex;
ScrollBarHighlight *highlights = NULL;
ScrollBarHighlight *highlights;
void paintEvent(QPaintEvent *);
int buttonHeight;
int trackHeight;
QRect thumbRect;
qreal maximum;
qreal minimum;
qreal largeChange;
qreal smallChange;
qreal value;
void updateScroll();
};
#endif // SCROLLBAR_H

View file

@ -3,11 +3,11 @@
ScrollBarHighlight::ScrollBarHighlight(float position, int colorIndex,
Style style, QString tag)
: m_position(position)
, m_colorIndex(std::max(
: position(position)
, colorIndex(std::max(
0, std::min(ColorScheme::instance().HighlightColorCount, colorIndex)))
, m_style(style)
, m_tag(tag)
, style(style)
, tag(tag)
, next(NULL)
{
}

View file

@ -8,40 +8,40 @@ class ScrollBarHighlight
public:
enum Style { Default, Left, Right, SingleLine };
ScrollBarHighlight(float position, int colorIndex, Style style = Default,
QString tag = "");
ScrollBarHighlight(float getPosition, int getColorIndex,
Style getStyle = Default, QString tag = "");
Style
style()
getStyle()
{
return m_style;
return style;
}
float
position()
getPosition()
{
return m_position;
return position;
}
int
colorIndex()
getColorIndex()
{
return m_colorIndex;
return colorIndex;
}
QString
getTag()
{
return m_tag;
return tag;
}
ScrollBarHighlight *next;
private:
Style m_style;
float m_position;
int m_colorIndex;
QString m_tag;
Style style;
float position;
int colorIndex;
QString tag;
};
#endif // SCROLLBARHIGHLIGHT_H

View file

@ -1,13 +1,13 @@
#include "settingsdialog.h"
#include "settingsdialogtab.h"
#include "QComboBox"
#include "QFile"
#include "QFormLayout"
#include "QGroupBox"
#include "QLabel"
#include "QPalette"
#include "QResource"
#include <QComboBox>
#include <QFile>
#include <QFormLayout>
#include <QGroupBox>
#include <QLabel>
#include <QPalette>
#include <QResource>
SettingsDialog::SettingsDialog()
{
@ -144,7 +144,7 @@ SettingsDialog::addTab(QLayout *layout, QString title, QString imageRes)
auto tab = new SettingsDialogTab(this, title, imageRes);
tab->widget = widget;
tab->setWidget(widget);
tabs.addWidget(tab, 0, Qt::AlignTop);
@ -158,7 +158,7 @@ SettingsDialog::addTab(QLayout *layout, QString title, QString imageRes)
void
SettingsDialog::select(SettingsDialogTab *tab)
{
pageStack.setCurrentWidget(tab->widget);
pageStack.setCurrentWidget(tab->getWidget());
if (selectedTab != NULL) {
selectedTab->setSelected(false);

View file

@ -1,18 +1,19 @@
#ifndef 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 <QButtonGroup>
#include <QCheckBox>
#include <QDialogButtonBox>
#include <QHBoxLayout>
#include <QListView>
#include <QMainWindow>
#include <QPushButton>
#include <QStackedLayout>
#include <QVBoxLayout>
#include <QWidget>
class SettingsDialog : public QWidget
{
public:

View file

@ -9,8 +9,8 @@ class SettingsDialog;
class SettingsDialogTab : public QWidget
{
Q_OBJECT
Q_PROPERTY(
bool selected READ selected WRITE setSelected NOTIFY selectedChanged)
Q_PROPERTY(bool getSelected READ getSelected WRITE setSelected NOTIFY
selectedChanged)
public:
SettingsDialogTab(SettingsDialog *dialog, QString label, QString imageRes);
@ -18,20 +18,30 @@ public:
void
setSelected(bool selected)
{
if (selected == m_selected)
if (selected == selected)
return;
m_selected = selected;
selected = selected;
emit selectedChanged(selected);
}
bool
selected() const
getSelected() const
{
return m_selected;
return selected;
}
QWidget *widget;
QWidget *
getWidget()
{
return widget;
}
void
setWidget(QWidget *widget)
{
this->widget = widget;
}
signals:
void selectedChanged(bool);
@ -40,12 +50,13 @@ private:
void paintEvent(QPaintEvent *);
void mouseReleaseEvent(QMouseEvent *event);
QWidget *widget;
QString label;
QImage image;
SettingsDialog *dialog = NULL;
bool m_selected = false;
bool selected = false;
};
#endif // SETTINGSNOTEBOOKTAB_H

View file

@ -3,21 +3,22 @@
TextInputDialog::TextInputDialog(QWidget *parent)
: QDialog(parent)
, m_vbox(this)
, m_lineEdit()
, m_buttonBox()
, m_okButton("OK")
, m_cancelButton("Cancel")
, vbox(this)
, lineEdit()
, buttonBox()
, okButton("OK")
, cancelButton("Cancel")
{
m_vbox.addWidget(&m_lineEdit);
m_vbox.addLayout(&m_buttonBox);
m_buttonBox.addStretch(1);
m_buttonBox.addWidget(&m_okButton);
m_buttonBox.addWidget(&m_cancelButton);
this->vbox.addWidget(&this->lineEdit);
this->vbox.addLayout(&this->buttonBox);
this->buttonBox.addStretch(1);
this->buttonBox.addWidget(&this->okButton);
this->buttonBox.addWidget(&this->cancelButton);
QObject::connect(&m_okButton, SIGNAL(clicked()), this, SLOT(okButtonClicked()));
QObject::connect(&m_cancelButton, SIGNAL(clicked()), this,
SLOT(cancelButtonClicked()));
QObject::connect(&this->okButton, SIGNAL(clicked()), this,
SLOT(okButtonClicked()));
QObject::connect(&this->cancelButton, SIGNAL(clicked()), this,
SLOT(cancelButtonClicked()));
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

View file

@ -16,23 +16,23 @@ public:
TextInputDialog(QWidget *parent = NULL);
QString
text() const
getText() const
{
return m_lineEdit.text();
return lineEdit.text();
}
void
setText(const QString &text)
{
m_lineEdit.setText(text);
lineEdit.setText(text);
}
private:
QVBoxLayout m_vbox;
QLineEdit m_lineEdit;
QHBoxLayout m_buttonBox;
QPushButton m_okButton;
QPushButton m_cancelButton;
QVBoxLayout vbox;
QLineEdit lineEdit;
QHBoxLayout buttonBox;
QPushButton okButton;
QPushButton cancelButton;
private slots:
void okButtonClicked();

View file

@ -6,27 +6,27 @@
struct TwitchEmoteValue {
public:
int
set()
getSet()
{
return m_set;
return set;
}
int
id()
getId()
{
return m_id;
return id;
}
const QString &
channelName()
getChannelName()
{
return m_channelName;
return channelName;
}
private:
int m_set;
int m_id;
QString m_channelName;
int set;
int id;
QString channelName;
};
#endif // TWITCHEMOTEVALUE_H

View file

@ -1,17 +1,17 @@
#include "windows.h"
QMutex Windows::m_windowMutex;
QMutex Windows::windowMutex;
MainWindow *Windows::m_mainWindow(NULL);
MainWindow *Windows::mainWindow(NULL);
void
Windows::layoutVisibleChatWidgets(Channel *channel)
{
m_mainWindow->layoutVisibleChatWidgets(channel);
Windows::mainWindow->layoutVisibleChatWidgets(channel);
}
void
Windows::repaintVisibleChatWidgets(Channel *channel)
{
m_mainWindow->repaintVisibleChatWidgets(channel);
Windows::mainWindow->repaintVisibleChatWidgets(channel);
}

View file

@ -12,15 +12,15 @@ public:
static void repaintVisibleChatWidgets(Channel *channel = NULL);
static MainWindow &
mainWindow()
getMainWindow()
{
m_windowMutex.lock();
if (m_mainWindow == NULL) {
m_mainWindow = new MainWindow();
windowMutex.lock();
if (mainWindow == NULL) {
mainWindow = new MainWindow();
}
m_windowMutex.unlock();
windowMutex.unlock();
return *m_mainWindow;
return *mainWindow;
}
private:
@ -28,9 +28,9 @@ private:
{
}
static QMutex m_windowMutex;
static QMutex windowMutex;
static MainWindow *m_mainWindow;
static MainWindow *mainWindow;
};
#endif // WINDOWS_H

View file

@ -3,30 +3,30 @@
// Image word
Word::Word(LazyLoadedImage *image, Type type, const QString &copytext,
const QString &tooltip, const Link &link)
: m_image(image)
, m_text()
, m_color()
, m_isImage(true)
, m_type(type)
, m_copyText(copytext)
, m_tooltip(tooltip)
, m_link(link)
, m_characterWidthCache()
: image(image)
, text()
, color()
, _isImage(true)
, type(type)
, copyText(copytext)
, tooltip(tooltip)
, link(link)
, characterWidthCache()
{
image->width(); // professional segfault test
image->getWidth(); // professional segfault test
}
// Text word
Word::Word(const QString &text, Type type, const QColor &color,
const QString &copytext, const QString &tooltip, const Link &link)
: m_image(NULL)
, m_text(text)
, m_color(color)
, m_isImage(false)
, m_type(type)
, m_copyText(copytext)
, m_tooltip(tooltip)
, m_link(link)
, m_characterWidthCache()
: image(NULL)
, text(text)
, color(color)
, _isImage(false)
, type(type)
, copyText(copytext)
, tooltip(tooltip)
, link(link)
, characterWidthCache()
{
}

102
word.h
View file

@ -63,148 +63,148 @@ public:
ButtonTimeout
};
explicit Word(LazyLoadedImage *m_image, Type type, const QString &copytext,
const QString &tooltip, const Link &link = Link());
explicit Word(const QString &m_text, Type type, const QColor &color,
const QString &copytext, const QString &tooltip,
const Link &link = Link());
explicit Word(LazyLoadedImage *image, Type getType, const QString &copytext,
const QString &getTooltip, const Link &getLink = Link());
explicit Word(const QString &text, Type getType, const QColor &getColor,
const QString &copytext, const QString &getTooltip,
const Link &getLink = Link());
LazyLoadedImage &
getImage() const
{
return *m_image;
return *image;
}
const QString &
getText() const
{
return m_text;
return text;
}
int
width() const
getWidth() const
{
return m_width;
return width;
}
int
height() const
getHeight() const
{
return m_height;
return height;
}
void
setSize(int width, int height)
{
m_width = width;
m_height = height;
width = width;
height = height;
}
bool
isImage() const
{
return m_isImage;
return _isImage;
}
bool
isText() const
{
return !m_isImage;
return !_isImage;
}
const QString &
copyText() const
getCopyText() const
{
return m_copyText;
return copyText;
}
bool
hasTrailingSpace() const
{
return m_hasTrailingSpace;
return _hasTrailingSpace;
}
QFont &
getFont() const
{
return Fonts::getFont(m_font);
return Fonts::getFont(font);
}
QFontMetrics &
getFontMetrics() const
{
return Fonts::getFontMetrics(m_font);
return Fonts::getFontMetrics(font);
}
Type
type() const
getType() const
{
return m_type;
return type;
}
const QString &
tooltip() const
getTooltip() const
{
return m_tooltip;
return tooltip;
}
const QColor &
color() const
getColor() const
{
return m_color;
return color;
}
const Link &
link() const
getLink() const
{
return m_link;
return link;
}
int
xOffset() const
getXOffset() const
{
return m_xOffset;
return xOffset;
}
int
yOffset() const
getYOffset() const
{
return m_yOffset;
return yOffset;
}
void
setOffset(int xOffset, int yOffset)
{
m_xOffset = std::max(0, xOffset);
m_yOffset = std::max(0, yOffset);
xOffset = std::max(0, xOffset);
yOffset = std::max(0, yOffset);
}
std::vector<short> &
characterWidthCache()
getCharacterWidthCache()
{
return m_characterWidthCache;
return characterWidthCache;
}
private:
LazyLoadedImage *m_image;
QString m_text;
QColor m_color;
bool m_isImage;
LazyLoadedImage *image;
QString text;
QColor color;
bool _isImage;
Type m_type;
QString m_copyText;
QString m_tooltip;
Type type;
QString copyText;
QString tooltip;
int m_width = 16;
int m_height = 16;
int m_xOffset = 0;
int m_yOffset = 0;
int width = 16;
int height = 16;
int xOffset = 0;
int yOffset = 0;
bool m_hasTrailingSpace;
Fonts::Type m_font = Fonts::Medium;
Link m_link;
bool _hasTrailingSpace;
Fonts::Type font = Fonts::Medium;
Link link;
std::vector<short> m_characterWidthCache;
std::vector<short> characterWidthCache;
};
#endif // WORD_H

View file

@ -4,13 +4,13 @@
WordPart::WordPart(Word &word, int x, int y, const QString &copyText,
bool allowTrailingSpace)
: m_word(word)
, m_copyText(copyText)
, m_x(x)
, m_y(y)
, m_width(word.width())
, m_height(word.height())
, m_trailingSpace(word.hasTrailingSpace() & allowTrailingSpace)
, m_text(word.isText() ? m_word.getText() : QString())
, copyText(copyText)
, x(x)
, y(y)
, width(word.getWidth())
, height(word.getHeight())
, _trailingSpace(word.hasTrailingSpace() & allowTrailingSpace)
, 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 &copyText, const QString &customText,
bool allowTrailingSpace)
: m_word(word)
, m_copyText(copyText)
, m_x(x)
, m_y(y)
, m_width(width)
, m_height(height)
, m_trailingSpace(word.hasTrailingSpace() & allowTrailingSpace)
, m_text(customText)
, copyText(copyText)
, x(x)
, y(y)
, width(width)
, height(height)
, _trailingSpace(word.hasTrailingSpace() & allowTrailingSpace)
, text(customText)
{
}

View file

@ -9,104 +9,104 @@ class Word;
class WordPart
{
public:
WordPart(Word &word, int x, int y, const QString &copyText,
WordPart(Word &getWord, int getX, int getY, const QString &getCopyText,
bool allowTrailingSpace = true);
WordPart(Word &word, int x, int y, int width, int height,
const QString &copyText, const QString &customText,
WordPart(Word &getWord, int getX, int getY, int getWidth, int getHeight,
const QString &getCopyText, const QString &customText,
bool allowTrailingSpace = true);
const Word &
word() const
getWord() const
{
return m_word;
}
int
width() const
getWidth() const
{
return m_width;
return width;
}
int
height() const
getHeight() const
{
return m_height;
return height;
}
int
x() const
getX() const
{
return m_x;
return x;
}
int
y() const
getY() const
{
return m_y;
return y;
}
void
setPosition(int x, int y)
{
m_x = x;
m_y = y;
x = x;
y = y;
}
void
setY(int y)
{
m_y = y;
y = y;
}
int
right() const
getRight() const
{
return m_x + m_width;
return x + width;
}
int
bottom() const
getBottom() const
{
return m_y + m_height;
return y + height;
}
QRect
rect() const
getRect() const
{
return QRect(m_x, m_y, m_width, m_height);
return QRect(x, y, width, height);
}
const QString
copyText() const
getCopyText() const
{
return m_copyText;
return copyText;
}
int
hasTrailingSpace() const
{
return m_trailingSpace;
return _trailingSpace;
}
const QString &
text() const
getText() const
{
return m_text;
return text;
}
private:
Word &m_word;
QString m_copyText;
QString m_text;
QString copyText;
QString text;
int m_x;
int m_y;
int m_width;
int m_height;
int x;
int y;
int width;
int height;
bool m_trailingSpace;
bool _trailingSpace;
};
#endif // WORDPART_H