mirror-chatterino2/src/messages/Image.hpp

70 lines
1.7 KiB
C++
Raw Normal View History

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>
#include <boost/noncopyable.hpp>
2018-01-19 22:45:33 +01:00
#include <atomic>
2017-01-18 21:30:23 +01:00
namespace chatterino {
class Image : public QObject, boost::noncopyable
2017-01-04 15:12:31 +01:00
{
public:
explicit Image(const QString &_url, qreal _scale = 1, const QString &_name = "",
const QString &_tooltip = "", const QMargins &_margin = QMargins(),
bool isHat = false);
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 &getCopyString() const;
2017-09-12 19:06:16 +02:00
const QString &getTooltip() const;
const QMargins &getMargin() const;
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
void setCopyString(const QString &newCopyString);
2017-01-05 16:07:20 +01:00
private:
2017-02-06 17:42:28 +01:00
struct FrameData {
QPixmap *image;
int duration;
2017-02-06 17:42:28 +01:00
};
static bool loadedEventQueued;
QPixmap *currentPixmap = nullptr;
QPixmap *loadedPixmap = nullptr;
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 copyString;
2017-09-12 19:06:16 +02:00
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 chatterino