The personal message of a contact is now show in the chat window, added also the needed code in Server.cpp to update the windows. Solved a bug with the contact avatar that was causing Caya to crash.
This commit is contained in:
parent
c22310f510
commit
3f2f2783ff
|
@ -51,12 +51,14 @@ ChatWindow::ChatWindow(ContactLinker* cl)
|
||||||
AddCommonFilter(new EditingFilter(fSendView));
|
AddCommonFilter(new EditingFilter(fSendView));
|
||||||
fSendView->MakeFocus(true);
|
fSendView->MakeFocus(true);
|
||||||
|
|
||||||
/*
|
|
||||||
BStringView* personalMessage = new BStringView("personalMessage", "");
|
fPersonalMessage = new BTextView("personalMessage", B_WILL_DRAW);
|
||||||
personalMessage->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
|
fPersonalMessage->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
|
||||||
personalMessage->SetText(fContactLinker->GetNotifyPersonalStatus());
|
fPersonalMessage->SetText(fContactLinker->GetNotifyPersonalStatus());
|
||||||
personalMessage->SetExplicitMaxSize(BSize(200, 200));
|
fPersonalMessage->SetExplicitMaxSize(BSize(400, 200));
|
||||||
*/
|
fPersonalMessage->MakeEditable(false);
|
||||||
|
fPersonalMessage->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
|
|
||||||
fStatus = new BStringView("status", "");
|
fStatus = new BStringView("status", "");
|
||||||
fStatus->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
|
fStatus->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
|
||||||
|
@ -65,13 +67,16 @@ ChatWindow::ChatWindow(ContactLinker* cl)
|
||||||
|
|
||||||
fAvatar = new BitmapView("ContactIcon");
|
fAvatar = new BitmapView("ContactIcon");
|
||||||
fAvatar->SetExplicitMaxSize(BSize(50, 50));
|
fAvatar->SetExplicitMaxSize(BSize(50, 50));
|
||||||
|
fAvatar->SetExplicitMinSize(BSize(50, 50));
|
||||||
fAvatar->SetExplicitPreferredSize(BSize(50, 50));
|
fAvatar->SetExplicitPreferredSize(BSize(50, 50));
|
||||||
fAvatar->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT, B_ALIGN_MIDDLE));
|
fAvatar->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT, B_ALIGN_MIDDLE));
|
||||||
fAvatar->SetBitmap(fContactLinker->AvatarBitmap());
|
fAvatar->SetBitmap(fContactLinker->AvatarBitmap());
|
||||||
|
|
||||||
AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
|
AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
|
||||||
// .Add(personalMessage)
|
.AddGroup(B_HORIZONTAL)
|
||||||
.Add(fAvatar, 1)
|
.Add(fPersonalMessage)
|
||||||
|
.Add(fAvatar)
|
||||||
|
.End()
|
||||||
.Add(scrollViewReceive, 2)
|
.Add(scrollViewReceive, 2)
|
||||||
.Add(scrollViewSend)
|
.Add(scrollViewSend)
|
||||||
.Add(fStatus, 3)
|
.Add(fStatus, 3)
|
||||||
|
@ -97,7 +102,20 @@ ChatWindow::QuitRequested()
|
||||||
void
|
void
|
||||||
ChatWindow::UpdateAvatar()
|
ChatWindow::UpdateAvatar()
|
||||||
{
|
{
|
||||||
fAvatar->SetBitmap(fContactLinker->AvatarBitmap());
|
if (fContactLinker->AvatarBitmap() != NULL)
|
||||||
|
fAvatar->SetBitmap(fContactLinker->AvatarBitmap());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ChatWindow::UpdatePersonalMessage()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (fContactLinker->GetNotifyPersonalStatus() != NULL) {
|
||||||
|
LockLooper();
|
||||||
|
fPersonalMessage->SetText(fContactLinker->GetNotifyPersonalStatus());
|
||||||
|
UnlockLooper();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ public:
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
|
|
||||||
void UpdateAvatar();
|
void UpdateAvatar();
|
||||||
|
void UpdatePersonalMessage();
|
||||||
void ImMessage(BMessage* msg);
|
void ImMessage(BMessage* msg);
|
||||||
|
|
||||||
void ObserveString(int32 what, BString str);
|
void ObserveString(int32 what, BString str);
|
||||||
|
@ -36,6 +37,7 @@ private:
|
||||||
ContactLinker* fContactLinker;
|
ContactLinker* fContactLinker;
|
||||||
CayaRenderView* fReceiveView;
|
CayaRenderView* fReceiveView;
|
||||||
BStringView* fStatus;
|
BStringView* fStatus;
|
||||||
|
BTextView* fPersonalMessage;
|
||||||
BitmapView* fAvatar;
|
BitmapView* fAvatar;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -247,8 +247,11 @@ Server::ImMessage(BMessage* msg)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
linker->SetNotifyStatus((CayaStatus)status);
|
linker->SetNotifyStatus((CayaStatus)status);
|
||||||
linker->SetNotifyPersonalStatus(msg->FindString("message"));
|
BString statusMsg;
|
||||||
|
if (msg->FindString("message", &statusMsg) == B_OK) {
|
||||||
|
linker->SetNotifyPersonalStatus(statusMsg);
|
||||||
|
linker->GetChatWindow()->UpdatePersonalMessage();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IM_CONTACT_INFO:
|
case IM_CONTACT_INFO:
|
||||||
|
@ -264,9 +267,10 @@ Server::ImMessage(BMessage* msg)
|
||||||
linker->SetNotifyName(name);
|
linker->SetNotifyName(name);
|
||||||
|
|
||||||
BString status;
|
BString status;
|
||||||
if (msg->FindString("message", &status) == B_OK)
|
if (msg->FindString("message", &status) == B_OK) {
|
||||||
linker->SetNotifyPersonalStatus(status);
|
linker->SetNotifyPersonalStatus(status);
|
||||||
|
linker->GetChatWindow()->UpdatePersonalMessage();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IM_EXTENDED_CONTACT_INFO:
|
case IM_EXTENDED_CONTACT_INFO:
|
||||||
|
|
Ŝarĝante…
Reference in New Issue