mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 03:00:46 +03:00
Handle room avatars in top bar without an icon
This commit is contained in:
parent
a859145983
commit
1c9e92b8bd
3 changed files with 13 additions and 0 deletions
|
@ -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();
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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("");
|
||||||
|
|
Loading…
Reference in a new issue