CHUI-315 (Nearby chat messages do not appear in conversation floater): cancelled inheritance LLNearbyChat from LLSingleton; set mSingleInstance flag for it.

master
AlexanderP ProductEngine 2012-08-31 16:52:50 +03:00
parent e271c47994
commit ae2e611dfb
17 changed files with 76 additions and 49 deletions

View File

@ -627,6 +627,13 @@ void LLFloater::setVisible( BOOL visible )
storeVisibilityControl();
}
void LLFloater::setIsSingleInstance(BOOL is_single_instance)
{
mSingleInstance = is_single_instance;
}
// virtual
void LLFloater::handleVisibilityChange ( BOOL new_visibility )
{

View File

@ -217,6 +217,7 @@ public:
/*virtual*/ void setFocus( BOOL b );
/*virtual*/ void setIsChrome(BOOL is_chrome);
/*virtual*/ void setRect(const LLRect &rect);
void setIsSingleInstance(BOOL is_single_instance);
void initFloater(const Params& p);

View File

@ -1911,7 +1911,8 @@ void LLAgent::startTyping()
{
sendAnimationRequest(ANIM_AGENT_TYPE, ANIM_REQUEST_START);
}
(LLNearbyChat::instance()).sendChatFromViewer("", CHAT_TYPE_START, FALSE);
(LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat"))->
sendChatFromViewer("", CHAT_TYPE_START, FALSE);
}
//-----------------------------------------------------------------------------
@ -1923,7 +1924,8 @@ void LLAgent::stopTyping()
{
clearRenderState(AGENT_STATE_TYPING);
sendAnimationRequest(ANIM_AGENT_TYPE, ANIM_REQUEST_STOP);
(LLNearbyChat::instance()).sendChatFromViewer("", CHAT_TYPE_STOP, FALSE);
(LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat"))->
sendChatFromViewer("", CHAT_TYPE_STOP, FALSE);
}
}

View File

@ -323,12 +323,12 @@ BOOL LLNearbyChatToastPanel::handleMouseUp (S32 x, S32 y, MASK mask)
return TRUE;
else
{
LLNearbyChat::instance().showHistory();
(LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat"))->showHistory();
return FALSE;
}
}
LLNearbyChat::instance().showHistory();
(LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat"))->showHistory();
return LLPanel::handleMouseUp(x,y,mask);
}

View File

@ -293,6 +293,7 @@ void LLFloaterTranslationSettings::onBtnOK()
gSavedSettings.setString("TranslationService", getSelectedService());
gSavedSettings.setString("BingTranslateAPIKey", getEnteredBingKey());
gSavedSettings.setString("GoogleTranslateAPIKey", getEnteredGoogleKey());
LLNearbyChat::instance().showTranslationCheckbox(LLTranslate::isTranslationConfigured());
(LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat"))->
showTranslationCheckbox(LLTranslate::isTranslationConfigured());
closeFloater(false);
}

View File

@ -35,6 +35,7 @@
// library
#include "llaudioengine.h"
#include "lldatapacker.h"
#include "llfloaterreg.h"
#include "llinventory.h"
#include "llkeyframemotion.h"
#include "llmultigesture.h"
@ -997,7 +998,8 @@ void LLGestureMgr::runStep(LLMultiGesture* gesture, LLGestureStep* step)
const BOOL animate = FALSE;
LLNearbyChat::instance().sendChatFromViewer(chat_text, CHAT_TYPE_NORMAL, animate);
(LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat"))->
sendChatFromViewer(chat_text, CHAT_TYPE_NORMAL, animate);
gesture->mCurrentStep++;
break;

View File

@ -144,7 +144,7 @@ BOOL LLIMConversation::postBuild()
updateHeaderAndToolbar();
mSaveRect = isTornOff();
mSaveRect = !getHost();
initRectControl();
if (isChatMultiTab())
@ -267,11 +267,11 @@ void LLIMConversation::hideOrShowTitle()
LLView* floater_contents = getChild<LLView>("contents_view");
LLRect floater_rect = getLocalRect();
S32 top_border_of_contents = floater_rect.mTop - (isTornOff()? floater_header_size : 0);
S32 top_border_of_contents = floater_rect.mTop - (getHost()? 0 : floater_header_size);
LLRect handle_rect (0, floater_rect.mTop, floater_rect.mRight, top_border_of_contents);
LLRect contents_rect (0, top_border_of_contents, floater_rect.mRight, floater_rect.mBottom);
mDragHandle->setShape(handle_rect);
mDragHandle->setVisible(isTornOff());
mDragHandle->setVisible(!getHost());
floater_contents->setShape(contents_rect);
}
@ -289,8 +289,8 @@ void LLIMConversation::hideAllStandardButtons()
void LLIMConversation::updateHeaderAndToolbar()
{
bool is_torn_off = !getHost();
if (!is_torn_off)
bool is_hosted = !!getHost();
if (is_hosted)
{
hideAllStandardButtons();
}
@ -299,7 +299,7 @@ void LLIMConversation::updateHeaderAndToolbar()
// Participant list should be visible only in torn off floaters.
bool is_participant_list_visible =
is_torn_off
!is_hosted
&& gSavedSettings.getBOOL("IMShowControlPanel")
&& !mIsP2PChat;
@ -307,21 +307,21 @@ void LLIMConversation::updateHeaderAndToolbar()
// Display collapse image (<<) if the floater is hosted
// or if it is torn off but has an open control panel.
bool is_expanded = !is_torn_off || is_participant_list_visible;
bool is_expanded = is_hosted || is_participant_list_visible;
mExpandCollapseBtn->setImageOverlay(getString(is_expanded ? "collapse_icon" : "expand_icon"));
// toggle floater's drag handle and title visibility
if (mDragHandle)
{
mDragHandle->setTitleVisible(is_torn_off);
mDragHandle->setTitleVisible(!is_hosted);
}
// The button (>>) should be disabled for torn off P2P conversations.
mExpandCollapseBtn->setEnabled(!is_torn_off || !mIsP2PChat);
mExpandCollapseBtn->setEnabled(is_hosted || !mIsP2PChat);
mTearOffBtn->setImageOverlay(getString(is_torn_off? "return_icon" : "tear_off_icon"));
mTearOffBtn->setImageOverlay(getString(is_hosted? "tear_off_icon" : "return_icon"));
mCloseBtn->setVisible(!is_torn_off && !mIsNearbyChat);
mCloseBtn->setVisible(is_hosted && !mIsNearbyChat);
enableDisableCallBtn();
@ -358,9 +358,10 @@ void LLIMConversation::processChatHistoryStyleUpdate()
}
}
if (LLNearbyChat::instanceExists())
LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat");
if (nearby_chat)
{
LLNearbyChat::instance().reloadMessages();
nearby_chat->reloadMessages();
}
}
@ -427,8 +428,8 @@ void LLIMConversation::onClose(bool app_quitting)
void LLIMConversation::onTearOffClicked()
{
setFollows(isTornOff()? FOLLOWS_ALL : FOLLOWS_NONE);
mSaveRect = isTornOff();
setFollows(getHost()? FOLLOWS_NONE : FOLLOWS_ALL);
mSaveRect = !getHost();
initRectControl();
LLFloater::onClickTearOff(this);
updateHeaderAndToolbar();

View File

@ -2486,9 +2486,11 @@ void LLIMMgr::addSystemMessage(const LLUUID& session_id, const std::string& mess
LLChat chat(message);
chat.mSourceType = CHAT_SOURCE_SYSTEM;
if (LLNearbyChat::instanceExists())
LLNearbyChat* nearby_chat = LLFloaterReg::findTypedInstance<LLNearbyChat>("nearby_chat");
if (nearby_chat)
{
LLNearbyChat::instance().addMessage(chat);
nearby_chat->addMessage(chat);
}
}
else // going to IM session

View File

@ -134,6 +134,7 @@ LLNearbyChat::LLNearbyChat(const LLSD& llsd)
mKey = LLSD();
mSpeakerMgr = LLLocalSpeakerMgr::getInstance();
setName("nearby_chat");
setIsSingleInstance(TRUE);
}
//virtual
@ -780,20 +781,21 @@ void LLNearbyChat::sendChatFromViewer(const LLWString &wtext, EChatType type, BO
// static
void LLNearbyChat::startChat(const char* line)
{
if (LLNearbyChat::instanceExists())
LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat");
if (nearby_chat)
{
(LLNearbyChat::instance()).show();
(LLNearbyChat::instance()).setVisible(TRUE);
(LLNearbyChat::instance()).setFocus(TRUE);
(LLNearbyChat::instance().mInputEditor)->setFocus(TRUE);
nearby_chat->show();
nearby_chat->setVisible(TRUE);
nearby_chat->setFocus(TRUE);
nearby_chat->mInputEditor->setFocus(TRUE);
if (line)
{
std::string line_string(line);
(LLNearbyChat::instance().mInputEditor)->setText(line_string);
nearby_chat->mInputEditor->setText(line_string);
}
(LLNearbyChat::instance().mInputEditor)->endOfDoc();
nearby_chat->mInputEditor->endOfDoc();
}
}
@ -801,9 +803,10 @@ void LLNearbyChat::startChat(const char* line)
// static
void LLNearbyChat::stopChat()
{
if (LLNearbyChat::instanceExists())
LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat");
if (nearby_chat)
{
(LLNearbyChat::instance().mInputEditor)->setFocus(FALSE);
nearby_chat->mInputEditor->setFocus(FALSE);
gAgent.stopTyping();
}
}

View File

@ -35,15 +35,13 @@
#include "lloutputmonitorctrl.h"
#include "llspeakers.h"
#include "llscrollbar.h"
#include "llsingleton.h"
#include "llviewerchat.h"
#include "llpanel.h"
class LLResizeBar;
class LLNearbyChat
: public LLIMConversation,
public LLSingleton<LLNearbyChat>
: public LLIMConversation
{
public:
// constructor for inline chat-bars (e.g. hosted in chat history window)

View File

@ -537,7 +537,8 @@ void LLNearbyChatHandler::processChat(const LLChat& chat_msg,
}
}
LLNearbyChat::instance().addMessage(chat_msg, true, args);
LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat");
nearby_chat->addMessage(chat_msg, true, args);
if(chat_msg.mSourceType == CHAT_SOURCE_AGENT
&& chat_msg.mFromID.notNull()
@ -553,7 +554,7 @@ void LLNearbyChatHandler::processChat(const LLChat& chat_msg,
// Send event on to LLEventStream
sChatWatcher->post(chat);
if( LLNearbyChat::instance().isInVisibleChain()
if( nearby_chat->isInVisibleChain()
|| ( chat_msg.mSourceType == CHAT_SOURCE_AGENT
&& gSavedSettings.getBOOL("UseChatBubbles") )
|| mChannel.isDead()

View File

@ -181,13 +181,14 @@ void LLHandlerUtil::logGroupNoticeToIMGroup(
// static
void LLHandlerUtil::logToNearbyChat(const LLNotificationPtr& notification, EChatSourceType type)
{
if (LLNearbyChat::instanceExists())
LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat");
if (nearby_chat)
{
LLChat chat_msg(notification->getMessage());
chat_msg.mSourceType = type;
chat_msg.mFromName = SYSTEM_FROM;
chat_msg.mFromID = LLUUID::null;
LLNearbyChat::instance().addMessage(chat_msg);
nearby_chat->addMessage(chat_msg);
}
}

View File

@ -85,7 +85,8 @@ bool LLTipHandler::processNotification(const LLNotificationPtr& notification)
LLHandlerUtil::logToNearbyChat(notification, CHAT_SOURCE_SYSTEM);
// don't show toast if Nearby Chat is opened
if (LLNearbyChat::instance().isChatVisible())
LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat");
if (nearby_chat && nearby_chat->isChatVisible())
{
return false;
}

View File

@ -33,6 +33,7 @@
#include "llviewerinventory.h"
#include "sound_ids.h" // for testing
#include "llfloaterreg.h"
#include "llkeyboard.h" // for key shortcuts for testing
#include "llinventorymodel.h"
#include "llvoavatar.h"
@ -130,7 +131,8 @@ void LLViewerGesture::doTrigger( BOOL send_chat )
{
// Don't play nodding animation, since that might not blend
// with the gesture animation.
LLNearbyChat::instance().sendChatFromViewer(mOutputString, CHAT_TYPE_NORMAL, FALSE);
(LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat"))->
sendChatFromViewer(mOutputString, CHAT_TYPE_NORMAL, FALSE);
}
}

View File

@ -27,6 +27,7 @@
#include "llviewerprecompiledheaders.h"
#include "llappviewer.h"
#include "llfloaterreg.h"
#include "llviewerkeyboard.h"
#include "llmath.h"
#include "llagent.h"
@ -543,7 +544,7 @@ void start_gesture( EKeystate s )
if (KEYSTATE_UP == s &&
! (focus_ctrlp && focus_ctrlp->acceptsTextInput()))
{
if (LLNearbyChat::instance().getCurrentChat().empty())
if ((LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat"))->getCurrentChat().empty())
{
// No existing chat in chat editor, insert '/'
LLNearbyChat::startChat("/");

View File

@ -2297,9 +2297,10 @@ void god_message_name_cb(const LLAvatarName& av_name, LLChat chat, std::string m
// Treat like a system message and put in chat history.
chat.mText = av_name.getCompleteName() + ": " + message;
if (LLNearbyChat::instanceExists())
LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat");
if (nearby_chat)
{
LLNearbyChat::instance().addMessage(chat);
nearby_chat->addMessage(chat);
}
}
@ -2895,7 +2896,8 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
// Note: lie to Nearby Chat, pretending that this is NOT an IM, because
// IMs from obejcts don't open IM sessions.
if(!chat_from_system && LLNearbyChat::instanceExists())
LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat");
if(!chat_from_system && nearby_chat)
{
chat.mOwnerID = from_id;
LLSD args;

View File

@ -2493,12 +2493,14 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask)
return TRUE;
}
LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat");
// Traverses up the hierarchy
if( keyboard_focus )
{
if (LLNearbyChat::instanceExists())
if (nearby_chat)
{
LLChatEntry* chat_editor = LLNearbyChat::instance().getChatBox();
LLChatEntry* chat_editor = nearby_chat->getChatBox();
// arrow keys move avatar while chatting hack
if (chat_editor && chat_editor->hasFocus())
@ -2562,11 +2564,11 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask)
if ( gSavedSettings.getS32("LetterKeysFocusChatBar") && !gAgentCamera.cameraMouselook() &&
!keyboard_focus && key < 0x80 && (mask == MASK_NONE || mask == MASK_SHIFT) )
{
LLChatEntry* chat_editor = LLNearbyChat::instance().getChatBox();
LLChatEntry* chat_editor = nearby_chat->getChatBox();
if (chat_editor)
{
// passing NULL here, character will be added later when it is handled by character handler.
LLNearbyChat::instance().startChat(NULL);
nearby_chat->startChat(NULL);
return TRUE;
}
}