summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llfloaterdeleteprefpreset.cpp18
-rwxr-xr-xindra/newview/llfloaterpreference.cpp17
-rwxr-xr-xindra/newview/llfloaterpreference.h2
-rw-r--r--indra/newview/llfloatersaveprefpreset.cpp6
-rw-r--r--indra/newview/llpanelpresetspulldown.cpp4
-rw-r--r--indra/newview/llpresetsmanager.cpp43
-rw-r--r--indra/newview/llpresetsmanager.h14
-rwxr-xr-xindra/newview/skins/default/xui/en/panel_preferences_graphics1.xml4
8 files changed, 77 insertions, 31 deletions
diff --git a/indra/newview/llfloaterdeleteprefpreset.cpp b/indra/newview/llfloaterdeleteprefpreset.cpp
index 74f8805d03..50abf1038b 100644
--- a/indra/newview/llfloaterdeleteprefpreset.cpp
+++ b/indra/newview/llfloaterdeleteprefpreset.cpp
@@ -58,7 +58,8 @@ void LLFloaterDeletePrefPreset::onOpen(const LLSD& key)
LLComboBox* combo = getChild<LLComboBox>("preset_combo");
- LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo);
+ EDefaultOptions option = DEFAULT_HIDE;
+ LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option);
}
void LLFloaterDeletePrefPreset::onBtnDelete()
@@ -66,19 +67,20 @@ void LLFloaterDeletePrefPreset::onBtnDelete()
LLComboBox* combo = getChild<LLComboBox>("preset_combo");
std::string name = combo->getSimple();
- // Ignore return status
- LLPresetsManager::getInstance()->deletePreset(mSubdirectory, name);
-
- LLSD args;
- args["NAME"] = name;
- LLNotificationsUtil::add("PresetDeleted", args);
+ if (LLPresetsManager::getInstance()->deletePreset(mSubdirectory, name))
+ {
+ LLSD args;
+ args["NAME"] = name;
+ LLNotificationsUtil::add("PresetDeleted", args);
+ }
}
void LLFloaterDeletePrefPreset::onPresetsListChange()
{
LLComboBox* combo = getChild<LLComboBox>("preset_combo");
- LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo);
+ EDefaultOptions option = DEFAULT_HIDE;
+ LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option);
}
void LLFloaterDeletePrefPreset::onBtnCancel()
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 521cc59dda..97af9d6ce0 100755
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -744,15 +744,7 @@ void LLFloaterPreference::onOpen(const LLSD& key)
saveSettings();
// Make sure there is a default preference file
- std::string default_file = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, PRESETS_DIR, PRESETS_GRAPHIC, "default.xml");
- if (!gDirUtilp->fileExists(default_file))
- {
- LL_WARNS() << "No " << default_file << " found -- creating one" << LL_ENDL;
- // Write current graphic settings to default.xml
- // If this name is to be localized additional code will be needed to delete the old default
- // when changing languages.
- LLPresetsManager::getInstance()->savePreset(PRESETS_GRAPHIC, "Default");
- }
+ LLPresetsManager::getInstance()->createMissingDefault();
bool started = (LLStartUp::getStartupState() == STATE_STARTED);
@@ -2121,6 +2113,10 @@ void LLPanelPreference::onChangePreset(const LLSD& user_data)
}
}
+void LLPanelPreference::setHardwareDefaults()
+{
+}
+
class LLPanelPreferencePrivacy : public LLPanelPreference
{
public:
@@ -2183,7 +2179,8 @@ void LLPanelPreferenceGraphics::setPresetNamesInComboBox()
{
LLComboBox* combo = getChild<LLComboBox>("graphic_preset_combo");
- LLPresetsManager::getInstance()->setPresetNamesInComboBox(PRESETS_GRAPHIC, combo);
+ EDefaultOptions option = DEFAULT_POSITION_TOP;
+ LLPresetsManager::getInstance()->setPresetNamesInComboBox(PRESETS_GRAPHIC, combo, option);
}
void LLPanelPreferenceGraphics::draw()
diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h
index 5452dc6442..99d133c1ac 100755
--- a/indra/newview/llfloaterpreference.h
+++ b/indra/newview/llfloaterpreference.h
@@ -211,7 +211,7 @@ public:
virtual void apply();
virtual void cancel();
void setControlFalse(const LLSD& user_data);
- virtual void setHardwareDefaults(){};
+ virtual void setHardwareDefaults();
// Disables "Allow Media to auto play" check box only when both
// "Streaming Music" and "Media" are unchecked. Otherwise enables it.
diff --git a/indra/newview/llfloatersaveprefpreset.cpp b/indra/newview/llfloatersaveprefpreset.cpp
index 16d77c0750..3148978778 100644
--- a/indra/newview/llfloatersaveprefpreset.cpp
+++ b/indra/newview/llfloatersaveprefpreset.cpp
@@ -70,7 +70,8 @@ void LLFloaterSavePrefPreset::onOpen(const LLSD& key)
setTitle(floater_title);
- LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, mPresetCombo);
+ EDefaultOptions option = DEFAULT_POSITION_TOP;
+ LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, mPresetCombo, option);
onPresetNameEdited();
}
@@ -88,7 +89,8 @@ void LLFloaterSavePrefPreset::onBtnSave()
void LLFloaterSavePrefPreset::onPresetsListChange()
{
- LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, mPresetCombo);
+ EDefaultOptions option = DEFAULT_POSITION_TOP;
+ LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, mPresetCombo, option);
}
void LLFloaterSavePrefPreset::onBtnCancel()
diff --git a/indra/newview/llpanelpresetspulldown.cpp b/indra/newview/llpanelpresetspulldown.cpp
index fc459a27e7..977e9ff5e2 100644
--- a/indra/newview/llpanelpresetspulldown.cpp
+++ b/indra/newview/llpanelpresetspulldown.cpp
@@ -35,6 +35,7 @@
#include "lltabcontainer.h"
#include "llfloaterreg.h"
#include "llfloaterpreference.h"
+#include "llpresetsmanager.h"
#include "llsliderctrl.h"
/* static */ const F32 LLPanelPresetsPulldown::sAutoCloseFadeStartTimeSec = 4.0f;
@@ -56,6 +57,9 @@ LLPanelPresetsPulldown::LLPanelPresetsPulldown()
BOOL LLPanelPresetsPulldown::postBuild()
{
+ // Make sure there is a default preference file
+ LLPresetsManager::getInstance()->createMissingDefault();
+
return LLPanel::postBuild();
}
diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index f6f2275da9..b9497efde6 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -45,7 +45,19 @@ LLPresetsManager::~LLPresetsManager()
{
}
-//std::string LLPresetsManager::getUserDir(const std::string& subdirectory)
+void LLPresetsManager::createMissingDefault()
+{
+ std::string default_file = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, PRESETS_DIR, PRESETS_GRAPHIC, "default.xml");
+ if (!gDirUtilp->fileExists(default_file))
+ {
+ LL_WARNS() << "No " << default_file << " found -- creating one" << LL_ENDL;
+ // Write current graphic settings to default.xml
+ // If this name is to be localized additional code will be needed to delete the old default
+ // when changing languages.
+ LLPresetsManager::getInstance()->savePreset(PRESETS_GRAPHIC, PRESETS_DEFAULT);
+ }
+}
+
std::string LLPresetsManager::getPresetsDir(const std::string& subdirectory)
{
std::string presets_path = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, PRESETS_DIR);
@@ -65,7 +77,7 @@ std::string LLPresetsManager::getPresetsDir(const std::string& subdirectory)
return full_path;
}
-void LLPresetsManager::loadPresetNamesFromDir(const std::string& dir, preset_name_list_t& presets)
+void LLPresetsManager::loadPresetNamesFromDir(const std::string& dir, preset_name_list_t& presets, EDefaultOptions default_option)
{
LL_INFOS("AppInit") << "Loading presets from " << dir << LL_ENDL;
@@ -82,13 +94,26 @@ void LLPresetsManager::loadPresetNamesFromDir(const std::string& dir, preset_nam
{
std::string path = gDirUtilp->add(dir, file);
std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), /*strip_exten = */ true));
- if ("Default" != name)
+ if (PRESETS_DEFAULT != name)
{
mPresetNames.push_back(name);
}
else
{
- mPresetNames.insert(mPresetNames.begin(), name);
+ switch (default_option)
+ {
+ case DEFAULT_POSITION_TOP:
+ mPresetNames.insert(mPresetNames.begin(), name);
+ break;
+
+ case DEFAULT_POSITION_NORMAL:
+ mPresetNames.push_back(name);
+ break;
+
+ case DEFAULT_HIDE:
+ default:
+ break;
+ }
}
}
}
@@ -177,7 +202,7 @@ void LLPresetsManager::savePreset(const std::string& subdirectory, const std::st
mPresetListChangeSignal();
}
-void LLPresetsManager::setPresetNamesInComboBox(const std::string& subdirectory, LLComboBox* combo)
+void LLPresetsManager::setPresetNamesInComboBox(const std::string& subdirectory, LLComboBox* combo, EDefaultOptions default_option)
{
combo->clearRows();
@@ -186,7 +211,7 @@ void LLPresetsManager::setPresetNamesInComboBox(const std::string& subdirectory,
if (!presets_dir.empty())
{
std::list<std::string> preset_names;
- loadPresetNamesFromDir(presets_dir, preset_names);
+ loadPresetNamesFromDir(presets_dir, preset_names, default_option);
if (preset_names.begin() != preset_names.end())
{
@@ -212,6 +237,12 @@ void LLPresetsManager::loadPreset(const std::string& subdirectory, const std::st
bool LLPresetsManager::deletePreset(const std::string& subdirectory, const std::string& name)
{
+ if (PRESETS_DEFAULT == name)
+ {
+ LL_WARNS("Presets") << "You are not allowed to delete the default preset." << LL_ENDL;
+ return false;
+ }
+
if (gDirUtilp->deleteFilesInDir(getPresetsDir(subdirectory), LLURI::escape(name) + ".xml") < 1)
{
LL_WARNS("Presets") << "Error removing preset " << name << " from disk" << LL_ENDL;
diff --git a/indra/newview/llpresetsmanager.h b/indra/newview/llpresetsmanager.h
index 878116e5aa..1bac2c65e1 100644
--- a/indra/newview/llpresetsmanager.h
+++ b/indra/newview/llpresetsmanager.h
@@ -32,19 +32,29 @@
#include <list>
#include <map>
+static const std::string PRESETS_DEFAULT = "Default";
static const std::string PRESETS_DIR = "presets";
static const std::string PRESETS_GRAPHIC = "graphic";
static const std::string PRESETS_CAMERA = "camera";
+enum EDefaultOptions
+{
+ DEFAULT_POSITION_TOP, // Put "Default" as the first item in the combobox
+ DEFAULT_POSITION_NORMAL, // No special positioning
+ DEFAULT_HIDE // Do not display "Default" in the combobox
+};
+
class LLPresetsManager : public LLSingleton<LLPresetsManager>
{
public:
+
typedef std::list<std::string> preset_name_list_t;
typedef boost::signals2::signal<void()> preset_list_signal_t;
+ void createMissingDefault();
static std::string getPresetsDir(const std::string& subdirectory);
- void setPresetNamesInComboBox(const std::string& subdirectory, LLComboBox* combo);
- void loadPresetNamesFromDir(const std::string& dir, preset_name_list_t& presets);
+ void setPresetNamesInComboBox(const std::string& subdirectory, LLComboBox* combo, EDefaultOptions default_option);
+ void loadPresetNamesFromDir(const std::string& dir, preset_name_list_t& presets, EDefaultOptions default_option);
void savePreset(const std::string& subdirectory, const std::string & name);
void loadPreset(const std::string& subdirectory, const std::string & name);
bool deletePreset(const std::string& subdirectory, const std::string& name);
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
index 32de123895..4248de4d96 100755
--- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
@@ -962,9 +962,9 @@
<button
follows="left|bottom"
height="23"
- label="Reset"
+ label="Undo"
layout="topleft"
- left_pad="5"
+ left_pad="5"
name="Defaults"
top="310"
width="115">