2019-06-11 20:03:04 +02:00
|
|
|
#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-11 20:03:04 +02:00
|
|
|
|
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_->pixmap();
|
|
|
|
if (pixmap)
|
|
|
|
{
|
|
|
|
tooltipWidget->setImage(*pixmap);
|
2019-06-11 20:03:04 +02:00
|
|
|
}
|
2019-06-12 00:31:02 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tooltipWidget->clearImage();
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
}
|
2019-06-11 20:03:04 +02:00
|
|
|
|
2019-06-12 00:31:02 +02:00
|
|
|
void TooltipPreviewImage::setImage(ImagePtr image)
|
|
|
|
{
|
|
|
|
this->image_ = image;
|
|
|
|
}
|
2019-06-11 20:03:04 +02:00
|
|
|
} // namespace chatterino
|