From b25e481418ce5348bb842bad86d5fc0a2fbebbd5 Mon Sep 17 00:00:00 2001
From: Nicolas Werner <nicolas.werner@hotmail.de>
Date: Sun, 22 Mar 2020 18:03:08 +0100
Subject: [PATCH] Clean up unused avatar functions

---
 src/TopRoomBar.cpp |  7 -------
 src/TopRoomBar.h   |  2 --
 src/ui/Avatar.cpp  | 19 ++++---------------
 src/ui/Avatar.h    |  3 ---
 src/ui/Theme.h     |  1 -
 5 files changed, 4 insertions(+), 28 deletions(-)

diff --git a/src/TopRoomBar.cpp b/src/TopRoomBar.cpp
index ffd57d50a..a45a751e7 100644
--- a/src/TopRoomBar.cpp
+++ b/src/TopRoomBar.cpp
@@ -196,13 +196,6 @@ TopRoomBar::updateRoomAvatar(const QString &avatar_image)
         update();
 }
 
-void
-TopRoomBar::updateRoomAvatar(const QIcon &icon)
-{
-        avatar_->setIcon(icon);
-        update();
-}
-
 void
 TopRoomBar::updateRoomName(const QString &name)
 {
diff --git a/src/TopRoomBar.h b/src/TopRoomBar.h
index 63ce847e1..1aa5934b6 100644
--- a/src/TopRoomBar.h
+++ b/src/TopRoomBar.h
@@ -29,7 +29,6 @@ class OverlayModal;
 
 class QPainter;
 class QLabel;
-class QIcon;
 class QHBoxLayout;
 class QVBoxLayout;
 
@@ -43,7 +42,6 @@ public:
         TopRoomBar(QWidget *parent = nullptr);
 
         void updateRoomAvatar(const QString &avatar_image);
-        void updateRoomAvatar(const QIcon &icon);
         void updateRoomName(const QString &name);
         void updateRoomTopic(QString topic);
         void updateRoomAvatarFromName(const QString &name);
diff --git a/src/ui/Avatar.cpp b/src/ui/Avatar.cpp
index 7ee58d03c..b8703e877 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,20 +90,14 @@ 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();
                                 });
 }
 
-void
-Avatar::setIcon(const QIcon &icon)
-{
-        icon_ = icon;
-        type_ = ui::AvatarType::Icon;
-        update();
-}
-
 void
 Avatar::paintEvent(QPaintEvent *)
 {
@@ -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 2910350d1..da8a57edd 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 ecff02b5b..349712800 100644
--- a/src/ui/Theme.h
+++ b/src/ui/Theme.h
@@ -7,7 +7,6 @@
 namespace ui {
 enum class AvatarType
 {
-        Icon,
         Image,
         Letter
 };
-- 
GitLab