From 38824f30ac4447f6fecc873595be79496e9642b4 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Mon, 14 Aug 2023 17:09:37 -0400 Subject: [PATCH] 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. --- src/notificationsmanager.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/notificationsmanager.cpp b/src/notificationsmanager.cpp index 22d9ef9e7..27e7eaa5d 100644 --- a/src/notificationsmanager.cpp +++ b/src/notificationsmanager.cpp @@ -291,7 +291,11 @@ QPixmap NotificationsManager::createNotificationImage(const QImage &icon, NeoCha roundedImage.fill(Qt::transparent); 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)); painter.setBrush(brush); @@ -302,6 +306,9 @@ QPixmap NotificationsManager::createNotificationImage(const QImage &icon, NeoCha if (icon != roomAvatar) { 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.drawRoundedRect(lowerQuarter, lowerQuarter.width(), lowerQuarter.height()); }