Added a simple WIP ContactInfoWindow that will be improved while we add new informations available in the ContactLiker, actually it's useful to get the contact id/email.

This commit is contained in:
barrett 2012-03-11 15:11:29 +00:00
parent b80c9b2b11
commit 730e9d3d49
7 changed files with 181 additions and 6 deletions

View File

@ -52,6 +52,7 @@ Application Caya :
NicknameTextControl.cpp NicknameTextControl.cpp
RosterItem.cpp RosterItem.cpp
RosterListView.cpp RosterListView.cpp
ContactInfoWindow.cpp
StatusMenuItem.cpp StatusMenuItem.cpp
StatusView.cpp StatusView.cpp
CayaRenderView.cpp CayaRenderView.cpp

View File

@ -289,6 +289,7 @@ MainWindow::ImMessage(BMessage* msg)
// Sort list view again // Sort list view again
fListView->Sort(); fListView->Sort();
// Check if the user want the notification
if (!CayaPreferences::Item()->NotifyContactStatus) if (!CayaPreferences::Item()->NotifyContactStatus)
break; break;

View File

@ -305,7 +305,8 @@ Server::ImMessage(BMessage* msg)
linker->SetNotifyAvatarBitmap(NULL); linker->SetNotifyAvatarBitmap(NULL);
break; break;
} }
case IM_SEND_MESSAGE: { case IM_SEND_MESSAGE:
{
// Route this message through the appropriate ProtocolLooper // Route this message through the appropriate ProtocolLooper
ContactLinker* linker = _EnsureContactLinker(msg); ContactLinker* linker = _EnsureContactLinker(msg);
if (linker->GetProtocolLooper()) if (linker->GetProtocolLooper())

View File

@ -0,0 +1,104 @@
/*
* Copyright 2012, Casalinuovo Dario. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Casalinuovo Dario
*/
#include <Alert.h>
#include <Application.h>
#include <Box.h>
#include <GridLayout.h>
#include <GridLayoutBuilder.h>
#include <GroupLayout.h>
#include <GroupLayoutBuilder.h>
#include <Layout.h>
#include <Message.h>
#include <SpaceLayoutItem.h>
#include <String.h>
#include "BitmapView.h"
#include "CayaMessages.h"
#include "CayaProtocolMessages.h"
#include "ContactLinker.h"
#include "CayaConstants.h"
#include "CayaRenderView.h"
#include "NotifyMessage.h"
#include "ContactInfoWindow.h"
ContactInfoWindow::ContactInfoWindow(ContactLinker* linker)
:
BWindow(BRect(200, 200, 500, 400),
"Contact Informations", B_FLOATING_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
fContactLinker(linker)
{
fPersonalMessage = new BTextView("personalMessage", B_WILL_DRAW);
fPersonalMessage->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
fPersonalMessage->SetText(fContactLinker->GetNotifyPersonalStatus());
fPersonalMessage->SetExplicitMaxSize(BSize(200, 200));
fPersonalMessage->MakeEditable(false);
fPersonalMessage->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
BString status(fContactLinker->GetName());
switch (fContactLinker->GetNotifyStatus()) {
case CAYA_ONLINE:
status << " is available";
break;
case CAYA_EXTENDED_AWAY:
case CAYA_AWAY:
status << " is away";
break;
case CAYA_DO_NOT_DISTURB:
status << " is busy, please do not disturb!";
break;
case CAYA_OFFLINE:
status << " is offline";
break;
default:
break;
}
status << "\n\n ID : ";
status << fContactLinker->GetId();
fStatus = new BTextView("status", B_WILL_DRAW);
fStatus->SetText(status);
fStatus->MakeEditable(false);
fStatus->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
SetLayout(new BGroupLayout(B_HORIZONTAL));
fAvatar = new BitmapView("ContactIcon");
fAvatar->SetExplicitMaxSize(BSize(70, 70));
fAvatar->SetExplicitMinSize(BSize(50, 50));
fAvatar->SetExplicitPreferredSize(BSize(50, 50));
fAvatar->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT, B_ALIGN_MIDDLE));
fAvatar->SetBitmap(fContactLinker->AvatarBitmap());
AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
.AddGroup(B_HORIZONTAL)
.Add(fStatus)
.Add(fAvatar)
.End()
.AddGroup(B_HORIZONTAL)
.Add(fPersonalMessage)
.End()
.SetInsets(5, 5, 5, 5)
);
MoveTo(BAlert::AlertPosition(Bounds().Width(), Bounds().Height() / 2));
}
void
ContactInfoWindow::MessageReceived(BMessage* message)
{
switch (message->what) {
default:
BWindow::MessageReceived(message);
break;
}
}

View File

@ -0,0 +1,34 @@
/*
* Copyright 2012, Casalinuovo Dario. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Casalinuovo Dario
*/
#ifndef _CONTACT_INFO_WINDOW_H
#define _CONTACT_INFO_WINDOW_H
#include <Window.h>
#include <TextView.h>
#include <StringView.h>
#include "Observer.h"
#include "CayaConstants.h"
class BitmapView;
class ContactLinker;
class ContactInfoWindow: public BWindow, public Observer {
public:
ContactInfoWindow(ContactLinker* linker);
virtual void MessageReceived(BMessage* message);
private:
BTextView* fStatus;
ContactLinker* fContactLinker;
BTextView* fPersonalMessage;
BitmapView* fAvatar;
};
#endif

View File

@ -14,6 +14,7 @@
#include <PopUpMenu.h> #include <PopUpMenu.h>
#include <SeparatorItem.h> #include <SeparatorItem.h>
#include "ContactInfoWindow.h"
#include "ContactLinker.h" #include "ContactLinker.h"
#include "RosterItem.h" #include "RosterItem.h"
#include "RosterListView.h" #include "RosterListView.h"
@ -54,8 +55,8 @@ RosterListView::RosterListView(const char* name)
fPrevItem(NULL) fPrevItem(NULL)
{ {
// Context menu // Context menu
fPopUp = new BPopUpMenu("contextMenu", false); fPopUp = new BPopUpMenu("contextMenu", false, false);
fPopUp->AddItem(new BMenuItem("Get Information", new BMessage(kGetInfo))); fPopUp->AddItem(new BMenuItem("Get Informations", new BMessage(kGetInfo)));
fPopUp->AddItem(new BMenuItem("Show Logs", new BMessage(kShowLogs))); fPopUp->AddItem(new BMenuItem("Show Logs", new BMessage(kShowLogs)));
fPopUp->AddItem(new BSeparatorItem()); fPopUp->AddItem(new BSeparatorItem());
fPopUp->AddItem(new BMenuItem("Add to Address Book", fPopUp->AddItem(new BMenuItem("Add to Address Book",
@ -67,12 +68,32 @@ RosterListView::RosterListView(const char* name)
// #pragama mark - // #pragama mark -
void
RosterListView::AttachedToWindow()
{
fPopUp->SetTargetForItems(this);
SetTarget(this);
}
void void
RosterListView::MessageReceived(BMessage* msg) RosterListView::MessageReceived(BMessage* msg)
{ {
switch (msg->what) { switch (msg->what) {
case kGetInfo: case kGetInfo:
{
BPoint where;
uint32 buttons;
GetMouse(&where, &buttons);
BListItem* item = ItemAt(IndexOf(where));
RosterItem* ritem = reinterpret_cast<RosterItem*>(item);
if (ritem == NULL)
return;
_InfoWindow(ritem->GetContactLinker());
break; break;
}
default: default:
BListView::MessageReceived(msg); BListView::MessageReceived(msg);
} }
@ -131,12 +152,13 @@ RosterListView::MouseDown(BPoint where)
Select(index); Select(index);
// Show context menu if right button is clicked // Show context menu if right button is clicked
(void)fPopUp->Go(ConvertToScreen(where), false, true, false); (void)fPopUp->Go(ConvertToScreen(where), true, true, false);
} }
} else } else {
// Call original MouseDown() // Call original MouseDown()
BListView::MouseDown(where); BListView::MouseDown(where);
} }
}
void void
@ -169,3 +191,11 @@ RosterListView::Sort()
{ {
SortItems(compare_by_name); SortItems(compare_by_name);
} }
void
RosterListView::_InfoWindow(ContactLinker* linker)
{
ContactInfoWindow* win = new ContactInfoWindow(linker);
win->Show();
}

View File

@ -9,6 +9,7 @@
class BPopUpMenu; class BPopUpMenu;
class ContactLinker;
class RosterItem; class RosterItem;
class RosterListView : public BListView class RosterListView : public BListView
@ -20,10 +21,13 @@ public:
virtual void MouseMoved(BPoint where, uint32 code, const BMessage*); virtual void MouseMoved(BPoint where, uint32 code, const BMessage*);
virtual void MouseDown(BPoint where); virtual void MouseDown(BPoint where);
virtual void Draw(BRect updateRect); virtual void Draw(BRect updateRect);
virtual void AttachedToWindow();
void Sort(); void Sort();
private: private:
void _InfoWindow(ContactLinker* linker);
BPopUpMenu* fPopUp; BPopUpMenu* fPopUp;
RosterItem* fPrevItem; RosterItem* fPrevItem;
}; };