summary refs log tree commit diff
path: root/src/ui
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2020-03-22 18:03:08 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2020-03-22 18:03:08 +0100
commitb25e481418ce5348bb842bad86d5fc0a2fbebbd5 (patch)
tree76b129be5399cfe9197784b6834edc61f8f9fdc1 /src/ui
parentFix broken avatars in quick switcher (diff)
downloadnheko-b25e481418ce5348bb842bad86d5fc0a2fbebbd5.tar.xz
Clean up unused avatar functions
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/Avatar.cpp19
-rw-r--r--src/ui/Avatar.h3
-rw-r--r--src/ui/Theme.h1
3 files changed, 4 insertions, 19 deletions
diff --git a/src/ui/Avatar.cpp b/src/ui/Avatar.cpp

index 7ee58d03..b8703e87 100644 --- a/src/ui/Avatar.cpp +++ b/src/ui/Avatar.cpp
@@ -72,6 +72,8 @@ Avatar::setImage(const QString &avatar_url) static_cast<int>(size_ * pixmap_.devicePixelRatio()), this, [this](QPixmap pm) { + if (pm.isNull()) + return; type_ = ui::AvatarType::Image; pixmap_ = pm; update(); @@ -88,6 +90,8 @@ Avatar::setImage(const QString &room, const QString &user) static_cast<int>(size_ * pixmap_.devicePixelRatio()), this, [this](QPixmap pm) { + if (pm.isNull()) + return; type_ = ui::AvatarType::Image; pixmap_ = pm; update(); @@ -95,14 +99,6 @@ Avatar::setImage(const QString &room, const QString &user) } void -Avatar::setIcon(const QIcon &icon) -{ - icon_ = icon; - type_ = ui::AvatarType::Icon; - update(); -} - -void Avatar::paintEvent(QPaintEvent *) { bool rounded = QSettings().value("user/avatar_circles", true).toBool(); @@ -135,13 +131,6 @@ Avatar::paintEvent(QPaintEvent *) } switch (type_) { - case ui::AvatarType::Icon: { - icon_.paint(&painter, - QRect((width() - hs) / 2, (height() - hs) / 2, hs, hs), - Qt::AlignCenter, - QIcon::Normal); - break; - } case ui::AvatarType::Image: { QPainterPath ppath; diff --git a/src/ui/Avatar.h b/src/ui/Avatar.h
index 2910350d..da8a57ed 100644 --- a/src/ui/Avatar.h +++ b/src/ui/Avatar.h
@@ -1,6 +1,5 @@ #pragma once -#include <QIcon> #include <QImage> #include <QPixmap> #include <QWidget> @@ -18,7 +17,6 @@ public: explicit Avatar(QWidget *parent = nullptr, int size = ui::AvatarSize); void setBackgroundColor(const QColor &color); - void setIcon(const QIcon &icon); void setImage(const QString &avatar_url); void setImage(const QString &room, const QString &user); void setLetter(const QString &letter); @@ -40,7 +38,6 @@ private: QString avatar_url_, room_, user_; QColor background_color_; QColor text_color_; - QIcon icon_; QPixmap pixmap_; int size_; }; diff --git a/src/ui/Theme.h b/src/ui/Theme.h
index ecff02b5..34971280 100644 --- a/src/ui/Theme.h +++ b/src/ui/Theme.h
@@ -7,7 +7,6 @@ namespace ui { enum class AvatarType { - Icon, Image, Letter };