Fixes #1215 Allow previewing badges

This commit is contained in:
fourtf 2019-08-21 01:52:01 +02:00
parent dbc20baa65
commit 6d9545157e
3 changed files with 21 additions and 3 deletions

View file

@ -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)

View file

@ -222,6 +222,8 @@ public:
void addToContainer(MessageLayoutContainer &container,
MessageElementFlags flags_) override;
EmotePtr getEmote() const;
private:
EmotePtr emote_;
};

View file

@ -1222,14 +1222,25 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
auto &tooltipPreviewImage = TooltipPreviewImage::getInstance();
auto emoteElement = dynamic_cast<const EmoteElement *>(
&hoverLayoutElement->getCreator());
auto badgeElement = dynamic_cast<const BadgeElement *>(
&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
{