From 6d9545157e0e58c069a53f6b257aec3255b9e04b Mon Sep 17 00:00:00 2001 From: fourtf Date: Wed, 21 Aug 2019 01:52:01 +0200 Subject: [PATCH] Fixes #1215 Allow previewing badges --- src/messages/MessageElement.cpp | 5 +++++ src/messages/MessageElement.hpp | 2 ++ src/widgets/helper/ChannelView.cpp | 17 ++++++++++++++--- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/messages/MessageElement.cpp b/src/messages/MessageElement.cpp index 03240db45..907bcc54a 100644 --- a/src/messages/MessageElement.cpp +++ b/src/messages/MessageElement.cpp @@ -185,6 +185,11 @@ void BadgeElement::addToContainer(MessageLayoutContainer &container, } } +EmotePtr BadgeElement::getEmote() const +{ + return this->emote_; +} + // TEXT TextElement::TextElement(const QString &text, MessageElementFlags flags, const MessageColor &color, FontStyle style) diff --git a/src/messages/MessageElement.hpp b/src/messages/MessageElement.hpp index 95c7090d4..3259405a6 100644 --- a/src/messages/MessageElement.hpp +++ b/src/messages/MessageElement.hpp @@ -222,6 +222,8 @@ public: void addToContainer(MessageLayoutContainer &container, MessageElementFlags flags_) override; + EmotePtr getEmote() const; + private: EmotePtr emote_; }; diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index 36f8dd8ec..3f936a9f3 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -1222,14 +1222,25 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event) auto &tooltipPreviewImage = TooltipPreviewImage::getInstance(); auto emoteElement = dynamic_cast( &hoverLayoutElement->getCreator()); + auto badgeElement = dynamic_cast( + &hoverLayoutElement->getCreator()); - if (emoteElement && getSettings()->emotesTooltipPreview.getValue()) + if ((badgeElement || emoteElement) && + getSettings()->emotesTooltipPreview.getValue()) { if (event->modifiers() == Qt::ShiftModifier || getSettings()->emotesTooltipPreview.getValue() == 1) { - tooltipPreviewImage.setImage( - emoteElement->getEmote()->images.getImage(3.0)); + if (emoteElement) + { + tooltipPreviewImage.setImage( + emoteElement->getEmote()->images.getImage(3.0)); + } + else if (badgeElement) + { + tooltipPreviewImage.setImage( + badgeElement->getEmote()->images.getImage(3.0)); + } } else {