diff options
Diffstat (limited to 'indra/newview')
-rwxr-xr-x | indra/newview/CMakeLists.txt | 2 | ||||
-rw-r--r-- | indra/newview/llfloaterdeleteprefpreset.cpp | 80 | ||||
-rw-r--r-- | indra/newview/llfloaterdeleteprefpreset.h | 51 | ||||
-rwxr-xr-x | indra/newview/llfloaterpreference.cpp | 36 | ||||
-rwxr-xr-x | indra/newview/llfloaterpreference.h | 3 | ||||
-rw-r--r-- | indra/newview/llpanelpresetspulldown.cpp | 13 | ||||
-rw-r--r-- | indra/newview/llpanelpresetspulldown.h | 5 | ||||
-rw-r--r-- | indra/newview/llpresetsmanager.cpp | 53 | ||||
-rw-r--r-- | indra/newview/llpresetsmanager.h | 9 | ||||
-rwxr-xr-x | indra/newview/llviewerfloaterreg.cpp | 2 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_delete_pref_preset.xml | 49 | ||||
-rwxr-xr-x | indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml | 4 | ||||
-rwxr-xr-x | indra/newview/skins/default/xui/en/strings.xml | 5 |
13 files changed, 257 insertions, 55 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index e29506bdf5..213446ccfb 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -225,6 +225,7 @@ set(viewer_SOURCE_FILES llfloaterconversationlog.cpp llfloaterconversationpreview.cpp llfloaterdeleteenvpreset.cpp + llfloaterdeleteprefpreset.cpp llfloaterdestinations.cpp llfloaterdisplayname.cpp llfloatereditdaycycle.cpp @@ -831,6 +832,7 @@ set(viewer_HEADER_FILES llfloatercolorpicker.h llfloaterconversationlog.h llfloaterconversationpreview.h + llfloaterdeleteprefpreset.h llfloaterdeleteenvpreset.h llfloaterdestinations.h llfloaterdisplayname.h diff --git a/indra/newview/llfloaterdeleteprefpreset.cpp b/indra/newview/llfloaterdeleteprefpreset.cpp new file mode 100644 index 0000000000..5dc51c4223 --- /dev/null +++ b/indra/newview/llfloaterdeleteprefpreset.cpp @@ -0,0 +1,80 @@ +/** + * @file llfloaterdeletprefpreset.cpp + * @brief Floater to delete a graphics / camera preset + * + * $LicenseInfo:firstyear=2014&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2014, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llfloaterdeleteprefpreset.h" + +#include "llbutton.h" +#include "llcombobox.h" +#include "llpresetsmanager.h" + +LLFloaterDeletePrefPreset::LLFloaterDeletePrefPreset(const LLSD &key) +: LLFloater(key) +{ +} + +// virtual +BOOL LLFloaterDeletePrefPreset::postBuild() +{ + getChild<LLButton>("delete")->setCommitCallback(boost::bind(&LLFloaterDeletePrefPreset::onBtnDelete, this)); + getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterDeletePrefPreset::onBtnCancel, this)); + LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterDeletePrefPreset::onPresetsListChange, this)); + + return TRUE; +} + +void LLFloaterDeletePrefPreset::onOpen(const LLSD& key) +{ + std::string param = key.asString(); + std::string floater_title = getString(std::string("title_") + param); + + setTitle(floater_title); + + LLComboBox* combo = getChild<LLComboBox>("preset_combo"); + + LLPresetsManager::getInstance()->setPresetNamesInComboBox(combo); +} + +void LLFloaterDeletePrefPreset::onBtnDelete() +{ + LLComboBox* combo = getChild<LLComboBox>("preset_combo"); + std::string name = combo->getSimple(); + + LLPresetsManager::getInstance()->deletePreset(name); +} + +void LLFloaterDeletePrefPreset::onPresetsListChange() +{ + LLComboBox* combo = getChild<LLComboBox>("preset_combo"); + + LLPresetsManager::getInstance()->setPresetNamesInComboBox(combo); +} + +void LLFloaterDeletePrefPreset::onBtnCancel() +{ + closeFloater(); +} diff --git a/indra/newview/llfloaterdeleteprefpreset.h b/indra/newview/llfloaterdeleteprefpreset.h new file mode 100644 index 0000000000..fc531ca1b7 --- /dev/null +++ b/indra/newview/llfloaterdeleteprefpreset.h @@ -0,0 +1,51 @@ +/** + * @file llfloaterdeleteprefpreset.h + * @brief Floater to delete a graphics / camera preset + + * + * $LicenseInfo:firstyear=2014&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2014, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLFLOATERDELETPREFPRESET_H +#define LL_LLFLOATERDELETEPREFPRESET_H + +#include "llfloater.h" + +class LLComboBox; + +class LLFloaterDeletePrefPreset : public LLFloater +{ + +public: + LLFloaterDeletePrefPreset(const LLSD &key); + + /*virtual*/ BOOL postBuild(); + /*virtual*/ void onOpen(const LLSD& key); + + void onBtnDelete(); + void onBtnCancel(); + +private: + void onPresetsListChange(); +}; + +#endif // LL_LLFLOATERDELETEPREFPRESET_H diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index e8590fc9dc..6b798f6549 100755 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -110,6 +110,7 @@ #include "llsdserialize.h" #include "llpresetsmanager.h" #include "llviewercontrol.h" +#include "llpresetsmanager.h" const F32 MAX_USER_FAR_CLIP = 512.f; const F32 MIN_USER_FAR_CLIP = 64.f; @@ -743,7 +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_DIR, "default.xml"); + 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; @@ -1881,6 +1882,7 @@ LLPanelPreference::LLPanelPreference() mCommitCallbackRegistrar.add("Pref.setControlFalse", boost::bind(&LLPanelPreference::setControlFalse,this, _2)); mCommitCallbackRegistrar.add("Pref.updateMediaAutoPlayCheckbox", boost::bind(&LLPanelPreference::updateMediaAutoPlayCheckbox, this, _1)); mCommitCallbackRegistrar.add("Pref.Preset", boost::bind(&LLPanelPreference::onChangePreset, this)); + mCommitCallbackRegistrar.add("Pref.PrefDelete", boost::bind(&LLPanelPreference::onDeletePreset, this)); } //virtual @@ -2078,6 +2080,11 @@ void LLPanelPreference::updateMediaAutoPlayCheckbox(LLUICtrl* ctrl) } } +void LLPanelPreference::onDeletePreset() +{ + LLFloaterReg::showInstance("delete_pref_preset", PRESETS_GRAPHIC); +} + void LLPanelPreference::onChangePreset() { LLComboBox* combo = getChild<LLComboBox>("graphic_preset_combo"); @@ -2135,9 +2142,9 @@ static LLPanelInjector<LLPanelPreferencePrivacy> t_pref_privacy("panel_preferenc BOOL LLPanelPreferenceGraphics::postBuild() { LLComboBox* combo = getChild<LLComboBox>("graphic_preset_combo"); - combo->setLabel(getString("graphic_preset_combo_label")); + combo->setLabel(LLTrans::getString("preset_combo_label")); - setPresetNamesInCombobox(); + setPresetNamesInComboBox(); LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLPanelPreferenceGraphics::onPresetsListChange, this)); @@ -2146,31 +2153,14 @@ BOOL LLPanelPreferenceGraphics::postBuild() void LLPanelPreferenceGraphics::onPresetsListChange() { - setPresetNamesInCombobox(); + setPresetNamesInComboBox(); } -void LLPanelPreferenceGraphics::setPresetNamesInCombobox() +void LLPanelPreferenceGraphics::setPresetNamesInComboBox() { LLComboBox* combo = getChild<LLComboBox>("graphic_preset_combo"); - combo->clearRows(); - - std::string presets_dir = LLPresetsManager::getGraphicPresetsDir(); - if (!presets_dir.empty()) - { - LLPresetsManager::getInstance()->loadPresetNamesFromDir(presets_dir); - std::list<std::string> preset_names; - LLPresetsManager::getInstance()->getPresetNames(preset_names); - - for (std::list<std::string>::const_iterator it = preset_names.begin(); it != preset_names.end(); ++it) - { - const std::string& name = *it; - combo->add(name, LLSD().with(0, name)); - } - } - else { - LL_WARNS() << "Could not obtain graphic presets path" << LL_ENDL; - } + LLPresetsManager::getInstance()->setPresetNamesInComboBox(combo); } void LLPanelPreferenceGraphics::draw() diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h index 66442a0b51..be228c8625 100755 --- a/indra/newview/llfloaterpreference.h +++ b/indra/newview/llfloaterpreference.h @@ -221,6 +221,7 @@ public: // cancel() can restore them. virtual void saveSettings(); + void onDeletePreset(); void onChangePreset(); class Updater; @@ -250,7 +251,7 @@ public: void cancel(); void saveSettings(); void setHardwareDefaults(); - void setPresetNamesInCombobox(); + void setPresetNamesInComboBox(); static const std::string getPresetsPath(); protected: diff --git a/indra/newview/llpanelpresetspulldown.cpp b/indra/newview/llpanelpresetspulldown.cpp index d93afd674c..fc459a27e7 100644 --- a/indra/newview/llpanelpresetspulldown.cpp +++ b/indra/newview/llpanelpresetspulldown.cpp @@ -1,11 +1,10 @@ /** * @file llpanelpresetspulldown.cpp - * @author Tofu Linden * @brief A panel showing a quick way to pick presets * - * $LicenseInfo:firstyear=2008&license=viewerlgpl$ + * $LicenseInfo:firstyear=2014&license=viewerlgpl$ * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * Copyright (C) 2014, Linden Research, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -29,11 +28,9 @@ #include "llpanelpresetspulldown.h" -// Viewer libs #include "llviewercontrol.h" #include "llstatusbar.h" -// Linden libs #include "llbutton.h" #include "lltabcontainer.h" #include "llfloaterreg.h" @@ -102,8 +99,7 @@ void LLPanelPresetsPulldown::onMoveViewButtonClick(const LLSD& user_data) setVisible(FALSE); // bring up the prefs floater - LLFloaterPreference* prefsfloater = dynamic_cast<LLFloaterPreference*> - (LLFloaterReg::showInstance("preferences")); + LLFloater* prefsfloater = LLFloaterReg::showInstance("preferences"); if (prefsfloater) { // grab the 'move' panel from the preferences floater and @@ -123,8 +119,7 @@ void LLPanelPresetsPulldown::onGraphicsButtonClick(const LLSD& user_data) setVisible(FALSE); // bring up the prefs floater - LLFloaterPreference* prefsfloater = dynamic_cast<LLFloaterPreference*> - (LLFloaterReg::showInstance("preferences")); + LLFloater* prefsfloater = LLFloaterReg::showInstance("preferences"); if (prefsfloater) { // grab the 'graphics' panel from the preferences floater and diff --git a/indra/newview/llpanelpresetspulldown.h b/indra/newview/llpanelpresetspulldown.h index 400dd73a4c..0cabf4aaad 100644 --- a/indra/newview/llpanelpresetspulldown.h +++ b/indra/newview/llpanelpresetspulldown.h @@ -1,11 +1,10 @@ /** * @file llpanelpresetspulldown.h - * @author Tofu Linden * @brief A panel showing a quick way to pick presets * - * $LicenseInfo:firstyear=2008&license=viewerlgpl$ + * $LicenseInfo:firstyear=2014&license=viewerlgpl$ * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * Copyright (C) 2014, Linden Research, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp index 642d9819fe..6b0023d97a 100644 --- a/indra/newview/llpresetsmanager.cpp +++ b/indra/newview/llpresetsmanager.cpp @@ -31,7 +31,9 @@ #include "llpresetsmanager.h" #include "lldiriterator.h" +#include "llfloater.h" #include "llsdserialize.h" +#include "lltrans.h" #include "lluictrlfactory.h" #include "llviewercontrol.h" @@ -64,12 +66,12 @@ std::string LLPresetsManager::getUserDir(const std::string& subdirectory) std::string LLPresetsManager::getCameraPresetsDir() { - return getUserDir(PRESETS_CAMERA_DIR); + return getUserDir(PRESETS_CAMERA); } std::string LLPresetsManager::getGraphicPresetsDir() { - return getUserDir(PRESETS_GRAPHIC_DIR); + return getUserDir(PRESETS_GRAPHIC); } void LLPresetsManager::getPresetNames(preset_name_list_t& presets) const @@ -164,7 +166,7 @@ void LLPresetsManager::savePreset(const std::string& name) paramsData[ctrl_name]["Value"] = value; } - std::string pathName(getUserDir(PRESETS_GRAPHIC_DIR) + "\\" + LLURI::escape(name) + ".xml"); + std::string pathName(getUserDir(PRESETS_GRAPHIC) + "\\" + LLURI::escape(name) + ".xml"); // write to file llofstream presetsXML(pathName); @@ -176,14 +178,40 @@ void LLPresetsManager::savePreset(const std::string& name) mPresetListChangeSignal(); } +void LLPresetsManager::setPresetNamesInComboBox(LLComboBox* combo) +{ + combo->clearRows(); + + std::string presets_dir = getGraphicPresetsDir(); + + if (!presets_dir.empty()) + { + loadPresetNamesFromDir(presets_dir); + std::list<std::string> preset_names; + getPresetNames(preset_names); + + combo->setLabel(LLTrans::getString("preset_combo_label")); + + for (std::list<std::string>::const_iterator it = preset_names.begin(); it != preset_names.end(); ++it) + { + const std::string& name = *it; + combo->add(name, LLSD().with(0, name)); + } + } + else + { + LL_WARNS() << "Could not obtain graphic presets path" << LL_ENDL; + } +} + void LLPresetsManager::loadPreset(const std::string& name) { - std::string pathName(getUserDir(PRESETS_GRAPHIC_DIR) + "\\" + LLURI::escape(name) + ".xml"); + std::string pathName(getUserDir(PRESETS_GRAPHIC) + "\\" + LLURI::escape(name) + ".xml"); gSavedSettings.loadFromFile(pathName, false, true); } -bool LLPresetsManager::removeParamSet(const std::string& name, bool delete_from_disk) +bool LLPresetsManager::deletePreset(const std::string& name) { // remove from param list preset_name_list_t::iterator it = find(mPresetNames.begin(), mPresetNames.end(), name); @@ -193,15 +221,14 @@ bool LLPresetsManager::removeParamSet(const std::string& name, bool delete_from_ return false; } - mPresetNames.erase(it); - - // remove from file system if requested - if (delete_from_disk) + // (*TODO Should the name be escaped here? + if (gDirUtilp->deleteFilesInDir(getUserDir(PRESETS_GRAPHIC), name + ".xml") < 1) { - if (gDirUtilp->deleteFilesInDir(getUserDir(PRESETS_GRAPHIC_DIR), LLURI::escape(name) + ".xml") < 1) - { - LL_WARNS("Presets") << "Error removing preset " << name << " from disk" << LL_ENDL; - } + LL_WARNS("Presets") << "Error removing preset " << name << " from disk" << LL_ENDL; + } + else + { + mPresetNames.erase(it); } // signal interested parties diff --git a/indra/newview/llpresetsmanager.h b/indra/newview/llpresetsmanager.h index 9b0de887ce..128c5850f2 100644 --- a/indra/newview/llpresetsmanager.h +++ b/indra/newview/llpresetsmanager.h @@ -27,12 +27,14 @@ #ifndef LL_PRESETSMANAGER_H #define LL_PRESETSMANAGER_H +#include "llcombobox.h" + #include <list> #include <map> static const std::string PRESETS_DIR = "presets"; -static const std::string PRESETS_GRAPHIC_DIR = "graphic"; -static const std::string PRESETS_CAMERA_DIR = "camera"; +static const std::string PRESETS_GRAPHIC = "graphic"; +static const std::string PRESETS_CAMERA = "camera"; class LLPresetsManager : public LLSingleton<LLPresetsManager> { @@ -40,13 +42,14 @@ public: typedef std::list<std::string> preset_name_list_t; typedef boost::signals2::signal<void()> preset_list_signal_t; + void setPresetNamesInComboBox(LLComboBox* combo); void getPresetNames(preset_name_list_t& presets) const; void loadPresetNamesFromDir(const std::string& dir); void savePreset(const std::string & name); void loadPreset(const std::string & name); static std::string getCameraPresetsDir(); static std::string getGraphicPresetsDir(); - bool removeParamSet(const std::string& name, bool delete_from_disk); + bool deletePreset(const std::string& name); /// Emitted when a preset gets loaded or deleted. boost::signals2::connection setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb); diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index e19fe9ca75..03360deaee 100755 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -55,6 +55,7 @@ #include "llfloaterconversationlog.h" #include "llfloaterconversationpreview.h" #include "llfloaterdeleteenvpreset.h" +#include "llfloaterdeleteprefpreset.h" #include "llfloaterdestinations.h" #include "llfloaterdisplayname.h" #include "llfloatereditdaycycle.h" @@ -204,6 +205,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("compile_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCompileQueue>); LLFloaterReg::add("conversation", "floater_conversation_log.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterConversationLog>); + LLFloaterReg::add("delete_pref_preset", "floater_delete_pref_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterDeletePrefPreset>); LLFloaterReg::add("destinations", "floater_destinations.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterDestinations>); LLFloaterReg::add("env_post_process", "floater_post_process.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPostProcess>); diff --git a/indra/newview/skins/default/xui/en/floater_delete_pref_preset.xml b/indra/newview/skins/default/xui/en/floater_delete_pref_preset.xml new file mode 100644 index 0000000000..03c5a412b6 --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_delete_pref_preset.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<floater + legacy_header_height="18" + height="130" + help_topic="" + layout="topleft" + name="Delete Pref Preset" + save_rect="true" + title="DELETE PREF PRESET" + width="550"> + + <string name="title_graphic">Delete Graphic Preset</string> + <string name="title_camera">Delete Camera Preset</string> + + <text + follows="top|left|right" + font="SansSerif" + height="10" + layout="topleft" + left="50" + name="Preset" + top="60" + width="60"> + Preset: + </text> + <combo_box + follows="top|left" + layout="topleft" + left_pad="10" + name="preset_combo" + top_delta="-5" + width="200"/> + <button + follows="bottom|right" + height="23" + label="Delete" + layout="topleft" + left_pad="15" + name="delete" + width="70"/> + <button + follows="bottom|right" + height="23" + label="Cancel" + layout="topleft" + left_pad="5" + name="cancel" + width="70"/> +</floater> 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 d8095c0476..3d7fdbb0ab 100755 --- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml @@ -9,7 +9,6 @@ name="Display panel" top="1" width="517"> - <string name="graphic_preset_combo_label">-None saved yet-</string> <!-- This block is always displayed --> <text @@ -56,7 +55,8 @@ top_delta="0" width="115"> <button.commit_callback - function="Pref.PrefDelete" /> + function="Pref.PrefDelete" + parameter="graphic"/> </button> <text type="string" diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index 5dcb8e2cdf..a763e3ee2f 100755 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -4041,5 +4041,8 @@ Try enclosing path to the editor with double quotes. <string name="loading_chat_logs"> Loading... </string> - + + <!-- Presets graphic/camera --> + <string name="preset_combo_label">-None saved yet-</string> + </strings> |