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
@@ -168,6 +168,33 @@ int ImageLayoutElement::getXFromIndex(int index)
}
}
//
// IMAGE WITH BACKGROUND
//
ImageWithBackgroundLayoutElement::ImageWithBackgroundLayoutElement(
MessageElement &creator, ImagePtr image, const QSize &size, QColor color)
: ImageLayoutElement(creator, image, size)
, color_(color)
{
}
void ImageWithBackgroundLayoutElement::paint(QPainter &painter)
{
if (this->image_ == nullptr)
{
return;
}
auto pixmap = this->image_->pixmapOrLoad();
if (pixmap && !this->image_->animated())
{
painter.fillRect(QRectF(this->getRect()), this->color_);
// fourtf: make it use qreal values
painter.drawPixmap(QRectF(this->getRect()), *pixmap, QRectF());
}
}
//
// TEXT
//