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:
parent
45d911a7c2
commit
ac7a745bf9
|
@ -42,6 +42,8 @@ ChatWindow::ChatWindow(ContactLinker* cl)
|
||||||
cl->GetName().String(), B_TITLED_WINDOW, 0),
|
cl->GetName().String(), B_TITLED_WINDOW, 0),
|
||||||
fContactLinker(cl)
|
fContactLinker(cl)
|
||||||
{
|
{
|
||||||
|
fMessageCount = 0;
|
||||||
|
|
||||||
fReceiveView = new CayaRenderView("fReceiveView");
|
fReceiveView = new CayaRenderView("fReceiveView");
|
||||||
fReceiveView->SetOtherNick(cl->GetName());
|
fReceiveView->SetOtherNick(cl->GetName());
|
||||||
BScrollView* scrollViewReceive = new BScrollView("scrollviewR",
|
BScrollView* scrollViewReceive = new BScrollView("scrollviewR",
|
||||||
|
@ -193,11 +195,15 @@ ChatWindow::ImMessage(BMessage* msg)
|
||||||
|
|
||||||
if (IsActive()) break;
|
if (IsActive()) break;
|
||||||
|
|
||||||
|
fMessageCount++;
|
||||||
|
|
||||||
// Mark unread window
|
// Mark unread window
|
||||||
if (CayaPreferences::Item()->MarkUnreadWindow) {
|
if (CayaPreferences::Item()->MarkUnreadWindow) {
|
||||||
BString title = "[*] ";
|
BString title = "[";
|
||||||
|
title<<fMessageCount;
|
||||||
|
title<<"] ";
|
||||||
title<<fContactLinker->GetName();
|
title<<fContactLinker->GetName();
|
||||||
SetTitle(title);
|
SetTitle(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the user want the notification
|
// Check if the user want the notification
|
||||||
|
@ -205,15 +211,21 @@ ChatWindow::ImMessage(BMessage* msg)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
BString notify_message;
|
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();
|
notify_message << fContactLinker->GetName().String();
|
||||||
|
|
||||||
|
|
||||||
BNotification notification(B_INFORMATION_NOTIFICATION);
|
BNotification notification(B_INFORMATION_NOTIFICATION);
|
||||||
notification.SetGroup(BString("Caya"));
|
notification.SetGroup(BString("Caya"));
|
||||||
notification.SetTitle(BString("New message"));
|
notification.SetTitle(BString("New message"));
|
||||||
notification.SetIcon(fAvatar->Bitmap());
|
notification.SetIcon(fAvatar->Bitmap());
|
||||||
notification.SetContent(notify_message);
|
notification.SetContent(notify_message);
|
||||||
|
notification.SetMessageID(fContactLinker->GetName());
|
||||||
notification.Send();
|
notification.Send();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -238,6 +250,7 @@ void
|
||||||
ChatWindow::WindowActivated(bool active)
|
ChatWindow::WindowActivated(bool active)
|
||||||
{
|
{
|
||||||
SetTitle(fContactLinker->GetName());
|
SetTitle(fContactLinker->GetName());
|
||||||
|
fMessageCount=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
#include <TextView.h>
|
#include <TextView.h>
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
|
#include <Notification.h>
|
||||||
#include "Observer.h"
|
#include "Observer.h"
|
||||||
|
|
||||||
#include "CayaConstants.h"
|
#include "CayaConstants.h"
|
||||||
|
@ -43,6 +44,7 @@ private:
|
||||||
BStringView* fStatus;
|
BStringView* fStatus;
|
||||||
BTextView* fPersonalMessage;
|
BTextView* fPersonalMessage;
|
||||||
BitmapView* fAvatar;
|
BitmapView* fAvatar;
|
||||||
|
int32 fMessageCount;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Ŝarĝante…
Reference in New Issue