12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490 |
- /**
- * @file hbprefscool.cpp
- * @author Henri Beauchamp
- * @brief Cool VL Viewer preferences panel
- *
- * $LicenseInfo:firstyear=2008&license=viewergpl$
- *
- * Copyright (c) 2008, Henri Beauchamp.
- *
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- *
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
- *
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- *
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
- #include "llviewerprecompiledheaders.h"
- #include "hbprefscool.h"
- #include "llcheckboxctrl.h"
- #include "llcombobox.h"
- #include "llcolorswatch.h"
- #include "llcorehttputil.h"
- #include "lldir.h"
- #include "llnotifications.h"
- #include "llradiogroup.h"
- #include "llsdserialize.h"
- #include "llsliderctrl.h"
- #include "llspellcheck.h"
- #include "lltabcontainer.h"
- #include "lltextbox.h"
- #include "lltexteditor.h"
- #include "lluictrlfactory.h"
- #include "llenvironment.h"
- #include "hbfloaterrlv.h"
- #include "llinventorymodel.h"
- #include "llpreviewnotecard.h"
- #include "llpreviewscript.h"
- #include "mkrlinterface.h"
- #include "llstartup.h"
- #include "llviewercontrol.h"
- #include "llvoavatarself.h"
- ///////////////////////////////////////////////////////////////////////////////
- // HBPrefFonts class
- // A small floater to select fonts for the note cards and script editor.
- ///////////////////////////////////////////////////////////////////////////////
- class HBPrefFonts final : public LLFloater,
- public LLFloaterSingleton<HBPrefFonts>
- {
- friend class LLUISingleton<HBPrefFonts, VisibilityPolicy<LLFloater> >;
- protected:
- LOG_CLASS(HBPrefFonts);
- private:
- // Open only via LLFloaterSingleton interface, i.e. showInstance() or
- // toggleInstance().
- HBPrefFonts(const LLSD&);
- ~HBPrefFonts() override;
- bool postBuild() override;
- std::string getFontName(bool script_font);
- static void onCancelButton(void* datap);
- static void onApplyButton(void* datap);
- static void onCommitCombo(LLUICtrl* ctrlp, void* datap);
- private:
- LLTextBox* mNoteCardFont;
- LLTextBox* mScriptFont;
- LLComboBox* mNotecardFontCombo;
- LLComboBox* mNotecardSizeCombo;
- LLComboBox* mScriptFontCombo;
- LLComboBox* mScriptSizeCombo;
- std::string mNoteCardFontName;
- std::string mScriptFontName;
- };
- HBPrefFonts::HBPrefFonts(const LLSD&)
- : mNoteCardFontName(gSavedSettings.getString("NotecardEditorFont")),
- mScriptFontName(gSavedSettings.getString("ScriptEditorFont"))
- {
- LLUICtrlFactory::getInstance()->buildFloater(this,
- "floater_preferences_fonts.xml");
- center();
- }
- HBPrefFonts::~HBPrefFonts()
- {
- gSavedSettings.setString("NotecardEditorFont", mNoteCardFontName);
- gSavedSettings.setString("ScriptEditorFont", mScriptFontName);
- }
- //virtual
- bool HBPrefFonts::postBuild()
- {
- mNoteCardFont = getChild<LLTextBox>("notecard_font");
- mScriptFont = getChild<LLTextBox>("script_font");
- mNotecardFontCombo = getChild<LLComboBox>("notecard_fonts_combo");
- mNotecardSizeCombo = getChild<LLComboBox>("notecard_sizes_combo");
- mScriptFontCombo = getChild<LLComboBox>("script_fonts_combo");
- mScriptSizeCombo = getChild<LLComboBox>("script_sizes_combo");
- LLFontGL* fontp = LLPreviewScript::getCustomFont();
- if (fontp)
- {
- const LLFontDescriptor& desc = fontp->getFontDesc();
- mScriptFontCombo->setValue(desc.getName());
- mScriptSizeCombo->setValue(desc.getSize());
- mScriptFont->setFont(fontp);
- }
- else
- {
- mScriptSizeCombo->setValue("Small");
- mScriptSizeCombo->setEnabled(false);
- }
- fontp = LLPreviewNotecard::getCustomFont();
- if (fontp)
- {
- const LLFontDescriptor& desc = fontp->getFontDesc();
- mNotecardFontCombo->setValue(desc.getName());
- mNotecardSizeCombo->setValue(desc.getSize());
- mNoteCardFont->setFont(fontp);
- }
- else
- {
- mNotecardSizeCombo->setValue("Medium");
- mNotecardSizeCombo->setEnabled(false);
- }
- mNotecardFontCombo->setCommitCallback(onCommitCombo);
- mNotecardFontCombo->setCallbackUserData(this);
- mNotecardSizeCombo->setCommitCallback(onCommitCombo);
- mNotecardSizeCombo->setCallbackUserData(this);
- mScriptFontCombo->setCommitCallback(onCommitCombo);
- mScriptFontCombo->setCallbackUserData(this);
- mScriptSizeCombo->setCommitCallback(onCommitCombo);
- mScriptSizeCombo->setCallbackUserData(this);
- childSetAction("cancel_btn", onCancelButton, this);
- childSetAction("apply_btn", onApplyButton, this);
- return true;
- }
- std::string HBPrefFonts::getFontName(bool script_font)
- {
- LLComboBox* name_combo;
- LLComboBox* size_combo;
- if (script_font)
- {
- name_combo = mScriptFontCombo;
- size_combo = mScriptSizeCombo;
- }
- else
- {
- name_combo = mNotecardFontCombo;
- size_combo = mNotecardSizeCombo;
- }
- std::string font = name_combo->getValue().asString();
- if (font == "Default")
- {
- return "";
- }
- return font + size_combo->getValue().asString();
- }
- //static
- void HBPrefFonts::onCommitCombo(LLUICtrl* ctrlp, void* datap)
- {
- HBPrefFonts* self = (HBPrefFonts*)datap;
- if (!self || !ctrlp)
- {
- return;
- }
- bool script_font = ctrlp == (LLUICtrl*)self->mScriptFontCombo ||
- ctrlp == (LLUICtrl*)self->mScriptSizeCombo;
- std::string font_name = self->getFontName(script_font);
- if (font_name.empty())
- {
- if (script_font)
- {
- self->mScriptSizeCombo->setValue("Small");
- self->mScriptSizeCombo->setEnabled(false);
- self->mScriptFont->setFont(LLFontGL::getFontMonospace());
- }
- else
- {
- self->mNotecardSizeCombo->setValue("Medium");
- self->mNotecardSizeCombo->setEnabled(false);
- self->mNoteCardFont->setFont(LLFontGL::getFontSansSerif());
- }
- return;
- }
- if (script_font)
- {
- self->mScriptSizeCombo->setEnabled(true);
- }
- else
- {
- self->mNotecardSizeCombo->setEnabled(true);
- }
- LLFontGL* fontp = LLFontGL::getFont(font_name.c_str());
- if (!fontp)
- {
- llwarns_once << "Could not load font: " << font_name << llendl;
- return;
- }
- if (script_font)
- {
- self->mScriptFont->setFont(fontp);
- }
- else
- {
- self->mNoteCardFont->setFont(fontp);
- }
- }
- //static
- void HBPrefFonts::onCancelButton(void* datap)
- {
- HBPrefFonts* self = (HBPrefFonts*)datap;
- if (self)
- {
- self->close();
- }
- }
- //static
- void HBPrefFonts::onApplyButton(void* datap)
- {
- HBPrefFonts* self = (HBPrefFonts*)datap;
- if (self)
- {
- self->mNoteCardFontName = self->getFontName(false);
- self->mScriptFontName = self->getFontName(true);
- self->close();
- }
- }
- ///////////////////////////////////////////////////////////////////////////////
- // HBPrefsCoolImpl class
- // The implement class for the HBPrefsCool preferences panel.
- ///////////////////////////////////////////////////////////////////////////////
- class HBPrefsCoolImpl final : public LLPanel
- {
- protected:
- LOG_CLASS(HBPrefsCoolImpl);
- public:
- HBPrefsCoolImpl();
- ~HBPrefsCoolImpl() override;
- void refresh() override;
- void draw() override;
- void apply();
- void cancel();
- void setDirty() { mIsDirty = true; }
- static void setQueryActive(bool active);
- std::string getDictName(const std::string& language);
- std::string getDictLanguage(const std::string& name);
- static HBPrefsCoolImpl* getInstance() { return sInstance; }
- private:
- void refreshValues();
- void setSunPositionLabel(F32 value);
- void refreshRestrainedLove(bool enable);
- void updateRestrainedLoveUserProfile();
- std::string getCategoryPath(LLFolderType::EType cat_type);
- std::string getCategoryPath(const LLUUID& cat_id);
- static void onTabChanged(void* user_data, bool);
- static void onCommitCheckBoxShowButton(LLUICtrl* ctrl, void* user_data);
- static void onCommitCheckBoxSpellCheck(LLUICtrl* ctrl, void* user_data);
- static void onCommitCheckBoxRestrainedLove(LLUICtrl* ctrl, void* user_data);
- static void onCommitCheckBoxSpeedRez(LLUICtrl* ctrl, void* user_data);
- static void onCommitSliderSunPositionAtLogin(LLUICtrl* ctrl, void* user_data);
- static void onCommitUserProfile(LLUICtrl* ctrl, void* user_data);
- static void onCommitCheckBoxAfterRestart(LLUICtrl* ctrl, void* user_data);
- static void onClickCustomBlackList(void* user_data);
- static void onClickSetFonts(void*);
- static void onClickDownloadDict(void* user_data);
- static void onClickResetSetting(void* user_data);
- static void fetchDictionaryCoro(std::string dictname);
- private:
- static HBPrefsCoolImpl* sInstance;
- static S32 sQueries;
- LLTabContainer* mTabContainer;
- LLTextBox* mSunPositionLabel;
- std::string mSunPositionSim;
- LLSD mDictsList;
- std::set<std::string> mInstalledDicts;
- std::set<std::string> mWarnedAfterRestart;
- S32 mRestrainedLoveUserProfile;
- bool mFirstRun;
- bool mIsDirty;
- bool mWatchBlackListFloater;
- // Saved values of the settings touched by this panel:
- bool mShowChatButton;
- bool mShowIMButton;
- bool mShowFriendsButton;
- bool mShowGroupsButton;
- bool mShowFlyButton;
- bool mShowSnapshotButton;
- bool mShowSearchButton;
- bool mShowBuildButton;
- bool mShowRadarButton;
- bool mShowMiniMapButton;
- bool mShowMapButton;
- bool mShowInventoryButton;
- bool mHideMasterRemote;
- bool mUseOldChatHistory;
- bool mAutoOpenTextInput;
- bool mIMTabsVerticalStacking;
- bool mUseOldStatusBarIcons;
- bool mUseOldTrackingDots;
- bool mHideTeleportProgress;
- bool mStackMinimizedTopToBottom;
- bool mStackMinimizedRightToLeft;
- bool mAllowMUpose;
- bool mAutoCloseOOC;
- bool mHighlightOwnNameInChat;
- bool mHighlightOwnNameInIM;
- bool mHighlightDisplayName;
- bool mSpellCheck;
- bool mSpellCheckShow;
- bool mAddAvatarNamesToIgnore;
- bool mAllowMultipleViewers;
- bool mSpeedRez;
- bool mTeleportHistoryDeparture;
- bool mMuteListIgnoreServer;
- bool mPreviewAnimInWorld;
- bool mAppearanceAnimation;
- bool mRevokePermsOnStandUp;
- bool mRevokePermsOnStopAnimation;
- bool mResetAnimOverrideOnStopAnimation;
- bool mTurnTowardsSelectedObject;
- bool mPlayDefaultBentoAnimation;
- bool mRezWithLandGroup;
- bool mNoMultipleShoes;
- bool mNoMultipleSkirts;
- bool mNoMultiplePhysics;
- bool mRenderBanWallAlways;
- bool mAutoShowInventoryThumbnails;
- bool mOSUseCOF;
- bool mOSAllowBakeOnMeshUploads;
- bool mOSWorldMapHasTerrain;
- bool mRestrainedLove;
- bool mRestrainedLoveNoSetEnv;
- bool mRestrainedLoveAllowWear;
- bool mRestrainedLoveForbidGiveToRLV;
- bool mRestrainedLoveShowEllipsis;
- bool mRestrainedLoveUntruncatedEmotes;
- bool mRestrainedLoveCanOoc;
- F32 mSunPositionAtLogin;
- F32 mTaskBarButtonFlashTime;
- U32 mFadeMouselookExitTip;
- U32 mDecimalsForTools;
- U32 mStackScreenWidthFraction;
- U32 mTimeFormat;
- U32 mDateFormat;
- U32 mThumbnailViewTimeout;
- U32 mBackgroundYieldTime;
- U32 mFrameRateLimit;
- U32 mSpeedRezInterval;
- U32 mNumImageDecodeThreads;
- U32 mFetchBoostAfterTPDuration;
- U32 mRenderBanWallMaxDist;
- U32 mDoubleClickInventorySoundAction;
- U32 mRestrainedLoveReattachDelay;
- LLColor4 mOwnNameChatColor;
- std::string mHighlightNicknames;
- std::string mSpellCheckLanguage;
- std::string mExternalEditor;
- std::string mRestrainedLoveRecvimMessage;
- std::string mRestrainedLoveSendimMessage;
- std::string mRestrainedLoveBlacklist;
- };
- HBPrefsCoolImpl* HBPrefsCoolImpl::sInstance = NULL;
- S32 HBPrefsCoolImpl::sQueries = 0;
- HBPrefsCoolImpl::HBPrefsCoolImpl()
- : LLPanel(std::string("Cool Preferences Panel")),
- mWatchBlackListFloater(false),
- mFirstRun(true),
- mIsDirty(true)
- {
- sInstance = this;
- LLUICtrlFactory::getInstance()->buildPanel(this,
- "panel_preferences_cool.xml");
- childSetCommitCallback("show_chat_button_check",
- onCommitCheckBoxShowButton, this);
- childSetCommitCallback("show_im_button_check",
- onCommitCheckBoxShowButton, this);
- childSetCommitCallback("show_friends_button_check",
- onCommitCheckBoxShowButton, this);
- childSetCommitCallback("show_group_button_check",
- onCommitCheckBoxShowButton, this);
- childSetCommitCallback("show_fly_button_check",
- onCommitCheckBoxShowButton, this);
- childSetCommitCallback("show_snapshot_button_check",
- onCommitCheckBoxShowButton, this);
- childSetCommitCallback("show_search_button_check",
- onCommitCheckBoxShowButton, this);
- childSetCommitCallback("show_build_button_check",
- onCommitCheckBoxShowButton, this);
- childSetCommitCallback("show_radar_button_check",
- onCommitCheckBoxShowButton, this);
- childSetCommitCallback("show_minimap_button_check",
- onCommitCheckBoxShowButton, this);
- childSetCommitCallback("show_map_button_check",
- onCommitCheckBoxShowButton, this);
- childSetCommitCallback("show_inventory_button_check",
- onCommitCheckBoxShowButton, this);
- childSetCommitCallback("use_old_chat_history_check",
- onCommitCheckBoxAfterRestart, this);
- childSetCommitCallback("im_tabs_vertical_stacking_check",
- onCommitCheckBoxAfterRestart, this);
- childSetCommitCallback("spell_check_check",
- onCommitCheckBoxSpellCheck, this);
- childSetCommitCallback("speed_rez_check",
- onCommitCheckBoxSpeedRez, this);
- childSetCommitCallback("num_image_decode_threads",
- onCommitCheckBoxAfterRestart, this);
- childSetCommitCallback("sun_position_at_login",
- onCommitSliderSunPositionAtLogin, this);
- childSetCommitCallback("os_terrain_map_check",
- onCommitCheckBoxAfterRestart, this);
- childSetCommitCallback("restrained_love_check",
- onCommitCheckBoxRestrainedLove, this);
- childSetCommitCallback("user_profile",
- onCommitUserProfile, this);
- childSetCommitCallback("restrained_love_no_setenv_check",
- onCommitCheckBoxAfterRestart, this);
- childSetCommitCallback("restrained_love_emotes_check",
- onCommitCheckBoxAfterRestart, this);
- childSetCommitCallback("restrained_love_can_ooc_check",
- onCommitCheckBoxAfterRestart, this);
- childSetAction("fonts_button", onClickSetFonts, this);
- childSetAction("dict_download_button", onClickDownloadDict, this);
- childSetAction("custom_profile_button", onClickCustomBlackList, this);
- LLLineEditor* line = getChild<LLLineEditor>("external_editor_cmd");
- line->setCommitOnFocusLost(true);
- // Examples of external editor command line for each OS:
- #if LL_LINUX
- # define EXT_EDIT "/usr/bin/gedit %s"
- #elif LL_DARWIN
- # define EXT_EDIT "/Applications/TextMate.app/Contents/Resources/mate %s"
- #elif LL_WINDOWS
- # define EXT_EDIT "\"C:\\Program Files\\Notepad++\\notepad++.exe\" %s"
- #endif
- line->setLabelArg("[CMD]", EXT_EDIT);
- mSunPositionLabel = getChild<LLTextBox>("sun_position_text");
- mSunPositionSim = mSunPositionLabel->getText();
- mTabContainer = getChild<LLTabContainer>("Cool Prefs");
- LLPanel* tab = mTabContainer->getChild<LLPanel>("User Interface");
- mTabContainer->setTabChangeCallback(tab, onTabChanged);
- mTabContainer->setTabUserData(tab, this);
- tab = mTabContainer->getChild<LLPanel>("Chat/IM");
- mTabContainer->setTabChangeCallback(tab, onTabChanged);
- mTabContainer->setTabUserData(tab, this);
- tab = mTabContainer->getChild<LLPanel>("Inventory");
- mTabContainer->setTabChangeCallback(tab, onTabChanged);
- mTabContainer->setTabUserData(tab, this);
- tab = mTabContainer->getChild<LLPanel>("Animations");
- mTabContainer->setTabChangeCallback(tab, onTabChanged);
- mTabContainer->setTabUserData(tab, this);
- tab = mTabContainer->getChild<LLPanel>("Miscellaneous");
- mTabContainer->setTabChangeCallback(tab, onTabChanged);
- mTabContainer->setTabUserData(tab, this);
- tab = mTabContainer->getChild<LLPanel>("RestrainedLove");
- mTabContainer->setTabChangeCallback(tab, onTabChanged);
- mTabContainer->setTabUserData(tab, this);
- if (!LLStartUp::isLoggedIn())
- {
- LLCheckBoxCtrl* rl = getChild<LLCheckBoxCtrl>("restrained_love_check");
- std::string tooltip = rl->getToolTip();
- tooltip += " " + getString("when_logged_in");
- rl->setToolTip(tooltip);
- }
- LLControlVariable* control =
- gSavedPerAccountSettings.getControl("UploadAnimationFolder");
- control->getSignal()->connect(boost::bind(&HBPrefsCoolImpl::setDirty,
- this));
- childSetAction("reset_animation_folder", onClickResetSetting, control);
- control = gSavedPerAccountSettings.getControl("UploadSoundFolder");
- control->getSignal()->connect(boost::bind(&HBPrefsCoolImpl::setDirty,
- this));
- childSetAction("reset_sound_folder", onClickResetSetting, control);
- control = gSavedPerAccountSettings.getControl("UploadTextureFolder");
- control->getSignal()->connect(boost::bind(&HBPrefsCoolImpl::setDirty,
- this));
- childSetAction("reset_texture_folder", onClickResetSetting, control);
- control = gSavedPerAccountSettings.getControl("UploadMaterialFolder");
- control->getSignal()->connect(boost::bind(&HBPrefsCoolImpl::setDirty,
- this));
- childSetAction("reset_material_folder", onClickResetSetting, control);
- control = gSavedPerAccountSettings.getControl("UploadModelFolder");
- control->getSignal()->connect(boost::bind(&HBPrefsCoolImpl::setDirty,
- this));
- childSetAction("reset_model_folder", onClickResetSetting, control);
- control = gSavedPerAccountSettings.getControl("NewOutfitFolder");
- control->getSignal()->connect(boost::bind(&HBPrefsCoolImpl::setDirty,
- this));
- childSetAction("reset_new_outfits_folder", onClickResetSetting, control);
- refresh();
- }
- HBPrefsCoolImpl::~HBPrefsCoolImpl()
- {
- sInstance = NULL;
- }
- void HBPrefsCoolImpl::draw()
- {
- if (mFirstRun)
- {
- mFirstRun = false;
- mTabContainer->selectTab(gSavedSettings.getS32("LastCoolPrefTab"));
- }
- if (mIsDirty)
- {
- // First get the list of all installed dictionaries
- mInstalledDicts.clear();
- mInstalledDicts = LLSpellCheck::getInstance()->getBaseDicts();
- // Then get the list of all existing dictionaries
- mDictsList.clear();
- std::string dict_list = gDirUtil.getFullPath(LL_PATH_APP_SETTINGS,
- "dictionaries",
- "dict_list.xml");
- llifstream inputstream(dict_list.c_str(), std::ios::binary);
- if (inputstream.is_open())
- {
- LLSDSerialize::fromXMLDocument(mDictsList, inputstream);
- inputstream.close();
- }
- if (mDictsList.size() == 0)
- {
- llwarns << "Failure to load the list of all existing dictionaries."
- << llendl;
- }
- bool found_one = false;
- std::string name = LLSpellCheck::getInstance()->getCurrentDict();
- std::string language;
- S32 selection = -1;
- LLComboBox* combo = getChild<LLComboBox>("installed_dicts_combo");
- combo->removeall();
- for (std::set<std::string>::iterator it = mInstalledDicts.begin();
- it != mInstalledDicts.end(); it++)
- {
- language = getDictLanguage(*it);
- if (language.empty())
- {
- language = *it;
- }
- combo->add(language);
- found_one = true;
- if (*it == name)
- {
- selection = combo->getItemCount() - 1;
- }
- }
- if (!found_one)
- {
- combo->add(LLStringUtil::null);
- }
- if (selection >= 0)
- {
- combo->setCurrentByIndex(selection);
- }
- found_one = false;
- combo = getChild<LLComboBox>("download_dict_combo");
- combo->removeall();
- for (LLSD::array_const_iterator it = mDictsList.beginArray();
- it != mDictsList.endArray(); it++)
- {
- const LLSD& entry = *it;
- name = entry["name"].asString();
- if (name.empty())
- {
- llwarns << "Invalid dictionary list entry: no name." << llendl;
- continue;
- }
- LLStringUtil::toLower(name);
- if (!mInstalledDicts.count(name))
- {
- language = entry["language"].asString();
- if (language.empty())
- {
- llwarns << "Invalid dictionary list entry. No language for: "
- << name << llendl;
- language = name;
- }
- combo->add(language);
- found_one = true;
- }
- }
- if (!found_one)
- {
- combo->add(LLStringUtil::null);
- }
- bool visible = (sQueries == 0);
- childSetVisible("download_dict_combo", visible);
- childSetVisible("dict_download_button", visible);
- childSetVisible("downloading", !visible);
- bool usable = gInventory.isInventoryUsable();
- if (usable)
- {
- LLLineEditor* line =
- getChild<LLLineEditor>("upload_folder_animation");
- line->setText(getCategoryPath(LLFolderType::FT_ANIMATION));
- line = getChild<LLLineEditor>("upload_folder_sound");
- line->setText(getCategoryPath(LLFolderType::FT_SOUND));
- line = getChild<LLLineEditor>("upload_folder_texture");
- line->setText(getCategoryPath(LLFolderType::FT_TEXTURE));
- line = getChild<LLLineEditor>("upload_material_folder");
- line->setText(getCategoryPath(LLFolderType::FT_MATERIAL));
- line = getChild<LLLineEditor>("upload_folder_model");
- line->setText(getCategoryPath(LLFolderType::FT_OBJECT));
- line = getChild<LLLineEditor>("new_outfits_folder");
- line->setText(getCategoryPath(LLFolderType::FT_MY_OUTFITS));
- }
- childSetEnabled("reset_animation_folder", usable);
- childSetEnabled("reset_sound_folder", usable);
- childSetEnabled("reset_texture_folder", usable);
- childSetEnabled("reset_material_folder", usable);
- childSetEnabled("reset_model_folder", usable);
- childSetEnabled("reset_new_outfits_folder", usable);
- mIsDirty = false;
- }
- if (mWatchBlackListFloater && !HBFloaterBlacklistRLV::instanceVisible())
- {
- mWatchBlackListFloater = false;
- updateRestrainedLoveUserProfile();
- }
- LLPanel::draw();
- }
- void HBPrefsCoolImpl::refreshRestrainedLove(bool enable)
- {
- // Enable/disable all children in the RestrainedLove panel
- LLPanel* panel = getChild<LLPanel>("RestrainedLove");
- LLView* child = panel->getFirstChild();
- while (child)
- {
- child->setEnabled(enable);
- child = panel->findNextSibling(child);
- }
- // RestrainedLove check box enabled only when logged in.
- childSetEnabled("restrained_love_check", LLStartUp::isLoggedIn());
- }
- void HBPrefsCoolImpl::refreshValues()
- {
- bool logged_in = LLStartUp::isLoggedIn();
- // User Interface
- mShowChatButton = gSavedSettings.getBool("ShowChatButton");
- mShowIMButton = gSavedSettings.getBool("ShowIMButton");
- mShowFriendsButton = gSavedSettings.getBool("ShowFriendsButton");
- mShowGroupsButton = gSavedSettings.getBool("ShowGroupsButton");
- mShowFlyButton = gSavedSettings.getBool("ShowFlyButton");
- mShowSnapshotButton = gSavedSettings.getBool("ShowSnapshotButton");
- mShowSearchButton = gSavedSettings.getBool("ShowSearchButton");
- mShowBuildButton = gSavedSettings.getBool("ShowBuildButton");
- mShowRadarButton = gSavedSettings.getBool("ShowRadarButton");
- mShowMiniMapButton = gSavedSettings.getBool("ShowMiniMapButton");
- mShowMapButton = gSavedSettings.getBool("ShowMapButton");
- mShowInventoryButton = gSavedSettings.getBool("ShowInventoryButton");
- mHideMasterRemote = gSavedSettings.getBool("HideMasterRemote");
- mFadeMouselookExitTip = gSavedSettings.getU32("FadeMouselookExitTip");
- mUseOldChatHistory = gSavedSettings.getBool("UseOldChatHistory");
- mAutoOpenTextInput = gSavedSettings.getBool("AutoOpenTextInput");
- mIMTabsVerticalStacking = gSavedSettings.getBool("IMTabsVerticalStacking");
- mUseOldStatusBarIcons = gSavedSettings.getBool("UseOldStatusBarIcons");
- mUseOldTrackingDots = gSavedSettings.getBool("UseOldTrackingDots");
- mDecimalsForTools = gSavedSettings.getU32("DecimalsForTools");
- mHideTeleportProgress = gSavedSettings.getBool("HideTeleportProgress");
- mStackMinimizedTopToBottom = gSavedSettings.getBool("StackMinimizedTopToBottom");
- mStackMinimizedRightToLeft = gSavedSettings.getBool("StackMinimizedRightToLeft");
- mStackScreenWidthFraction = gSavedSettings.getU32("StackScreenWidthFraction");
- // Chat, IM & Text
- mAllowMUpose = gSavedSettings.getBool("AllowMUpose");
- mAutoCloseOOC = gSavedSettings.getBool("AutoCloseOOC");
- mHighlightOwnNameInChat = gSavedSettings.getBool("HighlightOwnNameInChat");
- mHighlightOwnNameInIM = gSavedSettings.getBool("HighlightOwnNameInIM");
- mOwnNameChatColor = gSavedSettings.getColor4("OwnNameChatColor");
- if (logged_in)
- {
- mHighlightNicknames = gSavedPerAccountSettings.getString("HighlightNicknames");
- mHighlightDisplayName = gSavedPerAccountSettings.getBool("HighlightDisplayName");
- }
- mSpellCheck = gSavedSettings.getBool("SpellCheck");
- mSpellCheckShow = gSavedSettings.getBool("SpellCheckShow");
- mAddAvatarNamesToIgnore = gSavedSettings.getBool("AddAvatarNamesToIgnore");
- mSpellCheckLanguage = gSavedSettings.getString("SpellCheckLanguage");
- mTaskBarButtonFlashTime = gSavedSettings.getF32("TaskBarButtonFlashTime");
- // Inventory
- mRezWithLandGroup = gSavedSettings.getBool("RezWithLandGroup");
- mDoubleClickInventorySoundAction = gSavedSettings.getU32("DoubleClickInventorySoundAction");
- mNoMultipleShoes = gSavedSettings.getBool("NoMultipleShoes");
- mNoMultipleSkirts = gSavedSettings.getBool("NoMultipleSkirts");
- mNoMultiplePhysics = gSavedSettings.getBool("NoMultiplePhysics");
- mAutoShowInventoryThumbnails = gSavedSettings.getBool("AutoShowInventoryThumbnails");
- mThumbnailViewTimeout = gSavedSettings.getU32("ThumbnailViewTimeout");
- mOSUseCOF = gSavedSettings.getBool("OSUseCOF");
- // Miscellaneous
- mAllowMultipleViewers = gSavedSettings.getBool("AllowMultipleViewers");
- mBackgroundYieldTime = gSavedSettings.getU32("BackgroundYieldTime");
- mFrameRateLimit = gSavedSettings.getU32("FrameRateLimit");
- mSpeedRez = gSavedSettings.getBool("SpeedRez");
- mSpeedRezInterval = gSavedSettings.getU32("SpeedRezInterval");
- mNumImageDecodeThreads = gSavedSettings.getU32("NumImageDecodeThreads");
- mFetchBoostAfterTPDuration = gSavedSettings.getU32("TextureFetchBoostTimeAfterTP");
- mPreviewAnimInWorld = gSavedSettings.getBool("PreviewAnimInWorld");
- mAppearanceAnimation = gSavedSettings.getBool("AppearanceAnimation");
- mRevokePermsOnStandUp = gSavedSettings.getBool("RevokePermsOnStandUp");
- mRevokePermsOnStopAnimation = gSavedSettings.getBool("RevokePermsOnStopAnimation");
- mResetAnimOverrideOnStopAnimation = gSavedSettings.getBool("ResetAnimOverrideOnStopAnimation");
- mTurnTowardsSelectedObject = gSavedSettings.getBool("TurnTowardsSelectedObject");
- mPlayDefaultBentoAnimation = gSavedSettings.getBool("PlayDefaultBentoAnimation");
- mTeleportHistoryDeparture = gSavedSettings.getBool("TeleportHistoryDeparture");
- mMuteListIgnoreServer = gSavedSettings.getBool("MuteListIgnoreServer");
- mSunPositionAtLogin = gSavedSettings.getF32("SunPositionAtLogin");
- mRenderBanWallAlways = gSavedSettings.getBool("RenderBanWallAlways");
- mRenderBanWallMaxDist = gSavedSettings.getU32("RenderBanWallMaxDist");
- mExternalEditor = gSavedSettings.getString("ExternalEditor");
- mOSAllowBakeOnMeshUploads = gSavedSettings.getBool("OSAllowBakeOnMeshUploads");
- mOSWorldMapHasTerrain = gSavedSettings.getBool("OSWorldMapHasTerrain");
- // RestrainedLove
- mRestrainedLove = gSavedSettings.getBool("RestrainedLove");
- mRestrainedLoveBlacklist = gSavedSettings.getString("RestrainedLoveBlacklist");
- mRestrainedLoveNoSetEnv = gSavedSettings.getBool("RestrainedLoveNoSetEnv");
- mRestrainedLoveAllowWear = gSavedSettings.getBool("RestrainedLoveAllowWear");
- mRestrainedLoveReattachDelay = gSavedSettings.getU32("RestrainedLoveReattachDelay");
- mRestrainedLoveForbidGiveToRLV = gSavedSettings.getBool("RestrainedLoveForbidGiveToRLV");
- mRestrainedLoveShowEllipsis = gSavedSettings.getBool("RestrainedLoveShowEllipsis");
- mRestrainedLoveUntruncatedEmotes = gSavedSettings.getBool("RestrainedLoveUntruncatedEmotes");
- mRestrainedLoveCanOoc = gSavedSettings.getBool("RestrainedLoveCanOoc");
- if (logged_in)
- {
- mRestrainedLoveRecvimMessage = gSavedPerAccountSettings.getString("RestrainedLoveRecvimMessage");
- mRestrainedLoveSendimMessage = gSavedPerAccountSettings.getString("RestrainedLoveSendimMessage");
- }
- }
- void HBPrefsCoolImpl::updateRestrainedLoveUserProfile()
- {
- std::string blacklist = gSavedSettings.getString("RestrainedLoveBlacklist");
- if (blacklist.empty())
- {
- mRestrainedLoveUserProfile = 0;
- }
- else if (blacklist == RLInterface::sRolePlayBlackList)
- {
- mRestrainedLoveUserProfile = 1;
- }
- else if (blacklist == RLInterface::sVanillaBlackList)
- {
- mRestrainedLoveUserProfile = 2;
- }
- else
- {
- mRestrainedLoveUserProfile = 3;
- }
- LLRadioGroup* radio = getChild<LLRadioGroup>("user_profile");
- radio->selectNthItem(mRestrainedLoveUserProfile);
- }
- void HBPrefsCoolImpl::setSunPositionLabel(F32 value)
- {
- if (value < 0.f)
- {
- mSunPositionLabel->setText(mSunPositionSim);
- }
- else
- {
- F32 time = 24.f * value;
- U32 hours = (U32)time;
- U32 minutes = (U32)((time - (F32)hours) * 60.f);
- mSunPositionLabel->setText(llformat("%02d:%02d", hours, minutes));
- }
- }
- void HBPrefsCoolImpl::refresh()
- {
- refreshValues();
- // User Interface
- std::string format = gSavedSettings.getString("ShortTimeFormat");
- if (format.find("%p") == std::string::npos)
- {
- mTimeFormat = 0;
- }
- else
- {
- mTimeFormat = 1;
- }
- format = gSavedSettings.getString("ShortDateFormat");
- if (format.find("%m/%d/%") != std::string::npos)
- {
- mDateFormat = 2;
- }
- else if (format.find("%d/%m/%") != std::string::npos)
- {
- mDateFormat = 1;
- }
- else
- {
- mDateFormat = 0;
- }
- // time format combobox
- LLComboBox* combo = getChild<LLComboBox>("time_format_combobox");
- if (combo)
- {
- combo->setCurrentByIndex(mTimeFormat);
- }
- // date format combobox
- combo = getChild<LLComboBox>("date_format_combobox");
- if (combo)
- {
- combo->setCurrentByIndex(mDateFormat);
- }
- bool logged_in = LLStartUp::isLoggedIn();
- if (logged_in)
- {
- childSetValue("highlight_nicknames_text", mHighlightNicknames);
- childSetValue("highlight_display_name_check", mHighlightDisplayName);
- }
- else
- {
- childDisable("highlight_nicknames_text");
- childDisable("highlight_display_name_check");
- }
- // Spell checking
- childSetEnabled("spell_check_show_check", mSpellCheck);
- childSetEnabled("add_avatar_names_to_ignore_check", mSpellCheck);
- childSetEnabled("installed_dicts_combo", mSpellCheck);
- childSetEnabled("download_dict_combo", mSpellCheck);
- childSetEnabled("dict_download_button", mSpellCheck);
- // Miscellaneous
- childSetEnabled("speed_rez_interval", mSpeedRez);
- childSetEnabled("speed_rez_seconds", mSpeedRez);
- setSunPositionLabel(mSunPositionAtLogin);
- // RestrainedLove
- refreshRestrainedLove(mRestrainedLove);
- updateRestrainedLoveUserProfile();
- if (logged_in)
- {
- LLWString message = utf8str_to_wstring(gSavedPerAccountSettings.getString("RestrainedLoveRecvimMessage"));
- LLWStringUtil::replaceChar(message, '^', '\n');
- childSetText("receive_im_message_editor", wstring_to_utf8str(message));
- message = utf8str_to_wstring(gSavedPerAccountSettings.getString("RestrainedLoveSendimMessage"));
- LLWStringUtil::replaceChar(message, '^', '\n');
- childSetText("send_im_message_editor", wstring_to_utf8str(message));
- }
- else
- {
- std::string text = getString("when_logged_in");
- childSetText("receive_im_message_editor", text);
- childDisable("receive_im_message_editor");
- childSetText("send_im_message_editor", text);
- childDisable("send_im_message_editor");
- }
- }
- void HBPrefsCoolImpl::cancel()
- {
- bool logged_in = LLStartUp::isLoggedIn();
- // User Interface
- gSavedSettings.setBool("ShowChatButton", mShowChatButton);
- gSavedSettings.setBool("ShowIMButton", mShowIMButton);
- gSavedSettings.setBool("ShowFriendsButton", mShowFriendsButton);
- gSavedSettings.setBool("ShowGroupsButton", mShowGroupsButton);
- gSavedSettings.setBool("ShowFlyButton", mShowFlyButton);
- gSavedSettings.setBool("ShowSnapshotButton", mShowSnapshotButton);
- gSavedSettings.setBool("ShowSearchButton", mShowSearchButton);
- gSavedSettings.setBool("ShowBuildButton", mShowBuildButton);
- gSavedSettings.setBool("ShowRadarButton", mShowRadarButton);
- gSavedSettings.setBool("ShowMiniMapButton", mShowMiniMapButton);
- gSavedSettings.setBool("ShowMapButton", mShowMapButton);
- gSavedSettings.setBool("ShowInventoryButton", mShowInventoryButton);
- gSavedSettings.setBool("HideMasterRemote", mHideMasterRemote);
- gSavedSettings.setU32("FadeMouselookExitTip", mFadeMouselookExitTip);
- gSavedSettings.setBool("UseOldChatHistory", mUseOldChatHistory);
- gSavedSettings.setBool("AutoOpenTextInput", mAutoOpenTextInput);
- gSavedSettings.setBool("IMTabsVerticalStacking", mIMTabsVerticalStacking);
- gSavedSettings.setBool("UseOldStatusBarIcons", mUseOldStatusBarIcons);
- gSavedSettings.setBool("UseOldTrackingDots", mUseOldTrackingDots);
- gSavedSettings.setU32("DecimalsForTools", mDecimalsForTools);
- gSavedSettings.setBool("HideTeleportProgress", mHideTeleportProgress);
- gSavedSettings.setBool("StackMinimizedTopToBottom", mStackMinimizedTopToBottom);
- gSavedSettings.setBool("StackMinimizedRightToLeft", mStackMinimizedRightToLeft);
- gSavedSettings.setU32("StackScreenWidthFraction", mStackScreenWidthFraction);
- // Chat, IM & Text
- gSavedSettings.setBool("AllowMUpose", mAllowMUpose);
- gSavedSettings.setBool("AutoCloseOOC", mAutoCloseOOC);
- gSavedSettings.setBool("HighlightOwnNameInChat", mHighlightOwnNameInChat);
- gSavedSettings.setBool("HighlightOwnNameInIM", mHighlightOwnNameInIM);
- gSavedSettings.setColor4("OwnNameChatColor", mOwnNameChatColor);
- if (logged_in)
- {
- gSavedPerAccountSettings.setString("HighlightNicknames", mHighlightNicknames);
- gSavedPerAccountSettings.setBool("HighlightDisplayName", mHighlightDisplayName);
- }
- gSavedSettings.setBool("SpellCheck", mSpellCheck);
- gSavedSettings.setBool("SpellCheckShow", mSpellCheckShow);
- gSavedSettings.setBool("AddAvatarNamesToIgnore", mAddAvatarNamesToIgnore);
- gSavedSettings.setString("SpellCheckLanguage", mSpellCheckLanguage);
- gSavedSettings.setF32("TaskBarButtonFlashTime", mTaskBarButtonFlashTime);
- // Inventory
- gSavedSettings.setBool("RezWithLandGroup", mRezWithLandGroup);
- gSavedSettings.setU32("DoubleClickInventorySoundAction", mDoubleClickInventorySoundAction);
- gSavedSettings.setBool("NoMultipleShoes", mNoMultipleShoes);
- gSavedSettings.setBool("NoMultipleSkirts", mNoMultipleSkirts);
- gSavedSettings.setBool("NoMultiplePhysics", mNoMultiplePhysics);
- gSavedSettings.setBool("AutoShowInventoryThumbnails", mAutoShowInventoryThumbnails);
- gSavedSettings.setU32("ThumbnailViewTimeout", mThumbnailViewTimeout);
- gSavedSettings.setBool("OSUseCOF", mOSUseCOF);
- // Miscellaneous
- gSavedSettings.setBool("AllowMultipleViewers", mAllowMultipleViewers);
- gSavedSettings.setU32("BackgroundYieldTime", mBackgroundYieldTime);
- gSavedSettings.setU32("FrameRateLimit", mFrameRateLimit);
- gSavedSettings.setBool("SpeedRez", mSpeedRez);
- gSavedSettings.setU32("SpeedRezInterval", mSpeedRezInterval);
- gSavedSettings.setU32("NumImageDecodeThreads", mNumImageDecodeThreads);
- gSavedSettings.setU32("TextureFetchBoostTimeAfterTP", mFetchBoostAfterTPDuration);
- gSavedSettings.setBool("PreviewAnimInWorld", mPreviewAnimInWorld);
- gSavedSettings.setBool("AppearanceAnimation", mAppearanceAnimation);
- gSavedSettings.setBool("RevokePermsOnStandUp", mRevokePermsOnStandUp);
- gSavedSettings.setBool("RevokePermsOnStopAnimation", mRevokePermsOnStopAnimation);
- gSavedSettings.setBool("ResetAnimOverrideOnStopAnimation", mResetAnimOverrideOnStopAnimation);
- gSavedSettings.setBool("TurnTowardsSelectedObject", mTurnTowardsSelectedObject);
- gSavedSettings.setBool("PlayDefaultBentoAnimation", mPlayDefaultBentoAnimation);
- gSavedSettings.setBool("TeleportHistoryDeparture", mTeleportHistoryDeparture);
- gSavedSettings.setBool("MuteListIgnoreServer", mMuteListIgnoreServer);
- gSavedSettings.setF32("SunPositionAtLogin", mSunPositionAtLogin);
- gSavedSettings.setBool("RenderBanWallAlways", mRenderBanWallAlways);
- gSavedSettings.setU32("RenderBanWallMaxDist", mRenderBanWallMaxDist);
- gSavedSettings.setString("ExternalEditor", mExternalEditor);
- gSavedSettings.setBool("OSAllowBakeOnMeshUploads", mOSAllowBakeOnMeshUploads);
- gSavedSettings.setBool("OSWorldMapHasTerrain", mOSWorldMapHasTerrain);
- // RestrainedLove
- gSavedSettings.setBool("RestrainedLove", mRestrainedLove);
- gSavedSettings.setString("RestrainedLoveBlacklist", mRestrainedLoveBlacklist);
- gSavedSettings.setBool("RestrainedLoveNoSetEnv", mRestrainedLoveNoSetEnv);
- gSavedSettings.setBool("RestrainedLoveAllowWear", mRestrainedLoveAllowWear);
- gSavedSettings.setU32("RestrainedLoveReattachDelay", mRestrainedLoveReattachDelay);
- gSavedSettings.setBool("RestrainedLoveForbidGiveToRLV", mRestrainedLoveForbidGiveToRLV);
- gSavedSettings.setBool("RestrainedLoveShowEllipsis", mRestrainedLoveShowEllipsis);
- gSavedSettings.setBool("RestrainedLoveUntruncatedEmotes", mRestrainedLoveUntruncatedEmotes);
- gSavedSettings.setBool("RestrainedLoveCanOoc", mRestrainedLoveCanOoc);
- if (logged_in)
- {
- gSavedPerAccountSettings.setString("RestrainedLoveRecvimMessage",
- mRestrainedLoveRecvimMessage);
- gSavedPerAccountSettings.setString("RestrainedLoveSendimMessage",
- mRestrainedLoveSendimMessage);
- }
- }
- void HBPrefsCoolImpl::apply()
- {
- // User Interface
- std::string short_date, long_date, short_time, long_time, timestamp;
- LLComboBox* combo = getChild<LLComboBox>("time_format_combobox");
- if (combo)
- {
- mTimeFormat = combo->getCurrentIndex();
- }
- combo = getChild<LLComboBox>("date_format_combobox");
- if (combo)
- {
- mDateFormat = combo->getCurrentIndex();
- }
- if (mTimeFormat == 0)
- {
- short_time = "%H:%M";
- long_time = "%H:%M:%S";
- timestamp = " %H:%M:%S";
- }
- else
- {
- short_time = "%I:%M %p";
- long_time = "%I:%M:%S %p";
- timestamp = " %I:%M %p";
- }
- if (mDateFormat == 0)
- {
- short_date = "%Y-%m-%d";
- long_date = "%A %d %B %Y";
- timestamp = "%a %d %b %Y" + timestamp;
- }
- else if (mDateFormat == 1)
- {
- short_date = "%d/%m/%Y";
- long_date = "%A %d %B %Y";
- timestamp = "%a %d %b %Y" + timestamp;
- }
- else
- {
- short_date = "%m/%d/%Y";
- long_date = "%A, %B %d %Y";
- timestamp = "%a %b %d %Y" + timestamp;
- }
- gSavedSettings.setString("ShortDateFormat", short_date);
- gSavedSettings.setString("LongDateFormat", long_date);
- gSavedSettings.setString("ShortTimeFormat", short_time);
- gSavedSettings.setString("LongTimeFormat", long_time);
- gSavedSettings.setString("TimestampFormat", timestamp);
- // Chat, IM & Text
- combo = getChild<LLComboBox>("installed_dicts_combo");
- std::string dict_name = getDictName(combo->getSelectedItemLabel());
- if (!dict_name.empty())
- {
- gSavedSettings.setString("SpellCheckLanguage", dict_name);
- }
- if (LLStartUp::isLoggedIn())
- {
- gSavedPerAccountSettings.setString("HighlightNicknames",
- childGetValue("highlight_nicknames_text"));
- gSavedPerAccountSettings.setBool("HighlightDisplayName",
- childGetValue("highlight_display_name_check"));
- // RestrainedLove
- LLTextEditor* text = getChild<LLTextEditor>("receive_im_message_editor");
- LLWString message = text->getWText();
- LLWStringUtil::replaceTabsWithSpaces(message, 4);
- LLWStringUtil::replaceChar(message, '\n', '^');
- gSavedPerAccountSettings.setString("RestrainedLoveRecvimMessage",
- std::string(wstring_to_utf8str(message)));
- text = getChild<LLTextEditor>("send_im_message_editor");
- message = text->getWText();
- LLWStringUtil::replaceTabsWithSpaces(message, 4);
- LLWStringUtil::replaceChar(message, '\n', '^');
- gSavedPerAccountSettings.setString("RestrainedLoveSendimMessage",
- std::string(wstring_to_utf8str(message)));
- }
- refreshValues();
- }
- std::string HBPrefsCoolImpl::getDictName(const std::string& language)
- {
- std::string result;
- for (LLSD::array_const_iterator it = mDictsList.beginArray();
- it != mDictsList.endArray(); it++)
- {
- const LLSD& entry = *it;
- if (entry["language"].asString() == language)
- {
- result = entry["name"].asString();
- break;
- }
- }
- return result;
- }
- std::string HBPrefsCoolImpl::getDictLanguage(const std::string& name)
- {
- std::string result;
- for (LLSD::array_const_iterator it = mDictsList.beginArray();
- it != mDictsList.endArray(); it++)
- {
- const LLSD& entry = *it;
- if (entry["name"].asString() == name)
- {
- result = entry["language"].asString();
- break;
- }
- }
- return result;
- }
- std::string HBPrefsCoolImpl::getCategoryPath(const LLUUID& cat_id)
- {
- LLViewerInventoryCategory* cat = gInventory.getCategory(cat_id);
- if (!cat)
- {
- llwarns_once << "Could not find category for Id: " << cat_id << llendl;
- return "";
- }
- const LLUUID& parent_id = cat->getParentUUID();
- if (parent_id.notNull())
- {
- // Should be " \u25ba ", buy M$' Visual Shit does not accept it...
- static const std::string separator(" \xE2\x96\xBA ");
- return getCategoryPath(parent_id) + separator + cat->getName();
- }
- return cat->getName();
- }
- std::string HBPrefsCoolImpl::getCategoryPath(LLFolderType::EType cat_type)
- {
- LLUUID cat_id = gInventory.findChoosenCategoryUUIDForType(cat_type);
- return getCategoryPath(cat_id);
- }
- //static
- void HBPrefsCoolImpl::onTabChanged(void* user_data, bool)
- {
- HBPrefsCoolImpl* self = (HBPrefsCoolImpl*)user_data;
- if (self && self->mTabContainer)
- {
- gSavedSettings.setS32("LastCoolPrefTab",
- self->mTabContainer->getCurrentPanelIndex());
- }
- }
- //static
- void HBPrefsCoolImpl::setQueryActive(bool active)
- {
- if (active)
- {
- ++sQueries;
- }
- else
- {
- if (--sQueries < 0)
- {
- llwarns << "Lost the count of the dictionary download queries !"
- << llendl;
- sQueries = 0;
- }
- if (sQueries == 0)
- {
- gNotifications.add("DownloadDictFinished");
- }
- }
- if (HBPrefsCoolImpl::getInstance())
- {
- HBPrefsCoolImpl::getInstance()->setDirty();
- }
- }
- //static
- void HBPrefsCoolImpl::onCommitCheckBoxAfterRestart(LLUICtrl* ctrl,
- void* user_data)
- {
- HBPrefsCoolImpl* self = (HBPrefsCoolImpl*)user_data;
- LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
- if (!self || !check) return;
- std::string control = check->getControlName();
- if (!self->mWarnedAfterRestart.count(control))
- {
- self->mWarnedAfterRestart.emplace(control);
- gNotifications.add("InEffectAfterRestart");
- }
- }
- //static
- void HBPrefsCoolImpl::onCommitCheckBoxShowButton(LLUICtrl* ctrl,
- void* user_data)
- {
- HBPrefsCoolImpl* self = (HBPrefsCoolImpl*)user_data;
- LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
- if (!self || !check) return;
- bool enabled = check->get();
- if (enabled && !gSavedSettings.getBool("ShowToolBar"))
- {
- gSavedSettings.setBool("ShowToolBar", true);
- }
- }
- //static
- void HBPrefsCoolImpl::onCommitCheckBoxSpellCheck(LLUICtrl* ctrl,
- void* user_data)
- {
- HBPrefsCoolImpl* self = (HBPrefsCoolImpl*)user_data;
- LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
- if (!self || !check) return;
- bool enabled = check->get();
- self->childSetEnabled("spell_check_show_check", enabled);
- self->childSetEnabled("add_avatar_names_to_ignore_check", enabled);
- self->childSetEnabled("installed_dicts_combo", enabled);
- self->childSetEnabled("download_dict_combo", enabled);
- self->childSetEnabled("dict_download_button", enabled);
- }
- //static
- void HBPrefsCoolImpl::onClickSetFonts(void* user_data)
- {
- HBPrefFonts::showInstance();
- }
- //static
- void HBPrefsCoolImpl::onClickDownloadDict(void* user_data)
- {
- HBPrefsCoolImpl* self = (HBPrefsCoolImpl*)user_data;
- if (self)
- {
- LLComboBox* combo = self->getChild<LLComboBox>("download_dict_combo");
- if (combo)
- {
- std::string label = combo->getSelectedItemLabel();
- if (!label.empty())
- {
- std::string dict_name = self->getDictName(label);
- gCoros.launch("HBPrefsCoolImpl::fetchDictionaryCoro(aff)",
- boost::bind(&HBPrefsCoolImpl::fetchDictionaryCoro,
- dict_name + ".aff"));
- gCoros.launch("HBPrefsCoolImpl::fetchDictionaryCoro(dic)",
- boost::bind(&HBPrefsCoolImpl::fetchDictionaryCoro,
- dict_name + ".dic"));
- }
- }
- }
- }
- //static
- void HBPrefsCoolImpl::fetchDictionaryCoro(std::string dictname)
- {
- std::string url = gSavedSettings.getString("SpellCheckDictDownloadURL");
- url += dictname;
- setQueryActive(true);
- llinfos << "Fetching dictionary file from: " << url << llendl;
- LLCoreHttpUtil::HttpCoroutineAdapter adapter("fetchDictionaryCoro");
- LLSD result = adapter.getRawAndSuspend(url);
- setQueryActive(false);
- LLSD args;
- args["NAME"] = dictname;
- LLCore::HttpStatus status =
- LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(result);
- if (!status)
- {
- args["STATUS"] = llformat("%d", status.getType());
- args["REASON"] = status.toString();
- gNotifications.add("DownloadDictFailure", args);
- return;
- }
- const LLSD::Binary& raw =
- result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_RAW].asBinary();
- S32 size = raw.size();
- if (size <= 0)
- {
- gNotifications.add("DownloadDictEmpty", args);
- return;
- }
- std::string filename = gDirUtil.getFullPath(LL_PATH_USER_SETTINGS,
- "dictionaries",
- dictname.c_str());
- LLFile output(filename, "wb");
- if (!output || output.write(raw.data(), size) != size)
- {
- gNotifications.add("DictWriteFailure", args);
- }
- }
- //static
- void HBPrefsCoolImpl::onCommitCheckBoxSpeedRez(LLUICtrl* ctrl, void* user_data)
- {
- HBPrefsCoolImpl* self = (HBPrefsCoolImpl*)user_data;
- LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
- if (!self || !check) return;
- bool enabled = check->get();
- self->childSetEnabled("speed_rez_interval", enabled);
- self->childSetEnabled("speed_rez_seconds", enabled);
- }
- //static
- void HBPrefsCoolImpl::onCommitSliderSunPositionAtLogin(LLUICtrl* ctrl,
- void* user_data)
- {
- HBPrefsCoolImpl* self = (HBPrefsCoolImpl*)user_data;
- LLSliderCtrl* slider = (LLSliderCtrl*)ctrl;
- if (!self || !slider) return;
- F32 value = slider->getValueF32();
- self->setSunPositionLabel(value);
- if (!LLStartUp::isLoggedIn())
- {
- return;
- }
- gSavedSettings.setBool("UseParcelEnvironment", false);
- gEnvironment.setLocalEnvFromDefaultWindlightDay(value);
- }
- //static
- void HBPrefsCoolImpl::onCommitCheckBoxRestrainedLove(LLUICtrl* ctrl,
- void* user_data)
- {
- HBPrefsCoolImpl* self = (HBPrefsCoolImpl*)user_data;
- LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
- if (!self || !check) return;
- bool enable = check->get();
- self->refreshRestrainedLove(enable);
- if ((bool)self->mRestrainedLove != enable)
- {
- gNotifications.add("InEffectAfterRestart");
- }
- }
- //static
- void HBPrefsCoolImpl::onCommitUserProfile(LLUICtrl* ctrl, void* user_data)
- {
- HBPrefsCoolImpl* self = (HBPrefsCoolImpl*)user_data;
- LLRadioGroup* radio = (LLRadioGroup*)ctrl;
- if (!self || !radio) return;
- std::string blacklist;
- S32 profile = radio->getSelectedIndex();
- switch (profile)
- {
- case 0:
- blacklist.clear();
- break;
- case 1:
- blacklist = RLInterface::sRolePlayBlackList;
- break;
- case 2:
- blacklist = RLInterface::sVanillaBlackList;
- break;
- default:
- blacklist = gSavedSettings.getString("RestrainedLoveBlacklist");
- }
- gSavedSettings.setString("RestrainedLoveBlacklist", blacklist);
- if (self->mRestrainedLoveUserProfile != profile)
- {
- gNotifications.add("InEffectAfterRestart");
- }
- self->mRestrainedLoveUserProfile = profile;
- }
- //static
- void HBPrefsCoolImpl::onClickCustomBlackList(void* user_data)
- {
- HBPrefsCoolImpl* self = (HBPrefsCoolImpl*)user_data;
- if (self)
- {
- HBFloaterBlacklistRLV::showInstance();
- self->mWatchBlackListFloater = true;
- }
- }
- //static
- void HBPrefsCoolImpl::onClickResetSetting(void* user_data)
- {
- LLControlVariable* control = (LLControlVariable*)user_data;
- if (control)
- {
- control->resetToDefault(true);
- }
- }
- ///////////////////////////////////////////////////////////////////////////////
- // HBPrefsCool class proper
- ///////////////////////////////////////////////////////////////////////////////
- HBPrefsCool::HBPrefsCool()
- : impl(*new HBPrefsCoolImpl())
- {
- }
- HBPrefsCool::~HBPrefsCool()
- {
- delete &impl;
- }
- void HBPrefsCool::apply()
- {
- HBFloaterBlacklistRLV::hideInstance(); // Actually a closing
- impl.apply();
- }
- void HBPrefsCool::cancel()
- {
- HBFloaterBlacklistRLV::hideInstance(); // Actually a closing
- impl.cancel();
- }
- LLPanel* HBPrefsCool::getPanel()
- {
- return &impl;
- }
|