mirror-chatterino2/src/singletons/TooltipPreviewImage.hpp

35 lines
847 B
C++
Raw Normal View History

#pragma once
#include "messages/Image.hpp"
namespace chatterino {
2019-06-12 00:31:02 +02:00
class TooltipPreviewImage
{
public:
static TooltipPreviewImage &instance();
2019-06-12 00:31:02 +02:00
void setImage(ImagePtr image);
void setImageScale(int w, int h);
2019-06-12 00:31:02 +02:00
TooltipPreviewImage(const TooltipPreviewImage &) = delete;
2019-06-12 00:31:02 +02:00
private:
TooltipPreviewImage();
2019-06-12 00:31:02 +02:00
private:
ImagePtr image_ = nullptr;
int imageWidth_ = 0;
int imageHeight_ = 0;
2019-06-12 00:31:02 +02:00
std::vector<pajlada::Signals::ScopedConnection> connections_;
// attemptRefresh is set to true in case we want to preview an image that has not loaded yet (if pixmapOrLoad fails)
bool attemptRefresh{false};
// Refresh the pixmap used in the Tooltip Widget
// Called from setImage and from the "gif repaint" signal if the image is animated
void refreshTooltipWidgetPixmap();
2019-06-12 00:31:02 +02:00
};
} // namespace chatterino