From ffa1ba7bd3fd4ad69f4a55fdd042834dff37c618 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Mon, 24 May 2010 18:09:15 -0700 Subject: Added button to Preferences > Advanced to reset all preferences (#272) --- linden/indra/newview/app_settings/settings.xml | 11 +++++++++++ linden/indra/newview/llappviewer.cpp | 15 +++++++++++++-- linden/indra/newview/llprefsadvanced.cpp | 20 ++++++++++++++++++++ linden/indra/newview/llprefsadvanced.h | 3 +++ .../skins/default/xui/en-us/notifications.xml | 14 ++++++++++++++ .../default/xui/en-us/panel_preferences_advanced.xml | 4 ++++ 6 files changed, 65 insertions(+), 2 deletions(-) diff --git a/linden/indra/newview/app_settings/settings.xml b/linden/indra/newview/app_settings/settings.xml index da9cdc6..333c8b5 100644 --- a/linden/indra/newview/app_settings/settings.xml +++ b/linden/indra/newview/app_settings/settings.xml @@ -404,6 +404,17 @@ Value 1 + ResetAllPreferences + + Comment + Reset all preferences to their default values on successful quit + Persist + 0 + Type + Boolean + Value + 0 + RezWithLandGroup Comment diff --git a/linden/indra/newview/llappviewer.cpp b/linden/indra/newview/llappviewer.cpp index 44693c2..79a78b9 100644 --- a/linden/indra/newview/llappviewer.cpp +++ b/linden/indra/newview/llappviewer.cpp @@ -1362,13 +1362,24 @@ bool LLAppViewer::cleanup() // Store the time of our current logoff gSavedPerAccountSettings.setU32("LastLogoff", time_corrected()); + // Get filenames of settings files to reset if we do -- MC + std::string per_account_settings_filename = gSavedSettings.getString("PerAccountSettingsFile"); + std::string settings_filename = gSavedSettings.getString("ClientSettingsFile"); + + // Reset all preferences to default settings before we save everything -- MC + if (gSavedSettings.getBOOL("ResetAllPreferences")) + { + llinfos << "Resetting all viewer preferences" << llendflush; + gSavedSettings.resetToDefaults(); + gSavedPerAccountSettings.resetToDefaults(); + } + // Must do this after all panels have been deleted because panels that have persistent rects // save their rects on delete. - gSavedSettings.saveToFile(gSavedSettings.getString("ClientSettingsFile"), TRUE); + gSavedSettings.saveToFile(settings_filename, TRUE); // PerAccountSettingsFile should be empty if no use has been logged on. // *FIX:Mani This should get really saved in a "logoff" mode. - std::string per_account_settings_filename = gSavedSettings.getString("PerAccountSettingsFile"); if (!per_account_settings_filename.empty()) { gSavedPerAccountSettings.saveToFile(per_account_settings_filename, TRUE); diff --git a/linden/indra/newview/llprefsadvanced.cpp b/linden/indra/newview/llprefsadvanced.cpp index da7b8a7..e109818 100644 --- a/linden/indra/newview/llprefsadvanced.cpp +++ b/linden/indra/newview/llprefsadvanced.cpp @@ -41,6 +41,8 @@ LLPrefsAdvanced::LLPrefsAdvanced() { LLUICtrlFactory::getInstance()->buildPanel(this, "panel_preferences_advanced.xml"); childSetCommitCallback("speed_rez_check", onCommitCheckBox, this); + + childSetAction("reset_btn", onClickResetPrefs, this); } LLPrefsAdvanced::~LLPrefsAdvanced() @@ -145,3 +147,21 @@ void LLPrefsAdvanced::onCommitCheckBox(LLUICtrl* ctrl, void* user_data) LLPrefsAdvanced* self = (LLPrefsAdvanced*)user_data; self->refresh(); } + +// static +void LLPrefsAdvanced::onClickResetPrefs(void* user_data) +{ + LLPrefsAdvanced* self = (LLPrefsAdvanced*)user_data; + LLNotifications::instance().add("ConfirmResetAllPreferences", LLSD(), LLSD(), boost::bind(callbackReset, _1, _2, self)); +} + +// static +bool LLPrefsAdvanced::callbackReset(const LLSD& notification, const LLSD& response, LLPrefsAdvanced *self) +{ + S32 option = LLNotification::getSelectedOption(notification, response); + if ( option == 0 ) + { + gSavedSettings.setBOOL("ResetAllPreferences", TRUE); + } + return false; +} diff --git a/linden/indra/newview/llprefsadvanced.h b/linden/indra/newview/llprefsadvanced.h index 37fd050..efd0d40 100644 --- a/linden/indra/newview/llprefsadvanced.h +++ b/linden/indra/newview/llprefsadvanced.h @@ -47,6 +47,9 @@ public: private: static void onCommitCheckBox(LLUICtrl* ctrl, void* user_data); + static void onClickResetPrefs(void* user_data); + + static bool callbackReset(const LLSD& notification, const LLSD& response, LLPrefsAdvanced *self); }; #endif // LLPREFSADVANCED_H diff --git a/linden/indra/newview/skins/default/xui/en-us/notifications.xml b/linden/indra/newview/skins/default/xui/en-us/notifications.xml index e64b9b6..873f069 100644 --- a/linden/indra/newview/skins/default/xui/en-us/notifications.xml +++ b/linden/indra/newview/skins/default/xui/en-us/notifications.xml @@ -6598,6 +6598,20 @@ Are you sure you want to take off all clothes? notext="Cancel" yestext="Take Off"/> + + +Are you sure you want to reset ALL preferences? + +Preferences will be reset when you restart [VIEWER_NAME]. + + +