mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Fixes #1215 Allow previewing badges
This commit is contained in:
parent
dbc20baa65
commit
6d9545157e
3 changed files with 21 additions and 3 deletions
|
@ -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)
|
||||
|
|
|
@ -222,6 +222,8 @@ public:
|
|||
void addToContainer(MessageLayoutContainer &container,
|
||||
MessageElementFlags flags_) override;
|
||||
|
||||
EmotePtr getEmote() const;
|
||||
|
||||
private:
|
||||
EmotePtr emote_;
|
||||
};
|
||||
|
|
|
@ -1222,15 +1222,26 @@ 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)
|
||||
{
|
||||
if (emoteElement)
|
||||
{
|
||||
tooltipPreviewImage.setImage(
|
||||
emoteElement->getEmote()->images.getImage(3.0));
|
||||
}
|
||||
else if (badgeElement)
|
||||
{
|
||||
tooltipPreviewImage.setImage(
|
||||
badgeElement->getEmote()->images.getImage(3.0));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tooltipPreviewImage.setImage(nullptr);
|
||||
|
|
Loading…
Reference in a new issue