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