mirror-chatterino2/src/messages/image.hpp
Rasmus Karlsson 6ea3a1df08 Switch some c-style includes to c++-style includes (i.e. stdint.h to
cstdint)

Make MessageElement to a class to fit better with the derived classes.
Make MessageLayoutElement to a class to fit better with the derived
classes.

Remove virtual from override functions

Replace all instances of boost::signals2 with pajlada::Signals. This
lets us properly use clang code model to check for issues.

Add missing virtual destructor to AbstractIrcServer
Add missing virtual destructor to MessageLayoutElement

Remove unused "connectedConnection" connection in TwitchChannel

Fix typo in TrimChannelName function
Fix typo in MessageParseArgs

Replace some raw pointers with unique pointers where it made more sense.
This allowed us to remove some manually written destructors whose only
purpose was to delete that raw pointer.

Reformat: Add namespace comments
Reformat: Add empty empty lines between main namespace beginning and end
Reformat: Re-order includes
Reformat: Fix some includes that used quotes where they should use angle
brackets
Reformat: Replace some typedef's with using's

Filter out more useless warnings
2018-04-11 22:54:34 +02:00

67 lines
1.6 KiB
C++

#pragma once
#include <QPixmap>
#include <QString>
#include <boost/noncopyable.hpp>
#include <atomic>
namespace chatterino {
namespace messages {
class Image : public QObject, boost::noncopyable
{
public:
Image() = delete;
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);
const QPixmap *getPixmap();
qreal getScale() const;
const QString &getUrl() const;
const QString &getName() const;
const QString &getTooltip() const;
const QMargins &getMargin() const;
bool isAnimated() const;
bool isHat() const;
int getWidth() const;
int getScaledWidth() const;
int getHeight() const;
int getScaledHeight() const;
private:
struct FrameData {
QPixmap *image;
int duration;
};
QPixmap *currentPixmap;
QPixmap *loadedPixmap;
std::vector<FrameData> allFrames;
int currentFrame = 0;
int currentFrameOffset = 0;
QString url;
QString name;
QString tooltip;
bool animated = false;
QMargins margin;
bool ishat;
qreal scale;
bool isLoading = false;
std::atomic<bool> isLoaded{false};
void loadImage();
void gifUpdateTimout();
};
} // namespace messages
} // namespace chatterino