llprefschat.cpp 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /**
  2. * @file llprefschat.cpp
  3. * @author James Cook, Richard Nelson
  4. * @brief Chat preferences panel
  5. *
  6. * $LicenseInfo:firstyear=2003&license=viewergpl$
  7. *
  8. * Copyright (c) 2003-2009, Linden Research, Inc.
  9. *
  10. * Second Life Viewer Source Code
  11. * The source code in this file ("Source Code") is provided by Linden Lab
  12. * to you under the terms of the GNU General Public License, version 2.0
  13. * ("GPL"), unless you have obtained a separate licensing agreement
  14. * ("Other License"), formally executed by you and Linden Lab. Terms of
  15. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  16. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  17. *
  18. * There are special exceptions to the terms and conditions of the GPL as
  19. * it is applied to this Source Code. View the full text of the exception
  20. * in the file doc/FLOSS-exception.txt in this software distribution, or
  21. * online at
  22. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  23. *
  24. * By copying, modifying or distributing this software, you acknowledge
  25. * that you have read and understood your obligations described above,
  26. * and agree to abide by those obligations.
  27. *
  28. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  29. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  30. * COMPLETENESS OR PERFORMANCE.
  31. * $/LicenseInfo$
  32. */
  33. #include "llviewerprecompiledheaders.h"
  34. #include "llprefschat.h"
  35. #include "llcheckboxctrl.h"
  36. #include "llcolorswatch.h"
  37. #include "llradiogroup.h"
  38. #include "llstylemap.h"
  39. #include "lltexteditor.h"
  40. #include "lluictrlfactory.h"
  41. #include "llviewercontrol.h"
  42. class LLPrefsChatImpl final : public LLPanel
  43. {
  44. public:
  45. LLPrefsChatImpl();
  46. ~LLPrefsChatImpl() override {}
  47. void apply();
  48. void cancel();
  49. private:
  50. static void onCommitChatFullWidth(LLUICtrl* ctrl, void* user_data);
  51. static void onCommitCheckBoxedMessages(LLUICtrl* ctrl, void* user_data);
  52. static void onCommitCheckChatBubbles(LLUICtrl* ctrl, void* user_data);
  53. static void onCommitTabAutoCompleteName(LLUICtrl* ctrl, void* user_data);
  54. void refreshValues();
  55. private:
  56. S32 mChatSize;
  57. S32 mChatMaxLines;
  58. U32 mPlayChatAnims;
  59. U32 mLinksForChattingObjects;
  60. F32 mChatPersist;
  61. F32 mConsoleOpacity;
  62. F32 mBubbleOpacity;
  63. LLColor4 mSystemChatColor;
  64. LLColor4 mUserChatColor;
  65. LLColor4 mAgentChatColor;
  66. LLColor4 mIMChatColor;
  67. LLColor4 mObjectChatColor;
  68. LLColor4 mDirectChatColor;
  69. LLColor4 mOwnerSayChatColor;
  70. LLColor4 mBGChatColor;
  71. LLColor4 mScriptErrorColor;
  72. LLColor4 mHTMLLinkColor;
  73. bool mChatFullWidth;
  74. bool mDisableMessagesSpacing;
  75. bool mConsoleBoxPerMessage;
  76. bool mAutoFocusChat;
  77. bool mCloseChatOnReturn;
  78. bool mShowTimestamps;
  79. bool mPlayTypingAnim;
  80. bool mPlayTypingSound;
  81. bool mShowTypingInfo;
  82. bool mChatBubbles;
  83. bool mTabAutoCompleteName;
  84. bool mSelectAutoCompletedPart;
  85. };
  86. LLPrefsChatImpl::LLPrefsChatImpl()
  87. : LLPanel(std::string("Chat Preferences Panel"))
  88. {
  89. LLUICtrlFactory::getInstance()->buildPanel(this, "panel_preferences_chat.xml");
  90. childSetCommitCallback("chat_full_width_check", onCommitChatFullWidth, this);
  91. childSetCommitCallback("console_box_per_message_check", onCommitCheckBoxedMessages, this);
  92. childSetCommitCallback("bubble_text_chat", onCommitCheckChatBubbles, this);
  93. childSetCommitCallback("tab_auto_complete_name_check", onCommitTabAutoCompleteName, this);
  94. refreshValues(); // initialize member data from saved settings
  95. childSetEnabled("disable_messages_spacing_check", !mConsoleBoxPerMessage);
  96. childSetEnabled("show_typing_info_check", !mChatBubbles);
  97. childSetEnabled("select_auto_completed_part_check", mTabAutoCompleteName);
  98. }
  99. //static
  100. void LLPrefsChatImpl::onCommitChatFullWidth(LLUICtrl* ctrl, void* user_data)
  101. {
  102. LLPrefsChatImpl* self = (LLPrefsChatImpl*)user_data;
  103. LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
  104. if (self && check && check->get() != (bool)self->mChatFullWidth)
  105. {
  106. gNotifications.add("InEffectAfterRestart");
  107. }
  108. }
  109. //static
  110. void LLPrefsChatImpl::onCommitCheckBoxedMessages(LLUICtrl* ctrl, void* user_data)
  111. {
  112. LLPrefsChatImpl* self = (LLPrefsChatImpl*)user_data;
  113. LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
  114. if (self && check)
  115. {
  116. self->childSetEnabled("disable_messages_spacing_check", !check->get());
  117. }
  118. }
  119. //static
  120. void LLPrefsChatImpl::onCommitCheckChatBubbles(LLUICtrl* ctrl, void* user_data)
  121. {
  122. LLPrefsChatImpl* self = (LLPrefsChatImpl*)user_data;
  123. LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
  124. if (self && check)
  125. {
  126. self->childSetEnabled("show_typing_info_check", !check->get());
  127. }
  128. }
  129. //static
  130. void LLPrefsChatImpl::onCommitTabAutoCompleteName(LLUICtrl* ctrl, void* user_data)
  131. {
  132. LLPrefsChatImpl* self = (LLPrefsChatImpl*)user_data;
  133. LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
  134. if (self && check)
  135. {
  136. self->childSetEnabled("select_auto_completed_part_check", check->get());
  137. }
  138. }
  139. void LLPrefsChatImpl::refreshValues()
  140. {
  141. //set values
  142. mChatSize = gSavedSettings.getS32("ChatFontSize");
  143. mChatMaxLines = gSavedSettings.getU32("ChatConsoleMaxLines");
  144. mPlayChatAnims = gSavedSettings.getU32("PlayChatAnims");
  145. mLinksForChattingObjects = gSavedSettings.getU32("LinksForChattingObjects");
  146. mConsoleOpacity = gSavedSettings.getF32("ConsoleBackgroundOpacity");
  147. mBubbleOpacity = gSavedSettings.getF32("ChatBubbleOpacity");
  148. mChatPersist = gSavedSettings.getF32("ChatPersistTime");
  149. mShowTimestamps = gSavedSettings.getBool("ChatShowTimestamps");
  150. mChatBubbles = gSavedSettings.getBool("UseChatBubbles");
  151. mChatFullWidth = gSavedSettings.getBool("ChatFullWidth");
  152. mDisableMessagesSpacing = gSavedSettings.getBool("DisableMessagesSpacing");
  153. mConsoleBoxPerMessage = gSavedSettings.getBool("ConsoleBoxPerMessage");
  154. mAutoFocusChat = gSavedSettings.getBool("AutoFocusChat");
  155. mCloseChatOnReturn = gSavedSettings.getBool("CloseChatOnReturn");
  156. mPlayTypingAnim = gSavedSettings.getBool("PlayTypingAnim");
  157. mPlayTypingSound = gSavedSettings.getBool("UISndTypingEnable");
  158. mShowTypingInfo = gSavedSettings.getBool("ShowTypingInfo");
  159. mTabAutoCompleteName = gSavedSettings.getBool("TabAutoCompleteName");
  160. mSelectAutoCompletedPart = gSavedSettings.getBool("SelectAutoCompletedPart");
  161. mSystemChatColor = gSavedSettings.getColor4("SystemChatColor");
  162. mUserChatColor = gSavedSettings.getColor4("UserChatColor");
  163. mAgentChatColor = gSavedSettings.getColor4("AgentChatColor");
  164. mIMChatColor = gSavedSettings.getColor4("IMChatColor");
  165. mObjectChatColor = gSavedSettings.getColor4("ObjectChatColor");
  166. mDirectChatColor = gSavedSettings.getColor4("DirectChatColor");
  167. mOwnerSayChatColor = gSavedSettings.getColor4("llOwnerSayChatColor");
  168. mBGChatColor = gSavedSettings.getColor4("BackgroundChatColor");
  169. mScriptErrorColor = gSavedSettings.getColor4("ScriptErrorColor");
  170. mHTMLLinkColor = gSavedSettings.getColor4("HTMLLinkColor");
  171. }
  172. void LLPrefsChatImpl::cancel()
  173. {
  174. gSavedSettings.setS32("ChatFontSize", mChatSize);
  175. gSavedSettings.setU32("ChatConsoleMaxLines", mChatMaxLines);
  176. gSavedSettings.setU32("PlayChatAnims", mPlayChatAnims);
  177. gSavedSettings.setU32("LinksForChattingObjects", mLinksForChattingObjects);
  178. gSavedSettings.setF32("ChatPersistTime", mChatPersist);
  179. gSavedSettings.setF32("ConsoleBackgroundOpacity", mConsoleOpacity);
  180. gSavedSettings.setF32("ChatBubbleOpacity", mBubbleOpacity);
  181. gSavedSettings.setBool("ChatShowTimestamps", mShowTimestamps);
  182. gSavedSettings.setBool("UseChatBubbles", mChatBubbles);
  183. gSavedSettings.setBool("ChatFullWidth", mChatFullWidth);
  184. gSavedSettings.setBool("DisableMessagesSpacing", mDisableMessagesSpacing);
  185. gSavedSettings.setBool("ConsoleBoxPerMessage", mConsoleBoxPerMessage);
  186. gSavedSettings.setBool("AutoFocusChat", mAutoFocusChat);
  187. gSavedSettings.setBool("CloseChatOnReturn", mCloseChatOnReturn);
  188. gSavedSettings.setBool("PlayTypingAnim", mPlayTypingAnim);
  189. gSavedSettings.setBool("UISndTypingEnable", mPlayTypingSound);
  190. gSavedSettings.setBool("ShowTypingInfo", mShowTypingInfo);
  191. gSavedSettings.setBool("TabAutoCompleteName", mTabAutoCompleteName);
  192. gSavedSettings.setBool("SelectAutoCompletedPart", mSelectAutoCompletedPart);
  193. gSavedSettings.setColor4("SystemChatColor", mSystemChatColor);
  194. gSavedSettings.setColor4("UserChatColor", mUserChatColor);
  195. gSavedSettings.setColor4("AgentChatColor", mAgentChatColor);
  196. gSavedSettings.setColor4("IMChatColor", mIMChatColor);
  197. gSavedSettings.setColor4("ObjectChatColor", mObjectChatColor);
  198. gSavedSettings.setColor4("DirectChatColor", mDirectChatColor);
  199. gSavedSettings.setColor4("llOwnerSayChatColor", mOwnerSayChatColor);
  200. gSavedSettings.setColor4("BackgroundChatColor", mBGChatColor);
  201. gSavedSettings.setColor4("ScriptErrorColor", mScriptErrorColor);
  202. gSavedSettings.setColor4("HTMLLinkColor", mHTMLLinkColor);
  203. }
  204. void LLPrefsChatImpl::apply()
  205. {
  206. // member values become the official values and cancel becomes a no-op.
  207. refreshValues();
  208. LLTextEditor::setLinksColor(mHTMLLinkColor);
  209. }
  210. //---------------------------------------------------------------------------
  211. LLPrefsChat::LLPrefsChat()
  212. : impl(* new LLPrefsChatImpl())
  213. {
  214. }
  215. LLPrefsChat::~LLPrefsChat()
  216. {
  217. delete &impl;
  218. }
  219. void LLPrefsChat::apply()
  220. {
  221. impl.apply();
  222. gStyleMap.update();
  223. }
  224. void LLPrefsChat::cancel()
  225. {
  226. impl.cancel();
  227. }
  228. LLPanel* LLPrefsChat::getPanel()
  229. {
  230. return &impl;
  231. }