diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index e29506bdf549e0f9a7ab01b131404695ede84896..213446ccfb7d28e6bbe085f807cfa6d2326a30ce 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 0000000000000000000000000000000000000000..5dc51c4223355e0725978e2c5f9e6c199d62e612 --- /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 0000000000000000000000000000000000000000..fc531ca1b76dd87c7e6236c5896c42df3064eb39 --- /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 e8590fc9dcff592dd1f19d2bb652ed025d40a960..6b798f6549f84f004df9233c1b82a24ee5e43f7c 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 66442a0b51546ac90e6be3cbd85e180bcd082fa7..be228c862507e6b9d60ce35852f11e58027507c4 100755 --- a/indra/newview/llfloaterpreference.h +++ b/indra/newview/llfloaterpreference.h @@ -221,6 +221,7 @@ class LLPanelPreference : public LLPanel // cancel() can restore them. virtual void saveSettings(); + void onDeletePreset(); void onChangePreset(); class Updater; @@ -250,7 +251,7 @@ class LLPanelPreferenceGraphics : public LLPanelPreference 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 d93afd674ce59687d4958444f9859cd72fcddd9a..fc459a27e71e8d4769d97ffd95d58aa7c916480e 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 400dd73a4c5adddbc60fa5c5edb709670d3806ff..0cabf4aaadd24d4db8867c798790bb6a80728d95 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 642d9819fe168e72f6cfa59ace6815ff01201216..6b0023d97a0a407dd71a018fba171559fd65ba83 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 9b0de887cee0f20548856f87e40ed43e0f4059e4..128c5850f20ca7fb651c006dd98a8a64dd32f00d 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 @@ class LLPresetsManager : public LLSingleton<LLPresetsManager> 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 e19fe9ca754ca5859de3890077962894ad67d403..03360deaee91bd31369faa44c0164790e6b06b55 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 0000000000000000000000000000000000000000..03c5a412b66ae80f625379de5f51fa6df9bf55f0 --- /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 d8095c047620d6ab7c118fb45a518c8f8731d776..3d7fdbb0ab6c4db6cb4f792d80bc7243658a23fc 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 5dcb8e2cdf4564a1ba032652a1f16a7154c60e62..a763e3ee2f81a7196ffc16a0597dd77443e48f5d 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>