Further notification avatar improvements
The correct render hint is actually SmoothPixmapTransform, as
Antialiasing only matters for primitives. Also, render a white
background for potentially transparent avatars.
(cherry picked from commit 38824f30ac)
This commit is contained in:
@@ -293,7 +293,11 @@ QPixmap NotificationsManager::createNotificationImage(const QImage &icon, NeoCha
|
|||||||
roundedImage.fill(Qt::transparent);
|
roundedImage.fill(Qt::transparent);
|
||||||
|
|
||||||
QPainter painter(&roundedImage);
|
QPainter painter(&roundedImage);
|
||||||
painter.setRenderHint(QPainter::Antialiasing);
|
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
|
|
||||||
|
// Fill background for transparent avatars
|
||||||
|
painter.setBrush(Qt::white);
|
||||||
|
painter.drawRoundedRect(imageRect, imageRect.width(), imageRect.height());
|
||||||
|
|
||||||
QBrush brush(icon.scaledToHeight(biggestDimension));
|
QBrush brush(icon.scaledToHeight(biggestDimension));
|
||||||
painter.setBrush(brush);
|
painter.setBrush(brush);
|
||||||
@@ -304,6 +308,9 @@ QPixmap NotificationsManager::createNotificationImage(const QImage &icon, NeoCha
|
|||||||
if (icon != roomAvatar) {
|
if (icon != roomAvatar) {
|
||||||
const QRect lowerQuarter{imageRect.center(), imageRect.size() / 2};
|
const QRect lowerQuarter{imageRect.center(), imageRect.size() / 2};
|
||||||
|
|
||||||
|
painter.setBrush(Qt::white);
|
||||||
|
painter.drawRoundedRect(lowerQuarter, lowerQuarter.width(), lowerQuarter.height());
|
||||||
|
|
||||||
painter.setBrush(roomAvatar.scaled(lowerQuarter.size()));
|
painter.setBrush(roomAvatar.scaled(lowerQuarter.size()));
|
||||||
painter.drawRoundedRect(lowerQuarter, lowerQuarter.width(), lowerQuarter.height());
|
painter.drawRoundedRect(lowerQuarter, lowerQuarter.width(), lowerQuarter.height());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user