mirror-chatterino2/src/singletons/TooltipPreviewImage.cpp

38 lines
929 B
C++
Raw Normal View History

#include "TooltipPreviewImage.hpp"
#include "Application.hpp"
#include "singletons/WindowManager.hpp"
#include "widgets/TooltipWidget.hpp"
namespace chatterino {
2019-06-12 00:31:02 +02:00
TooltipPreviewImage &TooltipPreviewImage::getInstance()
{
static TooltipPreviewImage *instance = new TooltipPreviewImage();
return *instance;
}
2019-06-12 00:31:02 +02:00
TooltipPreviewImage::TooltipPreviewImage()
{
connections_.push_back(getApp()->windows->gifRepaintRequested.connect([&] {
auto tooltipWidget = TooltipWidget::getInstance();
if (this->image_ && !tooltipWidget->isHidden())
{
auto pixmap = this->image_->pixmapOrLoad();
2019-06-12 00:31:02 +02:00
if (pixmap)
{
tooltipWidget->setImage(*pixmap);
}
2019-06-12 00:31:02 +02:00
}
else
{
tooltipWidget->clearImage();
}
}));
}
2019-06-12 00:31:02 +02:00
void TooltipPreviewImage::setImage(ImagePtr image)
{
this->image_ = image;
}
} // namespace chatterino