From 8b42873968bdc6bd5cdd92949c51f4d3de697d6c Mon Sep 17 00:00:00 2001 From: Phenom Date: Sun, 4 Mar 2018 22:45:11 +0100 Subject: [PATCH] Fix Friend Avatar status overlay no depends size scale. --- retroshare-gui/src/gui/common/FriendList.cpp | 23 ++++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/retroshare-gui/src/gui/common/FriendList.cpp b/retroshare-gui/src/gui/common/FriendList.cpp index 726bf61ea..82f416909 100644 --- a/retroshare-gui/src/gui/common/FriendList.cpp +++ b/retroshare-gui/src/gui/common/FriendList.cpp @@ -496,22 +496,21 @@ void FriendList::groupsChanged() static QIcon createAvatar(const QPixmap &avatar, const QPixmap &overlay) { - int avatarWidth = avatar.width(); - int avatarHeight = avatar.height(); + int avatarWidth = avatar.width(); + int avatarHeight = avatar.height(); - QPixmap pixmap(avatar); + QPixmap pixmap(avatar); - int overlayWidth = avatarWidth / 2.5; - int overlayHeight = avatarHeight / 2.5; - int overlayX = avatarWidth - overlayWidth; - int overlayY = avatarHeight - overlayHeight; + int overlaySize = (avatarWidth > avatarHeight) ? (avatarWidth/2.5) : (avatarHeight/2.5); + int overlayX = avatarWidth - overlaySize; + int overlayY = avatarHeight - overlaySize; - QPainter painter(&pixmap); - painter.drawPixmap(overlayX, overlayY, overlayWidth, overlayHeight, overlay); + QPainter painter(&pixmap); + painter.drawPixmap(overlayX, overlayY, overlaySize, overlaySize, overlay); - QIcon icon; - icon.addPixmap(pixmap); - return icon; + QIcon icon; + icon.addPixmap(pixmap); + return icon; } static void getNameWidget(QTreeWidget *treeWidget, QTreeWidgetItem *item, ElidedLabel *&nameLabel, ElidedLabel *&textLabel)