diff options
Diffstat (limited to 'indra/newview/llfloaterpreference.cpp')
-rw-r--r-- | indra/newview/llfloaterpreference.cpp | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 95e8adca81..e20249a737 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -165,7 +165,6 @@ BOOL LLVoiceSetKeyDialog::handleKeyHere(KEY key, MASK mask) { mParent->setKey(key); } - closeFloater(); return result; } @@ -311,7 +310,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>); @@ -393,6 +393,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"); @@ -556,6 +570,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() @@ -574,7 +593,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() @@ -597,7 +616,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); @@ -625,6 +648,7 @@ void LLFloaterPreference::onBtnApply( ) } } apply(); + saveSettings(); LLPanelLogin::refreshLocation( false ); } @@ -641,7 +665,8 @@ void LLFloaterPreference::onBtnCancel() } refresh(); } - closeFloater(); // side effect will also cancel any unsaved changes. + cancel(); + closeFloater(); } // static @@ -1500,6 +1525,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; |