summary refs log tree commit diff
path: root/src/ui
diff options
context:
space:
mode:
authorAidan Hahn <aidan@aidanis.online>2019-09-01 14:41:23 -0700
committerAidan Hahn <aidan@aidanis.online>2019-09-01 14:41:23 -0700
commita1c2aed36a33ffc10a2f387bf58a3e3cabab0988 (patch)
treebedcde588132ff4aee62b700f9775579a3da392d /src/ui
parentadd controll bits for avatar rounding (diff)
downloadnheko-a1c2aed36a33ffc10a2f387bf58a3e3cabab0988.tar.xz
Refactored Avatar and RoomInfoListItem to access rounding settings in place
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/Avatar.cpp25
-rw-r--r--src/ui/Avatar.h2
2 files changed, 8 insertions, 19 deletions
diff --git a/src/ui/Avatar.cpp b/src/ui/Avatar.cpp
index 6a87e002..df649e1b 100644
--- a/src/ui/Avatar.cpp
+++ b/src/ui/Avatar.cpp
@@ -1,17 +1,15 @@
 #include <QPainter>
+#include <QSettings>
 
 #include "Utils.h"
 #include "ui/Avatar.h"
 
-#define AVATAR_RECT_ROUND 5
-
 Avatar::Avatar(QWidget *parent)
   : QWidget(parent)
 {
         size_    = ui::AvatarSize;
         type_    = ui::AvatarType::Letter;
         letter_  = "A";
-        rounded_ = true;
 
         QFont _font(font());
         _font.setPointSizeF(ui::FontSize);
@@ -104,14 +102,11 @@ Avatar::setIcon(const QIcon &icon)
 }
 
 void
-Avatar::setRounded(bool setting)
-{
-        rounded_ = setting;
-}
-
-void
 Avatar::paintEvent(QPaintEvent *)
 {
+
+        bool rounded = QSettings().value("user/avatar/circles", true).toBool();
+
         QPainter painter(this);
         painter.setRenderHint(QPainter::Antialiasing);
 
@@ -125,11 +120,9 @@ Avatar::paintEvent(QPaintEvent *)
 
                 painter.setPen(Qt::NoPen);
                 painter.setBrush(brush);
-                rounded_ ?
+                rounded ?
                   painter.drawEllipse(r.center(), hs, hs) :
-                  painter.drawRoundedRect( r,
-                                           AVATAR_RECT_ROUND,
-                                           AVATAR_RECT_ROUND);
+                  painter.drawRoundedRect(r, 3, 3);
         }
 
         switch (type_) {
@@ -143,11 +136,9 @@ Avatar::paintEvent(QPaintEvent *)
         case ui::AvatarType::Image: {
                 QPainterPath ppath;
 
-                rounded_ ?
+                rounded ?
                   ppath.addEllipse(width() / 2 - hs, height() / 2 - hs, size_, size_) :
-                  ppath.addRoundedRect( r,
-                                        AVATAR_RECT_ROUND,
-                                        AVATAR_RECT_ROUND);
+                  ppath.addRoundedRect(r, 3, 3);
 
                 painter.setClipPath(ppath);
                 painter.drawPixmap(QRect(width() / 2 - hs, height() / 2 - hs, size_, size_),
diff --git a/src/ui/Avatar.h b/src/ui/Avatar.h
index 5732da27..41967af5 100644
--- a/src/ui/Avatar.h
+++ b/src/ui/Avatar.h
@@ -23,7 +23,6 @@ public:
         void setLetter(const QString &letter);
         void setSize(int size);
         void setTextColor(const QColor &color);
-        void setRounded(bool setting);
 
         QColor backgroundColor() const;
         QColor textColor() const;
@@ -45,5 +44,4 @@ private:
         QImage image_;
         QPixmap pixmap_;
         int size_;
-        bool rounded_ = true;
 };