2017-06-06 21:18:05 +02:00
|
|
|
#pragma once
|
2017-01-04 15:12:31 +01:00
|
|
|
|
2017-01-13 18:59:11 +01:00
|
|
|
#include <QPixmap>
|
2017-01-11 18:52:09 +01:00
|
|
|
#include <QString>
|
2017-01-04 15:12:31 +01:00
|
|
|
|
2017-01-18 21:30:23 +01:00
|
|
|
namespace chatterino {
|
2017-06-13 21:13:58 +02:00
|
|
|
|
|
|
|
class EmoteManager;
|
|
|
|
class WindowManager;
|
|
|
|
|
2017-01-18 21:30:23 +01:00
|
|
|
namespace messages {
|
|
|
|
|
2017-02-06 17:42:28 +01:00
|
|
|
class LazyLoadedImage : QObject
|
2017-01-04 15:12:31 +01:00
|
|
|
{
|
|
|
|
public:
|
2017-06-13 21:13:58 +02:00
|
|
|
LazyLoadedImage() = delete;
|
|
|
|
|
|
|
|
explicit LazyLoadedImage(EmoteManager &_emoteManager, WindowManager &_windowManager,
|
|
|
|
const QString &_url, qreal _scale = 1, const QString &_name = "",
|
2017-04-14 14:52:31 +02:00
|
|
|
const QString &_tooltip = "", const QMargins &_margin = QMargins(),
|
2017-01-26 17:26:20 +01:00
|
|
|
bool isHat = false);
|
2017-06-13 21:13:58 +02:00
|
|
|
|
|
|
|
explicit LazyLoadedImage(EmoteManager &_emoteManager, WindowManager &_windowManager,
|
|
|
|
QPixmap *_currentPixmap, qreal _scale = 1, const QString &_name = "",
|
2017-04-14 14:52:31 +02:00
|
|
|
const QString &_tooltip = "", const QMargins &_margin = QMargins(),
|
2017-01-26 17:26:20 +01:00
|
|
|
bool isHat = false);
|
2017-01-05 16:07:20 +01:00
|
|
|
|
2017-09-12 19:06:16 +02:00
|
|
|
const QPixmap *getPixmap();
|
|
|
|
qreal getScale() const;
|
|
|
|
const QString &getUrl() const;
|
|
|
|
const QString &getName() const;
|
|
|
|
const QString &getTooltip() const;
|
|
|
|
const QMargins &getMargin() const;
|
|
|
|
bool getAnimated() const;
|
|
|
|
bool isHat() const;
|
|
|
|
int getWidth() const;
|
|
|
|
int getScaledWidth() const;
|
|
|
|
int getHeight() const;
|
|
|
|
int getScaledHeight() const;
|
2017-01-11 01:08:20 +01:00
|
|
|
|
2017-01-05 16:07:20 +01:00
|
|
|
private:
|
2017-06-13 21:13:58 +02:00
|
|
|
EmoteManager &emoteManager;
|
|
|
|
WindowManager &windowManager;
|
|
|
|
|
2017-02-06 17:42:28 +01:00
|
|
|
struct FrameData {
|
|
|
|
QPixmap *image;
|
2017-02-06 18:31:25 +01:00
|
|
|
int duration;
|
2017-02-06 17:42:28 +01:00
|
|
|
};
|
|
|
|
|
2017-09-12 19:06:16 +02:00
|
|
|
QPixmap *currentPixmap;
|
|
|
|
std::vector<FrameData> allFrames;
|
|
|
|
int currentFrame = 0;
|
|
|
|
int currentFrameOffset = 0;
|
2017-01-06 23:28:48 +01:00
|
|
|
|
2017-09-12 19:06:16 +02:00
|
|
|
QString url;
|
|
|
|
QString name;
|
|
|
|
QString tooltip;
|
|
|
|
bool animated = false;
|
|
|
|
QMargins margin;
|
|
|
|
bool ishat;
|
|
|
|
qreal scale;
|
2017-01-11 18:52:09 +01:00
|
|
|
|
2017-09-12 19:06:16 +02:00
|
|
|
bool isLoading;
|
2017-01-11 18:52:09 +01:00
|
|
|
|
|
|
|
void loadImage();
|
2017-02-06 17:42:28 +01:00
|
|
|
void gifUpdateTimout();
|
2017-01-04 15:12:31 +01:00
|
|
|
};
|
2017-06-06 21:18:05 +02:00
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
} // namespace messages
|
|
|
|
} // namespace chatterino
|