Make more use of single pattern
This commit is contained in:
@@ -19,12 +19,9 @@
|
||||
namespace chatterino {
|
||||
namespace messages {
|
||||
|
||||
LazyLoadedImage::LazyLoadedImage(EmoteManager &_emoteManager, WindowManager &_windowManager,
|
||||
const QString &url, qreal scale, const QString &name,
|
||||
LazyLoadedImage::LazyLoadedImage(const QString &url, qreal scale, const QString &name,
|
||||
const QString &tooltip, const QMargins &margin, bool isHat)
|
||||
: emoteManager(_emoteManager)
|
||||
, windowManager(_windowManager)
|
||||
, currentPixmap(nullptr)
|
||||
: currentPixmap(nullptr)
|
||||
, url(url)
|
||||
, name(name)
|
||||
, tooltip(tooltip)
|
||||
@@ -35,12 +32,9 @@ LazyLoadedImage::LazyLoadedImage(EmoteManager &_emoteManager, WindowManager &_wi
|
||||
{
|
||||
}
|
||||
|
||||
LazyLoadedImage::LazyLoadedImage(EmoteManager &_emoteManager, WindowManager &_windowManager,
|
||||
QPixmap *image, qreal scale, const QString &name,
|
||||
LazyLoadedImage::LazyLoadedImage(QPixmap *image, qreal scale, const QString &name,
|
||||
const QString &tooltip, const QMargins &margin, bool isHat)
|
||||
: emoteManager(_emoteManager)
|
||||
, windowManager(_windowManager)
|
||||
, currentPixmap(image)
|
||||
: currentPixmap(image)
|
||||
, name(name)
|
||||
, tooltip(tooltip)
|
||||
, margin(margin)
|
||||
@@ -85,12 +79,12 @@ void LazyLoadedImage::loadImage()
|
||||
lli->animated = true;
|
||||
}
|
||||
|
||||
lli->emoteManager.incGeneration();
|
||||
EmoteManager::getInstance().incGeneration();
|
||||
|
||||
lli->windowManager.layoutVisibleChatWidgets();
|
||||
WindowManager::instance->layoutVisibleChatWidgets();
|
||||
});
|
||||
|
||||
this->emoteManager.getGifUpdateSignal().connect([=]() {
|
||||
EmoteManager::getInstance().getGifUpdateSignal().connect([=]() {
|
||||
this->gifUpdateTimout();
|
||||
}); // For some reason when Boost signal is in thread scope and thread deletes the signal
|
||||
// doesn't work, so this is the fix.
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
#include <QString>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class EmoteManager;
|
||||
class WindowManager;
|
||||
|
||||
namespace messages {
|
||||
|
||||
class LazyLoadedImage : public QObject
|
||||
@@ -15,13 +11,11 @@ class LazyLoadedImage : public QObject
|
||||
public:
|
||||
LazyLoadedImage() = delete;
|
||||
|
||||
explicit LazyLoadedImage(EmoteManager &_emoteManager, WindowManager &_windowManager,
|
||||
const QString &_url, qreal _scale = 1, const QString &_name = "",
|
||||
explicit LazyLoadedImage(const QString &_url, qreal _scale = 1, const QString &_name = "",
|
||||
const QString &_tooltip = "", const QMargins &_margin = QMargins(),
|
||||
bool isHat = false);
|
||||
|
||||
explicit LazyLoadedImage(EmoteManager &_emoteManager, WindowManager &_windowManager,
|
||||
QPixmap *_currentPixmap, qreal _scale = 1, const QString &_name = "",
|
||||
explicit LazyLoadedImage(QPixmap *_currentPixmap, qreal _scale = 1, const QString &_name = "",
|
||||
const QString &_tooltip = "", const QMargins &_margin = QMargins(),
|
||||
bool isHat = false);
|
||||
|
||||
@@ -39,9 +33,6 @@ public:
|
||||
int getScaledHeight() const;
|
||||
|
||||
private:
|
||||
EmoteManager &emoteManager;
|
||||
WindowManager &windowManager;
|
||||
|
||||
struct FrameData {
|
||||
QPixmap *image;
|
||||
int duration;
|
||||
|
||||
@@ -33,6 +33,8 @@ int MessageRef::getHeight() const
|
||||
// return true if redraw is required
|
||||
bool MessageRef::layout(int width, float dpiMultiplyer)
|
||||
{
|
||||
auto &emoteManager = EmoteManager::getInstance();
|
||||
|
||||
bool layoutRequired = false;
|
||||
|
||||
// check if width changed
|
||||
@@ -41,9 +43,9 @@ bool MessageRef::layout(int width, float dpiMultiplyer)
|
||||
this->currentLayoutWidth = width;
|
||||
|
||||
// check if emotes changed
|
||||
bool imagesChanged = this->emoteGeneration != EmoteManager::instance->getGeneration();
|
||||
bool imagesChanged = this->emoteGeneration != emoteManager.getGeneration();
|
||||
layoutRequired |= imagesChanged;
|
||||
this->emoteGeneration = EmoteManager::instance->getGeneration();
|
||||
this->emoteGeneration = emoteManager.getGeneration();
|
||||
|
||||
// check if text changed
|
||||
bool textChanged = this->fontGeneration != FontManager::getInstance().getGeneration();
|
||||
|
||||
Reference in New Issue
Block a user