diff --git a/include/TopRoomBar.h b/include/TopRoomBar.h index bfc5a08f..1544ad46 100644 --- a/include/TopRoomBar.h +++ b/include/TopRoomBar.h @@ -39,6 +39,7 @@ public: inline void updateRoomAvatar(const QIcon &icon); inline void updateRoomName(const QString &name); inline void updateRoomTopic(const QString &topic); + void updateRoomAvatarFromName(const QString &name); void reset(); diff --git a/src/ChatPage.cc b/src/ChatPage.cc index e6b05c1d..a5e86f1f 100644 --- a/src/ChatPage.cc +++ b/src/ChatPage.cc @@ -292,6 +292,8 @@ void ChatPage::changeTopRoomInfo(const RoomInfo &info) if (room_avatars_.contains(info.id())) { QIcon icon(room_avatars_.value(info.id())); top_bar_->updateRoomAvatar(icon); + } else { + top_bar_->updateRoomAvatarFromName(info.name()); } current_room_ = info; diff --git a/src/TopRoomBar.cc b/src/TopRoomBar.cc index 3c05a953..adff71b0 100644 --- a/src/TopRoomBar.cc +++ b/src/TopRoomBar.cc @@ -77,6 +77,16 @@ TopRoomBar::TopRoomBar(QWidget *parent) setLayout(top_layout_); } +void TopRoomBar::updateRoomAvatarFromName(const QString &name) +{ + QChar letter = '?'; + + if (name.size() > 0) + letter = name[0]; + + avatar_->setLetter(letter); +} + void TopRoomBar::reset() { name_label_->setText("");