From 5eb90ef9cdeaf9722d7830d3ee44a7e1359b2f48 Mon Sep 17 00:00:00 2001 From: Siana Gearz Date: Mon, 5 Mar 2012 19:05:30 +0100 Subject: [PATCH] Preference button to clear settings --- indra/newview/app_settings/settings.xml | 2 +- indra/newview/llfloaterpreference.cpp | 13 +++- indra/newview/llfloaterpreference.h | 5 ++ indra/newview/llpanelgeneral.cpp | 44 ++++++++++++++ indra/newview/llpanelgeneral.h | 3 + .../skins/default/xui/en-us/notifications.xml | 59 +++++++++++++++++++ .../xui/en-us/panel_preferences_general.xml | 3 +- 7 files changed, 126 insertions(+), 3 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index f9b809665..681ef347e 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -6402,7 +6402,7 @@ Type Boolean Value - 1 + 0 FlycamAbsolute diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 231d680a0..6e102d58c 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -387,6 +387,7 @@ void LLPreferenceCore::refreshEnabledGraphics() LLFloaterPreference::LLFloaterPreference() { + mExitWithoutSaving = false; LLUICtrlFactory::getInstance()->buildFloater(this, "floater_preferences.xml"); } @@ -532,7 +533,10 @@ void LLFloaterPreference::onBtnApply( void* userdata ) void LLFloaterPreference::onClose(bool app_quitting) { LLPanelLogin::setAlwaysRefresh(false); - cancel(); // will be a no-op if OK or apply was performed just prior. + if (!mExitWithoutSaving) + { + cancel(); // will be a no-op if OK or apply was performed just prior. + } LLFloater::onClose(app_quitting); } @@ -572,3 +576,10 @@ void LLFloaterPreference::switchTab(S32 i) { sInstance->mPreferenceCore->getTabContainer()->selectTab(i); } + +// static +void LLFloaterPreference::closeWithoutSaving() +{ + sInstance->mExitWithoutSaving = true; + sInstance->close(); +} diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h index c849ac6ea..a662a08c7 100644 --- a/indra/newview/llfloaterpreference.h +++ b/indra/newview/llfloaterpreference.h @@ -124,6 +124,10 @@ public: static void switchTab(S32 i); + // *HACK: Close without doing anything. + // This is used by the "reset all settings" button. + static void closeWithoutSaving(); + protected: LLPreferenceCore *mPreferenceCore; @@ -133,6 +137,7 @@ protected: LLButton *mOKBtn; LLButton *mCancelBtn; LLButton *mApplyBtn; + bool mExitWithoutSaving; static void onClickAbout(void*); static void onBtnOK(void*); diff --git a/indra/newview/llpanelgeneral.cpp b/indra/newview/llpanelgeneral.cpp index a238d408d..fbd323a09 100644 --- a/indra/newview/llpanelgeneral.cpp +++ b/indra/newview/llpanelgeneral.cpp @@ -43,6 +43,7 @@ #include "llviewercontrol.h" #include "llagent.h" +#include "llfloaterpreference.h" #include "llviewerregion.h" #include "llavatarnamecache.h" #include "llvoavatar.h" @@ -109,6 +110,8 @@ BOOL LLPanelGeneral::postBuild() childSetVisible("maturity_desired_combobox", can_choose); childSetVisible("maturity_desired_textbox", !can_choose); + + childSetAction("clear_settings", &onClickClearSettings, this); return TRUE; } @@ -160,3 +163,44 @@ void LLPanelGeneral::cancel() { } +// static +void LLPanelGeneral::onClickClearSettings(void*) +{ + if(gAgent.getID().notNull()) { + LLNotifications::instance().add("ResetAllSettingsPrompt", LLSD(), LLSD(), &callbackResetAllSettings); + } + else + { + LLNotifications::instance().add("ResetSystemSettingsPrompt", LLSD(), LLSD(), &callbackResetAllSettings); + } +} + +// static +void LLPanelGeneral::callbackResetAllSettings(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotification::getSelectedOption(notification, response); + if(option != 3) //At least some settings want to be removed + { + // We probably want to avoid altering this setting, so keep it across the reset. + std::string client_settings_file = gSavedSettings.getString("ClientSettingsFile"); + if(option != 2) + { + gSavedSettings.resetToDefaults(); + gSavedSettings.setString("ClientSettingsFile", client_settings_file); + gSavedSettings.saveToFile(client_settings_file, TRUE); + } + + // Wipe user-specific settings for good measure and consistency. + // Obviously, we can only do this if we're actually logged in. + if(gAgent.getID().notNull() && (option != 1)) + { + gSavedPerAccountSettings.resetToDefaults(); + gSavedPerAccountSettings.saveToFile(gSavedSettings.getString("PerAccountSettingsFile"), TRUE); + } + LLNotifications::instance().add("ResetSettingsComplete"); + + // *HACK: Now close the floater without cancelling or applying. + // (the alternative route would be to add a method to every preference panel to handle this and update its UI) + LLFloaterPreference::closeWithoutSaving(); + } +} diff --git a/indra/newview/llpanelgeneral.h b/indra/newview/llpanelgeneral.h index 4afa5dd66..b60ce2289 100644 --- a/indra/newview/llpanelgeneral.h +++ b/indra/newview/llpanelgeneral.h @@ -46,6 +46,9 @@ public: void apply(); void cancel(); + + static void LLPanelGeneral::onClickClearSettings(void*); + static void callbackResetAllSettings(const LLSD& notification, const LLSD& response); }; #endif diff --git a/indra/newview/skins/default/xui/en-us/notifications.xml b/indra/newview/skins/default/xui/en-us/notifications.xml index 86b27d335..39d1f73a1 100644 --- a/indra/newview/skins/default/xui/en-us/notifications.xml +++ b/indra/newview/skins/default/xui/en-us/notifications.xml @@ -7032,6 +7032,65 @@ Your shape, skin, hair or eyes might be defect. yestext="OK"/> + + Settings have been reset. You should relog to ensure this takes full effect. + + + + Resetting all settings may be helpful if you are experiencing problems; however, you will need to redo any changes you have made to the default configuration. + + Would you like to reset system settings? +
+