Remove "custom on success" logic from Image.

Create a new message element and message layout element type for mod badges.
This commit is contained in:
Rasmus Karlsson
2019-09-08 11:30:06 +02:00
committed by fourtf
parent 256a65a12e
commit dbce128cc3
8 changed files with 84 additions and 53 deletions
+22 -1
View File
@@ -145,7 +145,7 @@ void EmoteElement::addToContainer(MessageLayoutContainer &container,
QSize(int(container.getScale() * image->width() * emoteScale),
int(container.getScale() * image->height() * emoteScale));
container.addElement((new ImageLayoutElement(*this, image, size))
container.addElement(this->makeImageLayoutElement(image, size)
->setLink(this->getLink()));
}
else
@@ -159,6 +159,27 @@ void EmoteElement::addToContainer(MessageLayoutContainer &container,
}
}
MessageLayoutElement *EmoteElement::makeImageLayoutElement(
const ImagePtr &image, const QSize &size)
{
return new ImageLayoutElement(*this, image, size);
}
// MOD BADGE
ModBadgeElement::ModBadgeElement(const EmotePtr &data,
MessageElementFlags flags_)
: EmoteElement(data, flags_)
{
}
MessageLayoutElement *ModBadgeElement::makeImageLayoutElement(
const ImagePtr &image, const QSize &size)
{
static const QColor modBadgeBackgroundColor("#34AE0A");
return new ImageWithBackgroundLayoutElement(*this, image, size,
modBadgeBackgroundColor);
}
// BADGE
BadgeElement::BadgeElement(const EmotePtr &emote, MessageElementFlags flags)
: MessageElement(flags)