Fix checking of ConversationView's visibility
Since ConversationViews were manually removed/added previously, now that a BCardLayout is used, the visibility-detection/some actions change (e.g., using BView::Show instead of BView::AttachedToWindow).
This commit is contained in:
parent
6f01818e8a
commit
ce4d3c2a26
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2021, Jaidyn Levesque <jadedctrl@teknik.io>
|
* Copyright 2021-2022, Jaidyn Levesque <jadedctrl@teknik.io>
|
||||||
* All rights reserved. Distributed under the terms of the MIT license.
|
* All rights reserved. Distributed under the terms of the MIT license.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -146,10 +146,10 @@ Conversation::ImMessage(BMessage* msg)
|
||||||
|
|
||||||
// Misc. features Caya contributors planned on adding
|
// Misc. features Caya contributors planned on adding
|
||||||
BWindow* mainWin = ((TheApp*)be_app)->GetMainWindow();
|
BWindow* mainWin = ((TheApp*)be_app)->GetMainWindow();
|
||||||
if (win == NULL && AppPreferences::Get()->MarkUnreadWindow == true)
|
if (winFocus == false && AppPreferences::Get()->MarkUnreadWindow == true)
|
||||||
mainWin->SetTitle(BString(mainWin->Title()).Prepend("[!]"));
|
mainWin->SetTitle(BString(mainWin->Title()).Prepend("[!]"));
|
||||||
|
|
||||||
if (win == NULL && AppPreferences::Get()->MoveToCurrentWorkspace)
|
if (winFocus == false && AppPreferences::Get()->MoveToCurrentWorkspace)
|
||||||
mainWin->SetWorkspaces(B_CURRENT_WORKSPACE);
|
mainWin->SetWorkspaces(B_CURRENT_WORKSPACE);
|
||||||
|
|
||||||
if (win == NULL && AppPreferences::Get()->RaiseOnMessageReceived)
|
if (win == NULL && AppPreferences::Get()->RaiseOnMessageReceived)
|
||||||
|
@ -157,9 +157,9 @@ Conversation::ImMessage(BMessage* msg)
|
||||||
|
|
||||||
|
|
||||||
// If unattached, highlight the ConversationItem
|
// If unattached, highlight the ConversationItem
|
||||||
if (win == NULL && mentioned == true)
|
if ((win == NULL || GetView()->IsHidden() == true) && mentioned == true)
|
||||||
NotifyInteger(INT_NEW_MENTION, fNotifyMentionCount);
|
NotifyInteger(INT_NEW_MENTION, fNotifyMentionCount);
|
||||||
else if (win == NULL)
|
else if (win == NULL || GetView()->IsHidden())
|
||||||
NotifyInteger(INT_NEW_MESSAGE, fNotifyMessageCount);
|
NotifyInteger(INT_NEW_MESSAGE, fNotifyMessageCount);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -319,7 +319,7 @@ Conversation::ObserveString(int32 what, BString str)
|
||||||
void
|
void
|
||||||
Conversation::ObserveInteger(int32 what, int32 value)
|
Conversation::ObserveInteger(int32 what, int32 value)
|
||||||
{
|
{
|
||||||
if (what == INT_WINDOW_FOCUSED) {
|
if (what == INT_CONV_VIEW_SELECTED) {
|
||||||
fNotifyMessageCount = 0;
|
fNotifyMessageCount = 0;
|
||||||
fNotifyMentionCount = 0;
|
fNotifyMentionCount = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ enum {
|
||||||
INT_NEW_MESSAGE,
|
INT_NEW_MESSAGE,
|
||||||
INT_NEW_MENTION,
|
INT_NEW_MENTION,
|
||||||
|
|
||||||
INT_WINDOW_FOCUSED,
|
INT_CONV_VIEW_SELECTED,
|
||||||
INT_ACCOUNTS_UPDATED
|
INT_ACCOUNTS_UPDATED
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ ConversationItem::ObserveInteger(int32 what, int32 num)
|
||||||
case INT_NEW_MENTION:
|
case INT_NEW_MENTION:
|
||||||
fStatus |= kMentioned;
|
fStatus |= kMentioned;
|
||||||
break;
|
break;
|
||||||
case INT_WINDOW_FOCUSED:
|
case INT_CONV_VIEW_SELECTED:
|
||||||
fStatus = 0;
|
fStatus = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2009-2011, Andrea Anzani. All rights reserved.
|
* Copyright 2009-2011, Andrea Anzani. All rights reserved.
|
||||||
* Copyright 2021, Jaidyn Levesque. All rights reserved.
|
* Copyright 2021-2022, Jaidyn Levesque. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
|
@ -67,7 +67,15 @@ ConversationView::AttachedToWindow()
|
||||||
if (fSubjectTextView->Text() != fConversation->GetSubject())
|
if (fSubjectTextView->Text() != fConversation->GetSubject())
|
||||||
fSubjectTextView->SetText(fConversation->GetSubject());
|
fSubjectTextView->SetText(fConversation->GetSubject());
|
||||||
}
|
}
|
||||||
NotifyInteger(INT_WINDOW_FOCUSED, 0);
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ConversationView::Show()
|
||||||
|
{
|
||||||
|
BView::Show();
|
||||||
|
|
||||||
|
NotifyInteger(INT_CONV_VIEW_SELECTED, 0);
|
||||||
fSendView->MakeFocus(true);
|
fSendView->MakeFocus(true);
|
||||||
fSendView->Invalidate();
|
fSendView->Invalidate();
|
||||||
}
|
}
|
||||||
|
@ -124,7 +132,7 @@ ConversationView::ImMessage(BMessage* msg)
|
||||||
case IM_MESSAGE_RECEIVED:
|
case IM_MESSAGE_RECEIVED:
|
||||||
{
|
{
|
||||||
_AppendOrEnqueueMessage(msg);
|
_AppendOrEnqueueMessage(msg);
|
||||||
fReceiveView->ScrollToBottom();
|
_ScrollToBottom();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IM_MESSAGE_SENT:
|
case IM_MESSAGE_SENT:
|
||||||
|
@ -132,7 +140,7 @@ ConversationView::ImMessage(BMessage* msg)
|
||||||
{
|
{
|
||||||
_AppendOrEnqueueMessage(msg);
|
_AppendOrEnqueueMessage(msg);
|
||||||
if (im_what == IM_MESSAGE_SENT)
|
if (im_what == IM_MESSAGE_SENT)
|
||||||
fReceiveView->ScrollToBottom();
|
_ScrollToBottom();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IM_ROOM_PARTICIPANT_JOINED:
|
case IM_ROOM_PARTICIPANT_JOINED:
|
||||||
|
@ -392,7 +400,7 @@ ConversationView::_AppendOrEnqueueMessage(BMessage* msg)
|
||||||
if (msg->HasInt64("when") == false)
|
if (msg->HasInt64("when") == false)
|
||||||
msg->AddInt64("when", (int64)time(NULL));
|
msg->AddInt64("when", (int64)time(NULL));
|
||||||
|
|
||||||
// If not attached to the chat window, then re-handle this message
|
// If not attached to a chat window, then re-handle this message
|
||||||
// later [AttachedToWindow()], since you can't edit an unattached
|
// later [AttachedToWindow()], since you can't edit an unattached
|
||||||
// RenderView.
|
// RenderView.
|
||||||
if (Window() == NULL) {
|
if (Window() == NULL) {
|
||||||
|
@ -503,6 +511,14 @@ ConversationView::_AppendMessage(BMessage* msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ConversationView::_ScrollToBottom()
|
||||||
|
{
|
||||||
|
if (IsHidden() == false)
|
||||||
|
fReceiveView->ScrollToBottom();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ConversationView::_EnableStartingFaces(BMessage* msg, int32 index, uint16* face,
|
ConversationView::_EnableStartingFaces(BMessage* msg, int32 index, uint16* face,
|
||||||
UInt16IntMap* indices, int32* next)
|
UInt16IntMap* indices, int32* next)
|
||||||
|
@ -607,7 +623,7 @@ ConversationView::_UserMessage(const char* format, const char* bodyFormat,
|
||||||
BMessage newMsg;
|
BMessage newMsg;
|
||||||
newMsg.AddString("body", newBody);
|
newMsg.AddString("body", newBody);
|
||||||
_AppendOrEnqueueMessage(&newMsg);
|
_AppendOrEnqueueMessage(&newMsg);
|
||||||
fReceiveView->ScrollToBottom();
|
_ScrollToBottom();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2009-2011, Andrea Anzani. All rights reserved.
|
* Copyright 2009-2011, Andrea Anzani. All rights reserved.
|
||||||
* Copyright 2021, Jaidyn Levesque. All rights reserved.
|
* Copyright 2021-2022, Jaidyn Levesque. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _CHAT_VIEW_H
|
#ifndef _CHAT_VIEW_H
|
||||||
|
@ -34,6 +34,7 @@ public:
|
||||||
ConversationView(Conversation* chat = NULL);
|
ConversationView(Conversation* chat = NULL);
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
|
void Show();
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
void ImMessage(BMessage* msg);
|
void ImMessage(BMessage* msg);
|
||||||
|
@ -58,6 +59,8 @@ private:
|
||||||
bool _AppendOrEnqueueMessage(BMessage* msg);
|
bool _AppendOrEnqueueMessage(BMessage* msg);
|
||||||
void _AppendMessage(BMessage* msg);
|
void _AppendMessage(BMessage* msg);
|
||||||
|
|
||||||
|
void _ScrollToBottom();
|
||||||
|
|
||||||
// Helper functions for _AppendFormattedMessage()
|
// Helper functions for _AppendFormattedMessage()
|
||||||
void _EnableStartingFaces(BMessage* msg, int32 index,
|
void _EnableStartingFaces(BMessage* msg, int32 index,
|
||||||
uint16* face, UInt16IntMap* indices, int32* next);
|
uint16* face, UInt16IntMap* indices, int32* next);
|
||||||
|
|
Ŝarĝante…
Reference in New Issue