Preference button to clear settings

This commit is contained in:
Siana Gearz
2012-03-05 19:05:30 +01:00
parent edd1b4d8e7
commit 5eb90ef9cd
7 changed files with 126 additions and 3 deletions

View File

@@ -6402,7 +6402,7 @@
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>1</integer>
<integer>0</integer>
</map>
<key>FlycamAbsolute</key>
<map>

View File

@@ -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();
}

View File

@@ -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*);

View File

@@ -43,6 +43,7 @@
#include "llviewercontrol.h"
#include "llagent.h"
#include "llfloaterpreference.h"
#include "llviewerregion.h"
#include "llavatarnamecache.h"
#include "llvoavatar.h"
@@ -110,6 +111,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();
}
}

View File

@@ -46,6 +46,9 @@ public:
void apply();
void cancel();
static void LLPanelGeneral::onClickClearSettings(void*);
static void callbackResetAllSettings(const LLSD& notification, const LLSD& response);
};
#endif

View File

@@ -7032,6 +7032,65 @@ Your shape, skin, hair or eyes might be defect.
yestext="OK"/>
</notification>
<notification
icon="alertmodal.tga"
label="All settings reset"
name="ResetSettingsComplete"
type="alertmodal">
Settings have been reset. You should relog to ensure this takes full effect.
</notification>
<notification
icon="alertmodal.tga"
label="Reset all settings"
name="ResetSystemSettingsPrompt"
type="alertmodal">
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?
<form>
<button
index="0"
name="all"
text="OK"/>
<button
default="true"
index="3"
name="cancel"
text="Cancel"/>
</form>
</notification>
<notification
icon="alertmodal.tga"
label="Reset all settings"
name="ResetAllSettingsPrompt"
type="alertmodal">
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.
Which settings would you like to reset?
<form>
<button
index="0"
name="all"
text="ALL"/>
<button
index="1"
name="system"
text="System"/>
<button
index="2"
name="user"
text="User"/>
<button
default="true"
index="3"
name="cancel"
text="Cancel"/>
</form>
</notification>
</notifications>

View File

@@ -67,5 +67,6 @@
<combo_item name="Alwayssend" value="Always send">Always send</combo_item>
<combo_item name="Neversend" value="Never send">Never send</combo_item>
</combo_box>
<check_box bottom="-385" height="16" initial_value="false" label="Share language with objects" left="101" name="language_is_public" tool_tip="This lets in-world objects know your preferred language."/>
<check_box bottom="-385" height="16" initial_value="false" label="Share language with objects" left="101" name="language_is_public" tool_tip="This lets in-world objects know your preferred language."/>
<button bottom="-425" height="25" label="Reset All Settings" name="clear_settings" width="200" />
</panel>