From 3cb1d280bc2e2f6ca2082cd9ab22264da6010d8b Mon Sep 17 00:00:00 2001 From: "Tux3 / Mlkj / !Lev.uXFMLA" Date: Wed, 24 Sep 2014 17:35:24 +0200 Subject: [PATCH] Fix avatars resetting after friend clicked on --- widget/friendwidget.cpp | 10 +++++++--- widget/friendwidget.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/widget/friendwidget.cpp b/widget/friendwidget.cpp index 60b655c96..b9d134878 100644 --- a/widget/friendwidget.cpp +++ b/widget/friendwidget.cpp @@ -26,7 +26,7 @@ #include FriendWidget::FriendWidget(int FriendId, QString id) - : friendId(FriendId) + : friendId(FriendId), isDefaultAvatar{true} { setMouseTracking(true); setAutoFillBackground(true); @@ -134,7 +134,8 @@ void FriendWidget::setAsActiveChatroom() QPalette pal3; pal3.setColor(QPalette::Background, Qt::white); this->setPalette(pal3); - avatar.setPixmap(QPixmap(":img/contact_dark.png")); + if (isDefaultAvatar) + avatar.setPixmap(QPixmap(":img/contact_dark.png")); } void FriendWidget::setAsInactiveChatroom() @@ -153,7 +154,9 @@ void FriendWidget::setAsInactiveChatroom() QPalette pal3; pal3.setColor(QPalette::Background, QColor(65,65,65,255)); this->setPalette(pal3); - avatar.setPixmap(QPixmap(":img/contact.png")); + + if (isDefaultAvatar) + avatar.setPixmap(QPixmap(":img/contact.png")); } void FriendWidget::updateStatusLight() @@ -196,5 +199,6 @@ void FriendWidget::onAvatarChange(int FriendId, const QPixmap& pic) if (FriendId != friendId) return; + isDefaultAvatar = false; avatar.setPixmap(pic); } diff --git a/widget/friendwidget.h b/widget/friendwidget.h index c693c6199..a1bae68a1 100644 --- a/widget/friendwidget.h +++ b/widget/friendwidget.h @@ -48,6 +48,7 @@ public: int friendId; QLabel avatar, statusPic; CroppingLabel name, statusMessage; + bool isDefaultAvatar; }; #endif // FRIENDWIDGET_H