Handle room avatars in top bar without an icon

This commit is contained in:
Konstantinos Sideris 2017-04-10 19:01:09 +03:00
parent a859145983
commit 1c9e92b8bd
3 changed files with 13 additions and 0 deletions

View file

@ -39,6 +39,7 @@ public:
inline void updateRoomAvatar(const QIcon &icon); inline void updateRoomAvatar(const QIcon &icon);
inline void updateRoomName(const QString &name); inline void updateRoomName(const QString &name);
inline void updateRoomTopic(const QString &topic); inline void updateRoomTopic(const QString &topic);
void updateRoomAvatarFromName(const QString &name);
void reset(); void reset();

View file

@ -292,6 +292,8 @@ void ChatPage::changeTopRoomInfo(const RoomInfo &info)
if (room_avatars_.contains(info.id())) { if (room_avatars_.contains(info.id())) {
QIcon icon(room_avatars_.value(info.id())); QIcon icon(room_avatars_.value(info.id()));
top_bar_->updateRoomAvatar(icon); top_bar_->updateRoomAvatar(icon);
} else {
top_bar_->updateRoomAvatarFromName(info.name());
} }
current_room_ = info; current_room_ = info;

View file

@ -77,6 +77,16 @@ TopRoomBar::TopRoomBar(QWidget *parent)
setLayout(top_layout_); setLayout(top_layout_);
} }
void TopRoomBar::updateRoomAvatarFromName(const QString &name)
{
QChar letter = '?';
if (name.size() > 0)
letter = name[0];
avatar_->setLetter(letter);
}
void TopRoomBar::reset() void TopRoomBar::reset()
{ {
name_label_->setText(""); name_label_->setText("");