some warnings fixed, new way of drawing avatars in message line

This commit is contained in:
Blue 2022-01-05 22:29:34 +03:00
parent e27ae1a82f
commit 7130e674c4
Signed by untrusted user: blue
GPG key ID: 9B203B252A63EE38
7 changed files with 65 additions and 16 deletions

View file

@ -104,13 +104,7 @@ void MessageDelegate::paint(QPainter* painter, const QStyleOptionViewItem& optio
painter->fillRect(option.rect, option.palette.brush(QPalette::Inactive, QPalette::Highlight));
}
QIcon icon(data.avatar);
if (data.sentByMe) {
painter->drawPixmap(option.rect.width() - avatarHeight - margin, option.rect.y() + margin / 2, icon.pixmap(avatarHeight, avatarHeight));
} else {
painter->drawPixmap(margin, option.rect.y() + margin / 2, icon.pixmap(avatarHeight, avatarHeight));
}
QStyleOptionViewItem opt = option;
QRect messageRect = option.rect.adjusted(margin, margin / 2, -(avatarHeight + 2 * margin), -margin / 2);
@ -163,6 +157,7 @@ void MessageDelegate::paint(QPainter* painter, const QStyleOptionViewItem& optio
break; //but it's a possible performance problem
case Models::uploading:
paintPreview(data, painter, opt);
[[fallthrough]];
case Models::downloading:
paintBar(getBar(data), painter, data.sentByMe, opt);
break;
@ -268,6 +263,7 @@ QSize MessageDelegate::sizeHint(const QStyleOptionViewItem& option, const QModel
break;
case Models::uploading:
messageSize.rheight() += Preview::calculateAttachSize(attach.localPath, messageRect).height() + textMargin;
[[fallthrough]];
case Models::downloading:
messageSize.rheight() += barHeight + textMargin;
break;