summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/app_settings/settings.xml13
-rw-r--r--indra/newview/llchathistory.cpp94
-rw-r--r--indra/newview/llchathistory.h7
-rw-r--r--indra/newview/llfloaterpreference.cpp7
-rw-r--r--indra/newview/llimfloater.cpp66
-rw-r--r--indra/newview/llimfloater.h3
-rw-r--r--indra/newview/llnearbychat.cpp4
-rw-r--r--indra/newview/skins/default/xui/en/panel_preferences_chat.xml9
8 files changed, 123 insertions, 80 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index c7279a2e33..1eca897ea5 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -5371,6 +5371,19 @@
<key>Value</key>
<real>1.0</real>
</map>
+
+ <key>PlainTextChatHistory</key>
+ <map>
+ <key>Comment</key>
+ <string>Enable/Disable plain text chat history style</string>
+ <key>Persist</key>
+ <integer>1</integer>
+ <key>Type</key>
+ <string>Boolean</string>
+ <key>Value</key>
+ <integer>0</integer>
+ </map>
+
<key>PluginInstancesLow</key>
<map>
<key>Comment</key>
diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp
index 4ce3b50ed5..422aae3c25 100644
--- a/indra/newview/llchathistory.cpp
+++ b/indra/newview/llchathistory.cpp
@@ -334,20 +334,14 @@ LLView* LLChatHistory::getHeader(const LLChat& chat,const LLStyle::Params& style
return header;
}
-void LLChatHistory::appendWidgetMessage(const LLChat& chat, const LLStyle::Params& input_append_params)
+void LLChatHistory::clear()
{
- LLView* view = NULL;
- std::string view_text = "\n[" + chat.mTimeStr + "] ";
- if (utf8str_trim(chat.mFromName).size() != 0 && chat.mFromName != SYSTEM_FROM)
- view_text += chat.mFromName + ": ";
-
-
- LLInlineViewSegment::Params p;
- p.force_newline = true;
- p.left_pad = mLeftWidgetPad;
- p.right_pad = mRightWidgetPad;
+ mLastFromName.clear();
+ LLTextEditor::clear();
+}
-
+void LLChatHistory::appendMessage(const LLChat& chat, const bool use_plain_text_chat_history, const LLStyle::Params& input_append_params)
+{
LLColor4 txt_color = LLUIColorTable::instance().getColor("White");
LLViewerChat::getChatColor(chat,txt_color);
LLFontGL* fontp = LLViewerChat::getChatFont();
@@ -360,39 +354,63 @@ void LLChatHistory::appendWidgetMessage(const LLChat& chat, const LLStyle::Param
style_params.font.size(font_size);
style_params.font.style(input_append_params.font.style);
-
+ std::string header_text = "[" + chat.mTimeStr + "] ";
+ if (utf8str_trim(chat.mFromName).size() != 0 && chat.mFromName != SYSTEM_FROM)
+ header_text += chat.mFromName + ": ";
- if (mLastFromName == chat.mFromName)
+ if (use_plain_text_chat_history)
{
- view = getSeparator();
- p.top_pad = mTopSeparatorPad;
- p.bottom_pad = mBottomSeparatorPad;
+ appendText(header_text, getText().size() != 0, style_params);
}
else
{
- view = getHeader(chat,style_params);
- if (getText().size() == 0)
- p.top_pad = 0;
+ LLView* view = NULL;
+ LLInlineViewSegment::Params p;
+ p.force_newline = true;
+ p.left_pad = mLeftWidgetPad;
+ p.right_pad = mRightWidgetPad;
+
+ if (mLastFromName == chat.mFromName)
+ {
+ view = getSeparator();
+ p.top_pad = mTopSeparatorPad;
+ p.bottom_pad = mBottomSeparatorPad;
+ }
else
- p.top_pad = mTopHeaderPad;
- p.bottom_pad = mBottomHeaderPad;
-
+ {
+ view = getHeader(chat, style_params);
+ if (getText().size() == 0)
+ p.top_pad = 0;
+ else
+ p.top_pad = mTopHeaderPad;
+ p.bottom_pad = mBottomHeaderPad;
+
+ }
+ p.view = view;
+
+ //Prepare the rect for the view
+ LLRect target_rect = getDocumentView()->getRect();
+ // squeeze down the widget by subtracting padding off left and right
+ target_rect.mLeft += mLeftWidgetPad + mHPad;
+ target_rect.mRight -= mRightWidgetPad;
+ view->reshape(target_rect.getWidth(), view->getRect().getHeight());
+ view->setOrigin(target_rect.mLeft, view->getRect().mBottom);
+
+ appendWidget(p, header_text, false);
+ mLastFromName = chat.mFromName;
}
- p.view = view;
-
- //Prepare the rect for the view
- LLRect target_rect = getDocumentView()->getRect();
- // squeeze down the widget by subtracting padding off left and right
- target_rect.mLeft += mLeftWidgetPad + mHPad;
- target_rect.mRight -= mRightWidgetPad;
- view->reshape(target_rect.getWidth(), view->getRect().getHeight());
- view->setOrigin(target_rect.mLeft, view->getRect().mBottom);
-
- appendWidget(p, view_text, false);
-
- //Append the text message
- appendText(chat.mText, FALSE, style_params);
+ //Handle IRC styled /me messages.
+ std::string prefix = chat.mText.substr(0, 4);
+ if (prefix == "/me " || prefix == "/me'")
+ {
+ style_params.font.style = "ITALIC";
- mLastFromName = chat.mFromName;
+ if (chat.mFromName.size() > 0)
+ appendText(chat.mFromName + " ", TRUE, style_params);
+ appendText(chat.mText.substr(4), FALSE, style_params);
+ }
+ else
+ appendText(chat.mText, FALSE, style_params);
blockUndo();
}
+
diff --git a/indra/newview/llchathistory.h b/indra/newview/llchathistory.h
index c89d4b4ec6..ef5839ff2f 100644
--- a/indra/newview/llchathistory.h
+++ b/indra/newview/llchathistory.h
@@ -106,10 +106,11 @@ class LLChatHistory : public LLTextEditor
* If last user appended message, concurs with current user,
* separator is added before the message, otherwise header is added.
* @param chat - base chat message.
- * @param time time of a message.
- * @param message message itself.
+ * @param use_plain_text_chat_history - whether to add message as plain text.
+ * @param input_append_params - font style.
*/
- void appendWidgetMessage(const LLChat& chat, const LLStyle::Params& input_append_params = LLStyle::Params());
+ void appendMessage(const LLChat& chat, const bool use_plain_text_chat_history = false, const LLStyle::Params& input_append_params = LLStyle::Params());
+ /*virtual*/ void clear();
private:
std::string mLastFromName;
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 7fc207d395..95e8adca81 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -56,6 +56,7 @@
#include "llfloaterabout.h"
#include "llfloaterhardwaresettings.h"
#include "llfloatervoicedevicesettings.h"
+#include "llimfloater.h"
#include "llkeyboard.h"
#include "llmodaldialog.h"
#include "llnavigationbar.h"
@@ -357,6 +358,8 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key)
BOOL LLFloaterPreference::postBuild()
{
+ gSavedSettings.getControl("PlainTextChatHistory")->getSignal()->connect(boost::bind(&LLIMFloater::processChatHistoryStyleUpdate, _2));
+
LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
if (!tabcontainer->selectTab(gSavedSettings.getS32("LastPrefTab")))
tabcontainer->selectFirstTab();
@@ -444,6 +447,8 @@ void LLFloaterPreference::apply()
// LLWString busy_response = utf8str_to_wstring(getChild<LLUICtrl>("busy_response")->getValue().asString());
// LLWStringUtil::replaceTabsWithSpaces(busy_response, 4);
+
+ gSavedSettings.setBOOL("PlainTextChatHistory", childGetValue("plain_text_chat_history").asBoolean());
if(mGotPersonalInfo)
{
@@ -1161,6 +1166,8 @@ void LLFloaterPreference::setPersonalInfo(const std::string& visibility, bool im
childSetLabelArg("online_visibility", "[DIR_VIS]", mDirectoryVisibility);
childEnable("send_im_to_email");
childSetValue("send_im_to_email", im_via_email);
+ childEnable("plain_text_chat_history");
+ childSetValue("plain_text_chat_history", gSavedSettings.getBOOL("PlainTextChatHistory"));
childEnable("log_instant_messages");
// childEnable("log_chat");
// childEnable("busy_response");
diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp
index 38a9fec192..795770d3db 100644
--- a/indra/newview/llimfloater.cpp
+++ b/indra/newview/llimfloater.cpp
@@ -110,10 +110,10 @@ void LLIMFloater::onFocusReceived()
// virtual
void LLIMFloater::onClose(bool app_quitting)
{
+ if (!gIMMgr->hasSession(mSessionID)) return;
+
setTyping(false);
- // SJB: We want the close button to hide the session window, not end it
- // *NOTE: Yhis is functional, but not ideal - it's still closing the floater; we really want to change the behavior of the X button instead.
- //gIMMgr->leaveSession(mSessionID);
+ gIMMgr->leaveSession(mSessionID);
}
/* static */
@@ -385,7 +385,7 @@ LLIMFloater* LLIMFloater::show(const LLUUID& session_id)
void LLIMFloater::getAllowedRect(LLRect& rect)
{
- rect = gViewerWindow->getWorldViewRectScaled();
+ rect = gViewerWindow->getWorldViewRectRaw();
}
void LLIMFloater::setDocked(bool docked, bool pop_on_undock)
@@ -482,6 +482,8 @@ void LLIMFloater::sessionInitReplyReceived(const LLUUID& im_session_id)
void LLIMFloater::updateMessages()
{
+ bool use_plain_text_chat_history = gSavedSettings.getBOOL("PlainTextChatHistory");
+
std::list<LLSD> messages;
LLIMModel::instance().getMessages(mSessionID, messages, mLastMessageIndex+1);
@@ -507,39 +509,7 @@ void LLIMFloater::updateMessages()
chat.mText = message;
chat.mTimeStr = time;
- //Handle IRC styled /me messages.
- std::string prefix = message.substr(0, 4);
- if (prefix == "/me " || prefix == "/me'")
- {
-
- LLColor4 txt_color = LLUIColorTable::instance().getColor("White");
- LLViewerChat::getChatColor(chat,txt_color);
- LLFontGL* fontp = LLViewerChat::getChatFont();
- std::string font_name = LLFontGL::nameFromFont(fontp);
- std::string font_size = LLFontGL::sizeFromFont(fontp);
- LLStyle::Params append_style_params;
- append_style_params.color(txt_color);
- append_style_params.readonly_color(txt_color);
- append_style_params.font.name(font_name);
- append_style_params.font.size(font_size);
-
- if (from.size() > 0)
- {
- append_style_params.font.style = "ITALIC";
- chat.mText = from;
- mChatHistory->appendWidgetMessage(chat, append_style_params);
- }
-
- message = message.substr(3);
- append_style_params.font.style = "ITALIC";
- mChatHistory->appendText(message, FALSE, append_style_params);
- }
- else
- {
- chat.mText = message;
- mChatHistory->appendWidgetMessage(chat);
- }
-
+ mChatHistory->appendMessage(chat, use_plain_text_chat_history);
mLastMessageIndex = msg["index"].asInteger();
}
}
@@ -670,6 +640,28 @@ void LLIMFloater::processAgentListUpdates(const LLSD& body)
}
}
+void LLIMFloater::updateChatHistoryStyle()
+{
+ mChatHistory->clear();
+ mLastMessageIndex = -1;
+ updateMessages();
+}
+
+void LLIMFloater::processChatHistoryStyleUpdate(const LLSD& newvalue)
+{
+ LLFloaterReg::const_instance_list_t& inst_list = LLFloaterReg::getFloaterList("impanel");
+ for (LLFloaterReg::const_instance_list_t::const_iterator iter = inst_list.begin();
+ iter != inst_list.end(); ++iter)
+ {
+ LLIMFloater* floater = dynamic_cast<LLIMFloater*>(*iter);
+ if (floater)
+ {
+ floater->updateChatHistoryStyle();
+ }
+ }
+
+}
+
void LLIMFloater::processSessionUpdate(const LLSD& session_update)
{
// *TODO : verify following code when moderated mode will be implemented
diff --git a/indra/newview/llimfloater.h b/indra/newview/llimfloater.h
index 32cba71f6e..9e1330ff49 100644
--- a/indra/newview/llimfloater.h
+++ b/indra/newview/llimfloater.h
@@ -97,6 +97,9 @@ public:
void processAgentListUpdates(const LLSD& body);
void processSessionUpdate(const LLSD& session_update);
+ void updateChatHistoryStyle();
+ static void processChatHistoryStyleUpdate(const LLSD& newvalue);
+
BOOL handleDragAndDrop(S32 x, S32 y, MASK mask,
BOOL drop, EDragAndDropType cargo_type,
void *cargo_data, EAcceptance *accept,
diff --git a/indra/newview/llnearbychat.cpp b/indra/newview/llnearbychat.cpp
index 09fd9b2949..80a6cc343f 100644
--- a/indra/newview/llnearbychat.cpp
+++ b/indra/newview/llnearbychat.cpp
@@ -173,7 +173,7 @@ void LLNearbyChat::addMessage(const LLChat& chat)
append_style_params.font.style = "ITALIC";
LLChat add_chat=chat;
add_chat.mText = chat.mFromName + " ";
- mChatHistory->appendWidgetMessage(add_chat, append_style_params);
+ mChatHistory->appendMessage(add_chat, false, append_style_params);
}
message = message.substr(3);
@@ -182,7 +182,7 @@ void LLNearbyChat::addMessage(const LLChat& chat)
}
else
{
- mChatHistory->appendWidgetMessage(chat);
+ mChatHistory->appendMessage(chat);
}
}
}
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_chat.xml b/indra/newview/skins/default/xui/en/panel_preferences_chat.xml
index 5a4b0a3892..fac0d5c60f 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_chat.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_chat.xml
@@ -309,4 +309,13 @@
name="send_im_to_email"
top_pad="5"
width="400" />
+ <check_box
+ enabled="false"
+ height="16"
+ label="Enable plain text chat history"
+ layout="topleft"
+ left_delta="0"
+ name="plain_text_chat_history"
+ top_pad="5"
+ width="400" />
</panel>