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>
|
2018-01-11 20:16:25 +01:00
|
|
|
#include <boost/noncopyable.hpp>
|
|
|
|
|
2018-01-19 22:45:33 +01:00
|
|
|
#include <atomic>
|
|
|
|
|
2017-01-18 21:30:23 +01:00
|
|
|
namespace chatterino {
|
|
|
|
namespace messages {
|
|
|
|
|
2018-01-11 20:16:25 +01:00
|
|
|
class Image : public QObject, boost::noncopyable
|
2017-01-04 15:12:31 +01:00
|
|
|
{
|
|
|
|
public:
|
2018-01-11 20:16:25 +01:00
|
|
|
explicit Image(const QString &_url, qreal _scale = 1, const QString &_name = "",
|
|
|
|
const QString &_tooltip = "", const QMargins &_margin = QMargins(),
|
|
|
|
bool isHat = false);
|
2017-06-13 21:13:58 +02:00
|
|
|
|
2018-01-11 20:16:25 +01:00
|
|
|
explicit Image(QPixmap *_currentPixmap, qreal _scale = 1, const QString &_name = "",
|
|
|
|
const QString &_tooltip = "", const QMargins &_margin = QMargins(),
|
|
|
|
bool isHat = false);
|
2018-04-06 16:37:30 +02:00
|
|
|
~Image();
|
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;
|
2018-01-11 20:16:25 +01:00
|
|
|
bool isAnimated() const;
|
2017-09-12 19:06:16 +02:00
|
|
|
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-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;
|
2018-01-19 22:45:33 +01:00
|
|
|
QPixmap *loadedPixmap;
|
2017-09-12 19:06:16 +02:00
|
|
|
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
|
|
|
|
2018-01-19 22:45:33 +01:00
|
|
|
bool isLoading = false;
|
|
|
|
std::atomic<bool> isLoaded{false};
|
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
|