hbprefscool.cpp 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490
  1. /**
  2. * @file hbprefscool.cpp
  3. * @author Henri Beauchamp
  4. * @brief Cool VL Viewer preferences panel
  5. *
  6. * $LicenseInfo:firstyear=2008&license=viewergpl$
  7. *
  8. * Copyright (c) 2008, Henri Beauchamp.
  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 http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #include "llviewerprecompiledheaders.h"
  33. #include "hbprefscool.h"
  34. #include "llcheckboxctrl.h"
  35. #include "llcombobox.h"
  36. #include "llcolorswatch.h"
  37. #include "llcorehttputil.h"
  38. #include "lldir.h"
  39. #include "llnotifications.h"
  40. #include "llradiogroup.h"
  41. #include "llsdserialize.h"
  42. #include "llsliderctrl.h"
  43. #include "llspellcheck.h"
  44. #include "lltabcontainer.h"
  45. #include "lltextbox.h"
  46. #include "lltexteditor.h"
  47. #include "lluictrlfactory.h"
  48. #include "llenvironment.h"
  49. #include "hbfloaterrlv.h"
  50. #include "llinventorymodel.h"
  51. #include "llpreviewnotecard.h"
  52. #include "llpreviewscript.h"
  53. #include "mkrlinterface.h"
  54. #include "llstartup.h"
  55. #include "llviewercontrol.h"
  56. #include "llvoavatarself.h"
  57. ///////////////////////////////////////////////////////////////////////////////
  58. // HBPrefFonts class
  59. // A small floater to select fonts for the note cards and script editor.
  60. ///////////////////////////////////////////////////////////////////////////////
  61. class HBPrefFonts final : public LLFloater,
  62. public LLFloaterSingleton<HBPrefFonts>
  63. {
  64. friend class LLUISingleton<HBPrefFonts, VisibilityPolicy<LLFloater> >;
  65. protected:
  66. LOG_CLASS(HBPrefFonts);
  67. private:
  68. // Open only via LLFloaterSingleton interface, i.e. showInstance() or
  69. // toggleInstance().
  70. HBPrefFonts(const LLSD&);
  71. ~HBPrefFonts() override;
  72. bool postBuild() override;
  73. std::string getFontName(bool script_font);
  74. static void onCancelButton(void* datap);
  75. static void onApplyButton(void* datap);
  76. static void onCommitCombo(LLUICtrl* ctrlp, void* datap);
  77. private:
  78. LLTextBox* mNoteCardFont;
  79. LLTextBox* mScriptFont;
  80. LLComboBox* mNotecardFontCombo;
  81. LLComboBox* mNotecardSizeCombo;
  82. LLComboBox* mScriptFontCombo;
  83. LLComboBox* mScriptSizeCombo;
  84. std::string mNoteCardFontName;
  85. std::string mScriptFontName;
  86. };
  87. HBPrefFonts::HBPrefFonts(const LLSD&)
  88. : mNoteCardFontName(gSavedSettings.getString("NotecardEditorFont")),
  89. mScriptFontName(gSavedSettings.getString("ScriptEditorFont"))
  90. {
  91. LLUICtrlFactory::getInstance()->buildFloater(this,
  92. "floater_preferences_fonts.xml");
  93. center();
  94. }
  95. HBPrefFonts::~HBPrefFonts()
  96. {
  97. gSavedSettings.setString("NotecardEditorFont", mNoteCardFontName);
  98. gSavedSettings.setString("ScriptEditorFont", mScriptFontName);
  99. }
  100. //virtual
  101. bool HBPrefFonts::postBuild()
  102. {
  103. mNoteCardFont = getChild<LLTextBox>("notecard_font");
  104. mScriptFont = getChild<LLTextBox>("script_font");
  105. mNotecardFontCombo = getChild<LLComboBox>("notecard_fonts_combo");
  106. mNotecardSizeCombo = getChild<LLComboBox>("notecard_sizes_combo");
  107. mScriptFontCombo = getChild<LLComboBox>("script_fonts_combo");
  108. mScriptSizeCombo = getChild<LLComboBox>("script_sizes_combo");
  109. LLFontGL* fontp = LLPreviewScript::getCustomFont();
  110. if (fontp)
  111. {
  112. const LLFontDescriptor& desc = fontp->getFontDesc();
  113. mScriptFontCombo->setValue(desc.getName());
  114. mScriptSizeCombo->setValue(desc.getSize());
  115. mScriptFont->setFont(fontp);
  116. }
  117. else
  118. {
  119. mScriptSizeCombo->setValue("Small");
  120. mScriptSizeCombo->setEnabled(false);
  121. }
  122. fontp = LLPreviewNotecard::getCustomFont();
  123. if (fontp)
  124. {
  125. const LLFontDescriptor& desc = fontp->getFontDesc();
  126. mNotecardFontCombo->setValue(desc.getName());
  127. mNotecardSizeCombo->setValue(desc.getSize());
  128. mNoteCardFont->setFont(fontp);
  129. }
  130. else
  131. {
  132. mNotecardSizeCombo->setValue("Medium");
  133. mNotecardSizeCombo->setEnabled(false);
  134. }
  135. mNotecardFontCombo->setCommitCallback(onCommitCombo);
  136. mNotecardFontCombo->setCallbackUserData(this);
  137. mNotecardSizeCombo->setCommitCallback(onCommitCombo);
  138. mNotecardSizeCombo->setCallbackUserData(this);
  139. mScriptFontCombo->setCommitCallback(onCommitCombo);
  140. mScriptFontCombo->setCallbackUserData(this);
  141. mScriptSizeCombo->setCommitCallback(onCommitCombo);
  142. mScriptSizeCombo->setCallbackUserData(this);
  143. childSetAction("cancel_btn", onCancelButton, this);
  144. childSetAction("apply_btn", onApplyButton, this);
  145. return true;
  146. }
  147. std::string HBPrefFonts::getFontName(bool script_font)
  148. {
  149. LLComboBox* name_combo;
  150. LLComboBox* size_combo;
  151. if (script_font)
  152. {
  153. name_combo = mScriptFontCombo;
  154. size_combo = mScriptSizeCombo;
  155. }
  156. else
  157. {
  158. name_combo = mNotecardFontCombo;
  159. size_combo = mNotecardSizeCombo;
  160. }
  161. std::string font = name_combo->getValue().asString();
  162. if (font == "Default")
  163. {
  164. return "";
  165. }
  166. return font + size_combo->getValue().asString();
  167. }
  168. //static
  169. void HBPrefFonts::onCommitCombo(LLUICtrl* ctrlp, void* datap)
  170. {
  171. HBPrefFonts* self = (HBPrefFonts*)datap;
  172. if (!self || !ctrlp)
  173. {
  174. return;
  175. }
  176. bool script_font = ctrlp == (LLUICtrl*)self->mScriptFontCombo ||
  177. ctrlp == (LLUICtrl*)self->mScriptSizeCombo;
  178. std::string font_name = self->getFontName(script_font);
  179. if (font_name.empty())
  180. {
  181. if (script_font)
  182. {
  183. self->mScriptSizeCombo->setValue("Small");
  184. self->mScriptSizeCombo->setEnabled(false);
  185. self->mScriptFont->setFont(LLFontGL::getFontMonospace());
  186. }
  187. else
  188. {
  189. self->mNotecardSizeCombo->setValue("Medium");
  190. self->mNotecardSizeCombo->setEnabled(false);
  191. self->mNoteCardFont->setFont(LLFontGL::getFontSansSerif());
  192. }
  193. return;
  194. }
  195. if (script_font)
  196. {
  197. self->mScriptSizeCombo->setEnabled(true);
  198. }
  199. else
  200. {
  201. self->mNotecardSizeCombo->setEnabled(true);
  202. }
  203. LLFontGL* fontp = LLFontGL::getFont(font_name.c_str());
  204. if (!fontp)
  205. {
  206. llwarns_once << "Could not load font: " << font_name << llendl;
  207. return;
  208. }
  209. if (script_font)
  210. {
  211. self->mScriptFont->setFont(fontp);
  212. }
  213. else
  214. {
  215. self->mNoteCardFont->setFont(fontp);
  216. }
  217. }
  218. //static
  219. void HBPrefFonts::onCancelButton(void* datap)
  220. {
  221. HBPrefFonts* self = (HBPrefFonts*)datap;
  222. if (self)
  223. {
  224. self->close();
  225. }
  226. }
  227. //static
  228. void HBPrefFonts::onApplyButton(void* datap)
  229. {
  230. HBPrefFonts* self = (HBPrefFonts*)datap;
  231. if (self)
  232. {
  233. self->mNoteCardFontName = self->getFontName(false);
  234. self->mScriptFontName = self->getFontName(true);
  235. self->close();
  236. }
  237. }
  238. ///////////////////////////////////////////////////////////////////////////////
  239. // HBPrefsCoolImpl class
  240. // The implement class for the HBPrefsCool preferences panel.
  241. ///////////////////////////////////////////////////////////////////////////////
  242. class HBPrefsCoolImpl final : public LLPanel
  243. {
  244. protected:
  245. LOG_CLASS(HBPrefsCoolImpl);
  246. public:
  247. HBPrefsCoolImpl();
  248. ~HBPrefsCoolImpl() override;
  249. void refresh() override;
  250. void draw() override;
  251. void apply();
  252. void cancel();
  253. void setDirty() { mIsDirty = true; }
  254. static void setQueryActive(bool active);
  255. std::string getDictName(const std::string& language);
  256. std::string getDictLanguage(const std::string& name);
  257. static HBPrefsCoolImpl* getInstance() { return sInstance; }
  258. private:
  259. void refreshValues();
  260. void setSunPositionLabel(F32 value);
  261. void refreshRestrainedLove(bool enable);
  262. void updateRestrainedLoveUserProfile();
  263. std::string getCategoryPath(LLFolderType::EType cat_type);
  264. std::string getCategoryPath(const LLUUID& cat_id);
  265. static void onTabChanged(void* user_data, bool);
  266. static void onCommitCheckBoxShowButton(LLUICtrl* ctrl, void* user_data);
  267. static void onCommitCheckBoxSpellCheck(LLUICtrl* ctrl, void* user_data);
  268. static void onCommitCheckBoxRestrainedLove(LLUICtrl* ctrl, void* user_data);
  269. static void onCommitCheckBoxSpeedRez(LLUICtrl* ctrl, void* user_data);
  270. static void onCommitSliderSunPositionAtLogin(LLUICtrl* ctrl, void* user_data);
  271. static void onCommitUserProfile(LLUICtrl* ctrl, void* user_data);
  272. static void onCommitCheckBoxAfterRestart(LLUICtrl* ctrl, void* user_data);
  273. static void onClickCustomBlackList(void* user_data);
  274. static void onClickSetFonts(void*);
  275. static void onClickDownloadDict(void* user_data);
  276. static void onClickResetSetting(void* user_data);
  277. static void fetchDictionaryCoro(std::string dictname);
  278. private:
  279. static HBPrefsCoolImpl* sInstance;
  280. static S32 sQueries;
  281. LLTabContainer* mTabContainer;
  282. LLTextBox* mSunPositionLabel;
  283. std::string mSunPositionSim;
  284. LLSD mDictsList;
  285. std::set<std::string> mInstalledDicts;
  286. std::set<std::string> mWarnedAfterRestart;
  287. S32 mRestrainedLoveUserProfile;
  288. bool mFirstRun;
  289. bool mIsDirty;
  290. bool mWatchBlackListFloater;
  291. // Saved values of the settings touched by this panel:
  292. bool mShowChatButton;
  293. bool mShowIMButton;
  294. bool mShowFriendsButton;
  295. bool mShowGroupsButton;
  296. bool mShowFlyButton;
  297. bool mShowSnapshotButton;
  298. bool mShowSearchButton;
  299. bool mShowBuildButton;
  300. bool mShowRadarButton;
  301. bool mShowMiniMapButton;
  302. bool mShowMapButton;
  303. bool mShowInventoryButton;
  304. bool mHideMasterRemote;
  305. bool mUseOldChatHistory;
  306. bool mAutoOpenTextInput;
  307. bool mIMTabsVerticalStacking;
  308. bool mUseOldStatusBarIcons;
  309. bool mUseOldTrackingDots;
  310. bool mHideTeleportProgress;
  311. bool mStackMinimizedTopToBottom;
  312. bool mStackMinimizedRightToLeft;
  313. bool mAllowMUpose;
  314. bool mAutoCloseOOC;
  315. bool mHighlightOwnNameInChat;
  316. bool mHighlightOwnNameInIM;
  317. bool mHighlightDisplayName;
  318. bool mSpellCheck;
  319. bool mSpellCheckShow;
  320. bool mAddAvatarNamesToIgnore;
  321. bool mAllowMultipleViewers;
  322. bool mSpeedRez;
  323. bool mTeleportHistoryDeparture;
  324. bool mMuteListIgnoreServer;
  325. bool mPreviewAnimInWorld;
  326. bool mAppearanceAnimation;
  327. bool mRevokePermsOnStandUp;
  328. bool mRevokePermsOnStopAnimation;
  329. bool mResetAnimOverrideOnStopAnimation;
  330. bool mTurnTowardsSelectedObject;
  331. bool mPlayDefaultBentoAnimation;
  332. bool mRezWithLandGroup;
  333. bool mNoMultipleShoes;
  334. bool mNoMultipleSkirts;
  335. bool mNoMultiplePhysics;
  336. bool mRenderBanWallAlways;
  337. bool mAutoShowInventoryThumbnails;
  338. bool mOSUseCOF;
  339. bool mOSAllowBakeOnMeshUploads;
  340. bool mOSWorldMapHasTerrain;
  341. bool mRestrainedLove;
  342. bool mRestrainedLoveNoSetEnv;
  343. bool mRestrainedLoveAllowWear;
  344. bool mRestrainedLoveForbidGiveToRLV;
  345. bool mRestrainedLoveShowEllipsis;
  346. bool mRestrainedLoveUntruncatedEmotes;
  347. bool mRestrainedLoveCanOoc;
  348. F32 mSunPositionAtLogin;
  349. F32 mTaskBarButtonFlashTime;
  350. U32 mFadeMouselookExitTip;
  351. U32 mDecimalsForTools;
  352. U32 mStackScreenWidthFraction;
  353. U32 mTimeFormat;
  354. U32 mDateFormat;
  355. U32 mThumbnailViewTimeout;
  356. U32 mBackgroundYieldTime;
  357. U32 mFrameRateLimit;
  358. U32 mSpeedRezInterval;
  359. U32 mNumImageDecodeThreads;
  360. U32 mFetchBoostAfterTPDuration;
  361. U32 mRenderBanWallMaxDist;
  362. U32 mDoubleClickInventorySoundAction;
  363. U32 mRestrainedLoveReattachDelay;
  364. LLColor4 mOwnNameChatColor;
  365. std::string mHighlightNicknames;
  366. std::string mSpellCheckLanguage;
  367. std::string mExternalEditor;
  368. std::string mRestrainedLoveRecvimMessage;
  369. std::string mRestrainedLoveSendimMessage;
  370. std::string mRestrainedLoveBlacklist;
  371. };
  372. HBPrefsCoolImpl* HBPrefsCoolImpl::sInstance = NULL;
  373. S32 HBPrefsCoolImpl::sQueries = 0;
  374. HBPrefsCoolImpl::HBPrefsCoolImpl()
  375. : LLPanel(std::string("Cool Preferences Panel")),
  376. mWatchBlackListFloater(false),
  377. mFirstRun(true),
  378. mIsDirty(true)
  379. {
  380. sInstance = this;
  381. LLUICtrlFactory::getInstance()->buildPanel(this,
  382. "panel_preferences_cool.xml");
  383. childSetCommitCallback("show_chat_button_check",
  384. onCommitCheckBoxShowButton, this);
  385. childSetCommitCallback("show_im_button_check",
  386. onCommitCheckBoxShowButton, this);
  387. childSetCommitCallback("show_friends_button_check",
  388. onCommitCheckBoxShowButton, this);
  389. childSetCommitCallback("show_group_button_check",
  390. onCommitCheckBoxShowButton, this);
  391. childSetCommitCallback("show_fly_button_check",
  392. onCommitCheckBoxShowButton, this);
  393. childSetCommitCallback("show_snapshot_button_check",
  394. onCommitCheckBoxShowButton, this);
  395. childSetCommitCallback("show_search_button_check",
  396. onCommitCheckBoxShowButton, this);
  397. childSetCommitCallback("show_build_button_check",
  398. onCommitCheckBoxShowButton, this);
  399. childSetCommitCallback("show_radar_button_check",
  400. onCommitCheckBoxShowButton, this);
  401. childSetCommitCallback("show_minimap_button_check",
  402. onCommitCheckBoxShowButton, this);
  403. childSetCommitCallback("show_map_button_check",
  404. onCommitCheckBoxShowButton, this);
  405. childSetCommitCallback("show_inventory_button_check",
  406. onCommitCheckBoxShowButton, this);
  407. childSetCommitCallback("use_old_chat_history_check",
  408. onCommitCheckBoxAfterRestart, this);
  409. childSetCommitCallback("im_tabs_vertical_stacking_check",
  410. onCommitCheckBoxAfterRestart, this);
  411. childSetCommitCallback("spell_check_check",
  412. onCommitCheckBoxSpellCheck, this);
  413. childSetCommitCallback("speed_rez_check",
  414. onCommitCheckBoxSpeedRez, this);
  415. childSetCommitCallback("num_image_decode_threads",
  416. onCommitCheckBoxAfterRestart, this);
  417. childSetCommitCallback("sun_position_at_login",
  418. onCommitSliderSunPositionAtLogin, this);
  419. childSetCommitCallback("os_terrain_map_check",
  420. onCommitCheckBoxAfterRestart, this);
  421. childSetCommitCallback("restrained_love_check",
  422. onCommitCheckBoxRestrainedLove, this);
  423. childSetCommitCallback("user_profile",
  424. onCommitUserProfile, this);
  425. childSetCommitCallback("restrained_love_no_setenv_check",
  426. onCommitCheckBoxAfterRestart, this);
  427. childSetCommitCallback("restrained_love_emotes_check",
  428. onCommitCheckBoxAfterRestart, this);
  429. childSetCommitCallback("restrained_love_can_ooc_check",
  430. onCommitCheckBoxAfterRestart, this);
  431. childSetAction("fonts_button", onClickSetFonts, this);
  432. childSetAction("dict_download_button", onClickDownloadDict, this);
  433. childSetAction("custom_profile_button", onClickCustomBlackList, this);
  434. LLLineEditor* line = getChild<LLLineEditor>("external_editor_cmd");
  435. line->setCommitOnFocusLost(true);
  436. // Examples of external editor command line for each OS:
  437. #if LL_LINUX
  438. # define EXT_EDIT "/usr/bin/gedit %s"
  439. #elif LL_DARWIN
  440. # define EXT_EDIT "/Applications/TextMate.app/Contents/Resources/mate %s"
  441. #elif LL_WINDOWS
  442. # define EXT_EDIT "\"C:\\Program Files\\Notepad++\\notepad++.exe\" %s"
  443. #endif
  444. line->setLabelArg("[CMD]", EXT_EDIT);
  445. mSunPositionLabel = getChild<LLTextBox>("sun_position_text");
  446. mSunPositionSim = mSunPositionLabel->getText();
  447. mTabContainer = getChild<LLTabContainer>("Cool Prefs");
  448. LLPanel* tab = mTabContainer->getChild<LLPanel>("User Interface");
  449. mTabContainer->setTabChangeCallback(tab, onTabChanged);
  450. mTabContainer->setTabUserData(tab, this);
  451. tab = mTabContainer->getChild<LLPanel>("Chat/IM");
  452. mTabContainer->setTabChangeCallback(tab, onTabChanged);
  453. mTabContainer->setTabUserData(tab, this);
  454. tab = mTabContainer->getChild<LLPanel>("Inventory");
  455. mTabContainer->setTabChangeCallback(tab, onTabChanged);
  456. mTabContainer->setTabUserData(tab, this);
  457. tab = mTabContainer->getChild<LLPanel>("Animations");
  458. mTabContainer->setTabChangeCallback(tab, onTabChanged);
  459. mTabContainer->setTabUserData(tab, this);
  460. tab = mTabContainer->getChild<LLPanel>("Miscellaneous");
  461. mTabContainer->setTabChangeCallback(tab, onTabChanged);
  462. mTabContainer->setTabUserData(tab, this);
  463. tab = mTabContainer->getChild<LLPanel>("RestrainedLove");
  464. mTabContainer->setTabChangeCallback(tab, onTabChanged);
  465. mTabContainer->setTabUserData(tab, this);
  466. if (!LLStartUp::isLoggedIn())
  467. {
  468. LLCheckBoxCtrl* rl = getChild<LLCheckBoxCtrl>("restrained_love_check");
  469. std::string tooltip = rl->getToolTip();
  470. tooltip += " " + getString("when_logged_in");
  471. rl->setToolTip(tooltip);
  472. }
  473. LLControlVariable* control =
  474. gSavedPerAccountSettings.getControl("UploadAnimationFolder");
  475. control->getSignal()->connect(boost::bind(&HBPrefsCoolImpl::setDirty,
  476. this));
  477. childSetAction("reset_animation_folder", onClickResetSetting, control);
  478. control = gSavedPerAccountSettings.getControl("UploadSoundFolder");
  479. control->getSignal()->connect(boost::bind(&HBPrefsCoolImpl::setDirty,
  480. this));
  481. childSetAction("reset_sound_folder", onClickResetSetting, control);
  482. control = gSavedPerAccountSettings.getControl("UploadTextureFolder");
  483. control->getSignal()->connect(boost::bind(&HBPrefsCoolImpl::setDirty,
  484. this));
  485. childSetAction("reset_texture_folder", onClickResetSetting, control);
  486. control = gSavedPerAccountSettings.getControl("UploadMaterialFolder");
  487. control->getSignal()->connect(boost::bind(&HBPrefsCoolImpl::setDirty,
  488. this));
  489. childSetAction("reset_material_folder", onClickResetSetting, control);
  490. control = gSavedPerAccountSettings.getControl("UploadModelFolder");
  491. control->getSignal()->connect(boost::bind(&HBPrefsCoolImpl::setDirty,
  492. this));
  493. childSetAction("reset_model_folder", onClickResetSetting, control);
  494. control = gSavedPerAccountSettings.getControl("NewOutfitFolder");
  495. control->getSignal()->connect(boost::bind(&HBPrefsCoolImpl::setDirty,
  496. this));
  497. childSetAction("reset_new_outfits_folder", onClickResetSetting, control);
  498. refresh();
  499. }
  500. HBPrefsCoolImpl::~HBPrefsCoolImpl()
  501. {
  502. sInstance = NULL;
  503. }
  504. void HBPrefsCoolImpl::draw()
  505. {
  506. if (mFirstRun)
  507. {
  508. mFirstRun = false;
  509. mTabContainer->selectTab(gSavedSettings.getS32("LastCoolPrefTab"));
  510. }
  511. if (mIsDirty)
  512. {
  513. // First get the list of all installed dictionaries
  514. mInstalledDicts.clear();
  515. mInstalledDicts = LLSpellCheck::getInstance()->getBaseDicts();
  516. // Then get the list of all existing dictionaries
  517. mDictsList.clear();
  518. std::string dict_list = gDirUtil.getFullPath(LL_PATH_APP_SETTINGS,
  519. "dictionaries",
  520. "dict_list.xml");
  521. llifstream inputstream(dict_list.c_str(), std::ios::binary);
  522. if (inputstream.is_open())
  523. {
  524. LLSDSerialize::fromXMLDocument(mDictsList, inputstream);
  525. inputstream.close();
  526. }
  527. if (mDictsList.size() == 0)
  528. {
  529. llwarns << "Failure to load the list of all existing dictionaries."
  530. << llendl;
  531. }
  532. bool found_one = false;
  533. std::string name = LLSpellCheck::getInstance()->getCurrentDict();
  534. std::string language;
  535. S32 selection = -1;
  536. LLComboBox* combo = getChild<LLComboBox>("installed_dicts_combo");
  537. combo->removeall();
  538. for (std::set<std::string>::iterator it = mInstalledDicts.begin();
  539. it != mInstalledDicts.end(); it++)
  540. {
  541. language = getDictLanguage(*it);
  542. if (language.empty())
  543. {
  544. language = *it;
  545. }
  546. combo->add(language);
  547. found_one = true;
  548. if (*it == name)
  549. {
  550. selection = combo->getItemCount() - 1;
  551. }
  552. }
  553. if (!found_one)
  554. {
  555. combo->add(LLStringUtil::null);
  556. }
  557. if (selection >= 0)
  558. {
  559. combo->setCurrentByIndex(selection);
  560. }
  561. found_one = false;
  562. combo = getChild<LLComboBox>("download_dict_combo");
  563. combo->removeall();
  564. for (LLSD::array_const_iterator it = mDictsList.beginArray();
  565. it != mDictsList.endArray(); it++)
  566. {
  567. const LLSD& entry = *it;
  568. name = entry["name"].asString();
  569. if (name.empty())
  570. {
  571. llwarns << "Invalid dictionary list entry: no name." << llendl;
  572. continue;
  573. }
  574. LLStringUtil::toLower(name);
  575. if (!mInstalledDicts.count(name))
  576. {
  577. language = entry["language"].asString();
  578. if (language.empty())
  579. {
  580. llwarns << "Invalid dictionary list entry. No language for: "
  581. << name << llendl;
  582. language = name;
  583. }
  584. combo->add(language);
  585. found_one = true;
  586. }
  587. }
  588. if (!found_one)
  589. {
  590. combo->add(LLStringUtil::null);
  591. }
  592. bool visible = (sQueries == 0);
  593. childSetVisible("download_dict_combo", visible);
  594. childSetVisible("dict_download_button", visible);
  595. childSetVisible("downloading", !visible);
  596. bool usable = gInventory.isInventoryUsable();
  597. if (usable)
  598. {
  599. LLLineEditor* line =
  600. getChild<LLLineEditor>("upload_folder_animation");
  601. line->setText(getCategoryPath(LLFolderType::FT_ANIMATION));
  602. line = getChild<LLLineEditor>("upload_folder_sound");
  603. line->setText(getCategoryPath(LLFolderType::FT_SOUND));
  604. line = getChild<LLLineEditor>("upload_folder_texture");
  605. line->setText(getCategoryPath(LLFolderType::FT_TEXTURE));
  606. line = getChild<LLLineEditor>("upload_material_folder");
  607. line->setText(getCategoryPath(LLFolderType::FT_MATERIAL));
  608. line = getChild<LLLineEditor>("upload_folder_model");
  609. line->setText(getCategoryPath(LLFolderType::FT_OBJECT));
  610. line = getChild<LLLineEditor>("new_outfits_folder");
  611. line->setText(getCategoryPath(LLFolderType::FT_MY_OUTFITS));
  612. }
  613. childSetEnabled("reset_animation_folder", usable);
  614. childSetEnabled("reset_sound_folder", usable);
  615. childSetEnabled("reset_texture_folder", usable);
  616. childSetEnabled("reset_material_folder", usable);
  617. childSetEnabled("reset_model_folder", usable);
  618. childSetEnabled("reset_new_outfits_folder", usable);
  619. mIsDirty = false;
  620. }
  621. if (mWatchBlackListFloater && !HBFloaterBlacklistRLV::instanceVisible())
  622. {
  623. mWatchBlackListFloater = false;
  624. updateRestrainedLoveUserProfile();
  625. }
  626. LLPanel::draw();
  627. }
  628. void HBPrefsCoolImpl::refreshRestrainedLove(bool enable)
  629. {
  630. // Enable/disable all children in the RestrainedLove panel
  631. LLPanel* panel = getChild<LLPanel>("RestrainedLove");
  632. LLView* child = panel->getFirstChild();
  633. while (child)
  634. {
  635. child->setEnabled(enable);
  636. child = panel->findNextSibling(child);
  637. }
  638. // RestrainedLove check box enabled only when logged in.
  639. childSetEnabled("restrained_love_check", LLStartUp::isLoggedIn());
  640. }
  641. void HBPrefsCoolImpl::refreshValues()
  642. {
  643. bool logged_in = LLStartUp::isLoggedIn();
  644. // User Interface
  645. mShowChatButton = gSavedSettings.getBool("ShowChatButton");
  646. mShowIMButton = gSavedSettings.getBool("ShowIMButton");
  647. mShowFriendsButton = gSavedSettings.getBool("ShowFriendsButton");
  648. mShowGroupsButton = gSavedSettings.getBool("ShowGroupsButton");
  649. mShowFlyButton = gSavedSettings.getBool("ShowFlyButton");
  650. mShowSnapshotButton = gSavedSettings.getBool("ShowSnapshotButton");
  651. mShowSearchButton = gSavedSettings.getBool("ShowSearchButton");
  652. mShowBuildButton = gSavedSettings.getBool("ShowBuildButton");
  653. mShowRadarButton = gSavedSettings.getBool("ShowRadarButton");
  654. mShowMiniMapButton = gSavedSettings.getBool("ShowMiniMapButton");
  655. mShowMapButton = gSavedSettings.getBool("ShowMapButton");
  656. mShowInventoryButton = gSavedSettings.getBool("ShowInventoryButton");
  657. mHideMasterRemote = gSavedSettings.getBool("HideMasterRemote");
  658. mFadeMouselookExitTip = gSavedSettings.getU32("FadeMouselookExitTip");
  659. mUseOldChatHistory = gSavedSettings.getBool("UseOldChatHistory");
  660. mAutoOpenTextInput = gSavedSettings.getBool("AutoOpenTextInput");
  661. mIMTabsVerticalStacking = gSavedSettings.getBool("IMTabsVerticalStacking");
  662. mUseOldStatusBarIcons = gSavedSettings.getBool("UseOldStatusBarIcons");
  663. mUseOldTrackingDots = gSavedSettings.getBool("UseOldTrackingDots");
  664. mDecimalsForTools = gSavedSettings.getU32("DecimalsForTools");
  665. mHideTeleportProgress = gSavedSettings.getBool("HideTeleportProgress");
  666. mStackMinimizedTopToBottom = gSavedSettings.getBool("StackMinimizedTopToBottom");
  667. mStackMinimizedRightToLeft = gSavedSettings.getBool("StackMinimizedRightToLeft");
  668. mStackScreenWidthFraction = gSavedSettings.getU32("StackScreenWidthFraction");
  669. // Chat, IM & Text
  670. mAllowMUpose = gSavedSettings.getBool("AllowMUpose");
  671. mAutoCloseOOC = gSavedSettings.getBool("AutoCloseOOC");
  672. mHighlightOwnNameInChat = gSavedSettings.getBool("HighlightOwnNameInChat");
  673. mHighlightOwnNameInIM = gSavedSettings.getBool("HighlightOwnNameInIM");
  674. mOwnNameChatColor = gSavedSettings.getColor4("OwnNameChatColor");
  675. if (logged_in)
  676. {
  677. mHighlightNicknames = gSavedPerAccountSettings.getString("HighlightNicknames");
  678. mHighlightDisplayName = gSavedPerAccountSettings.getBool("HighlightDisplayName");
  679. }
  680. mSpellCheck = gSavedSettings.getBool("SpellCheck");
  681. mSpellCheckShow = gSavedSettings.getBool("SpellCheckShow");
  682. mAddAvatarNamesToIgnore = gSavedSettings.getBool("AddAvatarNamesToIgnore");
  683. mSpellCheckLanguage = gSavedSettings.getString("SpellCheckLanguage");
  684. mTaskBarButtonFlashTime = gSavedSettings.getF32("TaskBarButtonFlashTime");
  685. // Inventory
  686. mRezWithLandGroup = gSavedSettings.getBool("RezWithLandGroup");
  687. mDoubleClickInventorySoundAction = gSavedSettings.getU32("DoubleClickInventorySoundAction");
  688. mNoMultipleShoes = gSavedSettings.getBool("NoMultipleShoes");
  689. mNoMultipleSkirts = gSavedSettings.getBool("NoMultipleSkirts");
  690. mNoMultiplePhysics = gSavedSettings.getBool("NoMultiplePhysics");
  691. mAutoShowInventoryThumbnails = gSavedSettings.getBool("AutoShowInventoryThumbnails");
  692. mThumbnailViewTimeout = gSavedSettings.getU32("ThumbnailViewTimeout");
  693. mOSUseCOF = gSavedSettings.getBool("OSUseCOF");
  694. // Miscellaneous
  695. mAllowMultipleViewers = gSavedSettings.getBool("AllowMultipleViewers");
  696. mBackgroundYieldTime = gSavedSettings.getU32("BackgroundYieldTime");
  697. mFrameRateLimit = gSavedSettings.getU32("FrameRateLimit");
  698. mSpeedRez = gSavedSettings.getBool("SpeedRez");
  699. mSpeedRezInterval = gSavedSettings.getU32("SpeedRezInterval");
  700. mNumImageDecodeThreads = gSavedSettings.getU32("NumImageDecodeThreads");
  701. mFetchBoostAfterTPDuration = gSavedSettings.getU32("TextureFetchBoostTimeAfterTP");
  702. mPreviewAnimInWorld = gSavedSettings.getBool("PreviewAnimInWorld");
  703. mAppearanceAnimation = gSavedSettings.getBool("AppearanceAnimation");
  704. mRevokePermsOnStandUp = gSavedSettings.getBool("RevokePermsOnStandUp");
  705. mRevokePermsOnStopAnimation = gSavedSettings.getBool("RevokePermsOnStopAnimation");
  706. mResetAnimOverrideOnStopAnimation = gSavedSettings.getBool("ResetAnimOverrideOnStopAnimation");
  707. mTurnTowardsSelectedObject = gSavedSettings.getBool("TurnTowardsSelectedObject");
  708. mPlayDefaultBentoAnimation = gSavedSettings.getBool("PlayDefaultBentoAnimation");
  709. mTeleportHistoryDeparture = gSavedSettings.getBool("TeleportHistoryDeparture");
  710. mMuteListIgnoreServer = gSavedSettings.getBool("MuteListIgnoreServer");
  711. mSunPositionAtLogin = gSavedSettings.getF32("SunPositionAtLogin");
  712. mRenderBanWallAlways = gSavedSettings.getBool("RenderBanWallAlways");
  713. mRenderBanWallMaxDist = gSavedSettings.getU32("RenderBanWallMaxDist");
  714. mExternalEditor = gSavedSettings.getString("ExternalEditor");
  715. mOSAllowBakeOnMeshUploads = gSavedSettings.getBool("OSAllowBakeOnMeshUploads");
  716. mOSWorldMapHasTerrain = gSavedSettings.getBool("OSWorldMapHasTerrain");
  717. // RestrainedLove
  718. mRestrainedLove = gSavedSettings.getBool("RestrainedLove");
  719. mRestrainedLoveBlacklist = gSavedSettings.getString("RestrainedLoveBlacklist");
  720. mRestrainedLoveNoSetEnv = gSavedSettings.getBool("RestrainedLoveNoSetEnv");
  721. mRestrainedLoveAllowWear = gSavedSettings.getBool("RestrainedLoveAllowWear");
  722. mRestrainedLoveReattachDelay = gSavedSettings.getU32("RestrainedLoveReattachDelay");
  723. mRestrainedLoveForbidGiveToRLV = gSavedSettings.getBool("RestrainedLoveForbidGiveToRLV");
  724. mRestrainedLoveShowEllipsis = gSavedSettings.getBool("RestrainedLoveShowEllipsis");
  725. mRestrainedLoveUntruncatedEmotes = gSavedSettings.getBool("RestrainedLoveUntruncatedEmotes");
  726. mRestrainedLoveCanOoc = gSavedSettings.getBool("RestrainedLoveCanOoc");
  727. if (logged_in)
  728. {
  729. mRestrainedLoveRecvimMessage = gSavedPerAccountSettings.getString("RestrainedLoveRecvimMessage");
  730. mRestrainedLoveSendimMessage = gSavedPerAccountSettings.getString("RestrainedLoveSendimMessage");
  731. }
  732. }
  733. void HBPrefsCoolImpl::updateRestrainedLoveUserProfile()
  734. {
  735. std::string blacklist = gSavedSettings.getString("RestrainedLoveBlacklist");
  736. if (blacklist.empty())
  737. {
  738. mRestrainedLoveUserProfile = 0;
  739. }
  740. else if (blacklist == RLInterface::sRolePlayBlackList)
  741. {
  742. mRestrainedLoveUserProfile = 1;
  743. }
  744. else if (blacklist == RLInterface::sVanillaBlackList)
  745. {
  746. mRestrainedLoveUserProfile = 2;
  747. }
  748. else
  749. {
  750. mRestrainedLoveUserProfile = 3;
  751. }
  752. LLRadioGroup* radio = getChild<LLRadioGroup>("user_profile");
  753. radio->selectNthItem(mRestrainedLoveUserProfile);
  754. }
  755. void HBPrefsCoolImpl::setSunPositionLabel(F32 value)
  756. {
  757. if (value < 0.f)
  758. {
  759. mSunPositionLabel->setText(mSunPositionSim);
  760. }
  761. else
  762. {
  763. F32 time = 24.f * value;
  764. U32 hours = (U32)time;
  765. U32 minutes = (U32)((time - (F32)hours) * 60.f);
  766. mSunPositionLabel->setText(llformat("%02d:%02d", hours, minutes));
  767. }
  768. }
  769. void HBPrefsCoolImpl::refresh()
  770. {
  771. refreshValues();
  772. // User Interface
  773. std::string format = gSavedSettings.getString("ShortTimeFormat");
  774. if (format.find("%p") == std::string::npos)
  775. {
  776. mTimeFormat = 0;
  777. }
  778. else
  779. {
  780. mTimeFormat = 1;
  781. }
  782. format = gSavedSettings.getString("ShortDateFormat");
  783. if (format.find("%m/%d/%") != std::string::npos)
  784. {
  785. mDateFormat = 2;
  786. }
  787. else if (format.find("%d/%m/%") != std::string::npos)
  788. {
  789. mDateFormat = 1;
  790. }
  791. else
  792. {
  793. mDateFormat = 0;
  794. }
  795. // time format combobox
  796. LLComboBox* combo = getChild<LLComboBox>("time_format_combobox");
  797. if (combo)
  798. {
  799. combo->setCurrentByIndex(mTimeFormat);
  800. }
  801. // date format combobox
  802. combo = getChild<LLComboBox>("date_format_combobox");
  803. if (combo)
  804. {
  805. combo->setCurrentByIndex(mDateFormat);
  806. }
  807. bool logged_in = LLStartUp::isLoggedIn();
  808. if (logged_in)
  809. {
  810. childSetValue("highlight_nicknames_text", mHighlightNicknames);
  811. childSetValue("highlight_display_name_check", mHighlightDisplayName);
  812. }
  813. else
  814. {
  815. childDisable("highlight_nicknames_text");
  816. childDisable("highlight_display_name_check");
  817. }
  818. // Spell checking
  819. childSetEnabled("spell_check_show_check", mSpellCheck);
  820. childSetEnabled("add_avatar_names_to_ignore_check", mSpellCheck);
  821. childSetEnabled("installed_dicts_combo", mSpellCheck);
  822. childSetEnabled("download_dict_combo", mSpellCheck);
  823. childSetEnabled("dict_download_button", mSpellCheck);
  824. // Miscellaneous
  825. childSetEnabled("speed_rez_interval", mSpeedRez);
  826. childSetEnabled("speed_rez_seconds", mSpeedRez);
  827. setSunPositionLabel(mSunPositionAtLogin);
  828. // RestrainedLove
  829. refreshRestrainedLove(mRestrainedLove);
  830. updateRestrainedLoveUserProfile();
  831. if (logged_in)
  832. {
  833. LLWString message = utf8str_to_wstring(gSavedPerAccountSettings.getString("RestrainedLoveRecvimMessage"));
  834. LLWStringUtil::replaceChar(message, '^', '\n');
  835. childSetText("receive_im_message_editor", wstring_to_utf8str(message));
  836. message = utf8str_to_wstring(gSavedPerAccountSettings.getString("RestrainedLoveSendimMessage"));
  837. LLWStringUtil::replaceChar(message, '^', '\n');
  838. childSetText("send_im_message_editor", wstring_to_utf8str(message));
  839. }
  840. else
  841. {
  842. std::string text = getString("when_logged_in");
  843. childSetText("receive_im_message_editor", text);
  844. childDisable("receive_im_message_editor");
  845. childSetText("send_im_message_editor", text);
  846. childDisable("send_im_message_editor");
  847. }
  848. }
  849. void HBPrefsCoolImpl::cancel()
  850. {
  851. bool logged_in = LLStartUp::isLoggedIn();
  852. // User Interface
  853. gSavedSettings.setBool("ShowChatButton", mShowChatButton);
  854. gSavedSettings.setBool("ShowIMButton", mShowIMButton);
  855. gSavedSettings.setBool("ShowFriendsButton", mShowFriendsButton);
  856. gSavedSettings.setBool("ShowGroupsButton", mShowGroupsButton);
  857. gSavedSettings.setBool("ShowFlyButton", mShowFlyButton);
  858. gSavedSettings.setBool("ShowSnapshotButton", mShowSnapshotButton);
  859. gSavedSettings.setBool("ShowSearchButton", mShowSearchButton);
  860. gSavedSettings.setBool("ShowBuildButton", mShowBuildButton);
  861. gSavedSettings.setBool("ShowRadarButton", mShowRadarButton);
  862. gSavedSettings.setBool("ShowMiniMapButton", mShowMiniMapButton);
  863. gSavedSettings.setBool("ShowMapButton", mShowMapButton);
  864. gSavedSettings.setBool("ShowInventoryButton", mShowInventoryButton);
  865. gSavedSettings.setBool("HideMasterRemote", mHideMasterRemote);
  866. gSavedSettings.setU32("FadeMouselookExitTip", mFadeMouselookExitTip);
  867. gSavedSettings.setBool("UseOldChatHistory", mUseOldChatHistory);
  868. gSavedSettings.setBool("AutoOpenTextInput", mAutoOpenTextInput);
  869. gSavedSettings.setBool("IMTabsVerticalStacking", mIMTabsVerticalStacking);
  870. gSavedSettings.setBool("UseOldStatusBarIcons", mUseOldStatusBarIcons);
  871. gSavedSettings.setBool("UseOldTrackingDots", mUseOldTrackingDots);
  872. gSavedSettings.setU32("DecimalsForTools", mDecimalsForTools);
  873. gSavedSettings.setBool("HideTeleportProgress", mHideTeleportProgress);
  874. gSavedSettings.setBool("StackMinimizedTopToBottom", mStackMinimizedTopToBottom);
  875. gSavedSettings.setBool("StackMinimizedRightToLeft", mStackMinimizedRightToLeft);
  876. gSavedSettings.setU32("StackScreenWidthFraction", mStackScreenWidthFraction);
  877. // Chat, IM & Text
  878. gSavedSettings.setBool("AllowMUpose", mAllowMUpose);
  879. gSavedSettings.setBool("AutoCloseOOC", mAutoCloseOOC);
  880. gSavedSettings.setBool("HighlightOwnNameInChat", mHighlightOwnNameInChat);
  881. gSavedSettings.setBool("HighlightOwnNameInIM", mHighlightOwnNameInIM);
  882. gSavedSettings.setColor4("OwnNameChatColor", mOwnNameChatColor);
  883. if (logged_in)
  884. {
  885. gSavedPerAccountSettings.setString("HighlightNicknames", mHighlightNicknames);
  886. gSavedPerAccountSettings.setBool("HighlightDisplayName", mHighlightDisplayName);
  887. }
  888. gSavedSettings.setBool("SpellCheck", mSpellCheck);
  889. gSavedSettings.setBool("SpellCheckShow", mSpellCheckShow);
  890. gSavedSettings.setBool("AddAvatarNamesToIgnore", mAddAvatarNamesToIgnore);
  891. gSavedSettings.setString("SpellCheckLanguage", mSpellCheckLanguage);
  892. gSavedSettings.setF32("TaskBarButtonFlashTime", mTaskBarButtonFlashTime);
  893. // Inventory
  894. gSavedSettings.setBool("RezWithLandGroup", mRezWithLandGroup);
  895. gSavedSettings.setU32("DoubleClickInventorySoundAction", mDoubleClickInventorySoundAction);
  896. gSavedSettings.setBool("NoMultipleShoes", mNoMultipleShoes);
  897. gSavedSettings.setBool("NoMultipleSkirts", mNoMultipleSkirts);
  898. gSavedSettings.setBool("NoMultiplePhysics", mNoMultiplePhysics);
  899. gSavedSettings.setBool("AutoShowInventoryThumbnails", mAutoShowInventoryThumbnails);
  900. gSavedSettings.setU32("ThumbnailViewTimeout", mThumbnailViewTimeout);
  901. gSavedSettings.setBool("OSUseCOF", mOSUseCOF);
  902. // Miscellaneous
  903. gSavedSettings.setBool("AllowMultipleViewers", mAllowMultipleViewers);
  904. gSavedSettings.setU32("BackgroundYieldTime", mBackgroundYieldTime);
  905. gSavedSettings.setU32("FrameRateLimit", mFrameRateLimit);
  906. gSavedSettings.setBool("SpeedRez", mSpeedRez);
  907. gSavedSettings.setU32("SpeedRezInterval", mSpeedRezInterval);
  908. gSavedSettings.setU32("NumImageDecodeThreads", mNumImageDecodeThreads);
  909. gSavedSettings.setU32("TextureFetchBoostTimeAfterTP", mFetchBoostAfterTPDuration);
  910. gSavedSettings.setBool("PreviewAnimInWorld", mPreviewAnimInWorld);
  911. gSavedSettings.setBool("AppearanceAnimation", mAppearanceAnimation);
  912. gSavedSettings.setBool("RevokePermsOnStandUp", mRevokePermsOnStandUp);
  913. gSavedSettings.setBool("RevokePermsOnStopAnimation", mRevokePermsOnStopAnimation);
  914. gSavedSettings.setBool("ResetAnimOverrideOnStopAnimation", mResetAnimOverrideOnStopAnimation);
  915. gSavedSettings.setBool("TurnTowardsSelectedObject", mTurnTowardsSelectedObject);
  916. gSavedSettings.setBool("PlayDefaultBentoAnimation", mPlayDefaultBentoAnimation);
  917. gSavedSettings.setBool("TeleportHistoryDeparture", mTeleportHistoryDeparture);
  918. gSavedSettings.setBool("MuteListIgnoreServer", mMuteListIgnoreServer);
  919. gSavedSettings.setF32("SunPositionAtLogin", mSunPositionAtLogin);
  920. gSavedSettings.setBool("RenderBanWallAlways", mRenderBanWallAlways);
  921. gSavedSettings.setU32("RenderBanWallMaxDist", mRenderBanWallMaxDist);
  922. gSavedSettings.setString("ExternalEditor", mExternalEditor);
  923. gSavedSettings.setBool("OSAllowBakeOnMeshUploads", mOSAllowBakeOnMeshUploads);
  924. gSavedSettings.setBool("OSWorldMapHasTerrain", mOSWorldMapHasTerrain);
  925. // RestrainedLove
  926. gSavedSettings.setBool("RestrainedLove", mRestrainedLove);
  927. gSavedSettings.setString("RestrainedLoveBlacklist", mRestrainedLoveBlacklist);
  928. gSavedSettings.setBool("RestrainedLoveNoSetEnv", mRestrainedLoveNoSetEnv);
  929. gSavedSettings.setBool("RestrainedLoveAllowWear", mRestrainedLoveAllowWear);
  930. gSavedSettings.setU32("RestrainedLoveReattachDelay", mRestrainedLoveReattachDelay);
  931. gSavedSettings.setBool("RestrainedLoveForbidGiveToRLV", mRestrainedLoveForbidGiveToRLV);
  932. gSavedSettings.setBool("RestrainedLoveShowEllipsis", mRestrainedLoveShowEllipsis);
  933. gSavedSettings.setBool("RestrainedLoveUntruncatedEmotes", mRestrainedLoveUntruncatedEmotes);
  934. gSavedSettings.setBool("RestrainedLoveCanOoc", mRestrainedLoveCanOoc);
  935. if (logged_in)
  936. {
  937. gSavedPerAccountSettings.setString("RestrainedLoveRecvimMessage",
  938. mRestrainedLoveRecvimMessage);
  939. gSavedPerAccountSettings.setString("RestrainedLoveSendimMessage",
  940. mRestrainedLoveSendimMessage);
  941. }
  942. }
  943. void HBPrefsCoolImpl::apply()
  944. {
  945. // User Interface
  946. std::string short_date, long_date, short_time, long_time, timestamp;
  947. LLComboBox* combo = getChild<LLComboBox>("time_format_combobox");
  948. if (combo)
  949. {
  950. mTimeFormat = combo->getCurrentIndex();
  951. }
  952. combo = getChild<LLComboBox>("date_format_combobox");
  953. if (combo)
  954. {
  955. mDateFormat = combo->getCurrentIndex();
  956. }
  957. if (mTimeFormat == 0)
  958. {
  959. short_time = "%H:%M";
  960. long_time = "%H:%M:%S";
  961. timestamp = " %H:%M:%S";
  962. }
  963. else
  964. {
  965. short_time = "%I:%M %p";
  966. long_time = "%I:%M:%S %p";
  967. timestamp = " %I:%M %p";
  968. }
  969. if (mDateFormat == 0)
  970. {
  971. short_date = "%Y-%m-%d";
  972. long_date = "%A %d %B %Y";
  973. timestamp = "%a %d %b %Y" + timestamp;
  974. }
  975. else if (mDateFormat == 1)
  976. {
  977. short_date = "%d/%m/%Y";
  978. long_date = "%A %d %B %Y";
  979. timestamp = "%a %d %b %Y" + timestamp;
  980. }
  981. else
  982. {
  983. short_date = "%m/%d/%Y";
  984. long_date = "%A, %B %d %Y";
  985. timestamp = "%a %b %d %Y" + timestamp;
  986. }
  987. gSavedSettings.setString("ShortDateFormat", short_date);
  988. gSavedSettings.setString("LongDateFormat", long_date);
  989. gSavedSettings.setString("ShortTimeFormat", short_time);
  990. gSavedSettings.setString("LongTimeFormat", long_time);
  991. gSavedSettings.setString("TimestampFormat", timestamp);
  992. // Chat, IM & Text
  993. combo = getChild<LLComboBox>("installed_dicts_combo");
  994. std::string dict_name = getDictName(combo->getSelectedItemLabel());
  995. if (!dict_name.empty())
  996. {
  997. gSavedSettings.setString("SpellCheckLanguage", dict_name);
  998. }
  999. if (LLStartUp::isLoggedIn())
  1000. {
  1001. gSavedPerAccountSettings.setString("HighlightNicknames",
  1002. childGetValue("highlight_nicknames_text"));
  1003. gSavedPerAccountSettings.setBool("HighlightDisplayName",
  1004. childGetValue("highlight_display_name_check"));
  1005. // RestrainedLove
  1006. LLTextEditor* text = getChild<LLTextEditor>("receive_im_message_editor");
  1007. LLWString message = text->getWText();
  1008. LLWStringUtil::replaceTabsWithSpaces(message, 4);
  1009. LLWStringUtil::replaceChar(message, '\n', '^');
  1010. gSavedPerAccountSettings.setString("RestrainedLoveRecvimMessage",
  1011. std::string(wstring_to_utf8str(message)));
  1012. text = getChild<LLTextEditor>("send_im_message_editor");
  1013. message = text->getWText();
  1014. LLWStringUtil::replaceTabsWithSpaces(message, 4);
  1015. LLWStringUtil::replaceChar(message, '\n', '^');
  1016. gSavedPerAccountSettings.setString("RestrainedLoveSendimMessage",
  1017. std::string(wstring_to_utf8str(message)));
  1018. }
  1019. refreshValues();
  1020. }
  1021. std::string HBPrefsCoolImpl::getDictName(const std::string& language)
  1022. {
  1023. std::string result;
  1024. for (LLSD::array_const_iterator it = mDictsList.beginArray();
  1025. it != mDictsList.endArray(); it++)
  1026. {
  1027. const LLSD& entry = *it;
  1028. if (entry["language"].asString() == language)
  1029. {
  1030. result = entry["name"].asString();
  1031. break;
  1032. }
  1033. }
  1034. return result;
  1035. }
  1036. std::string HBPrefsCoolImpl::getDictLanguage(const std::string& name)
  1037. {
  1038. std::string result;
  1039. for (LLSD::array_const_iterator it = mDictsList.beginArray();
  1040. it != mDictsList.endArray(); it++)
  1041. {
  1042. const LLSD& entry = *it;
  1043. if (entry["name"].asString() == name)
  1044. {
  1045. result = entry["language"].asString();
  1046. break;
  1047. }
  1048. }
  1049. return result;
  1050. }
  1051. std::string HBPrefsCoolImpl::getCategoryPath(const LLUUID& cat_id)
  1052. {
  1053. LLViewerInventoryCategory* cat = gInventory.getCategory(cat_id);
  1054. if (!cat)
  1055. {
  1056. llwarns_once << "Could not find category for Id: " << cat_id << llendl;
  1057. return "";
  1058. }
  1059. const LLUUID& parent_id = cat->getParentUUID();
  1060. if (parent_id.notNull())
  1061. {
  1062. // Should be " \u25ba ", buy M$' Visual Shit does not accept it...
  1063. static const std::string separator(" \xE2\x96\xBA ");
  1064. return getCategoryPath(parent_id) + separator + cat->getName();
  1065. }
  1066. return cat->getName();
  1067. }
  1068. std::string HBPrefsCoolImpl::getCategoryPath(LLFolderType::EType cat_type)
  1069. {
  1070. LLUUID cat_id = gInventory.findChoosenCategoryUUIDForType(cat_type);
  1071. return getCategoryPath(cat_id);
  1072. }
  1073. //static
  1074. void HBPrefsCoolImpl::onTabChanged(void* user_data, bool)
  1075. {
  1076. HBPrefsCoolImpl* self = (HBPrefsCoolImpl*)user_data;
  1077. if (self && self->mTabContainer)
  1078. {
  1079. gSavedSettings.setS32("LastCoolPrefTab",
  1080. self->mTabContainer->getCurrentPanelIndex());
  1081. }
  1082. }
  1083. //static
  1084. void HBPrefsCoolImpl::setQueryActive(bool active)
  1085. {
  1086. if (active)
  1087. {
  1088. ++sQueries;
  1089. }
  1090. else
  1091. {
  1092. if (--sQueries < 0)
  1093. {
  1094. llwarns << "Lost the count of the dictionary download queries !"
  1095. << llendl;
  1096. sQueries = 0;
  1097. }
  1098. if (sQueries == 0)
  1099. {
  1100. gNotifications.add("DownloadDictFinished");
  1101. }
  1102. }
  1103. if (HBPrefsCoolImpl::getInstance())
  1104. {
  1105. HBPrefsCoolImpl::getInstance()->setDirty();
  1106. }
  1107. }
  1108. //static
  1109. void HBPrefsCoolImpl::onCommitCheckBoxAfterRestart(LLUICtrl* ctrl,
  1110. void* user_data)
  1111. {
  1112. HBPrefsCoolImpl* self = (HBPrefsCoolImpl*)user_data;
  1113. LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
  1114. if (!self || !check) return;
  1115. std::string control = check->getControlName();
  1116. if (!self->mWarnedAfterRestart.count(control))
  1117. {
  1118. self->mWarnedAfterRestart.emplace(control);
  1119. gNotifications.add("InEffectAfterRestart");
  1120. }
  1121. }
  1122. //static
  1123. void HBPrefsCoolImpl::onCommitCheckBoxShowButton(LLUICtrl* ctrl,
  1124. void* user_data)
  1125. {
  1126. HBPrefsCoolImpl* self = (HBPrefsCoolImpl*)user_data;
  1127. LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
  1128. if (!self || !check) return;
  1129. bool enabled = check->get();
  1130. if (enabled && !gSavedSettings.getBool("ShowToolBar"))
  1131. {
  1132. gSavedSettings.setBool("ShowToolBar", true);
  1133. }
  1134. }
  1135. //static
  1136. void HBPrefsCoolImpl::onCommitCheckBoxSpellCheck(LLUICtrl* ctrl,
  1137. void* user_data)
  1138. {
  1139. HBPrefsCoolImpl* self = (HBPrefsCoolImpl*)user_data;
  1140. LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
  1141. if (!self || !check) return;
  1142. bool enabled = check->get();
  1143. self->childSetEnabled("spell_check_show_check", enabled);
  1144. self->childSetEnabled("add_avatar_names_to_ignore_check", enabled);
  1145. self->childSetEnabled("installed_dicts_combo", enabled);
  1146. self->childSetEnabled("download_dict_combo", enabled);
  1147. self->childSetEnabled("dict_download_button", enabled);
  1148. }
  1149. //static
  1150. void HBPrefsCoolImpl::onClickSetFonts(void* user_data)
  1151. {
  1152. HBPrefFonts::showInstance();
  1153. }
  1154. //static
  1155. void HBPrefsCoolImpl::onClickDownloadDict(void* user_data)
  1156. {
  1157. HBPrefsCoolImpl* self = (HBPrefsCoolImpl*)user_data;
  1158. if (self)
  1159. {
  1160. LLComboBox* combo = self->getChild<LLComboBox>("download_dict_combo");
  1161. if (combo)
  1162. {
  1163. std::string label = combo->getSelectedItemLabel();
  1164. if (!label.empty())
  1165. {
  1166. std::string dict_name = self->getDictName(label);
  1167. gCoros.launch("HBPrefsCoolImpl::fetchDictionaryCoro(aff)",
  1168. boost::bind(&HBPrefsCoolImpl::fetchDictionaryCoro,
  1169. dict_name + ".aff"));
  1170. gCoros.launch("HBPrefsCoolImpl::fetchDictionaryCoro(dic)",
  1171. boost::bind(&HBPrefsCoolImpl::fetchDictionaryCoro,
  1172. dict_name + ".dic"));
  1173. }
  1174. }
  1175. }
  1176. }
  1177. //static
  1178. void HBPrefsCoolImpl::fetchDictionaryCoro(std::string dictname)
  1179. {
  1180. std::string url = gSavedSettings.getString("SpellCheckDictDownloadURL");
  1181. url += dictname;
  1182. setQueryActive(true);
  1183. llinfos << "Fetching dictionary file from: " << url << llendl;
  1184. LLCoreHttpUtil::HttpCoroutineAdapter adapter("fetchDictionaryCoro");
  1185. LLSD result = adapter.getRawAndSuspend(url);
  1186. setQueryActive(false);
  1187. LLSD args;
  1188. args["NAME"] = dictname;
  1189. LLCore::HttpStatus status =
  1190. LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(result);
  1191. if (!status)
  1192. {
  1193. args["STATUS"] = llformat("%d", status.getType());
  1194. args["REASON"] = status.toString();
  1195. gNotifications.add("DownloadDictFailure", args);
  1196. return;
  1197. }
  1198. const LLSD::Binary& raw =
  1199. result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_RAW].asBinary();
  1200. S32 size = raw.size();
  1201. if (size <= 0)
  1202. {
  1203. gNotifications.add("DownloadDictEmpty", args);
  1204. return;
  1205. }
  1206. std::string filename = gDirUtil.getFullPath(LL_PATH_USER_SETTINGS,
  1207. "dictionaries",
  1208. dictname.c_str());
  1209. LLFile output(filename, "wb");
  1210. if (!output || output.write(raw.data(), size) != size)
  1211. {
  1212. gNotifications.add("DictWriteFailure", args);
  1213. }
  1214. }
  1215. //static
  1216. void HBPrefsCoolImpl::onCommitCheckBoxSpeedRez(LLUICtrl* ctrl, void* user_data)
  1217. {
  1218. HBPrefsCoolImpl* self = (HBPrefsCoolImpl*)user_data;
  1219. LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
  1220. if (!self || !check) return;
  1221. bool enabled = check->get();
  1222. self->childSetEnabled("speed_rez_interval", enabled);
  1223. self->childSetEnabled("speed_rez_seconds", enabled);
  1224. }
  1225. //static
  1226. void HBPrefsCoolImpl::onCommitSliderSunPositionAtLogin(LLUICtrl* ctrl,
  1227. void* user_data)
  1228. {
  1229. HBPrefsCoolImpl* self = (HBPrefsCoolImpl*)user_data;
  1230. LLSliderCtrl* slider = (LLSliderCtrl*)ctrl;
  1231. if (!self || !slider) return;
  1232. F32 value = slider->getValueF32();
  1233. self->setSunPositionLabel(value);
  1234. if (!LLStartUp::isLoggedIn())
  1235. {
  1236. return;
  1237. }
  1238. gSavedSettings.setBool("UseParcelEnvironment", false);
  1239. gEnvironment.setLocalEnvFromDefaultWindlightDay(value);
  1240. }
  1241. //static
  1242. void HBPrefsCoolImpl::onCommitCheckBoxRestrainedLove(LLUICtrl* ctrl,
  1243. void* user_data)
  1244. {
  1245. HBPrefsCoolImpl* self = (HBPrefsCoolImpl*)user_data;
  1246. LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
  1247. if (!self || !check) return;
  1248. bool enable = check->get();
  1249. self->refreshRestrainedLove(enable);
  1250. if ((bool)self->mRestrainedLove != enable)
  1251. {
  1252. gNotifications.add("InEffectAfterRestart");
  1253. }
  1254. }
  1255. //static
  1256. void HBPrefsCoolImpl::onCommitUserProfile(LLUICtrl* ctrl, void* user_data)
  1257. {
  1258. HBPrefsCoolImpl* self = (HBPrefsCoolImpl*)user_data;
  1259. LLRadioGroup* radio = (LLRadioGroup*)ctrl;
  1260. if (!self || !radio) return;
  1261. std::string blacklist;
  1262. S32 profile = radio->getSelectedIndex();
  1263. switch (profile)
  1264. {
  1265. case 0:
  1266. blacklist.clear();
  1267. break;
  1268. case 1:
  1269. blacklist = RLInterface::sRolePlayBlackList;
  1270. break;
  1271. case 2:
  1272. blacklist = RLInterface::sVanillaBlackList;
  1273. break;
  1274. default:
  1275. blacklist = gSavedSettings.getString("RestrainedLoveBlacklist");
  1276. }
  1277. gSavedSettings.setString("RestrainedLoveBlacklist", blacklist);
  1278. if (self->mRestrainedLoveUserProfile != profile)
  1279. {
  1280. gNotifications.add("InEffectAfterRestart");
  1281. }
  1282. self->mRestrainedLoveUserProfile = profile;
  1283. }
  1284. //static
  1285. void HBPrefsCoolImpl::onClickCustomBlackList(void* user_data)
  1286. {
  1287. HBPrefsCoolImpl* self = (HBPrefsCoolImpl*)user_data;
  1288. if (self)
  1289. {
  1290. HBFloaterBlacklistRLV::showInstance();
  1291. self->mWatchBlackListFloater = true;
  1292. }
  1293. }
  1294. //static
  1295. void HBPrefsCoolImpl::onClickResetSetting(void* user_data)
  1296. {
  1297. LLControlVariable* control = (LLControlVariable*)user_data;
  1298. if (control)
  1299. {
  1300. control->resetToDefault(true);
  1301. }
  1302. }
  1303. ///////////////////////////////////////////////////////////////////////////////
  1304. // HBPrefsCool class proper
  1305. ///////////////////////////////////////////////////////////////////////////////
  1306. HBPrefsCool::HBPrefsCool()
  1307. : impl(*new HBPrefsCoolImpl())
  1308. {
  1309. }
  1310. HBPrefsCool::~HBPrefsCool()
  1311. {
  1312. delete &impl;
  1313. }
  1314. void HBPrefsCool::apply()
  1315. {
  1316. HBFloaterBlacklistRLV::hideInstance(); // Actually a closing
  1317. impl.apply();
  1318. }
  1319. void HBPrefsCool::cancel()
  1320. {
  1321. HBFloaterBlacklistRLV::hideInstance(); // Actually a closing
  1322. impl.cancel();
  1323. }
  1324. LLPanel* HBPrefsCool::getPanel()
  1325. {
  1326. return &impl;
  1327. }