Huge refactor
- Remove some underscore-prefixes
- Start using this-> more
- Remove a few of the singletons (We pass references to managers to
things that need it now. Might not be much better, but for now
it works. It also shows what places might be slightly wrong
designed)
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#include "messages/lazyloadedimage.hpp"
|
||||
|
||||
#include "asyncexec.hpp"
|
||||
#include "emotemanager.hpp"
|
||||
#include "ircmanager.hpp"
|
||||
@@ -18,15 +17,15 @@
|
||||
namespace chatterino {
|
||||
namespace messages {
|
||||
|
||||
LazyLoadedImage::LazyLoadedImage(const QString &url, qreal scale, const QString &name,
|
||||
LazyLoadedImage::LazyLoadedImage(EmoteManager &_emoteManager, WindowManager &_windowManager,
|
||||
const QString &url, qreal scale, const QString &name,
|
||||
const QString &tooltip, const QMargins &margin, bool isHat)
|
||||
: _currentPixmap(nullptr)
|
||||
, _currentFrame(0)
|
||||
, _currentFrameOffset(0)
|
||||
: emoteManager(_emoteManager)
|
||||
, windowManager(_windowManager)
|
||||
, _currentPixmap(nullptr)
|
||||
, _url(url)
|
||||
, _name(name)
|
||||
, _tooltip(tooltip)
|
||||
, _animated(false)
|
||||
, _margin(margin)
|
||||
, _ishat(isHat)
|
||||
, _scale(scale)
|
||||
@@ -34,14 +33,14 @@ LazyLoadedImage::LazyLoadedImage(const QString &url, qreal scale, const QString
|
||||
{
|
||||
}
|
||||
|
||||
LazyLoadedImage::LazyLoadedImage(QPixmap *image, qreal scale, const QString &name,
|
||||
LazyLoadedImage::LazyLoadedImage(EmoteManager &_emoteManager, WindowManager &_windowManager,
|
||||
QPixmap *image, qreal scale, const QString &name,
|
||||
const QString &tooltip, const QMargins &margin, bool isHat)
|
||||
: _currentPixmap(image)
|
||||
, _currentFrame(0)
|
||||
, _currentFrameOffset(0)
|
||||
: emoteManager(_emoteManager)
|
||||
, windowManager(_windowManager)
|
||||
, _currentPixmap(image)
|
||||
, _name(name)
|
||||
, _tooltip(tooltip)
|
||||
, _animated(false)
|
||||
, _margin(margin)
|
||||
, _ishat(isHat)
|
||||
, _scale(scale)
|
||||
@@ -81,11 +80,13 @@ void LazyLoadedImage::loadImage()
|
||||
if (_allFrames.size() > 1) {
|
||||
_animated = true;
|
||||
|
||||
EmoteManager::getInstance().getGifUpdateSignal().connect([this] { gifUpdateTimout(); });
|
||||
this->emoteManager.getGifUpdateSignal().connect([this] {
|
||||
gifUpdateTimout(); //
|
||||
});
|
||||
}
|
||||
|
||||
EmoteManager::getInstance().incGeneration();
|
||||
WindowManager::getInstance().layoutVisibleChatWidgets();
|
||||
this->emoteManager.incGeneration();
|
||||
this->windowManager.layoutVisibleChatWidgets();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -4,15 +4,24 @@
|
||||
#include <QString>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class EmoteManager;
|
||||
class WindowManager;
|
||||
|
||||
namespace messages {
|
||||
|
||||
class LazyLoadedImage : QObject
|
||||
{
|
||||
public:
|
||||
explicit LazyLoadedImage(const QString &_url, qreal _scale = 1, const QString &_name = "",
|
||||
LazyLoadedImage() = delete;
|
||||
|
||||
explicit LazyLoadedImage(EmoteManager &_emoteManager, WindowManager &_windowManager,
|
||||
const QString &_url, qreal _scale = 1, const QString &_name = "",
|
||||
const QString &_tooltip = "", const QMargins &_margin = QMargins(),
|
||||
bool isHat = false);
|
||||
explicit LazyLoadedImage(QPixmap *_currentPixmap, qreal _scale = 1, const QString &_name = "",
|
||||
|
||||
explicit LazyLoadedImage(EmoteManager &_emoteManager, WindowManager &_windowManager,
|
||||
QPixmap *_currentPixmap, qreal _scale = 1, const QString &_name = "",
|
||||
const QString &_tooltip = "", const QMargins &_margin = QMargins(),
|
||||
bool isHat = false);
|
||||
|
||||
@@ -78,6 +87,9 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
EmoteManager &emoteManager;
|
||||
WindowManager &windowManager;
|
||||
|
||||
struct FrameData {
|
||||
QPixmap *image;
|
||||
int duration;
|
||||
@@ -85,13 +97,13 @@ private:
|
||||
|
||||
QPixmap *_currentPixmap;
|
||||
std::vector<FrameData> _allFrames;
|
||||
int _currentFrame;
|
||||
int _currentFrameOffset;
|
||||
int _currentFrame = 0;
|
||||
int _currentFrameOffset = 0;
|
||||
|
||||
QString _url;
|
||||
QString _name;
|
||||
QString _tooltip;
|
||||
bool _animated;
|
||||
bool _animated = false;
|
||||
QMargins _margin;
|
||||
bool _ishat;
|
||||
qreal _scale;
|
||||
|
||||
@@ -21,16 +21,16 @@ namespace chatterino {
|
||||
namespace messages {
|
||||
|
||||
Message::Message(const QString &text)
|
||||
: _words()
|
||||
, _text(text)
|
||||
: _text(text)
|
||||
, _words()
|
||||
{
|
||||
_words.push_back(
|
||||
Word(text, Word::Text, ColorScheme::getInstance().SystemMessageColor, text, QString()));
|
||||
}
|
||||
|
||||
Message::Message(const QString &text, const std::vector<Word> &words)
|
||||
: _words(words)
|
||||
, _text(text)
|
||||
: _text(text)
|
||||
, _words(words)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ typedef std::shared_ptr<Message> SharedMessage;
|
||||
class Message
|
||||
{
|
||||
public:
|
||||
Message(const QString &text);
|
||||
Message(const QString &text, const std::vector<messages::Word> &words);
|
||||
explicit Message(const QString &text);
|
||||
explicit Message(const QString &text, const std::vector<messages::Word> &words);
|
||||
|
||||
bool getCanHighlightTab() const;
|
||||
const QString &getTimeoutUser() const;
|
||||
|
||||
@@ -41,7 +41,11 @@ bool MessageRef::layout(int width, bool enableEmoteMargins)
|
||||
int mediumTextLineHeight =
|
||||
FontManager::getInstance().getFontMetrics(FontManager::Medium).height();
|
||||
|
||||
/* TODO(pajlada): Re-implement
|
||||
bool recalculateImages = _emoteGeneration != EmoteManager::getInstance().getGeneration();
|
||||
*/
|
||||
bool recalculateImages = true;
|
||||
|
||||
bool recalculateText = _fontGeneration != FontManager::getInstance().getGeneration();
|
||||
bool newWordTypes = _currentWordTypes != SettingsManager::getInstance().getWordTypeMask();
|
||||
|
||||
@@ -53,7 +57,7 @@ bool MessageRef::layout(int width, bool enableEmoteMargins)
|
||||
return false;
|
||||
}
|
||||
|
||||
_emoteGeneration = EmoteManager::getInstance().getGeneration();
|
||||
// _emoteGeneration = EmoteManager::getInstance().getGeneration();
|
||||
_fontGeneration = FontManager::getInstance().getGeneration();
|
||||
|
||||
for (auto &word : _message->getWords()) {
|
||||
|
||||
Reference in New Issue
Block a user