summary refs log tree commit diff
path: root/src/RoomInfoListItem.cpp
diff options
context:
space:
mode:
authorJoe <rubberduckie3554@gmail.com>2019-11-02 00:27:54 -0400
committerJoe <rubberduckie3554@gmail.com>2019-11-02 00:27:54 -0400
commit35759d2c6cbc86bd6a5df2c96de5d2dd078742ec (patch)
treee97c5aafb4488755d617bdad2e5f969fe94386f0 /src/RoomInfoListItem.cpp
parentUpdate README with translation information (diff)
parentFix boost build in FreeBSD (diff)
downloadnheko-35759d2c6cbc86bd6a5df2c96de5d2dd078742ec.tar.xz
Merge branch '0.7.0-dev' of https://github.com/Nheko-Reborn/nheko into 0.7.0-dev
Diffstat (limited to 'src/RoomInfoListItem.cpp')
-rw-r--r--src/RoomInfoListItem.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/RoomInfoListItem.cpp b/src/RoomInfoListItem.cpp

index 9bcce134..8aadbea2 100644 --- a/src/RoomInfoListItem.cpp +++ b/src/RoomInfoListItem.cpp
@@ -19,8 +19,10 @@ #include <QDebug> #include <QMouseEvent> #include <QPainter> +#include <QSettings> #include <QtGlobal> +#include "AvatarProvider.h" #include "Cache.h" #include "Config.h" #include "RoomInfoListItem.h" @@ -140,6 +142,8 @@ RoomInfoListItem::resizeEvent(QResizeEvent *) void RoomInfoListItem::paintEvent(QPaintEvent *event) { + bool rounded = QSettings().value("user/avatar/circles", true).toBool(); + Q_UNUSED(event); QPainter p(this); @@ -287,7 +291,8 @@ RoomInfoListItem::paintEvent(QPaintEvent *event) p.setPen(Qt::NoPen); p.setBrush(brush); - p.drawEllipse(avatarRegion.center(), wm.iconSize / 2, wm.iconSize / 2); + rounded ? p.drawEllipse(avatarRegion.center(), wm.iconSize / 2, wm.iconSize / 2) + : p.drawRoundedRect(avatarRegion, 3, 3); QFont bubbleFont; bubbleFont.setPointSizeF(bubbleFont.pointSizeF() * 1.4); @@ -300,7 +305,9 @@ RoomInfoListItem::paintEvent(QPaintEvent *event) p.save(); QPainterPath path; - path.addEllipse(wm.padding, wm.padding, wm.iconSize, wm.iconSize); + rounded ? path.addEllipse(wm.padding, wm.padding, wm.iconSize, wm.iconSize) + : path.addRoundedRect(avatarRegion, 3, 3); + p.setClipPath(path); p.drawPixmap(avatarRegion, roomAvatar_); @@ -434,10 +441,12 @@ RoomInfoListItem::mousePressEvent(QMouseEvent *event) } void -RoomInfoListItem::setAvatar(const QImage &img) +RoomInfoListItem::setAvatar(const QString &avatar_url) { - roomAvatar_ = utils::scaleImageToPixmap(img, IconSize); - update(); + AvatarProvider::resolve(avatar_url, IconSize, this, [this](const QPixmap &img) { + roomAvatar_ = img; + update(); + }); } void