Skip to content
Snippets Groups Projects
Commit b25e4814 authored by Nicolas Werner's avatar Nicolas Werner
Browse files

Clean up unused avatar functions

parent 31a83c51
No related branches found
No related tags found
No related merge requests found
...@@ -196,13 +196,6 @@ TopRoomBar::updateRoomAvatar(const QString &avatar_image) ...@@ -196,13 +196,6 @@ TopRoomBar::updateRoomAvatar(const QString &avatar_image)
update(); update();
} }
void
TopRoomBar::updateRoomAvatar(const QIcon &icon)
{
avatar_->setIcon(icon);
update();
}
void void
TopRoomBar::updateRoomName(const QString &name) TopRoomBar::updateRoomName(const QString &name)
{ {
......
...@@ -29,7 +29,6 @@ class OverlayModal; ...@@ -29,7 +29,6 @@ class OverlayModal;
class QPainter; class QPainter;
class QLabel; class QLabel;
class QIcon;
class QHBoxLayout; class QHBoxLayout;
class QVBoxLayout; class QVBoxLayout;
...@@ -43,7 +42,6 @@ public: ...@@ -43,7 +42,6 @@ public:
TopRoomBar(QWidget *parent = nullptr); TopRoomBar(QWidget *parent = nullptr);
void updateRoomAvatar(const QString &avatar_image); void updateRoomAvatar(const QString &avatar_image);
void updateRoomAvatar(const QIcon &icon);
void updateRoomName(const QString &name); void updateRoomName(const QString &name);
void updateRoomTopic(QString topic); void updateRoomTopic(QString topic);
void updateRoomAvatarFromName(const QString &name); void updateRoomAvatarFromName(const QString &name);
......
...@@ -72,6 +72,8 @@ Avatar::setImage(const QString &avatar_url) ...@@ -72,6 +72,8 @@ Avatar::setImage(const QString &avatar_url)
static_cast<int>(size_ * pixmap_.devicePixelRatio()), static_cast<int>(size_ * pixmap_.devicePixelRatio()),
this, this,
[this](QPixmap pm) { [this](QPixmap pm) {
if (pm.isNull())
return;
type_ = ui::AvatarType::Image; type_ = ui::AvatarType::Image;
pixmap_ = pm; pixmap_ = pm;
update(); update();
...@@ -88,20 +90,14 @@ Avatar::setImage(const QString &room, const QString &user) ...@@ -88,20 +90,14 @@ Avatar::setImage(const QString &room, const QString &user)
static_cast<int>(size_ * pixmap_.devicePixelRatio()), static_cast<int>(size_ * pixmap_.devicePixelRatio()),
this, this,
[this](QPixmap pm) { [this](QPixmap pm) {
if (pm.isNull())
return;
type_ = ui::AvatarType::Image; type_ = ui::AvatarType::Image;
pixmap_ = pm; pixmap_ = pm;
update(); update();
}); });
} }
void
Avatar::setIcon(const QIcon &icon)
{
icon_ = icon;
type_ = ui::AvatarType::Icon;
update();
}
void void
Avatar::paintEvent(QPaintEvent *) Avatar::paintEvent(QPaintEvent *)
{ {
...@@ -135,13 +131,6 @@ Avatar::paintEvent(QPaintEvent *) ...@@ -135,13 +131,6 @@ Avatar::paintEvent(QPaintEvent *)
} }
switch (type_) { 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: { case ui::AvatarType::Image: {
QPainterPath ppath; QPainterPath ppath;
......
#pragma once #pragma once
#include <QIcon>
#include <QImage> #include <QImage>
#include <QPixmap> #include <QPixmap>
#include <QWidget> #include <QWidget>
...@@ -18,7 +17,6 @@ public: ...@@ -18,7 +17,6 @@ public:
explicit Avatar(QWidget *parent = nullptr, int size = ui::AvatarSize); explicit Avatar(QWidget *parent = nullptr, int size = ui::AvatarSize);
void setBackgroundColor(const QColor &color); void setBackgroundColor(const QColor &color);
void setIcon(const QIcon &icon);
void setImage(const QString &avatar_url); void setImage(const QString &avatar_url);
void setImage(const QString &room, const QString &user); void setImage(const QString &room, const QString &user);
void setLetter(const QString &letter); void setLetter(const QString &letter);
...@@ -40,7 +38,6 @@ private: ...@@ -40,7 +38,6 @@ private:
QString avatar_url_, room_, user_; QString avatar_url_, room_, user_;
QColor background_color_; QColor background_color_;
QColor text_color_; QColor text_color_;
QIcon icon_;
QPixmap pixmap_; QPixmap pixmap_;
int size_; int size_;
}; };
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
namespace ui { namespace ui {
enum class AvatarType enum class AvatarType
{ {
Icon,
Image, Image,
Letter Letter
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment