Merge pull request #1 from ksiazkowicz/master

Notification code update
This commit is contained in:
Barrett17 2013-07-30 15:59:57 -07:00
commit f8179b8bad
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;
};