forked from blue/squawk
unread messages count now is displayed on the launcher icon
This commit is contained in:
parent
721d3a1a89
commit
3916aec358
7 changed files with 35 additions and 2 deletions
|
@ -171,6 +171,7 @@ void Models::Element::fileError(const QString& messageId, const QString& error,
|
|||
|
||||
void Models::Element::onFeedUnreadMessagesCountChanged()
|
||||
{
|
||||
emit unreadMessagesCountChanged();
|
||||
if (type == contact) {
|
||||
changed(4);
|
||||
} else if (type == room) {
|
||||
|
|
|
@ -52,6 +52,7 @@ signals:
|
|||
void requestArchive(const QString& before);
|
||||
void fileDownloadRequest(const QString& url);
|
||||
void unnoticedMessage(const QString& account, const Shared::Message& msg);
|
||||
void unreadMessagesCountChanged();
|
||||
void localPathInvalid(const QString& path);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -99,6 +99,7 @@ public:
|
|||
signals:
|
||||
void requestArchive(const QString& account, const QString& jid, const QString& before);
|
||||
void fileDownloadRequest(const QString& url);
|
||||
void unreadMessagesCountChanged(int count);
|
||||
void unnoticedMessage(const QString& account, const Shared::Message& msg);
|
||||
void localPathInvalid(const QString& path);
|
||||
|
||||
|
@ -113,6 +114,7 @@ private slots:
|
|||
void onChildIsAboutToBeMoved(Item* source, int first, int last, Item* destination, int newIndex);
|
||||
void onChildMoved();
|
||||
void onElementRequestArchive(const QString& before);
|
||||
void recalculateUnreadMessages();
|
||||
|
||||
private:
|
||||
Item* root;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue