Newer
Older
if (gInventory.isInventoryUsable())
{
getChild<LLTextBox>("upload_animation")->setText(get_category_path(LLFolderType::FT_ANIMATION));
}
}
// FIXME: this will stop you from spawning the sidetray from preferences dialog on login screen
// but the UI for this will still be enabled
void LLFloaterPreference::onClickBlockList()
{
LLFloaterSidePanelContainer::showPanel("people", "panel_people",
LLSD().with("people_panel_tab_name", "blocked_panel"));
}
void LLFloaterPreference::onClickProxySettings()
Andrew Productengine
committed
{
LLFloaterReg::showInstance("prefs_proxy");
Andrew Productengine
committed
}
void LLFloaterPreference::onClickTranslationSettings()
Andrew Productengine
committed
{
LLFloaterReg::showInstance("prefs_translation");
Andrew Productengine
committed
}
Oz Linden
committed
void LLFloaterPreference::onClickAutoReplace()
{
LLFloaterReg::showInstance("prefs_autoreplace");
}
Kitty Barnett
committed
void LLFloaterPreference::onClickSpellChecker()
{
LLFloaterReg::showInstance("prefs_spellchecker");
Kitty Barnett
committed
}
void LLFloaterPreference::onClickRenderExceptions()
{
LLFloaterReg::showInstance("avatar_render_settings");
}
void LLFloaterPreference::onClickAdvanced()
{
LLFloaterReg::showInstance("prefs_graphics_advanced");
AndreyL ProductEngine
committed
LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
iter != tabcontainer->getChildList()->end(); ++iter)
{
LLView* view = *iter;
LLPanelPreferenceGraphics* panel = dynamic_cast<LLPanelPreferenceGraphics*>(view);
if (panel)
{
panel->resetDirtyChilds();
}
}
}
void LLFloaterPreference::onClickPermsDefault()
{
LLFloaterReg::showInstance("perms_default");
}
void LLFloaterPreference::onClickRememberedUsernames()
{
LLFloaterReg::showInstance("forget_username");
}
maksymsproductengine
committed
void LLFloaterPreference::onDeleteTranscripts()
{
Gilbert Gonzales
committed
LLSD args;
args["FOLDER"] = gDirUtilp->getUserName();
LLNotificationsUtil::add("PreferenceChatDeleteTranscripts", args, LLSD(), boost::bind(&LLFloaterPreference::onDeleteTranscriptsResponse, this, _1, _2));
maksymsproductengine
committed
}
void LLFloaterPreference::onDeleteTranscriptsResponse(const LLSD& notification, const LLSD& response)
{
if (0 == LLNotificationsUtil::getSelectedOption(notification, response))
{
maksymsproductengine
committed
LLLogChat::deleteTranscripts();
Mnikolenko ProductEngine
committed
updateDeleteTranscriptsButton();
maksymsproductengine
committed
}
}
void LLFloaterPreference::onLogChatHistorySaved()
{
LLButton * delete_transcripts_buttonp = getChild<LLButton>("delete_transcripts");
if (!delete_transcripts_buttonp->getEnabled())
{
delete_transcripts_buttonp->setEnabled(true);
}
}
void LLFloaterPreference::applyUIColor(LLUICtrl* ctrl, const LLSD& param)
{
LLUIColorTable::instance().setColor(param.asString(), LLColor4(ctrl->getValue()));
}
void LLFloaterPreference::getUIColor(LLUICtrl* ctrl, const LLSD& param)
{
LLColorSwatchCtrl* color_swatch = (LLColorSwatchCtrl*) ctrl;
color_swatch->setOriginal(LLUIColorTable::instance().getColor(param.asString()));
}
Vadim ProductEngine
committed
void LLFloaterPreference::setCacheLocation(const LLStringExplicit& location)
{
LLUICtrl* cache_location_editor = getChild<LLUICtrl>("cache_location");
cache_location_editor->setValue(location);
cache_location_editor->setToolTip(location);
}
void LLFloaterPreference::selectPanel(const LLSD& name)
{
LLTabContainer * tab_containerp = getChild<LLTabContainer>("pref core");
LLPanel * panel = tab_containerp->getPanelByName(name);
if (NULL != panel)
{
tab_containerp->selectTabPanel(panel);
}
}
void LLFloaterPreference::selectPrivacyPanel()
{
selectPanel("im");
}
void LLFloaterPreference::selectChatPanel()
{
selectPanel("chat");
}
maksymsproductengine
committed
void LLFloaterPreference::changed()
{
getChild<LLButton>("clear_log")->setEnabled(LLConversationLog::instance().getConversations().size() > 0);
Mnikolenko ProductEngine
committed
// set 'enable' property for 'Delete transcripts...' button
updateDeleteTranscriptsButton();
maksymsproductengine
committed
}
AndreyL ProductEngine
committed
void LLFloaterPreference::saveGraphicsPreset(std::string& preset)
{
mSavedGraphicsPreset = preset;
}
Paul ProductEngine
committed
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
//------------------------------Updater---------------------------------------
static bool handleBandwidthChanged(const LLSD& newvalue)
{
gViewerThrottle.setMaxBandwidth((F32) newvalue.asReal());
return true;
}
class LLPanelPreference::Updater : public LLEventTimer
{
public:
typedef boost::function<bool(const LLSD&)> callback_t;
Updater(callback_t cb, F32 period)
:LLEventTimer(period),
mCallback(cb)
{
mEventTimer.stop();
}
virtual ~Updater(){}
void update(const LLSD& new_value)
{
mNewValue = new_value;
mEventTimer.start();
}
protected:
BOOL tick()
{
mCallback(mNewValue);
mEventTimer.stop();
return FALSE;
}
private:
LLSD mNewValue;
callback_t mCallback;
};
//----------------------------------------------------------------------------
static LLPanelInjector<LLPanelPreference> t_places("panel_preference");
LLPanelPreference::LLPanelPreference()
Paul ProductEngine
committed
: LLPanel(),
mBandWidthUpdater(NULL)
mCommitCallbackRegistrar.add("Pref.setControlFalse", boost::bind(&LLPanelPreference::setControlFalse,this, _2));
paul_productengine
committed
mCommitCallbackRegistrar.add("Pref.updateMediaAutoPlayCheckbox", boost::bind(&LLPanelPreference::updateMediaAutoPlayCheckbox, this, _1));
mCommitCallbackRegistrar.add("Pref.PrefDelete", boost::bind(&LLPanelPreference::deletePreset, this, _2));
mCommitCallbackRegistrar.add("Pref.PrefSave", boost::bind(&LLPanelPreference::savePreset, this, _2));
mCommitCallbackRegistrar.add("Pref.PrefLoad", boost::bind(&LLPanelPreference::loadPreset, this, _2));
James Cook
committed
}
//virtual
BOOL LLPanelPreference::postBuild()
{
////////////////////// PanelGeneral ///////////////////
AlexanderP ProductEngine
committed
if (hasChild("display_names_check", TRUE))
{
BOOL use_people_api = gSavedSettings.getBOOL("UsePeopleAPI");
LLCheckBoxCtrl* ctrl_display_name = getChild<LLCheckBoxCtrl>("display_names_check");
ctrl_display_name->setEnabled(use_people_api);
if (!use_people_api)
{
ctrl_display_name->setValue(FALSE);
}
}
////////////////////// PanelVoice ///////////////////
AlexanderP ProductEngine
committed
if (hasChild("voice_unavailable", TRUE))
BOOL voice_disabled = gSavedSettings.getBOOL("CmdLineDisableVoice");
getChildView("voice_unavailable")->setVisible( voice_disabled);
getChildView("enable_voice_check")->setVisible( !voice_disabled);
}
//////////////////////PanelSkins ///////////////////
AlexanderP ProductEngine
committed
if (hasChild("skin_selection", TRUE))
{
LLFloaterPreference::refreshSkin(this);
// if skin is set to a skin that no longer exists (silver) set back to default
if (getChild<LLRadioGroup>("skin_selection")->getSelectedIndex() < 0)
gSavedSettings.setString("SkinCurrent", "default");
LLFloaterPreference::refreshSkin(this);
//////////////////////PanelPrivacy ///////////////////
AlexanderP ProductEngine
committed
if (hasChild("media_enabled", TRUE))
{
bool media_enabled = gSavedSettings.getBOOL("AudioStreamingMedia");
Igor Borovkov
committed
getChild<LLCheckBoxCtrl>("media_enabled")->set(media_enabled);
getChild<LLCheckBoxCtrl>("autoplay_enabled")->setEnabled(media_enabled);
}
AlexanderP ProductEngine
committed
if (hasChild("music_enabled", TRUE))
{
getChild<LLCheckBoxCtrl>("music_enabled")->set(gSavedSettings.getBOOL("AudioStreamingMusic"));
AlexanderP ProductEngine
committed
if (hasChild("voice_call_friends_only_check", TRUE))
Igor Borovkov
committed
{
getChild<LLCheckBoxCtrl>("voice_call_friends_only_check")->setCommitCallback(boost::bind(&showFriendsOnlyWarning, _1, _2));
}
maxim_productengine
committed
if (hasChild("allow_multiple_viewer_check", TRUE))
{
getChild<LLCheckBoxCtrl>("allow_multiple_viewer_check")->setCommitCallback(boost::bind(&showMultipleViewersWarning, _1, _2));
}
AlexanderP ProductEngine
committed
if (hasChild("favorites_on_login_check", TRUE))
Andrew Productengine
committed
{
Mnikolenko ProductEngine
committed
getChild<LLCheckBoxCtrl>("favorites_on_login_check")->setCommitCallback(boost::bind(&handleFavoritesOnLoginChanged, _1, _2));
callum_linden
committed
bool show_favorites_at_login = LLPanelLogin::getShowFavorites();
getChild<LLCheckBoxCtrl>("favorites_on_login_check")->setValue(show_favorites_at_login);
Andrew Productengine
committed
}
maxim_productengine
committed
if (hasChild("mute_chb_label", TRUE))
{
getChild<LLTextBox>("mute_chb_label")->setShowCursorHand(false);
maxim_productengine
committed
getChild<LLTextBox>("mute_chb_label")->setSoundFlags(LLView::MOUSE_UP);
maxim_productengine
committed
getChild<LLTextBox>("mute_chb_label")->setClickedCallback(boost::bind(&toggleMuteWhenMinimized));
}
Igor Borovkov
committed
Paul ProductEngine
committed
//////////////////////PanelSetup ///////////////////
AlexanderP ProductEngine
committed
if (hasChild("max_bandwidth"), TRUE)
Paul ProductEngine
committed
{
mBandWidthUpdater = new LLPanelPreference::Updater(boost::bind(&handleBandwidthChanged, _1), BANDWIDTH_UPDATER_TIMEOUT);
Paul ProductEngine
committed
gSavedSettings.getControl("ThrottleBandwidthKBPS")->getSignal()->connect(boost::bind(&LLPanelPreference::Updater::update, mBandWidthUpdater, _2));
}
#ifdef EXTERNAL_TOS
LLRadioGroup* ext_browser_settings = getChild<LLRadioGroup>("preferred_browser_behavior");
if (ext_browser_settings)
{
// turn off ability to set external/internal browser
ext_browser_settings->setSelectedByValue(LLWeb::BROWSER_EXTERNAL_ONLY, true);
ext_browser_settings->setEnabled(false);
}
#endif
apply();
return true;
Paul ProductEngine
committed
LLPanelPreference::~LLPanelPreference()
{
if (mBandWidthUpdater)
{
delete mBandWidthUpdater;
}
}
void LLPanelPreference::apply()
{
// no-op
}
void LLPanelPreference::saveSettings()
LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
// Save the value of all controls in the hierarchy
mSavedValues.clear();
std::list<LLView*> view_stack;
view_stack.push_back(this);
if (advanced)
{
view_stack.push_back(advanced);
}
while(!view_stack.empty())
{
// Process view on top of the stack
LLView* curview = view_stack.front();
view_stack.pop_front();
James Cook
committed
LLColorSwatchCtrl* color_swatch = dynamic_cast<LLColorSwatchCtrl *>(curview);
if (color_swatch)
{
mSavedColors[color_swatch->getName()] = color_swatch->get();
}
else
James Cook
committed
LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
if (ctrl)
James Cook
committed
LLControlVariable* control = ctrl->getControlVariable();
if (control)
{
mSavedValues[control] = control->getValue();
}
James Cook
committed
// Push children onto the end of the work stack
for (child_list_t::const_iterator iter = curview->getChildList()->begin();
iter != curview->getChildList()->end(); ++iter)
{
view_stack.push_back(*iter);
}
maxim_productengine
committed
void LLPanelPreference::showMultipleViewersWarning(LLUICtrl* checkbox, const LLSD& value)
{
if (checkbox && checkbox->getValue())
{
LLNotificationsUtil::add("AllowMultipleViewers");
}
}
Igor Borovkov
committed
void LLPanelPreference::showFriendsOnlyWarning(LLUICtrl* checkbox, const LLSD& value)
{
if (checkbox && checkbox->getValue())
{
LLNotificationsUtil::add("FriendsAndGroupsOnly");
}
}
Mnikolenko ProductEngine
committed
void LLPanelPreference::handleFavoritesOnLoginChanged(LLUICtrl* checkbox, const LLSD& value)
Andrew Productengine
committed
{
Mnikolenko ProductEngine
committed
if (checkbox)
Andrew Productengine
committed
{
Mnikolenko ProductEngine
committed
LLFavoritesOrderStorage::instance().showFavoritesOnLoginChanged(checkbox->getValue().asBoolean());
if(checkbox->getValue())
{
LLNotificationsUtil::add("FavoritesOnLogin");
}
Andrew Productengine
committed
}
}
maxim_productengine
committed
void LLPanelPreference::toggleMuteWhenMinimized()
{
std::string mute("MuteWhenMinimized");
gSavedSettings.setBOOL(mute, !gSavedSettings.getBOOL(mute));
maxim_productengine
committed
LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
if (instance)
{
instance->getChild<LLCheckBoxCtrl>("mute_when_minimized")->setBtnFocus();
}
maxim_productengine
committed
}
void LLPanelPreference::cancel()
for (control_values_map_t::iterator iter = mSavedValues.begin();
iter != mSavedValues.end(); ++iter)
LLControlVariable* control = iter->first;
LLSD ctrl_value = iter->second;
Mnikolenko ProductEngine
committed
if((control->getName() == "InstantMessageLogPath") && (ctrl_value.asString() == ""))
{
continue;
}
control->set(ctrl_value);
James Cook
committed
for (string_color_map_t::iterator iter = mSavedColors.begin();
iter != mSavedColors.end(); ++iter)
{
LLColorSwatchCtrl* color_swatch = findChild<LLColorSwatchCtrl>(iter->first);
James Cook
committed
{
color_swatch->set(iter->second);
color_swatch->onCommit();
}
}
void LLPanelPreference::setControlFalse(const LLSD& user_data)
{
std::string control_name = user_data.asString();
LLControlVariable* control = findControl(control_name);
if (control)
control->set(LLSD(FALSE));
paul_productengine
committed
}
void LLPanelPreference::updateMediaAutoPlayCheckbox(LLUICtrl* ctrl)
{
std::string name = ctrl->getName();
// Disable "Allow Media to auto play" only when both
// "Streaming Music" and "Media" are unchecked. STORM-513.
if ((name == "enable_music") || (name == "enable_media"))
{
bool music_enabled = getChild<LLCheckBoxCtrl>("enable_music")->get();
bool media_enabled = getChild<LLCheckBoxCtrl>("enable_media")->get();
getChild<LLCheckBoxCtrl>("media_auto_play_combo")->setEnabled(music_enabled || media_enabled);
paul_productengine
committed
}
}
Ychebotarev ProductEngine
committed
void LLPanelPreference::deletePreset(const LLSD& user_data)
std::string subdirectory = user_data.asString();
LLFloaterReg::showInstance("delete_pref_preset", subdirectory);
void LLPanelPreference::savePreset(const LLSD& user_data)
std::string subdirectory = user_data.asString();
LLFloaterReg::showInstance("save_pref_preset", subdirectory);
}
void LLPanelPreference::loadPreset(const LLSD& user_data)
{
std::string subdirectory = user_data.asString();
LLFloaterReg::showInstance("load_pref_preset", subdirectory);
void LLPanelPreference::setHardwareDefaults()
{
}
Vadim ProductEngine
committed
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
class LLPanelPreferencePrivacy : public LLPanelPreference
{
public:
LLPanelPreferencePrivacy()
{
mAccountIndependentSettings.push_back("VoiceCallsFriendsOnly");
mAccountIndependentSettings.push_back("AutoDisengageMic");
}
/*virtual*/ void saveSettings()
{
LLPanelPreference::saveSettings();
// Don't save (=erase from the saved values map) per-account privacy settings
// if we're not logged in, otherwise they will be reset to defaults on log off.
if (LLStartUp::getStartupState() != STATE_STARTED)
{
// Erase only common settings, assuming there are no color settings on Privacy page.
for (control_values_map_t::iterator it = mSavedValues.begin(); it != mSavedValues.end(); )
{
const std::string setting = it->first->getName();
maksymsproductengine
committed
if (find(mAccountIndependentSettings.begin(),
Vadim ProductEngine
committed
mAccountIndependentSettings.end(), setting) == mAccountIndependentSettings.end())
{
mSavedValues.erase(it++);
}
else
{
++it;
}
}
}
}
private:
std::list<std::string> mAccountIndependentSettings;
};
static LLPanelInjector<LLPanelPreferenceGraphics> t_pref_graph("panel_preference_graphics");
static LLPanelInjector<LLPanelPreferencePrivacy> t_pref_privacy("panel_preference_privacy");
Ychebotarev ProductEngine
committed
BOOL LLPanelPreferenceGraphics::postBuild()
{
LLFloaterReg::showInstance("prefs_graphics_advanced");
LLFloaterReg::hideInstance("prefs_graphics_advanced");
Jonathan Yap
committed
resetDirtyChilds();
setPresetText();
Jonathan Yap
committed
Oz Linden
committed
LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
presetsMgr->setPresetListChangeCallback(boost::bind(&LLPanelPreferenceGraphics::onPresetsListChange, this));
presetsMgr->createMissingDefault(); // a no-op after the first time, but that's ok
Ychebotarev ProductEngine
committed
return LLPanelPreference::postBuild();
}
Ychebotarev ProductEngine
committed
void LLPanelPreferenceGraphics::draw()
{
setPresetText();
Ychebotarev ProductEngine
committed
LLPanelPreference::draw();
void LLPanelPreferenceGraphics::onPresetsListChange()
{
resetDirtyChilds();
setPresetText();
AndreyL ProductEngine
committed
LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
if (instance && !gSavedSettings.getString("PresetGraphicActive").empty())
{
instance->saveSettings(); //make cancel work correctly after changing the preset
}
maxim_productengine
committed
else
{
std::string dummy;
instance->saveGraphicsPreset(dummy);
maxim_productengine
committed
}
void LLPanelPreferenceGraphics::setPresetText()
LLTextBox* preset_text = getChild<LLTextBox>("preset_text");
std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive");
AndreyL ProductEngine
committed
if (!preset_graphic_active.empty() && preset_graphic_active != preset_text->getText())
Ychebotarev ProductEngine
committed
{
AndreyL ProductEngine
committed
LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
if (instance)
{
instance->saveGraphicsPreset(preset_graphic_active);
}
AndreyL ProductEngine
committed
}
if (hasDirtyChilds() && !preset_graphic_active.empty())
AndreyL ProductEngine
committed
{
gSavedSettings.setString("PresetGraphicActive", "");
preset_graphic_active.clear();
Jonathan Yap
committed
// This doesn't seem to cause an infinite recursion. This trigger is needed to cause the pulldown
// panel to update.
LLPresetsManager::getInstance()->triggerChangeSignal();
Ychebotarev ProductEngine
committed
if (!preset_graphic_active.empty())
{
if (preset_graphic_active == PRESETS_DEFAULT)
{
Ansariel
committed
preset_graphic_active = LLTrans::getString(PRESETS_DEFAULT);
}
preset_text->setText(preset_graphic_active);
}
else
{
preset_text->setText(LLTrans::getString("none_paren_cap"));
Ychebotarev ProductEngine
committed
}
preset_text->resetDirty();
Ychebotarev ProductEngine
committed
}
Ychebotarev ProductEngine
committed
bool LLPanelPreferenceGraphics::hasDirtyChilds()
{
LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
Ychebotarev ProductEngine
committed
std::list<LLView*> view_stack;
view_stack.push_back(this);
if (advanced)
{
view_stack.push_back(advanced);
}
Ychebotarev ProductEngine
committed
while(!view_stack.empty())
{
// Process view on top of the stack
LLView* curview = view_stack.front();
view_stack.pop_front();
LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
if (ctrl)
{
LLControlVariable* control = ctrl->getControlVariable();
if (control)
{
std::string control_name = control->getName();
if (!control_name.empty())
{
return true;
}
}
Ychebotarev ProductEngine
committed
}
// Push children onto the end of the work stack
for (child_list_t::const_iterator iter = curview->getChildList()->begin();
iter != curview->getChildList()->end(); ++iter)
{
view_stack.push_back(*iter);
}
Jonathan Yap
committed
}
Ychebotarev ProductEngine
committed
return false;
}
void LLPanelPreferenceGraphics::resetDirtyChilds()
{
LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
Ychebotarev ProductEngine
committed
std::list<LLView*> view_stack;
view_stack.push_back(this);
if (advanced)
{
view_stack.push_back(advanced);
}
Ychebotarev ProductEngine
committed
while(!view_stack.empty())
{
// Process view on top of the stack
LLView* curview = view_stack.front();
view_stack.pop_front();
LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
if (ctrl)
{
ctrl->resetDirty();
}
// Push children onto the end of the work stack
for (child_list_t::const_iterator iter = curview->getChildList()->begin();
iter != curview->getChildList()->end(); ++iter)
{
view_stack.push_back(*iter);
}
}
}
Ychebotarev ProductEngine
committed
void LLPanelPreferenceGraphics::cancel()
{
LLPanelPreference::cancel();
}
void LLPanelPreferenceGraphics::saveSettings()
{
resetDirtyChilds();
std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive");
if (preset_graphic_active.empty())
maxim_productengine
committed
{
LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
if (instance)
{
//don't restore previous preset after closing Preferences
instance->saveGraphicsPreset(preset_graphic_active);
maxim_productengine
committed
}
}
Ychebotarev ProductEngine
committed
LLPanelPreference::saveSettings();
}
void LLPanelPreferenceGraphics::setHardwareDefaults()
{
resetDirtyChilds();
}
//------------------------LLPanelPreferenceControls--------------------------------
static LLPanelInjector<LLPanelPreferenceControls> t_pref_contrls("panel_preference_controls");
LLPanelPreferenceControls::LLPanelPreferenceControls()
:LLPanelPreference(),
mEditingColumn(-1),
// MODE_COUNT - 1 because there are currently no settings assigned to 'saved settings'.
for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT - 1; ++i)
mConflictHandler[i].setLoadMode((LLKeyConflictHandler::ESourceMode)i);
LLPanelPreferenceControls::~LLPanelPreferenceControls()
{
}
BOOL LLPanelPreferenceControls::postBuild()
{
// populate list of controls
pControlsTable = getChild<LLScrollListCtrl>("controls_list");
pKeyModeBox = getChild<LLComboBox>("key_mode");
pControlsTable->setCommitCallback(boost::bind(&LLPanelPreferenceControls::onListCommit, this));
pKeyModeBox->setCommitCallback(boost::bind(&LLPanelPreferenceControls::onModeCommit, this));
getChild<LLButton>("restore_defaults")->setCommitCallback(boost::bind(&LLPanelPreferenceControls::onRestoreDefaultsBtn, this));
void LLPanelPreferenceControls::regenerateControls()
{
mEditingMode = pKeyModeBox->getValue().asInteger();
mConflictHandler[mEditingMode].loadFromSettings((LLKeyConflictHandler::ESourceMode)mEditingMode);
populateControlTable();
}
void LLPanelPreferenceControls::populateControlTable()
{
pControlsTable->clearRows();
pControlsTable->clearColumns();
std::string filename;
switch ((LLKeyConflictHandler::ESourceMode)mEditingMode)
{
case LLKeyConflictHandler::MODE_THIRD_PERSON:
case LLKeyConflictHandler::MODE_FIRST_PERSON:
case LLKeyConflictHandler::MODE_EDIT_AVATAR:
case LLKeyConflictHandler::MODE_SITTING:
filename = "control_table_contents.xml";
break;
default:
// 'saved settings' mode doesn't have UI or actual settings yet
LL_INFOS() << "Unimplemented mode" << LL_ENDL;
return;
}
LLXMLNodePtr xmlNode;
LLScrollListCtrl::Contents contents;
if (!LLUICtrlFactory::getLayeredXMLNode(filename, xmlNode))
{
LL_WARNS() << "Failed to load " << filename << LL_ENDL;
return;
}
LLXUIParser parser;
parser.readXUI(xmlNode, contents, filename);
if (!contents.validateBlock())
{
return;
}
for (LLInitParam::ParamIterator<LLScrollListColumn::Params>::const_iterator col_it = contents.columns.begin();
col_it != contents.columns.end();
++col_it)
{
pControlsTable->addColumn(*col_it);
}
LLScrollListCell::Params cell_params;
// init basic cell params
cell_params.font = LLFontGL::getFontSansSerif();
cell_params.font_halign = LLFontGL::LEFT;
cell_params.column = "";
cell_params.value = "";
for (LLInitParam::ParamIterator<LLScrollListItem::Params>::const_iterator row_it = contents.rows.begin();
row_it != contents.rows.end();
++row_it)
std::string control = row_it->value.getValue().asString();
if (!control.empty() && control != "menu_separator")
// At the moment 4 collumns are hardcoded
LLScrollListItem::Params item_params(*row_it);
bool enabled = mConflictHandler[mEditingMode].canAssignControl(control);
item_params.enabled.setValue(enabled);
cell_params.column = "lst_ctrl1";
cell_params.value = mConflictHandler[mEditingMode].getControlString(control, 0);
item_params.columns.add(cell_params);
cell_params.column = "lst_ctrl2";
cell_params.value = mConflictHandler[mEditingMode].getControlString(control, 1);
item_params.columns.add(cell_params);
cell_params.column = "lst_ctrl3";
cell_params.value = mConflictHandler[mEditingMode].getControlString(control, 2);
item_params.columns.add(cell_params);
pControlsTable->addRow(item_params, EAddPosition::ADD_BOTTOM);
}
else
{
pControlsTable->addRow(*row_it, EAddPosition::ADD_BOTTOM);
// Just a workaround to not care about first separator before headers (we can start from random header)
void LLPanelPreferenceControls::addSeparator()
if (pControlsTable->getItemCount() > 0)
{
pControlsTable->addSeparator(EAddPosition::ADD_BOTTOM);
}
void LLPanelPreferenceControls::updateTable()
{
mEditingControl.clear();
std::vector<LLScrollListItem*> list = pControlsTable->getAllData();
for (S32 i = 0; i < list.size(); ++i)
{
std::string control = list[i]->getValue();
if (!control.empty())
{
LLScrollListCell* cell = list[i]->getColumn(1);
cell->setValue(mConflictHandler[mEditingMode].getControlString(control, 0));
cell = list[i]->getColumn(2);
cell->setValue(mConflictHandler[mEditingMode].getControlString(control, 1));
cell = list[i]->getColumn(3);
cell->setValue(mConflictHandler[mEditingMode].getControlString(control, 2));
}
}
pControlsTable->deselectAllItems();
void LLPanelPreferenceControls::apply()
for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT - 1; ++i)
{
if (mConflictHandler[i].hasUnsavedChanges())
{
mConflictHandler[i].saveToSettings();
}
}
void LLPanelPreferenceControls::cancel()
for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT - 1; ++i)
{
if (mConflictHandler[i].hasUnsavedChanges())
{
mConflictHandler[i].clear();
}
}
pControlsTable->clear();
void LLPanelPreferenceControls::saveSettings()
for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT - 1; ++i)
{
if (mConflictHandler[i].hasUnsavedChanges())
{
mConflictHandler[i].saveToSettings();
mConflictHandler[i].clear();
}
}
S32 mode = pKeyModeBox->getValue().asInteger();
if (mConflictHandler[mode].empty())
{
regenerateControls();
}
}
void LLPanelPreferenceControls::resetDirtyChilds()
{
regenerateControls();
}
void LLPanelPreferenceControls::onListCommit()
{
LLScrollListItem* item = pControlsTable->getFirstSelected();
if (item == NULL)
{
return;
}
std::string control = item->getValue();
if (control.empty())
pControlsTable->deselectAllItems();
if (!mConflictHandler[mEditingMode].canAssignControl(control))
pControlsTable->deselectAllItems();
return;
}
S32 cell_ind = item->getSelectedCell();
if (cell_ind <= 0)
{
pControlsTable->deselectAllItems();
// List does not tell us what cell was clicked, so we have to figure it out manually, but
// fresh mouse coordinates are not yet accessible during onCommit() and there are other issues,
// so we cheat: remember item user clicked at, trigger 'key dialog' on hover that comes next,
// use coordinates from hover to calculate cell
LLScrollListCell* cell = item->getColumn(cell_ind);
if (cell)
{
LLSetKeyBindDialog* dialog = LLFloaterReg::getTypedInstance<LLSetKeyBindDialog>("keybind_dialog", LLSD());
if (dialog)
{
mEditingControl = control;
mEditingColumn = cell_ind;
andreykproductengine
committed
dialog->setParent(this, pControlsTable, DEFAULT_KEY_FILTER);
LLFloater* root_floater = gFloaterView->getParentFloater(this);
if (root_floater)
root_floater->addDependentFloater(dialog);
dialog->openFloater();
dialog->setFocus(TRUE);
}
}
else
pControlsTable->deselectAllItems();
void LLPanelPreferenceControls::onModeCommit()
mEditingMode = pKeyModeBox->getValue().asInteger();
if (mConflictHandler[mEditingMode].empty())
{
// opening for first time
mConflictHandler[mEditingMode].loadFromSettings((LLKeyConflictHandler::ESourceMode)mEditingMode);
}
populateControlTable();
andreykproductengine
committed
{
LLNotificationsUtil::add("PreferenceControlsDefaults", LLSD(), LLSD(), boost::bind(&LLPanelPreferenceControls::onRestoreDefaultsResponse, this, _1, _2));
}
void LLPanelPreferenceControls::onRestoreDefaultsResponse(const LLSD& notification, const LLSD& response)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
switch(option)
andreykproductengine
committed
{
case 0: // All
for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT - 1; ++i)
{
mConflictHandler[i].resetToDefaults();
// Apply changes to viewer as 'temporary'
mConflictHandler[i].saveToSettings(true);
}
updateTable();
break;
case 1: // Current
mConflictHandler[mEditingMode].resetToDefaults();
// Apply changes to viewer as 'temporary'
updateTable();
break;
case 2: // Cancel
default:
//exit;
break;
}
andreykproductengine
committed
}
// todo: copy onSetKeyBind to interface and inherit from interface
bool LLPanelPreferenceControls::onSetKeyBind(EMouseClickType click, KEY key, MASK mask, bool all_modes)
if (!mConflictHandler[mEditingMode].canAssignControl(mEditingControl))
return true;
if (all_modes)
{
for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT - 1; ++i)
{
if (mConflictHandler[i].empty())
{
mConflictHandler[i].loadFromSettings((LLKeyConflictHandler::ESourceMode)i);
}
mConflictHandler[i].registerControl(mEditingControl, mEditingColumn - 1, click, key, mask, true);
// Apply changes to viewer as 'temporary'
mConflictHandler[i].saveToSettings(true);
}
}
else
{
mConflictHandler[mEditingMode].registerControl(mEditingControl, mEditingColumn - 1, click, key, mask, true);