9 #include <boost/noncopyable.hpp> 10 #include <boost/optional.hpp> 11 #include <boost/variant.hpp> 16 #include <pajlada/signals/signal.hpp> 23 template <
typename Image>
37 bool animated()
const;
39 boost::optional<QPixmap> current()
const;
40 boost::optional<QPixmap> first()
const;
44 QVector<Frame<QPixmap>> items_;
46 int durationOffset_{0};
47 pajlada::Signals::Connection gifTimerConnection_;
52 using ImagePtr = std::shared_ptr<Image>;
55 class Image :
public std::enable_shared_from_this<Image>, boost::noncopyable
59 static constexpr
int maxBytesRam = 20 * 1024 * 1024;
63 static ImagePtr fromUrl(
const Url &url, qreal scale = 1);
64 static ImagePtr fromResourcePixmap(
const QPixmap &pixmap, qreal scale = 1);
67 const Url &url()
const;
70 boost::optional<QPixmap> pixmapOrLoad()
const;
76 bool animated()
const;
83 Image(
const Url &url, qreal scale);
86 void setPixmap(
const QPixmap &pixmap);
91 const qreal scale_{1};
92 std::atomic_bool empty_{
false};
94 mutable std::chrono::time_point<std::chrono::steady_clock> lastUsed_;
96 bool shouldLoad_{
false};
99 std::unique_ptr<detail::Frames> frames_{};
113 void removeImagePtr(
Image *rawPtr);
126 std::map<Image *, std::weak_ptr<Image>> allImages_;
Image image
Definition: Image.hpp:25
Definition: Application.cpp:48
This class is thread safe.
Definition: Image.hpp:55
Definition: Image.hpp:104
std::shared_ptr< Image > ImagePtr
Definition: ModerationAction.hpp:14
bool operator==(const Emote &a, const Emote &b)
Definition: Emote.cpp:7
void load(const std::shared_ptr< NetworkData > &data)
Definition: NetworkPrivate.cpp:391
int duration
Definition: Image.hpp:26
bool operator!=(const Emote &a, const Emote &b)
Definition: Emote.cpp:13