This commit is contained in:
Rasmus Karlsson 2018-04-01 16:43:30 +02:00 committed by fourtf
parent 13705f15ed
commit 4888178079
12 changed files with 62 additions and 67 deletions

View file

@ -244,6 +244,7 @@ void MessageLayout::addSelectionText(QString &str, int from, int to)
{
this->container.addSelectionText(str, from, to);
}
} // namespace layouts
} // namespace messages
} // namespace chatterino

View file

@ -15,6 +15,7 @@
namespace chatterino {
namespace messages {
namespace layouts {
class MessageLayout : boost::noncopyable
{
public:
@ -73,7 +74,8 @@ private:
void updateBuffer(QPixmap *pixmap, int messageIndex, Selection &selection);
};
typedef std::shared_ptr<MessageLayout> MessageLayoutPtr;
using MessageLayoutPtr = std::shared_ptr<MessageLayout>;
} // namespace layouts
} // namespace messages
} // namespace chatterino

View file

@ -12,13 +12,6 @@
namespace chatterino {
namespace messages {
namespace layouts {
MessageLayoutContainer::MessageLayoutContainer()
: scale(1)
, flags(Message::None)
, margin(4, 8, 4, 8)
{
this->clear();
}
int MessageLayoutContainer::getHeight() const
{
@ -36,11 +29,11 @@ float MessageLayoutContainer::getScale() const
}
// methods
void MessageLayoutContainer::begin(int width, float _scale, Message::MessageFlags _flags)
void MessageLayoutContainer::begin(int _width, float _scale, Message::MessageFlags _flags)
{
this->clear();
this->width = width;
this->scale = this->scale;
this->width = _width;
this->scale = _scale;
this->flags = _flags;
}
@ -434,6 +427,7 @@ void MessageLayoutContainer::addSelectionText(QString &str, int from, int to)
index += c;
}
}
} // namespace layouts
} // namespace messages
} // namespace chatterino

View file

@ -43,12 +43,11 @@ struct Margin {
};
struct MessageLayoutContainer {
public:
MessageLayoutContainer();
MessageLayoutContainer() = default;
Margin margin;
bool centered;
bool enableCompactEmotes;
Margin margin = {4, 8, 4, 8};
bool centered = false;
bool enableCompactEmotes = false;
int getHeight() const;
int getWidth() const;
@ -89,20 +88,22 @@ private:
void _addElement(MessageLayoutElement *element);
// variables
float scale;
int width;
Message::MessageFlags flags;
int line;
int height;
int currentX, currentY;
float scale = 1.f;
int width = 0;
Message::MessageFlags flags = Message::MessageFlags::None;
int line = 0;
int height = 0;
int currentX = 0;
int currentY = 0;
int charIndex = 0;
size_t lineStart = 0;
int lineHeight = 0;
int spaceWidth = 4;
std::vector<std::unique_ptr<MessageLayoutElement>> elements;
std::vector<std::unique_ptr<MessageLayoutElement>> elements;
std::vector<Line> lines;
};
} // namespace layouts
} // namespace messages
} // namespace chatterino

View file

@ -272,6 +272,7 @@ int TextIconLayoutElement::getXFromIndex(int index)
return this->getRect().right();
}
}
} // namespace layouts
} // namespace messages
} // namespace chatterino

View file

@ -56,12 +56,12 @@ public:
ImageLayoutElement(MessageElement &creator, Image *image, const QSize &size);
protected:
virtual void addCopyTextToString(QString &str, int from = 0, int to = INT_MAX) const override;
virtual int getSelectionIndexCount() override;
virtual void paint(QPainter &painter) override;
virtual void paintAnimated(QPainter &painter, int yOffset) override;
virtual int getMouseOverIndex(const QPoint &abs) override;
virtual int getXFromIndex(int index) override;
void addCopyTextToString(QString &str, int from = 0, int to = INT_MAX) const override;
int getSelectionIndexCount() override;
void paint(QPainter &painter) override;
void paintAnimated(QPainter &painter, int yOffset) override;
int getMouseOverIndex(const QPoint &abs) override;
int getXFromIndex(int index) override;
private:
Image *image;
@ -75,12 +75,12 @@ public:
FontStyle style, float scale);
protected:
virtual void addCopyTextToString(QString &str, int from = 0, int to = INT_MAX) const override;
virtual int getSelectionIndexCount() override;
virtual void paint(QPainter &painter) override;
virtual void paintAnimated(QPainter &painter, int yOffset) override;
virtual int getMouseOverIndex(const QPoint &abs) override;
virtual int getXFromIndex(int index) override;
void addCopyTextToString(QString &str, int from = 0, int to = INT_MAX) const override;
int getSelectionIndexCount() override;
void paint(QPainter &painter) override;
void paintAnimated(QPainter &painter, int yOffset) override;
int getMouseOverIndex(const QPoint &abs) override;
int getXFromIndex(int index) override;
private:
QString text;
@ -98,18 +98,19 @@ public:
float scale, const QSize &size);
protected:
virtual void addCopyTextToString(QString &str, int from = 0, int to = INT_MAX) const override;
virtual int getSelectionIndexCount() override;
virtual void paint(QPainter &painter) override;
virtual void paintAnimated(QPainter &painter, int yOffset) override;
virtual int getMouseOverIndex(const QPoint &abs) override;
virtual int getXFromIndex(int index) override;
void addCopyTextToString(QString &str, int from = 0, int to = INT_MAX) const override;
int getSelectionIndexCount() override;
void paint(QPainter &painter) override;
void paintAnimated(QPainter &painter, int yOffset) override;
int getMouseOverIndex(const QPoint &abs) override;
int getXFromIndex(int index) override;
private:
QString line1;
QString line2;
float scale;
};
} // namespace layouts
} // namespace messages
} // namespace chatterino

View file

@ -247,6 +247,7 @@ void AbstractIrcServer::forEachChannel(std::function<void(ChannelPtr)> func)
func(chan);
}
}
} // namespace irc
} // namespace providers
} // namespace chatterino

View file

@ -1,15 +1,16 @@
#pragma once
#include "channel.hpp"
#include <IrcMessage>
#include <functional>
#include <mutex>
#include <pajlada/signals/signal.hpp>
#include "channel.hpp"
namespace chatterino {
namespace providers {
namespace irc {
class AbstractIrcServer
{
public:
@ -64,6 +65,7 @@ private:
std::mutex connectionMutex;
};
} // namespace irc
} // namespace providers
} // namespace chatterino

View file

@ -24,15 +24,15 @@ public:
const ChannelPtr mentionsChannel;
protected:
virtual void initializeConnection(Communi::IrcConnection *connection, bool isRead,
void initializeConnection(Communi::IrcConnection *connection, bool isRead,
bool isWrite) override;
virtual std::shared_ptr<Channel> createChannel(const QString &channelName) override;
std::shared_ptr<Channel> createChannel(const QString &channelName) override;
virtual void privateMessageReceived(Communi::IrcPrivateMessage *message) override;
virtual void messageReceived(Communi::IrcMessage *message) override;
virtual void writeConnectionMessageReceived(Communi::IrcMessage *message) override;
void privateMessageReceived(Communi::IrcPrivateMessage *message) override;
void messageReceived(Communi::IrcMessage *message) override;
void writeConnectionMessageReceived(Communi::IrcMessage *message) override;
virtual std::shared_ptr<Channel> getCustomChannel(const QString &channelname) override;
std::shared_ptr<Channel> getCustomChannel(const QString &channelname) override;
QString CleanChannelName(const QString &dirtyChannelName) override;
};

View file

@ -75,10 +75,8 @@ void FillInFFZEmoteData(const QJsonObject &urls, const QString &code, util::Emot
} // namespace
EmoteManager::EmoteManager(SettingManager &_settingsManager, WindowManager &_windowManager)
: settingsManager(_settingsManager)
, windowManager(_windowManager)
, findShortCodesRegex(":([-+\\w]+):")
EmoteManager::EmoteManager()
: findShortCodesRegex(":([-+\\w]+):")
{
auto &accountManager = AccountManager::getInstance();
@ -91,7 +89,7 @@ EmoteManager::EmoteManager(SettingManager &_settingsManager, WindowManager &_win
EmoteManager &EmoteManager::getInstance()
{
static EmoteManager instance(SettingManager::getInstance(), WindowManager::getInstance());
static EmoteManager instance;
return instance;
}
@ -562,7 +560,9 @@ boost::signals2::signal<void()> &EmoteManager::getGifUpdateSignal()
this->gifUpdateTimer.setInterval(30);
this->gifUpdateTimer.start();
this->settingsManager.enableGifAnimations.connect([this](bool enabled, auto) {
auto &settingManager = singletons::SettingManager::getInstance();
settingManager.enableGifAnimations.connect([this](bool enabled, auto) {
if (enabled) {
this->gifUpdateTimer.start();
} else {
@ -573,7 +573,8 @@ boost::signals2::signal<void()> &EmoteManager::getGifUpdateSignal()
QObject::connect(&this->gifUpdateTimer, &QTimer::timeout, [this] {
this->gifUpdateTimerSignal();
// fourtf:
this->windowManager.repaintGifEmotes();
auto &windowManager = singletons::WindowManager::getInstance();
windowManager.repaintGifEmotes();
});
}

View file

@ -20,13 +20,9 @@
namespace chatterino {
namespace singletons {
class SettingManager;
class WindowManager;
class EmoteManager
{
explicit EmoteManager(singletons::SettingManager &manager,
singletons::WindowManager &windowManager);
EmoteManager();
public:
static EmoteManager &getInstance();
@ -66,9 +62,6 @@ public:
util::ConcurrentMap<QString, messages::Image *> miscImageCache;
private:
SettingManager &settingsManager;
WindowManager &windowManager;
/// Emojis
QRegularExpression findShortCodesRegex;

View file

@ -3,8 +3,6 @@
#include "messages/image.hpp"
#include "util/concurrentmap.hpp"
#include <cassert>
namespace chatterino {
namespace util {