unread messages count now is displayed on the launcher icon

This commit is contained in:
Blue 2022-04-23 16:58:08 +03:00
parent 721d3a1a89
commit 3916aec358
Signed by untrusted user: blue
GPG key ID: 9B203B252A63EE38
7 changed files with 35 additions and 2 deletions

View file

@ -463,6 +463,7 @@ void Models::Roster::addContact(const QString& account, const QString& jid, cons
connect(contact, &Contact::fileDownloadRequest, this, &Roster::fileDownloadRequest);
connect(contact, &Contact::unnoticedMessage, this, &Roster::unnoticedMessage);
connect(contact, &Contact::localPathInvalid, this, &Roster::localPathInvalid);
connect(contact, &Contact::unreadMessagesCountChanged, this, &Roster::recalculateUnreadMessages);
contacts.insert(std::make_pair(id, contact));
} else {
contact = itr->second;
@ -805,6 +806,7 @@ void Models::Roster::addRoom(const QString& account, const QString jid, const QM
connect(room, &Room::fileDownloadRequest, this, &Roster::fileDownloadRequest);
connect(room, &Room::unnoticedMessage, this, &Roster::unnoticedMessage);
connect(room, &Room::localPathInvalid, this, &Roster::localPathInvalid);
connect(room, &Room::unreadMessagesCountChanged, this, &Roster::recalculateUnreadMessages);
rooms.insert(std::make_pair(id, room));
acc->appendChild(room);
}
@ -1049,3 +1051,14 @@ void Models::Roster::onAccountReconnected()
}
}
void Models::Roster::recalculateUnreadMessages()
{
int count(0);
for (const std::pair<const ElId, Contact*>& pair : contacts) {
count += pair.second->getMessagesCount();
}
for (const std::pair<const ElId, Room*>& pair : rooms) {
count += pair.second->getMessagesCount();
}
emit unreadMessagesCountChanged(count);
}