Newer
Older
Melinda Green
committed
* @brief Global preferences with and without persistence.
* $LicenseInfo:firstyear=2002&license=viewerlgpl$
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
*/
/*
* App-wide preferences. Note that these are not per-user,
* because we need to load many preferences before we have
* a login name.
*/
#include "llviewerprecompiledheaders.h"
#include "llfloaterpreference.h"
#include "message.h"
Oz Linden
committed
#include "llfloaterautoreplacesettings.h"
#include "llagent.h"
Mnikolenko ProductEngine
committed
#include "llagentcamera.h"
#include "llcheckboxctrl.h"
James Cook
committed
#include "llcolorswatch.h"
#include "llcombobox.h"
#include "llcommandhandler.h"
#include "lldiriterator.h"
#include "lldirpicker.h"
Paul ProductEngine
committed
#include "lleventtimer.h"
#include "llfeaturemanager.h"
#include "llfilepicker.h"
#include "llfocusmgr.h"
//#include "llfirstuse.h"
#include "llfloaterreg.h"
Mnikolenko ProductEngine
committed
#include "llfavoritesbar.h"
#include "llfloatersidepanelcontainer.h"
AlexanderP ProductEngine
committed
#include "llfloaterimsession.h"
#include "llkeyboard.h"
#include "llmodaldialog.h"
James Cook
committed
#include "llnavigationbar.h"
AlexanderP ProductEngine
committed
#include "llfloaterimnearbychat.h"
#include "llnotifications.h"
#include "llnotificationsutil.h"
#include "llnotificationtemplate.h"
#include "llpanellogin.h"
#include "llpanelvoicedevicesettings.h"
#include "llradiogroup.h"
#include "llsky.h"
#include "llscrolllistctrl.h"
#include "llscrolllistitem.h"
#include "llsliderctrl.h"
#include "lltabcontainer.h"
#include "lltrans.h"
#include "llviewercamera.h"
#include "llviewermessage.h"
#include "llviewershadermgr.h"
Paul ProductEngine
committed
#include "llviewerthrottle.h"
Mnikolenko ProductEngine
committed
#include "llvoavatarself.h"
#include "llvotree.h"
#include "llvosky.h"
prep@lindenlab.com
committed
#include "llfloaterpathfindingconsole.h"
// linden library includes
#include "llavatarnamecache.h"
#include "llerror.h"
#include "llfontgl.h"
#include "llrect.h"
#include "llstring.h"
#include "alunzip.h"
// project includes
#include "llbutton.h"
#include "llflexibleobject.h"
#include "lllineeditor.h"
#include "llresmgr.h"
#include "llspinctrl.h"
#include "llstartup.h"
#include "lltextbox.h"
#include "llui.h"
#include "llversioninfo.h"
#include "llviewerobjectlist.h"
#include "llvoavatar.h"
#include "llvovolume.h"
#include "llwindow.h"
#include "llworld.h"
#include "pipeline.h"
#include "lluictrlfactory.h"
#include "llviewermedia.h"
#include "llpluginclassmedia.h"
#include "llweb.h"
// [RLVa:KB] - Checked: 2010-03-18 (RLVa-1.2.0a)
#include "rlvactions.h"
Eugene Mutavchi
committed
#include "lllogininstance.h" // to check if logged in yet
Andrew Productengine
committed
#include "llsdserialize.h"
#include "llpresetsmanager.h"
#include "llviewercontrol.h"
#include "llviewertexturelist.h"
Eugene Mutavchi
committed
#include <json/json.h>
#include <utility>
#include "llsearchableui.h"
Richard Linden
committed
char const* const VISIBILITY_DEFAULT = "default";
char const* const VISIBILITY_HIDDEN = "hidden";
//control value for middle mouse as talk2push button
const static std::string MIDDLE_MOUSE_CV = "MiddleMouse"; // for voice client and redability
const static std::string MOUSE_BUTTON_4_CV = "MouseButton4";
const static std::string MOUSE_BUTTON_5_CV = "MouseButton5";
/// This must equal the maximum value set for the IndirectMaxComplexity slider in panel_preferences_graphics1.xml
static const U32 INDIRECT_MAX_ARC_OFF = 101; // all the way to the right == disabled
static const U32 MIN_INDIRECT_ARC_LIMIT = 1; // must match minimum of IndirectMaxComplexity in panel_preferences_graphics1.xml
static const U32 MAX_INDIRECT_ARC_LIMIT = INDIRECT_MAX_ARC_OFF-1; // one short of all the way to the right...
/// These are the effective range of values for RenderAvatarMaxComplexity
static const F32 MIN_ARC_LIMIT = 20000.0f;
static const F32 MAX_ARC_LIMIT = 350000.0f;
static const F32 MIN_ARC_LOG = log(MIN_ARC_LIMIT);
static const F32 MAX_ARC_LOG = log(MAX_ARC_LIMIT);
static const F32 ARC_LIMIT_MAP_SCALE = (MAX_ARC_LOG - MIN_ARC_LOG) / (MAX_INDIRECT_ARC_LIMIT - MIN_INDIRECT_ARC_LIMIT);
andreykproductengine
committed
struct LabelDef : public LLInitParam::Block<LabelDef>
{
Mandatory<std::string> name;
Mandatory<std::string> value;
LabelDef()
: name("name"),
value("value")
{}
};
struct LabelTable : public LLInitParam::Block<LabelTable>
{
Multiple<LabelDef> labels;
LabelTable()
: labels("label")
{}
};
class LLVoiceSetKeyDialog : public LLModalDialog
{
public:
LLVoiceSetKeyDialog(const LLSD& key);
~LLVoiceSetKeyDialog();
/*virtual*/ BOOL postBuild();
void setParent(LLFloaterPreference* parent) { mParent = parent; }
BOOL handleKeyHere(KEY key, MASK mask);
BOOL handleAnyMouseClick(S32 x, S32 y, MASK mask, LLMouseHandler::EClickType clicktype, BOOL down);
static void onCancel(void* user_data);
private:
LLFloaterPreference* mParent;
};
typedef enum e_skin_type
{
SYSTEM_SKIN,
USER_SKIN
} ESkinType;
typedef struct skin_t
{
std::string mName = "Unknown";
std::string mAuthor = "Unknown";
std::string mUrl = "Unknown";
LLDate mDate = LLDate(0.0);
std::string mCompatVer = "Unknown";
std::string mNotes = LLStringUtil::null;
ESkinType mType = USER_SKIN;
} skin_t;
LLVoiceSetKeyDialog::LLVoiceSetKeyDialog(const LLSD& key)
: LLModalDialog(key),
mParent(NULL)
{
}
Christian Goetze
committed
//virtual
BOOL LLVoiceSetKeyDialog::postBuild()
childSetAction("Cancel", onCancel, this);
getChild<LLUICtrl>("Cancel")->setFocus(TRUE);
gFocusMgr.setKeystrokesOnly(TRUE);
LLVoiceSetKeyDialog::~LLVoiceSetKeyDialog()
BOOL LLVoiceSetKeyDialog::handleKeyHere(KEY key, MASK mask)
BOOL result = TRUE;
if (key == 'Q' && mask == MASK_CONTROL)
{
result = FALSE;
}
{
mParent->setKey(key);
}
closeFloater();
return result;
}
BOOL LLVoiceSetKeyDialog::handleAnyMouseClick(S32 x, S32 y, MASK mask, LLMouseHandler::EClickType clicktype, BOOL down)
{
BOOL result = FALSE;
if (down
&& (clicktype == LLMouseHandler::CLICK_MIDDLE || clicktype == LLMouseHandler::CLICK_BUTTON4 || clicktype == LLMouseHandler::CLICK_BUTTON5)
&& mask == 0)
{
mParent->setMouse(clicktype);
result = TRUE;
closeFloater();
}
else
{
result = LLMouseHandler::handleAnyMouseClick(x, y, mask, clicktype, down);
}
return result;
}
//static
void LLVoiceSetKeyDialog::onCancel(void* user_data)
{
LLVoiceSetKeyDialog* self = (LLVoiceSetKeyDialog*)user_data;
self->closeFloater();
}
// global functions
// helper functions for getting/freeing the web browser media
// if creating/destroying these is too slow, we'll need to create
// a static member and update all our static callbacks
James Cook
committed
void handleNameTagOptionChanged(const LLSD& newvalue);
void handleDisplayNamesOptionChanged(const LLSD& newvalue);
bool callback_clear_browser_cache(const LLSD& notification, const LLSD& response);
bool callback_clear_cache(const LLSD& notification, const LLSD& response);
//bool callback_skip_dialogs(const LLSD& notification, const LLSD& response, LLFloaterPreference* floater);
//bool callback_reset_dialogs(const LLSD& notification, const LLSD& response, LLFloaterPreference* floater);
void fractionFromDecimal(F32 decimal_val, S32& numerator, S32& denominator);
bool callback_clear_cache(const LLSD& notification, const LLSD& response)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
if ( option == 0 ) // YES
{
// flag client texture cache for clearing next time the client runs
gSavedSettings.setBOOL("PurgeCacheOnNextStartup", TRUE);
LLNotificationsUtil::add("CacheWillClear");
}
return false;
}
bool callback_clear_browser_cache(const LLSD& notification, const LLSD& response)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
if ( option == 0 ) // YES
Christian Goetze
committed
{
James Cook
committed
// clean web
LLViewerMedia::getInstance()->clearAllCaches();
LLViewerMedia::getInstance()->clearAllCookies();
James Cook
committed
// clean nav bar history
LLNavigationBar::getInstance()->clearHistoryCache();
// flag client texture cache for clearing next time the client runs
gSavedSettings.setBOOL("PurgeCacheOnNextStartup", TRUE);
LLNotificationsUtil::add("CacheWillClear");
LLSearchHistory::getInstance()->clearHistory();
LLSearchHistory::getInstance()->save();
LLSearchComboBox* search_ctrl = LLNavigationBar::getInstance()->getChild<LLSearchComboBox>("search_combo_box");
search_ctrl->clearHistory();
LLTeleportHistoryStorage::getInstance()->purgeItems();
LLTeleportHistoryStorage::getInstance()->save();
Christian Goetze
committed
}
James Cook
committed
return false;
}
Christian Goetze
committed
James Cook
committed
void handleNameTagOptionChanged(const LLSD& newvalue)
{
LLAvatarNameCache::getInstance()->setUseUsernames(gSavedSettings.getBOOL("NameTagShowUsernames"));
LLVOAvatar::invalidateNameTags();
James Cook
committed
}
void handleDisplayNamesOptionChanged(const LLSD& newvalue)
{
LLAvatarNameCache::getInstance()->setUseDisplayNames(newvalue.asBoolean());
LLVOAvatar::invalidateNameTags();
Mnikolenko ProductEngine
committed
void handleAppearanceCameraMovementChanged(const LLSD& newvalue)
{
if(!newvalue.asBoolean() && gAgentCamera.getCameraMode() == CAMERA_MODE_CUSTOMIZE_AVATAR)
{
gAgentCamera.changeCameraToDefault();
gAgentCamera.resetView();
}
}
/*bool callback_skip_dialogs(const LLSD& notification, const LLSD& response, LLFloaterPreference* floater)
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
if (0 == option && floater )
if ( floater )
{
floater->setAllIgnored();
// LLFirstUse::disableFirstUse();
floater->buildPopupLists();
bool callback_reset_dialogs(const LLSD& notification, const LLSD& response, LLFloaterPreference* floater)
Don Kjer
committed
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
if ( 0 == option && floater )
Don Kjer
committed
{
if ( floater )
{
floater->resetAllIgnored();
//LLFirstUse::resetFirstUse();
floater->buildPopupLists();
Don Kjer
committed
}
return false;
}
*/
void fractionFromDecimal(F32 decimal_val, S32& numerator, S32& denominator)
{
numerator = 0;
denominator = 0;
for (F32 test_denominator = 1.f; test_denominator < 30.f; test_denominator += 1.f)
{
if (fmodf((decimal_val * test_denominator) + 0.01f, 1.f) < 0.02f)
{
callum_linden
committed
numerator = ll_round(decimal_val * test_denominator);
denominator = ll_round(test_denominator);
break;
}
}
}
// static
std::string LLFloaterPreference::sSkin = "";
//////////////////////////////////////////////
// LLFloaterPreference
LLFloaterPreference::LLFloaterPreference(const LLSD& key)
: LLFloater(key),
mGotPersonalInfo(false),
Andrew Productengine
committed
mOriginalIMViaEmail(false),
Vadim ProductEngine
committed
mLanguageChanged(false),
mClickActionDirty(false)
maksymsproductengine
committed
LLConversationLog::instance().addObserver(this);
//Build Floater is now Called from LLFloaterReg::add("preferences", "floater_preferences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreference>);
static bool registered_dialog = false;
if (!registered_dialog)
{
LLFloaterReg::add("voice_set_key", "floater_select_key.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLVoiceSetKeyDialog>);
registered_dialog = true;
}
mCommitCallbackRegistrar.add("Pref.Cancel", boost::bind(&LLFloaterPreference::onBtnCancel, this, _2));
mCommitCallbackRegistrar.add("Pref.OK", boost::bind(&LLFloaterPreference::onBtnOK, this, _2));
mCommitCallbackRegistrar.add("Pref.ClearCache", boost::bind(&LLFloaterPreference::onClickClearCache, this));
James Cook
committed
mCommitCallbackRegistrar.add("Pref.WebClearCache", boost::bind(&LLFloaterPreference::onClickBrowserClearCache, this));
mCommitCallbackRegistrar.add("Pref.SetCache", boost::bind(&LLFloaterPreference::onClickSetCache, this));
mCommitCallbackRegistrar.add("Pref.ResetCache", boost::bind(&LLFloaterPreference::onClickResetCache, this));
mCommitCallbackRegistrar.add("Pref.VoiceSetKey", boost::bind(&LLFloaterPreference::onClickSetKey, this));
mCommitCallbackRegistrar.add("Pref.VoiceSetMiddleMouse", boost::bind(&LLFloaterPreference::onClickSetMiddleMouse, this));
mCommitCallbackRegistrar.add("Pref.SetSounds", boost::bind(&LLFloaterPreference::onClickSetSounds, this));
mCommitCallbackRegistrar.add("Pref.ClickEnablePopup", boost::bind(&LLFloaterPreference::onClickEnablePopup, this));
James Cook
committed
mCommitCallbackRegistrar.add("Pref.ClickDisablePopup", boost::bind(&LLFloaterPreference::onClickDisablePopup, this));
mCommitCallbackRegistrar.add("Pref.LogPath", boost::bind(&LLFloaterPreference::onClickLogPath, this));
mCommitCallbackRegistrar.add("Pref.RenderExceptions", boost::bind(&LLFloaterPreference::onClickRenderExceptions, this));
mCommitCallbackRegistrar.add("Pref.HardwareDefaults", boost::bind(&LLFloaterPreference::setHardwareDefaults, this));
mCommitCallbackRegistrar.add("Pref.AvatarImpostorsEnable", boost::bind(&LLFloaterPreference::onAvatarImpostorsEnable, this));
mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxComplexity", boost::bind(&LLFloaterPreference::updateMaxComplexity, this));
mCommitCallbackRegistrar.add("Pref.RenderOptionUpdate", boost::bind(&LLFloaterPreference::onRenderOptionEnable, this));
mCommitCallbackRegistrar.add("Pref.WindowedMod", boost::bind(&LLFloaterPreference::onCommitWindowedMode, this));
mCommitCallbackRegistrar.add("Pref.UpdateSliderText", boost::bind(&LLFloaterPreference::refreshUI,this));
mCommitCallbackRegistrar.add("Pref.QualityPerformance", boost::bind(&LLFloaterPreference::onChangeQuality, this, _2));
mCommitCallbackRegistrar.add("Pref.applyUIColor", boost::bind(&LLFloaterPreference::applyUIColor, this ,_1, _2));
mCommitCallbackRegistrar.add("Pref.getUIColor", boost::bind(&LLFloaterPreference::getUIColor, this ,_1, _2));
mCommitCallbackRegistrar.add("Pref.MaturitySettings", boost::bind(&LLFloaterPreference::onChangeMaturity, this));
mCommitCallbackRegistrar.add("Pref.BlockList", boost::bind(&LLFloaterPreference::onClickBlockList, this));
mCommitCallbackRegistrar.add("Pref.Proxy", boost::bind(&LLFloaterPreference::onClickProxySettings, this));
mCommitCallbackRegistrar.add("Pref.TranslationSettings", boost::bind(&LLFloaterPreference::onClickTranslationSettings, this));
Oz Linden
committed
mCommitCallbackRegistrar.add("Pref.AutoReplace", boost::bind(&LLFloaterPreference::onClickAutoReplace, this));
mCommitCallbackRegistrar.add("Pref.PermsDefault", boost::bind(&LLFloaterPreference::onClickPermsDefault, this));
mCommitCallbackRegistrar.add("Pref.RememberedUsernames", boost::bind(&LLFloaterPreference::onClickRememberedUsernames, this));
Kitty Barnett
committed
mCommitCallbackRegistrar.add("Pref.SpellChecker", boost::bind(&LLFloaterPreference::onClickSpellChecker, this));
mCommitCallbackRegistrar.add("Pref.Advanced", boost::bind(&LLFloaterPreference::onClickAdvanced, this));
sSkin = gSavedSettings.getString("SkinCurrent");
maksymsproductengine
committed
mCommitCallbackRegistrar.add("Pref.ClickActionChange", boost::bind(&LLFloaterPreference::onClickActionChange, this));
gSavedSettings.getControl("NameTagShowUsernames")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged, _2));
gSavedSettings.getControl("NameTagShowFriends")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged, _2));
gSavedSettings.getControl("UseDisplayNames")->getCommitSignal()->connect(boost::bind(&handleDisplayNamesOptionChanged, _2));
Mnikolenko ProductEngine
committed
gSavedSettings.getControl("AppearanceCameraMovement")->getCommitSignal()->connect(boost::bind(&handleAppearanceCameraMovementChanged, _2));
LLAvatarPropertiesProcessor::getInstance()->addObserver( gAgent.getID(), this );
maksymsproductengine
committed
mCommitCallbackRegistrar.add("Pref.ClearLog", boost::bind(&LLConversationLog::onClearLog, &LLConversationLog::instance()));
mCommitCallbackRegistrar.add("Pref.DeleteTranscripts", boost::bind(&LLFloaterPreference::onDeleteTranscripts, this));
mCommitCallbackRegistrar.add("UpdateFilter", boost::bind(&LLFloaterPreference::onUpdateFilterTerm, this, false)); // <FS:ND/> Hook up for filtering
mCommitCallbackRegistrar.add("Pref.AddSkin", boost::bind(&LLFloaterPreference::onAddSkin, this));
mCommitCallbackRegistrar.add("Pref.RemoveSkin", boost::bind(&LLFloaterPreference::onRemoveSkin, this));
mCommitCallbackRegistrar.add("Pref.ApplySkin", boost::bind(&LLFloaterPreference::onApplySkin, this));
mCommitCallbackRegistrar.add("Pref.SelectSkin", boost::bind(&LLFloaterPreference::onSelectSkin, this, _2));
void LLFloaterPreference::processProperties( void* pData, EAvatarProcessorType type )
{
if ( APT_PROPERTIES == type )
{
const LLAvatarData* pAvatarData = static_cast<const LLAvatarData*>( pData );
Leslie Linden
committed
if (pAvatarData && (gAgent.getID() == pAvatarData->avatar_id) && (pAvatarData->avatar_id != LLUUID::null))
{
storeAvatarProperties( pAvatarData );
processProfileProperties( pAvatarData );
}
}
}
void LLFloaterPreference::storeAvatarProperties( const LLAvatarData* pAvatarData )
{
Leslie Linden
committed
if (LLStartUp::getStartupState() == STATE_STARTED)
Leslie Linden
committed
mAvatarProperties.avatar_id = pAvatarData->avatar_id;
mAvatarProperties.image_id = pAvatarData->image_id;
mAvatarProperties.fl_image_id = pAvatarData->fl_image_id;
mAvatarProperties.about_text = pAvatarData->about_text;
mAvatarProperties.fl_about_text = pAvatarData->fl_about_text;
mAvatarProperties.profile_url = pAvatarData->profile_url;
mAvatarProperties.flags = pAvatarData->flags;
mAvatarProperties.allow_publish = pAvatarData->flags & AVATAR_ALLOW_PUBLISH;
mAvatarDataInitialized = true;
}
}
void LLFloaterPreference::processProfileProperties(const LLAvatarData* pAvatarData )
{
getChild<LLUICtrl>("online_searchresults")->setValue( (bool)(pAvatarData->flags & AVATAR_ALLOW_PUBLISH) );
void LLFloaterPreference::saveAvatarProperties( void )
{
Leslie Linden
committed
const BOOL allowPublish = getChild<LLUICtrl>("online_searchresults")->getValue();
if (allowPublish)
Leslie Linden
committed
//
// NOTE: We really don't want to send the avatar properties unless we absolutely
// need to so we can avoid the accidental profile reset bug, so, if we're
// logged in, the avatar data has been initialized and we have a state change
// for the "allow publish" flag, then set the flag to its new value and send
// the properties update.
//
// NOTE: The only reason we can not remove this update altogether is because of the
// "allow publish" flag, the last remaining profile setting in the viewer
// that doesn't exist in the web profile.
//
if ((LLStartUp::getStartupState() == STATE_STARTED) && mAvatarDataInitialized && (allowPublish != mAvatarProperties.allow_publish))
Leslie Linden
committed
mAvatarProperties.allow_publish = allowPublish;
LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesUpdate( &mAvatarProperties );
}
}
BOOL LLFloaterPreference::postBuild()
{
maksymsproductengine
committed
gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&LLFloaterIMSessionTab::processChatHistoryStyleUpdate, false));
Eugene Mutavchi
committed
Vadim ProductEngine
committed
gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&LLViewerChat::signalChatFontChanged));
Seth ProductEngine
committed
gSavedSettings.getControl("ChatBubbleOpacity")->getSignal()->connect(boost::bind(&LLFloaterPreference::onNameTagOpacityChange, this, _2));
Todd Stinson
committed
gSavedSettings.getControl("PreferredMaturity")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeMaturity, this));
gSavedPerAccountSettings.getControl("ModelUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeModelFolder, this));
gSavedPerAccountSettings.getControl("TextureUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeTextureFolder, this));
gSavedPerAccountSettings.getControl("SoundUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeSoundFolder, this));
gSavedPerAccountSettings.getControl("AnimationUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeAnimationFolder, this));
LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
if (!tabcontainer->selectTab(gSavedSettings.getS32("LastPrefTab")))
tabcontainer->selectFirstTab();
Leyla Farazha
committed
Vadim ProductEngine
committed
getChild<LLUICtrl>("cache_location")->setEnabled(FALSE); // make it read-only but selectable (STORM-227)
std::string cache_location = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "");
Vadim ProductEngine
committed
setCacheLocation(cache_location);
Leyla Farazha
committed
Merov Linden
committed
getChild<LLUICtrl>("log_path_string")->setEnabled(FALSE); // make it read-only but selectable
Vadim ProductEngine
committed
getChild<LLComboBox>("language_combobox")->setCommitCallback(boost::bind(&LLFloaterPreference::onLanguageChange, this));
maxim_productengine
committed
getChild<LLComboBox>("FriendIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"FriendIMOptions"));
getChild<LLComboBox>("NonFriendIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"NonFriendIMOptions"));
getChild<LLComboBox>("ConferenceIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"ConferenceIMOptions"));
getChild<LLComboBox>("GroupChatOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"GroupChatOptions"));
getChild<LLComboBox>("NearbyChatOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"NearbyChatOptions"));
getChild<LLComboBox>("ObjectIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"ObjectIMOptions"));
maxim_productengine
committed
William Todd Stinson
committed
// if floater is opened before login set default localized do not disturb message
Andrew Dyukov
committed
if (LLStartUp::getStartupState() < STATE_STARTED)
{
William Todd Stinson
committed
gSavedPerAccountSettings.setString("DoNotDisturbModeResponse", LLTrans::getString("DoNotDisturbModeResponseDefault"));
Andrew Dyukov
committed
}
maksymsproductengine
committed
// set 'enable' property for 'Clear log...' button
changed();
LLLogChat::getInstance()->setSaveHistorySignal(boost::bind(&LLFloaterPreference::onLogChatHistorySaved, this));
loadUserSkins();
maksymsproductengine
committed
Mnikolenko ProductEngine
committed
LLSliderCtrl* fov_slider = getChild<LLSliderCtrl>("camera_fov");
fov_slider->setMinValue(LLViewerCamera::getInstance()->getMinView());
fov_slider->setMaxValue(LLViewerCamera::getInstance()->getMaxView());
// Hook up and init for filtering
mFilterEdit = getChild<LLSearchEditor>("search_prefs_edit");
mFilterEdit->setKeystrokeCallback(boost::bind(&LLFloaterPreference::onUpdateFilterTerm, this, false));
andreykproductengine
committed
// Load and assign label for 'default language'
std::string user_filename = gDirUtilp->getExpandedFilename(LL_PATH_DEFAULT_SKIN, "default_languages.xml");
std::map<std::string, std::string> labels;
if (loadFromFilename(user_filename, labels))
{
std::string system_lang = gSavedSettings.getString("SystemLanguage");
std::map<std::string, std::string>::iterator iter = labels.find(system_lang);
if (iter != labels.end())
{
getChild<LLComboBox>("language_combobox")->add(iter->second, LLSD("default"), ADD_TOP, true);
}
else
{
LL_WARNS() << "Language \"" << system_lang << "\" is not in default_languages.xml" << LL_ENDL;
getChild<LLComboBox>("language_combobox")->add("System default", LLSD("default"), ADD_TOP, true);
}
}
else
{
LL_WARNS() << "Failed to load labels from " << user_filename << ". Using default." << LL_ENDL;
getChild<LLComboBox>("language_combobox")->add("System default", LLSD("default"), ADD_TOP, true);
}
return TRUE;
}
maksymsproductengine
committed
void LLFloaterPreference::updateDeleteTranscriptsButton()
{
std::vector<std::string> list_of_transcriptions_file_names;
LLLogChat::getListOfTranscriptFiles(list_of_transcriptions_file_names);
getChild<LLButton>("delete_transcripts")->setEnabled(list_of_transcriptions_file_names.size() > 0);
}
William Todd Stinson
committed
void LLFloaterPreference::onDoNotDisturbResponseChanged()
Andrew Dyukov
committed
{
William Todd Stinson
committed
// set "DoNotDisturbResponseChanged" TRUE if user edited message differs from default, FALSE otherwise
bool response_changed_flag =
LLTrans::getString("DoNotDisturbModeResponseDefault")
!= getChild<LLUICtrl>("do_not_disturb_response")->getValue().asString();
AlexanderP ProductEngine
committed
William Todd Stinson
committed
gSavedPerAccountSettings.setBOOL("DoNotDisturbResponseChanged", response_changed_flag );
Andrew Dyukov
committed
}
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
////////////////////////////////////////////////////
// Skins panel
skin_t manifestFromJson(const std::string& filename, const ESkinType type)
{
skin_t skin;
Json::Reader reader;
Json::Value root;
llifstream in;
in.open(filename);
if (in.is_open())
{
if (reader.parse(in, root, false))
{
skin.mName = root.get("name", "Unknown").asString();
skin.mAuthor = root.get("author", "Unknown").asString();
skin.mUrl = root.get("url", "Unknown").asString();
skin.mCompatVer = root.get("compatibility", "Unknown").asString();
skin.mDate = LLDate(root.get("date", "1983-04-20T00:00:00+00:00").asString());
skin.mNotes = root.get("notes", "").asString();
// If it's a system skin, the compatability version is always the current build
if (type == SYSTEM_SKIN)
{
skin.mCompatVer = LLVersionInfo::getShortVersion();
}
}
else
{
LL_WARNS() << "Failed to parse " << filename << ": " << reader.getFormatedErrorMessages() << LL_ENDL;
}
in.close();
}
skin.mType = type;
return skin;
}
void LLFloaterPreference::loadUserSkins()
{
mUserSkins.clear();
LLDirIterator sysiter(gDirUtilp->getSkinBaseDir(), "*");
bool found = true;
while (found)
{
std::string dir;
if ((found = sysiter.next(dir)))
{
const std::string& fullpath = gDirUtilp->add(gDirUtilp->getSkinBaseDir(), dir);
if (!LLFile::isdir(fullpath)) continue; // only directories!
const std::string& manifestpath = gDirUtilp->add(fullpath, "manifest.json");
skin_t skin = manifestFromJson(manifestpath, SYSTEM_SKIN);
mUserSkins.emplace(dir, skin);
}
}
const std::string userskindir = gDirUtilp->add(gDirUtilp->getOSUserAppDir(), "skins");
if (LLFile::isdir(userskindir))
{
LLDirIterator iter(userskindir, "*");
found = true;
while (found)
{
std::string dir;
if ((found = iter.next(dir)))
{
const std::string& fullpath = gDirUtilp->add(userskindir, dir);
if (!LLFile::isdir(fullpath)) continue; // only directories!
const std::string& manifestpath = gDirUtilp->add(fullpath, "manifest.json");
skin_t skin = manifestFromJson(manifestpath, USER_SKIN);
mUserSkins.emplace(dir, skin);
}
}
}
reloadSkinList();
}
void LLFloaterPreference::reloadSkinList()
{
LLScrollListCtrl* skin_list = getChild<LLScrollListCtrl>("skin_list");
const std::string current_skin = gSavedSettings.getString("SkinCurrent");
skin_list->clearRows();
// User Downloaded Skins
for (const auto& skin : mUserSkins)
{
LLSD row;
row["id"] = skin.first;
row["columns"][0]["value"] = skin.second.mName == "Unknown" ? skin.first : skin.second.mName;
row["columns"][0]["font"]["style"] = current_skin == skin.first ? "BOLD" : "NORMAL";
skin_list->addElement(row);
}
skin_list->setSelectedByValue(current_skin, TRUE);
onSelectSkin(skin_list->getSelectedValue());
}
void LLFloaterPreference::onAddSkin()
{
LLFilePicker& filepicker = LLFilePicker::instance();
if (filepicker.getOpenFile(LLFilePicker::FFLOAD_ZIP))
{
const std::string& package = filepicker.getFirstFile();
auto zip = std::make_unique<ALUnZip>(package);
if (zip->isValid())
{
size_t buf_size = zip->getSizeFile("manifest.json");
if (buf_size)
{
buf_size++;
buf_size *= sizeof(char);
auto buf = std::make_unique<char[]>(buf_size);
zip->extractFile("manifest.json", buf.get(), buf_size);
buf[buf_size - 1] = '\0'; // force.
std::stringstream ss;
ss << std::string(const_cast<const char*>(buf.get()), buf_size);
buf.reset();
Json::Reader reader;
Json::Value root;
std::string errors;
if (reader.parse(ss, root, false))
{
const std::string& name = root.get("name", "Unknown").asString();
std::string pathname = gDirUtilp->add(gDirUtilp->getOSUserAppDir(), "skins");
if (!gDirUtilp->fileExists(pathname))
{
LLFile::mkdir(pathname);
}
pathname = gDirUtilp->add(pathname, name);
if (!LLFile::isdir(pathname) && (LLFile::mkdir(pathname) != 0))
{
LLNotificationsUtil::add("AddSkinUnpackFailed");
}
else if (!zip->extract(pathname))
{
LLNotificationsUtil::add("AddSkinUnpackFailed");
}
else
{
loadUserSkins();
LLNotificationsUtil::add("AddSkinSuccess", LLSD().with("PACKAGE", name));
}
}
else
{
LLNotificationsUtil::add("AddSkinCantParseManifest", LLSD().with("PACKAGE", package));
}
}
else
{
LLNotificationsUtil::add("AddSkinNoManifest", LLSD().with("PACKAGE", package));
}
}
}
}
void LLFloaterPreference::onRemoveSkin()
{
LLScrollListCtrl* skin_list = findChild<LLScrollListCtrl>("skin_list");
if (skin_list)
{
LLSD args;
args["SKIN"] = skin_list->getSelectedValue().asString();
LLNotificationsUtil::add("ConfirmRemoveSkin", args, args,
boost::bind(&LLFloaterPreference::callbackRemoveSkin, this, _1, _2));
}
}
void LLFloaterPreference::callbackRemoveSkin(const LLSD& notification, const LLSD& response)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
if (option == 0) // YES
{
const std::string& skin = notification["payload"]["SKIN"].asString();
std::string dir = gDirUtilp->add(gDirUtilp->getOSUserAppDir(), "skins");
dir = gDirUtilp->add(dir, skin);
if (gDirUtilp->deleteDirAndContents(dir) > 0)
{
skinmap_t::iterator iter = mUserSkins.find(skin);
if (iter != mUserSkins.end())
mUserSkins.erase(iter);
// If we just deleted the current skin, reset to default. It might not even be a good
// idea to allow this, but we'll see!
if (gSavedSettings.getString("SkinCurrent") == skin)
{
gSavedSettings.setString("SkinCurrent", DEFAULT_SKIN);
}
LLNotificationsUtil::add("RemoveSkinSuccess", LLSD().with("SKIN", skin));
}
else
{
LLNotificationsUtil::add("RemoveSkinFailure", LLSD().with("SKIN", skin));
}
reloadSkinList();
}
}
void LLFloaterPreference::callbackApplySkin(const LLSD& notification, const LLSD& response)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
switch (option)
{
case 0: // Yes
gSavedSettings.setBOOL("ResetUserColorsOnLogout", TRUE);
break;
case 1: // No
gSavedSettings.setBOOL("ResetUserColorsOnLogout", FALSE);
break;
case 2: // Cancel
gSavedSettings.setString("SkinCurrent", sSkin);
reloadSkinList();
break;
default:
LL_WARNS() << "Unhandled option! How could this be?" << LL_ENDL;
break;
}
}
void LLFloaterPreference::onApplySkin()
{
LLScrollListCtrl* skin_list = findChild<LLScrollListCtrl>("skin_list");
if (skin_list)
{
gSavedSettings.setString("SkinCurrent", skin_list->getSelectedValue().asString());
reloadSkinList();
}
if (sSkin != gSavedSettings.getString("SkinCurrent"))
{
LLNotificationsUtil::add("ChangeSkin", LLSD(), LLSD(),
boost::bind(&LLFloaterPreference::callbackApplySkin, this, _1, _2));
}
}
void LLFloaterPreference::onSelectSkin(const LLSD& data)
{
bool userskin = false;
skinmap_t::iterator iter = mUserSkins.find(data.asString());
if (iter != mUserSkins.end())
{
refreshSkinInfo(iter->second);
userskin = (iter->second.mType == USER_SKIN);
}
getChild<LLUICtrl>("remove_skin")->setEnabled(userskin);
}
void LLFloaterPreference::refreshSkinInfo(const skin_t& skin)
{
getChild<LLTextBase>("skin_name")->setText(skin.mName);
getChild<LLTextBase>("skin_author")->setText(skin.mAuthor);
getChild<LLTextBase>("skin_homepage")->setText(skin.mUrl);
getChild<LLTextBase>("skin_date")->setText(skin.mDate.toHTTPDateString("%A, %d %b %Y"));
getChild<LLTextBase>("skin_compatibility")->setText(skin.mCompatVer);
getChild<LLTextBase>("skin_notes")->setText(skin.mNotes);
}
LLFloaterPreference::~LLFloaterPreference()
{
maksymsproductengine
committed
LLConversationLog::instance().removeObserver(this);
void LLFloaterPreference::draw()
{
BOOL has_first_selected = (getChildRef<LLScrollListCtrl>("disabled_popups").getFirstSelected()!=NULL);
gSavedSettings.setBOOL("FirstSelectedDisabledPopups", has_first_selected);
James Cook
committed
has_first_selected = (getChildRef<LLScrollListCtrl>("enabled_popups").getFirstSelected()!=NULL);
gSavedSettings.setBOOL("FirstSelectedEnabledPopups", has_first_selected);
LLFloater::draw();
}
void LLFloaterPreference::saveSettings()
{
LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
child_list_t::const_iterator end = tabcontainer->getChildList()->end();
for ( ; iter != end; ++iter)
{
LLView* view = *iter;
LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
if (panel)
panel->saveSettings();
}
}
void LLFloaterPreference::apply()
{
LLAvatarPropertiesProcessor::getInstance()->addObserver( gAgent.getID(), this );
LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
if (sSkin != gSavedSettings.getString("SkinCurrent"))
Don Kjer
committed
{
sSkin = gSavedSettings.getString("SkinCurrent");
Don Kjer
committed
}
// Call apply() on all panels that derive from LLPanelPreference
for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
iter != tabcontainer->getChildList()->end(); ++iter)
Don Kjer
committed
{
LLView* view = *iter;
LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
if (panel)
panel->apply();
Don Kjer
committed
}
gViewerWindow->requestResolutionUpdate(); // for UIScaleFactor
LLSliderCtrl* fov_slider = getChild<LLSliderCtrl>("camera_fov");
fov_slider->setMinValue(LLViewerCamera::getInstance()->getMinView());
fov_slider->setMaxValue(LLViewerCamera::getInstance()->getMaxView());
std::string cache_location = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "");
Vadim ProductEngine
committed
setCacheLocation(cache_location);
LLViewerMedia::getInstance()->setCookiesEnabled(getChild<LLUICtrl>("cookies_enabled")->getValue());
AlexanderP ProductEngine
committed
if (hasChild("web_proxy_enabled", TRUE) &&hasChild("web_proxy_editor", TRUE) && hasChild("web_proxy_port", TRUE))
Don Kjer
committed
{
bool proxy_enable = getChild<LLUICtrl>("web_proxy_enabled")->getValue();
std::string proxy_address = getChild<LLUICtrl>("web_proxy_editor")->getValue();
int proxy_port = getChild<LLUICtrl>("web_proxy_port")->getValue();
LLViewerMedia::getInstance()->setProxyConfig(proxy_enable, proxy_address, proxy_port);
Don Kjer
committed
}
bool new_im_via_email = getChild<LLUICtrl>("send_im_to_email")->getValue().asBoolean();
bool new_hide_online = getChild<LLUICtrl>("online_visibility")->getValue().asBoolean();
if ((new_im_via_email != mOriginalIMViaEmail)
||(new_hide_online != mOriginalHideOnlineStatus))
{
// This hack is because we are representing several different
// possible strings with a single checkbox. Since most users
// can only select between 2 values, we represent it as a
// checkbox. This breaks down a little bit for liaisons, but
// works out in the end.
if (new_hide_online != mOriginalHideOnlineStatus)
{
if (new_hide_online) mDirectoryVisibility = VISIBILITY_HIDDEN;
else mDirectoryVisibility = VISIBILITY_DEFAULT;
//Update showonline value, otherwise multiple applys won't work
mOriginalHideOnlineStatus = new_hide_online;
gAgent.sendAgentUpdateUserInfo(new_im_via_email,mDirectoryVisibility);
}
}
Andrew Productengine
committed
saveAvatarProperties();
Andrew Productengine
committed
if (mClickActionDirty)
Andrew Productengine
committed
{
updateClickActionSettings();
mClickActionDirty = false;
Andrew Productengine
committed
}
}
void LLFloaterPreference::cancel()
{