Newer
Older
panel->resetDirtyChilds();
}
}
}
Andrey Kleshchev
committed
void LLFloaterPreference::onClickActionChange()
{
updateClickActionControls();
}
void LLFloaterPreference::onClickPermsDefault()
{
LLFloaterReg::showInstance("perms_default");
}
void LLFloaterPreference::onClickRememberedUsernames()
{
LLFloaterReg::showInstance("forget_username");
}
maksymsproductengine
committed
void LLFloaterPreference::onDeleteTranscripts()
{
LLSD args;
args["FOLDER"] = gDirUtilp->getUserName();
Gilbert Gonzales
committed
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))
{
LLLogChat::deleteTranscripts();
updateDeleteTranscriptsButton();
}
maksymsproductengine
committed
}
void LLFloaterPreference::onLogChatHistorySaved()
{
LLButton * delete_transcripts_buttonp = getChild<LLButton>("delete_transcripts");
maksymsproductengine
committed
if (!delete_transcripts_buttonp->getEnabled())
{
delete_transcripts_buttonp->setEnabled(true);
}
maksymsproductengine
committed
}
Andrey Kleshchev
committed
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
void LLFloaterPreference::updateClickActionControls()
{
const int single_clk_action = getChild<LLComboBox>("single_click_action_combo")->getValue().asInteger();
const int double_clk_action = getChild<LLComboBox>("double_click_action_combo")->getValue().asInteger();
// Todo: This is a very ugly way to get access to keybindings.
// Reconsider possible options.
// Potential option: make constructor of LLKeyConflictHandler private
// but add a getter that will return shared pointer for specific
// mode, pointer should only exist so long as there are external users.
// In such case we won't need to do this 'dynamic_cast' nightmare.
// updateTable() can also be avoided
LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
iter != tabcontainer->getChildList()->end(); ++iter)
{
LLView* view = *iter;
LLPanelPreferenceControls* panel = dynamic_cast<LLPanelPreferenceControls*>(view);
if (panel)
{
panel->setKeyBind("walk_to",
EMouseClickType::CLICK_LEFT,
KEY_NONE,
MASK_NONE,
single_clk_action == 1);
panel->setKeyBind("walk_to",
EMouseClickType::CLICK_DOUBLELEFT,
KEY_NONE,
MASK_NONE,
double_clk_action == 1);
panel->setKeyBind("teleport_to",
EMouseClickType::CLICK_DOUBLELEFT,
KEY_NONE,
MASK_NONE,
double_clk_action == 2);
panel->updateAndApply();
Andrey Kleshchev
committed
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
}
}
}
void LLFloaterPreference::updateClickActionViews()
{
bool click_to_walk = false;
bool dbl_click_to_walk = false;
bool dbl_click_to_teleport = false;
// Todo: This is a very ugly way to get access to keybindings.
// Reconsider possible options.
LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
iter != tabcontainer->getChildList()->end(); ++iter)
{
LLView* view = *iter;
LLPanelPreferenceControls* panel = dynamic_cast<LLPanelPreferenceControls*>(view);
if (panel)
{
click_to_walk = panel->canKeyBindHandle("walk_to",
EMouseClickType::CLICK_LEFT,
KEY_NONE,
MASK_NONE);
dbl_click_to_walk = panel->canKeyBindHandle("walk_to",
EMouseClickType::CLICK_DOUBLELEFT,
KEY_NONE,
MASK_NONE);
dbl_click_to_teleport = panel->canKeyBindHandle("teleport_to",
EMouseClickType::CLICK_DOUBLELEFT,
KEY_NONE,
MASK_NONE);
}
}
getChild<LLComboBox>("single_click_action_combo")->setValue((int)click_to_walk);
getChild<LLComboBox>("double_click_action_combo")->setValue(dbl_click_to_teleport ? 2 : (int)dbl_click_to_walk);
}
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);
Vadim ProductEngine
committed
}
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()
{
}
void LLFloaterPreference::selectChatPanel()
{
}
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();
Mnikolenko ProductEngine
committed
maksymsproductengine
committed
}
AndreyL ProductEngine
committed
void LLFloaterPreference::saveGraphicsPreset(std::string& preset)
{
AndreyL ProductEngine
committed
}
Paul ProductEngine
committed
//------------------------------Updater---------------------------------------
static bool handleBandwidthChanged(const LLSD& newvalue)
{
gViewerThrottle.setMaxBandwidth((F32) newvalue.asReal());
return true;
Paul ProductEngine
committed
}
class LLPanelPreference::Updater : public LLEventTimer
{
public:
typedef boost::function<bool(const LLSD&)> callback_t;
Paul ProductEngine
committed
Updater(callback_t cb, F32 period)
:LLEventTimer(period),
mCallback(cb)
{
mEventTimer.stop();
}
Paul ProductEngine
committed
Paul ProductEngine
committed
void update(const LLSD& new_value)
{
mNewValue = new_value;
mEventTimer.start();
}
Paul ProductEngine
committed
protected:
BOOL tick()
{
mCallback(mNewValue);
mEventTimer.stop();
Paul ProductEngine
committed
Paul ProductEngine
committed
private:
LLSD mNewValue;
callback_t mCallback;
Paul ProductEngine
committed
};
//----------------------------------------------------------------------------
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));
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()
{
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
////////////////////// PanelGeneral ///////////////////
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 ///////////////////
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 ///////////////////
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 ///////////////////
if (hasChild("media_enabled", TRUE))
{
bool media_enabled = gSavedSettings.getBOOL("AudioStreamingMedia");
getChild<LLCheckBoxCtrl>("media_enabled")->set(media_enabled);
getChild<LLCheckBoxCtrl>("autoplay_enabled")->setEnabled(media_enabled);
}
if (hasChild("music_enabled", TRUE))
{
getChild<LLCheckBoxCtrl>("music_enabled")->set(gSavedSettings.getBOOL("AudioStreamingMusic"));
}
if (hasChild("voice_call_friends_only_check", TRUE))
{
getChild<LLCheckBoxCtrl>("voice_call_friends_only_check")->setCommitCallback(boost::bind(&showFriendsOnlyWarning, _1, _2));
}
if (hasChild("allow_multiple_viewer_check", TRUE))
{
getChild<LLCheckBoxCtrl>("allow_multiple_viewer_check")->setCommitCallback(boost::bind(&showMultipleViewersWarning, _1, _2));
}
if (hasChild("favorites_on_login_check", TRUE))
{
getChild<LLCheckBoxCtrl>("favorites_on_login_check")->setCommitCallback(boost::bind(&handleFavoritesOnLoginChanged, _1, _2));
bool show_favorites_at_login = LLPanelLogin::getShowFavorites();
getChild<LLCheckBoxCtrl>("favorites_on_login_check")->setValue(show_favorites_at_login);
}
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);
getChild<LLTextBox>("mute_chb_label")->setClickedCallback(boost::bind(&toggleMuteWhenMinimized));
}
//////////////////////PanelSetup ///////////////////
if (hasChild("max_bandwidth"), TRUE)
{
mBandWidthUpdater = new LLPanelPreference::Updater(boost::bind(&handleBandwidthChanged, _1), BANDWIDTH_UPDATER_TIMEOUT);
gSavedSettings.getControl("ThrottleBandwidthKBPS")->getSignal()->connect(boost::bind(&LLPanelPreference::Updater::update, mBandWidthUpdater, _2));
}
Paul ProductEngine
committed
#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
Paul ProductEngine
committed
LLPanelPreference::~LLPanelPreference()
{
if (mBandWidthUpdater)
{
delete mBandWidthUpdater;
}
Paul ProductEngine
committed
}
void LLPanelPreference::apply()
{
}
void LLPanelPreference::saveSettings()
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
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();
LLColorSwatchCtrl* color_swatch = dynamic_cast<LLColorSwatchCtrl *>(curview);
if (color_swatch)
{
mSavedColors[color_swatch->getName()] = color_swatch->get();
}
else
{
LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
if (ctrl)
{
LLControlVariable* control = ctrl->getControlVariable();
if (control)
{
mSavedValues[control] = control->getValue();
}
}
}
// 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");
}
Igor Borovkov
committed
}
Mnikolenko ProductEngine
committed
void LLPanelPreference::handleFavoritesOnLoginChanged(LLUICtrl* checkbox, const LLSD& value)
Andrew Productengine
committed
{
if (checkbox)
{
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;
}
Mnikolenko ProductEngine
committed
James Cook
committed
for (string_color_map_t::iterator iter = mSavedColors.begin();
iter != mSavedColors.end(); ++iter)
{
LLColorSwatchCtrl* color_swatch = findChild<LLColorSwatchCtrl>(iter->first);
if (color_swatch)
{
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)
{
paul_productengine
committed
// 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();
paul_productengine
committed
getChild<LLCheckBoxCtrl>("media_auto_play_combo")->setEnabled(music_enabled || media_enabled);
}
Ychebotarev ProductEngine
committed
void LLPanelPreference::deletePreset(const LLSD& user_data)
Mnikolenko Productengine
committed
LLFloaterReg::showInstance("delete_pref_preset", user_data.asString());
void LLPanelPreference::savePreset(const LLSD& user_data)
Mnikolenko Productengine
committed
LLFloaterReg::showInstance("save_pref_preset", user_data.asString());
void LLPanelPreference::loadPreset(const LLSD& user_data)
Mnikolenko Productengine
committed
LLFloaterReg::showInstance("load_pref_preset", user_data.asString());
void LLPanelPreference::setHardwareDefaults()
{
}
Vadim ProductEngine
committed
class LLPanelPreferencePrivacy : public LLPanelPreference
{
public:
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
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();
if (find(mAccountIndependentSettings.begin(),
mAccountIndependentSettings.end(), setting) == mAccountIndependentSettings.end())
{
mSavedValues.erase(it++);
}
else
{
++it;
}
}
}
}
Vadim ProductEngine
committed
private:
std::list<std::string> mAccountIndependentSettings;
Vadim ProductEngine
committed
};
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");
resetDirtyChilds();
setPresetText();
Jonathan Yap
committed
LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
Oz Linden
committed
presetsMgr->setPresetListChangeCallback(boost::bind(&LLPanelPreferenceGraphics::onPresetsListChange, this));
presetsMgr->createMissingDefault(PRESETS_GRAPHIC); // a no-op after the first time, but that's ok
Oz Linden
committed
Ychebotarev ProductEngine
committed
}
Ychebotarev ProductEngine
committed
void LLPanelPreferenceGraphics::draw()
{
setPresetText();
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
}
void LLPanelPreferenceGraphics::setPresetText()
LLTextBox* preset_text = getChild<LLTextBox>("preset_text");
std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive");
if (!preset_graphic_active.empty() && preset_graphic_active != preset_text->getText())
{
LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
if (instance)
{
instance->saveGraphicsPreset(preset_graphic_active);
}
}
if (hasDirtyChilds() && !preset_graphic_active.empty())
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
{
gSavedSettings.setString("PresetGraphicActive", "");
preset_graphic_active.clear();
// This doesn't seem to cause an infinite recursion. This trigger is needed to cause the pulldown
// panel to update.
LLPresetsManager::getInstance()->triggerChangeSignal();
}
if (!preset_graphic_active.empty())
{
if (preset_graphic_active == PRESETS_DEFAULT)
{
preset_graphic_active = LLTrans::getString(PRESETS_DEFAULT);
}
preset_text->setText(preset_graphic_active);
}
else
{
preset_text->setText(LLTrans::getString("none_paren_cap"));
}
preset_text->resetDirty();
Ychebotarev ProductEngine
committed
}
Ychebotarev ProductEngine
committed
bool LLPanelPreferenceGraphics::hasDirtyChilds()
{
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
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();
LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
if (ctrl)
{
if (ctrl->isDirty())
{
LLControlVariable* control = ctrl->getControlVariable();
if (control)
{
std::string control_name = control->getName();
if (!control_name.empty())
{
return true;
}
}
}
}
// 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);
}
}
return false;
Ychebotarev ProductEngine
committed
}
void LLPanelPreferenceGraphics::resetDirtyChilds()
{
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
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();
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
}
Ychebotarev ProductEngine
committed
void LLPanelPreferenceGraphics::cancel()
{
Ychebotarev ProductEngine
committed
}
void LLPanelPreferenceGraphics::saveSettings()
{
resetDirtyChilds();
std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive");
if (preset_graphic_active.empty())
{
LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
if (instance)
{
//don't restore previous preset after closing Preferences
instance->saveGraphicsPreset(preset_graphic_active);
}
}
LLPanelPreference::saveSettings();
Ychebotarev ProductEngine
committed
}
void LLPanelPreferenceGraphics::setHardwareDefaults()
{
Ychebotarev ProductEngine
committed
}
//------------------------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();
}
bool LLPanelPreferenceControls::addControlTableColumns(const std::string &filename)
LLXMLNodePtr xmlNode;
LLScrollListCtrl::Contents contents;
if (!LLUICtrlFactory::getLayeredXMLNode(filename, xmlNode))
{
LL_WARNS() << "Failed to load " << filename << LL_ENDL;
return false;
}
LLXUIParser parser;
parser.readXUI(xmlNode, contents, filename);
if (!contents.validateBlock())
{
return false;
}
for (LLInitParam::ParamIterator<LLScrollListColumn::Params>::const_iterator col_it = contents.columns.begin();
col_it != contents.columns.end();
++col_it)
{
pControlsTable->addColumn(*col_it);
}
return true;
}
bool LLPanelPreferenceControls::addControlTableRows(const std::string &filename)
{
LLXMLNodePtr xmlNode;
LLScrollListCtrl::Contents contents;
if (!LLUICtrlFactory::getLayeredXMLNode(filename, xmlNode))
{
LL_WARNS() << "Failed to load " << filename << LL_ENDL;
return false;
}
LLXUIParser parser;
parser.readXUI(xmlNode, contents, filename);
if (!contents.validateBlock())
{
return false;
}
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")
bool show = true;
bool enabled = mConflictHandler[mEditingMode].canAssignControl(control);
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
if (!enabled)
{
// If empty: this is a placeholder to make sure user won't assign
// value by accident, don't show it
// If not empty: predefined control combination user should see
// to know that combination is reserved
show = !mConflictHandler[mEditingMode].isControlEmpty(control);
// example: teleport_to and walk_to in first person view, and
// sitting related functions, see generatePlaceholders()
}
if (show)
{
// At the moment viewer is hardcoded to assume that columns are named as lst_ctrl%d
LLScrollListItem::Params item_params(*row_it);
item_params.enabled.setValue(enabled);
S32 num_columns = pControlsTable->getNumColumns();
for (S32 col = 1; col < num_columns; col++)
{
cell_params.column = llformat("lst_ctrl%d", col);
cell_params.value = mConflictHandler[mEditingMode].getControlString(control, col - 1);
item_params.columns.add(cell_params);
}
pControlsTable->addRow(item_params, EAddPosition::ADD_BOTTOM);
}
}
else
{
// Separator example:
// <rows
// enabled = "false">
// <columns
// type = "icon"
// color = "0 0 0 0.7"
// halign = "center"
// value = "menu_separator"
// column = "lst_action" / >
//</rows>
pControlsTable->addRow(*row_it, EAddPosition::ADD_BOTTOM);
return true;
}
void LLPanelPreferenceControls::addControlTableSeparator()
{
LLScrollListItem::Params separator_params;
separator_params.enabled(false);
LLScrollListCell::Params column_params;
column_params.type = "icon";
column_params.value = "menu_separator";
column_params.column = "lst_action";
column_params.color = LLColor4(0.f, 0.f, 0.f, 0.7f);
column_params.font_halign = LLFontGL::HCENTER;
separator_params.columns.add(column_params);
pControlsTable->addRow(separator_params, EAddPosition::ADD_BOTTOM);
void LLPanelPreferenceControls::populateControlTable()
pControlsTable->clearRows();
pControlsTable->clearColumns();
// Add columns
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_columns_basic.xml";
break;
default:
// Either unknown mode or MODE_SAVED_SETTINGS
// It doesn't have UI or actual settings yet
LL_INFOS() << "Unimplemented mode" << LL_ENDL;
return;
}
addControlTableColumns(filename);
// Add rows.
// Each file represents individual visual group (movement/camera/media...)
if (mEditingMode == LLKeyConflictHandler::MODE_FIRST_PERSON)
// Don't display whole camera and editing groups
addControlTableRows("control_table_contents_movement.xml");
addControlTableSeparator();
addControlTableRows("control_table_contents_media.xml");
}
// MODE_THIRD_PERSON; MODE_EDIT_AVATAR; MODE_SITTING
else if (mEditingMode < LLKeyConflictHandler::MODE_SAVED_SETTINGS)
{
// In case of 'sitting' mode, movements still apply due to vehicles
// but walk_to is not supported and will be hidden by addControlTableRows
addControlTableRows("control_table_contents_movement.xml");
addControlTableSeparator();
addControlTableRows("control_table_contents_camera.xml");
addControlTableSeparator();
addControlTableRows("control_table_contents_editing.xml");
addControlTableSeparator();
addControlTableRows("control_table_contents_media.xml");
}
else
{
LL_INFOS() << "Unimplemented mode" << LL_ENDL;
return;
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 = NULL;
S32 num_columns = pControlsTable->getNumColumns();
for (S32 col = 1; col < num_columns; col++)
{
cell = list[i]->getColumn(col);
cell->setValue(mConflictHandler[mEditingMode].getControlString(control, col - 1));
}
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->clearRows();
pControlsTable->clearColumns();
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();
Andrey Kleshchev
committed
if (mConflictHandler[mode].empty() || pControlsTable->isEmpty())
{
regenerateControls();
}
}
void LLPanelPreferenceControls::resetDirtyChilds()
{
regenerateControls();
}
void LLPanelPreferenceControls::onListCommit()
{
LLScrollListItem* item = pControlsTable->getFirstSelected();
if (item == NULL)
{
return;
}
std::string control = item->getValue();
if (control.empty())