Default chat icon, use other user's avatar
For one-on-one chats without a custom icon, the other user's avatar will be used as the chat's icon. A default chat icon was also added (haiku/data/artwork/icons/WebsiteComments).
This commit is contained in:
parent
6c1c5ccf18
commit
7df377d996
|
@ -24,7 +24,8 @@ enum {
|
|||
kExitMenuReplicant = 1401,
|
||||
kReplicantMessageReceived = 1402,
|
||||
|
||||
kPersonIcon = 1500
|
||||
kPersonIcon = 1500,
|
||||
kChatIcon = 1501
|
||||
};
|
||||
|
||||
#endif // _APP_RESOURCES_H
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "ConversationItem.h"
|
||||
#include "ConversationView.h"
|
||||
#include "Flags.h"
|
||||
#include "ImageCache.h"
|
||||
#include "MainWindow.h"
|
||||
#include "NotifyMessage.h"
|
||||
#include "ProtocolLooper.h"
|
||||
|
@ -36,12 +37,13 @@ Conversation::Conversation(BString id, BMessenger msgn)
|
|||
fMessenger(msgn),
|
||||
fChatView(NULL),
|
||||
fLooper(NULL),
|
||||
fIcon(NULL),
|
||||
fIcon(ImageCache::Get()->GetImage("kChatIcon")),
|
||||
fDateFormatter(),
|
||||
fRoomFlags(0),
|
||||
fDisallowedFlags(0),
|
||||
fNotifyMessageCount(0),
|
||||
fNotifyMentionCount(0)
|
||||
fNotifyMentionCount(0),
|
||||
fUserIcon(false)
|
||||
{
|
||||
fConversationItem = new ConversationItem(fName.String(), this);
|
||||
RegisterObserver(fConversationItem);
|
||||
|
@ -275,6 +277,18 @@ Conversation::SetNotifySubject(const char* subject)
|
|||
}
|
||||
|
||||
|
||||
bool
|
||||
Conversation::SetIconBitmap(BBitmap* icon)
|
||||
{
|
||||
if (icon != NULL) {
|
||||
fIcon = icon;
|
||||
GetView()->UpdateIcon();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
BMessenger
|
||||
Conversation::Messenger() const
|
||||
{
|
||||
|
@ -564,6 +578,8 @@ Conversation::_EnsureUser(BMessage* msg)
|
|||
fUsers.AddItem(id, serverUser);
|
||||
user = serverUser;
|
||||
GetView()->UpdateUserList(fUsers);
|
||||
|
||||
_CloneUserIcon(user);
|
||||
}
|
||||
// Not anywhere; create user
|
||||
else if (user == NULL) {
|
||||
|
@ -573,6 +589,8 @@ Conversation::_EnsureUser(BMessage* msg)
|
|||
fLooper->AddUser(user);
|
||||
fUsers.AddItem(id, user);
|
||||
GetView()->UpdateUserList(fUsers);
|
||||
|
||||
_CloneUserIcon(user);
|
||||
}
|
||||
|
||||
if (name.IsEmpty() == false) {
|
||||
|
@ -583,6 +601,23 @@ Conversation::_EnsureUser(BMessage* msg)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
Conversation::_CloneUserIcon(User* user)
|
||||
{
|
||||
// If it's a one-on-one chat without custom icon, steal a user's
|
||||
if ((fUsers.CountItems() <= 2 && user->GetId() != GetOwnContact()->GetId())
|
||||
&& (fIcon == ImageCache::Get()->GetImage("kChatIcon")
|
||||
|| fIcon == NULL))
|
||||
fUserIcon = SetIconBitmap(user->AvatarBitmap());
|
||||
|
||||
// If it's no longer one-on-one, revert
|
||||
if (fUsers.CountItems() > 2 && fUserIcon == true) {
|
||||
SetIconBitmap(ImageCache::Get()->GetImage("kChatIcon"));
|
||||
fUserIcon = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Conversation::_SortConversationList()
|
||||
{
|
||||
|
|
|
@ -44,6 +44,8 @@ public:
|
|||
void SetNotifyName(const char* name);
|
||||
void SetNotifySubject(const char* subject);
|
||||
|
||||
bool SetIconBitmap(BBitmap* icon);
|
||||
|
||||
BMessenger Messenger() const;
|
||||
void SetMessenger(BMessenger messenger);
|
||||
|
||||
|
@ -83,6 +85,7 @@ private:
|
|||
|
||||
void _EnsureCachePath();
|
||||
User* _EnsureUser(BMessage* msg);
|
||||
void _CloneUserIcon(User* user);
|
||||
|
||||
void _SortConversationList();
|
||||
|
||||
|
@ -100,6 +103,7 @@ private:
|
|||
BString fSubject;
|
||||
|
||||
BBitmap* fIcon;
|
||||
bool fUserIcon;
|
||||
|
||||
BPath fCachePath;
|
||||
BDateTimeFormat fDateFormatter;
|
||||
|
|
|
@ -27,6 +27,7 @@ ImageCache* ImageCache::fInstance = NULL;
|
|||
ImageCache::ImageCache()
|
||||
{
|
||||
_LoadResource(kPersonIcon, "kPersonIcon");
|
||||
_LoadResource(kChatIcon, "kChatIcon");
|
||||
|
||||
_LoadResource(kAwayReplicant, "kAwayReplicant");
|
||||
_LoadResource(kBusyReplicant, "kBusyReplicant");
|
||||
|
|
|
@ -99,6 +99,7 @@ RDEFS = Cardie.rdef \
|
|||
data/icons/replicant/MessageReceived.rdef \
|
||||
data/icons/replicant/Offline.rdef \
|
||||
data/icons/replicant/Online.rdef \
|
||||
data/icons/misc/Chat.rdef \
|
||||
data/icons/misc/Person.rdef \
|
||||
data/icons/misc/Search.rdef \
|
||||
data/icons/misc/Tool.rdef
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,9 @@
|
|||
#include "application/AppResources.h"
|
||||
|
||||
resource(kChatIcon) #'VICN' array {
|
||||
$"6E63696604052803010100020106023E80000000000000003D800048C0004940"
|
||||
$"0000F8E278FFFAECA9020106023E80000000000000003D800048000049000000"
|
||||
$"FFFFFFFFF3E6AA010606BF0F3C30C36F30B8E030244024BC3A24C3453C50B8E0"
|
||||
$"503C584858C160C5C14458C512C4DF544054C28454BC3A040A00010030282401"
|
||||
$"158802040A0201002028240A01010030201401158802040A030100202014"
|
||||
};
|
Ŝarĝante…
Reference in New Issue