summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterimsessiontab.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloaterimsessiontab.cpp')
-rw-r--r--indra/newview/llfloaterimsessiontab.cpp118
1 files changed, 106 insertions, 12 deletions
diff --git a/indra/newview/llfloaterimsessiontab.cpp b/indra/newview/llfloaterimsessiontab.cpp
index 2621ce576c..733e178de3 100644
--- a/indra/newview/llfloaterimsessiontab.cpp
+++ b/indra/newview/llfloaterimsessiontab.cpp
@@ -35,10 +35,12 @@
#include "llavatariconctrl.h"
#include "llchatentry.h"
#include "llchathistory.h"
+#include "llfloaterchatmentionpicker.h"
#include "llchiclet.h"
#include "llchicletbar.h"
#include "lldraghandle.h"
#include "llemojidictionary.h"
+#include "llemojihelper.h"
#include "llfloaterreg.h"
#include "llfloateremojipicker.h"
#include "llfloaterimsession.h"
@@ -80,6 +82,7 @@ LLFloaterIMSessionTab::LLFloaterIMSessionTab(const LLSD& session_id)
{
setAutoFocus(false);
mSession = LLIMModel::getInstance()->findIMSession(mSessionID);
+ LLIMMgr::instance().addSessionObserver(this);
mCommitCallbackRegistrar.add("IMSession.Menu.Action",
boost::bind(&LLFloaterIMSessionTab::onIMSessionMenuItemClicked, this, _2));
@@ -102,6 +105,8 @@ LLFloaterIMSessionTab::LLFloaterIMSessionTab(const LLSD& session_id)
LLFloaterIMSessionTab::~LLFloaterIMSessionTab()
{
delete mRefreshTimer;
+ LLIMMgr::instance().removeSessionObserver(this);
+ mEmojiCloseConn.disconnect();
LLFloaterIMContainer* im_container = LLFloaterIMContainer::findInstance();
if (im_container)
@@ -298,10 +303,13 @@ bool LLFloaterIMSessionTab::postBuild()
mEmojiPickerShowBtn = getChild<LLButton>("emoji_picker_show_btn");
mEmojiPickerShowBtn->setClickedCallback([this](LLUICtrl*, const LLSD&) { onEmojiPickerShowBtnClicked(); });
+ mEmojiPickerShowBtn->setMouseDownCallback([this](LLUICtrl*, const LLSD&) { onEmojiPickerShowBtnDown(); });
+ mEmojiCloseConn = LLEmojiHelper::instance().setCloseCallback([this](LLUICtrl*, const LLSD&) { onEmojiPickerClosed(); });
mGearBtn = getChild<LLButton>("gear_btn");
mAddBtn = getChild<LLButton>("add_btn");
mVoiceButton = getChild<LLButton>("voice_call_btn");
+ mVoiceButton->setClickedCallback([this](LLUICtrl*, const LLSD&) { onCallButtonClicked(); });
mParticipantListPanel = getChild<LLLayoutPanel>("speakers_list_panel");
mRightPartPanel = getChild<LLLayoutPanel>("right_part_holder");
@@ -434,16 +442,39 @@ void LLFloaterIMSessionTab::draw()
void LLFloaterIMSessionTab::enableDisableCallBtn()
{
- if (LLVoiceClient::instanceExists() && mVoiceButton)
+ if (!mVoiceButton)
+ return;
+
+ bool enable = false;
+
+ if (mSessionID.notNull()
+ && mSession
+ && mSession->mSessionInitialized
+ && mSession->mCallBackEnabled)
{
- mVoiceButton->setEnabled(
- mSessionID.notNull()
- && mSession
- && mSession->mSessionInitialized
- && LLVoiceClient::getInstance()->voiceEnabled()
- && LLVoiceClient::getInstance()->isVoiceWorking()
- && mSession->mCallBackEnabled);
+ if (mVoiceButtonHangUpMode)
+ {
+ // We allow to hang up from any state
+ enable = true;
+ }
+ else
+ {
+ // We allow to start call from this state only
+ if (LLVoiceClient::instanceExists() &&
+ mSession->mVoiceChannel &&
+ !mSession->mVoiceChannel->callStarted()
+ )
+ {
+ LLVoiceClient* client = LLVoiceClient::getInstance();
+ if (client->voiceEnabled() && client->isVoiceWorking())
+ {
+ enable = true;
+ }
+ }
+ }
}
+
+ mVoiceButton->setEnabled(enable);
}
// virtual
@@ -456,6 +487,7 @@ void LLFloaterIMSessionTab::onFocusReceived()
LLIMModel::instance().sendNoUnreadMessages(mSessionID);
}
+ LLFloaterChatMentionPicker::updateSessionID(mSessionID);
super::onFocusReceived();
}
@@ -466,6 +498,22 @@ void LLFloaterIMSessionTab::onFocusLost()
super::onFocusLost();
}
+void LLFloaterIMSessionTab::onCallButtonClicked()
+{
+ if (mVoiceButtonHangUpMode)
+ {
+ // We allow to hang up from any state
+ gIMMgr->endCall(mSessionID);
+ }
+ else
+ {
+ if (mSession->mVoiceChannel && !mSession->mVoiceChannel->callStarted())
+ {
+ gIMMgr->startCall(mSessionID);
+ }
+ }
+}
+
void LLFloaterIMSessionTab::onInputEditorClicked()
{
LLFloaterIMContainer* im_box = LLFloaterIMContainer::findInstance();
@@ -490,8 +538,43 @@ void LLFloaterIMSessionTab::onEmojiRecentPanelToggleBtnClicked()
void LLFloaterIMSessionTab::onEmojiPickerShowBtnClicked()
{
- mInputEditor->setFocus(true);
- mInputEditor->showEmojiHelper();
+ if (!mEmojiPickerShowBtn->getToggleState())
+ {
+ mInputEditor->hideEmojiHelper();
+ mInputEditor->setFocus(true);
+ mInputEditor->showEmojiHelper();
+ mEmojiPickerShowBtn->setToggleState(true); // in case hideEmojiHelper closed a visible instance
+ }
+ else
+ {
+ mInputEditor->hideEmojiHelper();
+ mEmojiPickerShowBtn->setToggleState(false);
+ }
+}
+
+void LLFloaterIMSessionTab::onEmojiPickerShowBtnDown()
+{
+ if (mEmojiHelperLastCallbackFrame == LLFrameTimer::getFrameCount())
+ {
+ // Helper gets closed by focus lost event on Down before before onEmojiPickerShowBtnDown
+ // triggers.
+ // If this condition is true, user pressed button and it was 'toggled' during press,
+ // restore 'toggled' state so that button will not reopen helper.
+ mEmojiPickerShowBtn->setToggleState(true);
+ }
+}
+
+void LLFloaterIMSessionTab::onEmojiPickerClosed()
+{
+ if (mEmojiPickerShowBtn->getToggleState())
+ {
+ mEmojiPickerShowBtn->setToggleState(false);
+ // Helper gets closed by focus lost event on Down before onEmojiPickerShowBtnDown
+ // triggers. If mEmojiHelperLastCallbackFrame is set and matches Down, means close
+ // was triggered by user's press.
+ // A bit hacky, but I can't think of a better way to handle this without rewriting helper.
+ mEmojiHelperLastCallbackFrame = LLFrameTimer::getFrameCount();
+ }
}
void LLFloaterIMSessionTab::initEmojiRecentPanel()
@@ -556,7 +639,8 @@ void LLFloaterIMSessionTab::deleteAllChildren()
std::string LLFloaterIMSessionTab::appendTime()
{
std::string timeStr = "[" + LLTrans::getString("TimeHour") + "]:"
- "[" + LLTrans::getString("TimeMin") + "]";
+ "[" + LLTrans::getString("TimeMin") + "]:"
+ "[" + LLTrans::getString("TimeSec") + "]";
LLSD substitution;
substitution["datetime"] = (S32)time_corrected();
@@ -591,7 +675,8 @@ void LLFloaterIMSessionTab::appendMessage(const LLChat& chat, const LLSD& args)
chat_args["show_names_for_p2p_conv"] = !mIsP2PChat ||
gSavedSettings.getBOOL("IMShowNamesForP2PConv");
- mChatHistory->appendMessage(chat, chat_args);
+ static const LLStyle::Params input_append_params = LLStyle::Params();
+ mChatHistory->appendMessage(chat, chat_args, input_append_params);
}
void LLFloaterIMSessionTab::updateUsedEmojis(LLWStringView text)
@@ -1040,6 +1125,7 @@ void LLFloaterIMSessionTab::updateCallBtnState(bool callIsActive)
{
mVoiceButton->setImageOverlay(callIsActive? getString("call_btn_stop") : getString("call_btn_start"));
mVoiceButton->setToolTip(callIsActive? getString("end_call_button_tooltip") : getString("start_call_button_tooltip"));
+ mVoiceButtonHangUpMode = callIsActive;
enableDisableCallBtn();
}
@@ -1329,6 +1415,14 @@ LLView* LLFloaterIMSessionTab::getChatHistory()
return mChatHistory;
}
+void LLFloaterIMSessionTab::sessionRemoved(const LLUUID& session_id)
+{
+ if (session_id == mSessionID)
+ {
+ mSession = nullptr;
+ }
+}
+
bool LLFloaterIMSessionTab::handleKeyHere(KEY key, MASK mask )
{
bool handled = false;