From a84716547b5c63e33708d709a3c28ea227a4e75e Mon Sep 17 00:00:00 2001 From: rexim Date: Wed, 5 Jun 2019 00:59:08 +0700 Subject: [PATCH] Animate gifs in the tooltip preview --- src/widgets/helper/ChannelView.cpp | 20 +++++++++++++------- src/widgets/helper/ChannelView.hpp | 3 +++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index 1f0147f35..ef3c290fc 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -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(&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()); diff --git a/src/widgets/helper/ChannelView.hpp b/src/widgets/helper/ChannelView.hpp index 70b5fd0b4..7abf29380 100644 --- a/src/widgets/helper/ChannelView.hpp +++ b/src/widgets/helper/ChannelView.hpp @@ -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 @@ -209,6 +210,8 @@ private: static constexpr int leftPadding = 8; static constexpr int scrollbarPadding = 8; + EmotePtr currentPreviewEmote = nullptr; + private slots: void wordFlagsChanged() {