Animate gifs in the tooltip preview

This commit is contained in:
rexim 2019-06-05 00:59:08 +07:00
parent 94e705ec1b
commit a84716547b
2 changed files with 16 additions and 7 deletions

View file

@ -311,6 +311,15 @@ void ChannelView::queueUpdate()
// }
// this->repaint();
auto tooltipWidget = TooltipWidget::getInstance();
if (this->currentPreviewEmote) {
auto pixmap = this->currentPreviewEmote->images.getImage(3.0)->pixmap();
if (pixmap) {
tooltipWidget->setImage(*pixmap);
}
}
this->update();
// this->updateTimer.start();
@ -1217,15 +1226,12 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
}
else
{
tooltipWidget->clearImage();
auto emoteElement = dynamic_cast<const EmoteElement*>(&hoverLayoutElement->getCreator());
if (emoteElement && getSettings()->emotesTooltipPreview.getValue()) {
auto pixmap = emoteElement->getEmote()->images.getImage(3.0)->pixmap();
if (pixmap) {
// FIXME: Gifs are not animated
tooltipWidget->setImage(*pixmap);
}
this->currentPreviewEmote = emoteElement->getEmote();
} else {
this->currentPreviewEmote = nullptr;
tooltipWidget->clearImage();
}
tooltipWidget->moveTo(this, event->globalPos());

View file

@ -4,6 +4,7 @@
#include "messages/LimitedQueue.hpp"
#include "messages/LimitedQueueSnapshot.hpp"
#include "messages/Selection.hpp"
#include "messages/Emote.hpp"
#include "widgets/BaseWidget.hpp"
#include <QPaintEvent>
@ -209,6 +210,8 @@ private:
static constexpr int leftPadding = 8;
static constexpr int scrollbarPadding = 8;
EmotePtr currentPreviewEmote = nullptr;
private slots:
void wordFlagsChanged()
{