From 020bfa66ba9f1fee3e403595a1d6c95332bb16f7 Mon Sep 17 00:00:00 2001
From: Maxim Nikolenko <maximnproductengine@lindenlab.com>
Date: Tue, 10 Jan 2023 22:53:32 +0200
Subject: [PATCH] SL-18923 Add Reset to default settings button

---
 indra/newview/llfloaterperformance.cpp        | 10 ++++++++
 indra/newview/llfloaterperformance.h          |  1 +
 indra/newview/llfloaterpreference.cpp         |  6 +++++
 indra/newview/llfloaterpreference.h           |  2 ++
 .../xui/en/panel_performance_preferences.xml  | 25 +++++++++++++------
 5 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/indra/newview/llfloaterperformance.cpp b/indra/newview/llfloaterperformance.cpp
index 36912971d9e..88319b170fb 100644
--- a/indra/newview/llfloaterperformance.cpp
+++ b/indra/newview/llfloaterperformance.cpp
@@ -127,6 +127,7 @@ BOOL LLFloaterPerformance::postBuild()
     mObjectList->setIconClickedCallback(boost::bind(&LLFloaterPerformance::detachItem, this, _1));
 
     mSettingsPanel->getChild<LLButton>("advanced_btn")->setCommitCallback(boost::bind(&LLFloaterPerformance::onClickAdvanced, this));
+    mSettingsPanel->getChild<LLButton>("defaults_btn")->setCommitCallback(boost::bind(&LLFloaterPerformance::onClickDefaults, this));
     mSettingsPanel->getChild<LLRadioGroup>("graphics_quality")->setCommitCallback(boost::bind(&LLFloaterPerformance::onChangeQuality, this, _2));
     mSettingsPanel->getChild<LLCheckBoxCtrl>("advanced_lighting_model")->setMouseDownCallback(boost::bind(&LLFloaterPerformance::onClickAdvancedLighting, this));
     mSettingsPanel->getChild<LLComboBox>("ShadowDetail")->setMouseDownCallback(boost::bind(&LLFloaterPerformance::onClickShadows, this));
@@ -477,6 +478,15 @@ void LLFloaterPerformance::onClickAdvanced()
     LLFloaterReg::showInstance("prefs_graphics_advanced");
 }
 
+void LLFloaterPerformance::onClickDefaults()
+{
+    LLFloaterPreference* instance = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences");
+    if (instance)
+    {
+        instance->setRecommendedSettings();
+    }
+}
+
 void LLFloaterPerformance::onChangeQuality(const LLSD& data)
 {
     LLFloaterPreference* instance = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences");
diff --git a/indra/newview/llfloaterperformance.h b/indra/newview/llfloaterperformance.h
index 09bcd18bb58..6a72f3d7c52 100644
--- a/indra/newview/llfloaterperformance.h
+++ b/indra/newview/llfloaterperformance.h
@@ -61,6 +61,7 @@ class LLFloaterPerformance : public LLFloater
     void setFPSText();
 
     void onClickAdvanced();
+    void onClickDefaults();
     void onChangeQuality(const LLSD& data);
     void onClickHideAvatars();
     void onClickExceptions();
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 76633a46a94..bb4ddf59690 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -788,6 +788,12 @@ void LLFloaterPreference::setHardwareDefaults()
 		saveGraphicsPreset(preset_graphic_active);
 		saveSettings(); // save here to be able to return to the previous preset by Cancel
 	}
+    setRecommendedSettings();
+}
+
+void LLFloaterPreference::setRecommendedSettings()
+{
+    gSavedSettings.setBOOL("AutoTuneFPS", FALSE);
 
 	LLFeatureManager::getInstance()->applyRecommendedSettings();
 
diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h
index d5d0aca9398..32a55a2948f 100644
--- a/indra/newview/llfloaterpreference.h
+++ b/indra/newview/llfloaterpreference.h
@@ -199,6 +199,8 @@ class LLFloaterPreference : public LLFloater, public LLAvatarPropertiesObserver,
 	void saveCameraPreset(std::string& preset);
 	void saveGraphicsPreset(std::string& preset);
 
+    void setRecommendedSettings();
+
 private:
 
 	void onDeleteTranscripts();
diff --git a/indra/newview/skins/default/xui/en/panel_performance_preferences.xml b/indra/newview/skins/default/xui/en/panel_performance_preferences.xml
index 9c1a3ebd9ee..b52c19d5e3d 100644
--- a/indra/newview/skins/default/xui/en/panel_performance_preferences.xml
+++ b/indra/newview/skins/default/xui/en/panel_performance_preferences.xml
@@ -47,14 +47,23 @@
     Graphics settings
   </text>
   <button
-    follows="top|left"
-    height="23"
-    label="Open Advanced Settings"
-    layout="topleft"
-    left="360"
-    name="advanced_btn"
-    top_delta="0"
-    width="200"/>
+   follows="top|left"
+   height="23"
+   label="Open Advanced Settings"
+   layout="topleft"
+   left="360"
+   name="advanced_btn"
+   top_delta="-35"
+   width="200"/>
+  <button
+   follows="top|left"
+   height="23"
+   label="Reset to recommended settings"
+   layout="topleft"
+   left="350"
+   name="defaults_btn"
+   top_pad="10"
+   width="210"/>
   <view_border
    bevel_style="in"
    height="0"
-- 
GitLab