Add message count to notifications

Added unread message count to window title and also in notification.
Made one notification for each conversation, with new messages, the
count is simply being updated.
This commit is contained in:
pisarzk@gmail.com 2013-07-30 20:54:22 +02:00
parent 45d911a7c2
commit ac7a745bf9
2 changed files with 19 additions and 4 deletions

View File

@ -42,6 +42,8 @@ ChatWindow::ChatWindow(ContactLinker* cl)
cl->GetName().String(), B_TITLED_WINDOW, 0),
fContactLinker(cl)
{
fMessageCount = 0;
fReceiveView = new CayaRenderView("fReceiveView");
fReceiveView->SetOtherNick(cl->GetName());
BScrollView* scrollViewReceive = new BScrollView("scrollviewR",
@ -193,9 +195,13 @@ ChatWindow::ImMessage(BMessage* msg)
if (IsActive()) break;
fMessageCount++;
// Mark unread window
if (CayaPreferences::Item()->MarkUnreadWindow) {
BString title = "[*] ";
BString title = "[";
title<<fMessageCount;
title<<"] ";
title<<fContactLinker->GetName();
SetTitle(title);
}
@ -205,15 +211,21 @@ ChatWindow::ImMessage(BMessage* msg)
break;
BString notify_message;
notify_message << "You've got new message from ";
notify_message << "You've got ";
notify_message << fMessageCount;
if (fMessageCount==1) {
notify_message << " new message from ";
} else {
notify_message << " new messages from ";
};
notify_message << fContactLinker->GetName().String();
BNotification notification(B_INFORMATION_NOTIFICATION);
notification.SetGroup(BString("Caya"));
notification.SetTitle(BString("New message"));
notification.SetIcon(fAvatar->Bitmap());
notification.SetContent(notify_message);
notification.SetMessageID(fContactLinker->GetName());
notification.Send();
break;
@ -238,6 +250,7 @@ void
ChatWindow::WindowActivated(bool active)
{
SetTitle(fContactLinker->GetName());
fMessageCount=0;
}
void

View File

@ -8,6 +8,7 @@
#include <Window.h>
#include <TextView.h>
#include <StringView.h>
#include <Notification.h>
#include "Observer.h"
#include "CayaConstants.h"
@ -43,6 +44,7 @@ private:
BStringView* fStatus;
BTextView* fPersonalMessage;
BitmapView* fAvatar;
int32 fMessageCount;
};