summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/Roster/RosterDelegate.cpp')
-rw-r--r--Swift/QtUI/Roster/RosterDelegate.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/Swift/QtUI/Roster/RosterDelegate.cpp b/Swift/QtUI/Roster/RosterDelegate.cpp
index 5f6e778..47ae948 100644
--- a/Swift/QtUI/Roster/RosterDelegate.cpp
+++ b/Swift/QtUI/Roster/RosterDelegate.cpp
@@ -93,13 +93,16 @@ void RosterDelegate::paintContact(QPainter* painter, const QStyleOptionViewItem&
// Apply a rounded rectangle mask
// FIXME: We shouldn't go via a 128x128 pixmap
QPixmap avatarPixmap = avatar.pixmap(128, 128);
- QPixmap mask(avatarPixmap.size());
- QPainter maskPainter(&mask);
- maskPainter.fillRect(mask.rect(), Qt::white);
+ QPixmap maskedAvatar(avatarPixmap.size());
+ maskedAvatar.fill(QColor(0, 0, 0, 0));
+ QPainter maskPainter(&maskedAvatar);
maskPainter.setBrush(Qt::black);
- maskPainter.drawRoundedRect(mask.rect(), 13, 13);
- avatarPixmap.setMask(mask.createMaskFromColor(Qt::white));
- avatarPixmap = avatarPixmap.scaled(avatarRegion.height(), avatarRegion.width(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ maskPainter.drawRoundedRect(maskedAvatar.rect(), 13, 13);
+ maskPainter.setCompositionMode(QPainter::CompositionMode_SourceIn);
+ maskPainter.drawPixmap(0, 0, avatarPixmap);
+ maskPainter.end();
+
+ avatarPixmap = maskedAvatar.scaled(avatarRegion.height(), avatarRegion.width(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
painter->drawPixmap(avatarRegion.topLeft() + QPoint(((avatarRegion.width() - avatarPixmap.width()) / 2), (avatarRegion.height() - avatarPixmap.height()) / 2), avatarPixmap);