summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llfloaterpreference.cpp38
-rw-r--r--indra/newview/llfloaterpreference.h9
2 files changed, 43 insertions, 4 deletions
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 7fc207d395..6d2c35442a 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -164,7 +164,6 @@ BOOL LLVoiceSetKeyDialog::handleKeyHere(KEY key, MASK mask)
{
mParent->setKey(key);
}
-
closeFloater();
return result;
}
@@ -310,7 +309,8 @@ F32 LLFloaterPreference::sAspectRatio = 0.0;
LLFloaterPreference::LLFloaterPreference(const LLSD& key)
: LLFloater(key),
mGotPersonalInfo(false),
- mOriginalIMViaEmail(false)
+ mOriginalIMViaEmail(false),
+ mCancelOnClose(true)
{
//Build Floater is now Called from LLFloaterReg::add("preferences", "floater_preferences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreference>);
@@ -390,6 +390,20 @@ void LLFloaterPreference::draw()
LLFloater::draw();
}
+void LLFloaterPreference::saveSettings()
+{
+ LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
+ child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
+ child_list_t::const_iterator end = tabcontainer->getChildList()->end();
+ for ( ; iter != end; ++iter)
+ {
+ LLView* view = *iter;
+ LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
+ if (panel)
+ panel->saveSettings();
+ }
+}
+
void LLFloaterPreference::apply()
{
LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
@@ -551,6 +565,11 @@ void LLFloaterPreference::onOpen(const LLSD& key)
LLPanelLogin::setAlwaysRefresh(true);
refresh();
+
+ // Make sure the current state of prefs are saved away when
+ // when the floater is opened. That will make cancel do its
+ // job
+ saveSettings();
}
void LLFloaterPreference::onVertexShaderEnable()
@@ -569,7 +588,7 @@ void LLFloaterPreference::onClose(bool app_quitting)
{
gSavedSettings.setS32("LastPrefTab", getChild<LLTabContainer>("pref core")->getCurrentPanelIndex());
LLPanelLogin::setAlwaysRefresh(false);
- cancel(); // will be a no-op if OK or apply was performed just prior.
+ if (mCancelOnClose) cancel();
}
void LLFloaterPreference::onOpenHardwareSettings()
@@ -592,7 +611,11 @@ void LLFloaterPreference::onBtnOK()
if (canClose())
{
apply();
+ // Here we do not want to cancel on close, so we do this funny thing
+ // that prevents cancel from undoing our changes when we hit OK
+ mCancelOnClose = false;
closeFloater(false);
+ mCancelOnClose = true;
gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile"), TRUE );
LLUIColorTable::instance().saveUserSettings();
std::string crash_settings_filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, CRASH_SETTINGS_FILE);
@@ -620,6 +643,7 @@ void LLFloaterPreference::onBtnApply( )
}
}
apply();
+ saveSettings();
LLPanelLogin::refreshLocation( false );
}
@@ -636,7 +660,8 @@ void LLFloaterPreference::onBtnCancel()
}
refresh();
}
- closeFloater(); // side effect will also cancel any unsaved changes.
+ cancel();
+ closeFloater();
}
// static
@@ -1493,6 +1518,11 @@ BOOL LLPanelPreference::postBuild()
void LLPanelPreference::apply()
{
+ // no-op
+}
+
+void LLPanelPreference::saveSettings()
+{
// Save the value of all controls in the hierarchy
mSavedValues.clear();
std::list<LLView*> view_stack;
diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h
index 41c8bb7124..a30422564a 100644
--- a/indra/newview/llfloaterpreference.h
+++ b/indra/newview/llfloaterpreference.h
@@ -97,6 +97,10 @@ protected:
// callback for when client turns on shaders
void onVertexShaderEnable();
+ // This function squirrels away the current values of the controls so that
+ // cancel() can restore them.
+ void saveSettings();
+
public:
@@ -145,6 +149,7 @@ private:
static std::string sSkin;
bool mGotPersonalInfo;
bool mOriginalIMViaEmail;
+ bool mCancelOnClose;
bool mOriginalHideOnlineStatus;
std::string mDirectoryVisibility;
@@ -161,6 +166,10 @@ public:
virtual void cancel();
void setControlFalse(const LLSD& user_data);
+ // This function squirrels away the current values of the controls so that
+ // cancel() can restore them.
+ virtual void saveSettings();
+
private:
typedef std::map<LLControlVariable*, LLSD> control_values_map_t;
control_values_map_t mSavedValues;