From 36a44ba0e9133e78cc66f7d0b65d0890cfeb3db5 Mon Sep 17 00:00:00 2001 From: Ychebotarev ProductEngine Date: Thu, 4 Feb 2010 15:37:25 +0200 Subject: fix for normal EXT-1888 Apply button remains active after Applying changes --HG-- branch : product-engine --- indra/newview/llfloaterpreference.cpp | 100 +++++++++++++++++++++ indra/newview/llfloaterpreference.h | 16 ++++ .../skins/default/xui/en/floater_preferences.xml | 2 +- 3 files changed, 117 insertions(+), 1 deletion(-) diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index ef444c8ba4..9d9fbacee3 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -571,6 +571,16 @@ void LLFloaterPreference::setHardwareDefaults() { LLFeatureManager::getInstance()->applyRecommendedSettings(); refreshEnabledGraphics(); + LLTabContainer* tabcontainer = getChild("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(view); + if (panel) + panel->setHardwareDefaults(); + } } //virtual @@ -1525,3 +1535,93 @@ void LLPanelPreference::setControlFalse(const LLSD& user_data) if (control) control->set(LLSD(FALSE)); } + +static LLRegisterPanelClassWrapper t_pref_graph("panel_preference_graphics"); + +BOOL LLPanelPreferenceGraphics::postBuild() +{ + return LLPanelPreference::postBuild(); +} +void LLPanelPreferenceGraphics::draw() +{ + LLPanelPreference::draw(); + + LLButton* button_apply = findChild("Apply"); + + if(button_apply && button_apply->getVisible()) + { + bool enable = hasDirtyChilds(); + + button_apply->setEnabled(enable); + + } +} +bool LLPanelPreferenceGraphics::hasDirtyChilds() +{ + std::list view_stack; + view_stack.push_back(this); + while(!view_stack.empty()) + { + // Process view on top of the stack + LLView* curview = view_stack.front(); + view_stack.pop_front(); + + LLUICtrl* ctrl = dynamic_cast(curview); + if (ctrl) + { + if(ctrl->isDirty()) + return true; + } + // Push children onto the end of the work stack + for (child_list_t::const_iterator iter = curview->getChildList()->begin(); + iter != curview->getChildList()->end(); ++iter) + { + view_stack.push_back(*iter); + } + } + return false; +} + +void LLPanelPreferenceGraphics::resetDirtyChilds() +{ + std::list view_stack; + view_stack.push_back(this); + while(!view_stack.empty()) + { + // Process view on top of the stack + LLView* curview = view_stack.front(); + view_stack.pop_front(); + + LLUICtrl* ctrl = dynamic_cast(curview); + if (ctrl) + { + ctrl->resetDirty(); + } + // Push children onto the end of the work stack + for (child_list_t::const_iterator iter = curview->getChildList()->begin(); + iter != curview->getChildList()->end(); ++iter) + { + view_stack.push_back(*iter); + } + } +} +void LLPanelPreferenceGraphics::apply() +{ + resetDirtyChilds(); + LLPanelPreference::apply(); +} +void LLPanelPreferenceGraphics::cancel() +{ + resetDirtyChilds(); + LLPanelPreference::cancel(); +} +void LLPanelPreferenceGraphics::saveSettings() +{ + resetDirtyChilds(); + LLPanelPreference::saveSettings(); +} +void LLPanelPreferenceGraphics::setHardwareDefaults() +{ + resetDirtyChilds(); + LLPanelPreference::setHardwareDefaults(); +} diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h index 8778d76a5a..0827c7c2b2 100644 --- a/indra/newview/llfloaterpreference.h +++ b/indra/newview/llfloaterpreference.h @@ -161,6 +161,7 @@ public: virtual void apply(); virtual void cancel(); void setControlFalse(const LLSD& user_data); + virtual void setHardwareDefaults(){}; // This function squirrels away the current values of the controls so that // cancel() can restore them. @@ -177,4 +178,19 @@ private: string_color_map_t mSavedColors; }; +class LLPanelPreferenceGraphics : public LLPanelPreference +{ +public: + BOOL postBuild(); + void draw(); + void apply(); + void cancel(); + void saveSettings(); + void setHardwareDefaults(); +protected: + bool hasDirtyChilds(); + void resetDirtyChilds(); + +}; + #endif // LL_LLPREFERENCEFLOATER_H diff --git a/indra/newview/skins/default/xui/en/floater_preferences.xml b/indra/newview/skins/default/xui/en/floater_preferences.xml index 15655a920e..05deca705a 100644 --- a/indra/newview/skins/default/xui/en/floater_preferences.xml +++ b/indra/newview/skins/default/xui/en/floater_preferences.xml @@ -56,7 +56,7 @@ help_topic="preferences_general_tab" name="general" />