From ce17ae8a182cf8b1acd88bbbb3dceb7ff39fd0ff Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Sat, 12 May 2012 07:29:25 -0400 Subject: STORM-1738: get autoreplace preferences working, clean up some coding and naming conventions --- indra/newview/CMakeLists.txt | 4 +- indra/newview/llautoreplacefloater.cpp | 377 --------------------- indra/newview/llautoreplacefloater.h | 75 ---- indra/newview/llfloaterautoreplacesettings.cpp | 367 ++++++++++++++++++++ indra/newview/llfloaterautoreplacesettings.h | 70 ++++ indra/newview/llfloaterpreference.cpp | 12 +- indra/newview/llfloaterpreference.h | 1 + indra/newview/llviewerfloaterreg.cpp | 4 +- .../skins/default/xui/en/floater_autoreplace.xml | 4 +- .../default/xui/en/panel_preferences_chat.xml | 2 +- 10 files changed, 455 insertions(+), 461 deletions(-) delete mode 100644 indra/newview/llautoreplacefloater.cpp delete mode 100644 indra/newview/llautoreplacefloater.h create mode 100644 indra/newview/llfloaterautoreplacesettings.cpp create mode 100644 indra/newview/llfloaterautoreplacesettings.h diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 90468ccbef..a45467324b 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -99,7 +99,6 @@ set(viewer_SOURCE_FILES llattachmentsmgr.cpp llaudiosourcevo.cpp llautoreplace.cpp - llautoreplacefloater.cpp llavataractions.cpp llavatariconctrl.cpp llavatarlist.cpp @@ -171,6 +170,7 @@ set(viewer_SOURCE_FILES llfloaterabout.cpp llfloaterbvhpreview.cpp llfloaterauction.cpp + llfloaterautoreplacesettings.cpp llfloateravatar.cpp llfloateravatarpicker.cpp llfloateravatartextures.cpp @@ -657,7 +657,6 @@ set(viewer_HEADER_FILES llattachmentsmgr.h llaudiosourcevo.h llautoreplace.h - llautoreplacefloater.h llavataractions.h llavatariconctrl.h llavatarlist.h @@ -729,6 +728,7 @@ set(viewer_HEADER_FILES llfloaterabout.h llfloaterbvhpreview.h llfloaterauction.h + llfloaterautoreplacesettings.h llfloateravatar.h llfloateravatarpicker.h llfloateravatartextures.h diff --git a/indra/newview/llautoreplacefloater.cpp b/indra/newview/llautoreplacefloater.cpp deleted file mode 100644 index c2d7be269b..0000000000 --- a/indra/newview/llautoreplacefloater.cpp +++ /dev/null @@ -1,377 +0,0 @@ -/** - * @file llautoreplacefloater.cpp - * @brief Auto Replace List floater - * - * $LicenseInfo:firstyear=2012&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2012, 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; either - * version 2.1 of the License, or (at your option) any later version. - * - * 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 - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llautoreplacefloater.h" - -#include "llagentdata.h" -#include "llcommandhandler.h" -#include "llfloater.h" -#include "lluictrlfactory.h" -#include "llagent.h" -#include "llpanel.h" -#include "llbutton.h" -#include "llcolorswatch.h" -#include "llcombobox.h" -#include "llview.h" -#include "llhttpclient.h" -#include "llbufferstream.h" -#include "llcheckboxctrl.h" -#include "llviewercontrol.h" - -#include "llui.h" -#include "llcontrol.h" -#include "llscrollingpanellist.h" -#include "llautoreplace.h" -#include "llfilepicker.h" -#include "llfile.h" -#include "llsdserialize.h" -//#include "llfloaterchat.h" -#include "llchat.h" -#include "llinventorymodel.h" -#include "llhost.h" -#include "llassetstorage.h" -#include "roles_constants.h" -#include "llviewertexteditor.h" -#include - -#include -#include "llfloaterreg.h" -#include "llinspecttoast.h" -#include "llnotificationhandler.h" -#include "llnotificationmanager.h" - - -AutoReplaceFloater::AutoReplaceFloater(const LLSD& key) : -LLFloater(key) -{ -} -void AutoReplaceFloater::onClose(bool app_quitting) -{ - destroy(); -} - -BOOL AutoReplaceFloater::postBuild(void) -{ - - namesList = getChild("ac_list_name"); - entryList = getChild("ac_list_entry"); - mOldText = getChild("ac_old_text"); - mNewText = getChild("ac_new_text"); - - childSetCommitCallback("ac_enable",onBoxCommitEnabled,this); - - childSetCommitCallback("ac_list_enabled",onEntrySettingChange,this); - childSetCommitCallback("ac_list_show",onEntrySettingChange,this); - childSetCommitCallback("ac_list_style",onEntrySettingChange,this); - childSetCommitCallback("ac_priority",onEntrySettingChange,this); - - - - updateEnabledStuff(); - updateNamesList(); - - - namesList->setCommitOnSelectionChange(TRUE); - childSetCommitCallback("ac_list_name", onSelectName, this); - - childSetAction("ac_deletelist",removeList,this); - childSetAction("ac_rementry",deleteEntry,this); - childSetAction("ac_exportlist",exportList,this); - childSetAction("ac_addentry",addEntry,this); - childSetAction("ac_loadlist",loadList,this); - - return true; -} - -void AutoReplaceFloater::onSelectName(LLUICtrl* ctrl, void* user_data) -{ - if ( user_data ) - { - AutoReplaceFloater* self = ( AutoReplaceFloater* )user_data; - if ( self ) - self->updateItemsList(); - } - -} -void AutoReplaceFloater::updateItemsList() -{ - entryList->deleteAllItems(); - if((namesList->getAllSelected().size())<=0) - { - - updateListControlsEnabled(FALSE); - return; - } - - updateListControlsEnabled(TRUE); - std::string listName= namesList->getFirstSelected()->getColumn(0)->getValue().asString(); - - LLSD listData = AutoReplace::getInstance()->getAutoReplaceEntries(listName); - childSetValue("ac_list_enabled",listData["enabled"].asBoolean()); - childSetValue("ac_text_name",listName); - childSetValue("ac_priority",listData["priority"]); - - LLSD autoReplaces = listData["data"]; - LLSD::map_const_iterator loc_it = autoReplaces.beginMap(); - LLSD::map_const_iterator loc_end = autoReplaces.endMap(); - for ( ; loc_it != loc_end; ++loc_it) - { - const std::string& wrong = (*loc_it).first; - const std::string& right = (*loc_it).second; - - //std::string lentry(wrong+"=>"+right); - - LLSD element; - element["id"] = wrong; - LLSD& s_column = element["columns"][0]; - s_column["column"] = "Search"; - s_column["value"] = wrong; - s_column["font"] = "SANSSERIF"; - LLSD& r_column = element["columns"][1]; - r_column["column"] = "Replace"; - r_column["value"] = right; - r_column["font"] = "SANSSERIF"; - - entryList->addElement(element, ADD_BOTTOM); - } - -} -void AutoReplaceFloater::updateNamesList() -{ - namesList->deleteAllItems(); - if(!gSavedSettings.getBOOL("AutoReplace")) - { - updateItemsList(); - return; - } - LLSD autoReplaces = AutoReplace::getInstance()->getAutoReplaces(); - LLSD::map_const_iterator loc_it = autoReplaces.beginMap(); - LLSD::map_const_iterator loc_end = autoReplaces.endMap(); - for ( ; loc_it != loc_end; ++loc_it) - { - const std::string& listName = (*loc_it).first; - - LLSD element; - element["id"] = listName; - LLSD& friend_column = element["columns"][0]; - friend_column["column"] = "Entries"; - friend_column["value"] = listName; - //friend_column["font"] = "SANSSERIF"; - const LLSD& loc_map = (*loc_it).second; - if(loc_map["enabled"].asBoolean()) - friend_column["font"] = "SANSSERIF"; - //friend_column["style"] = "BOLD"; - else - friend_column["font"] = "SANSSERIF_SMALL"; - //friend_column["style"] = "NORMAL"; - if(namesList) - namesList->addElement(element, ADD_BOTTOM); - } - updateItemsList(); -} -void AutoReplaceFloater::updateListControlsEnabled(BOOL selected) -{ - - childSetEnabled("ac_text1",selected); - childSetEnabled("ac_text2",selected); - childSetEnabled("ac_text_name",selected); - childSetEnabled("ac_list_enabled",selected); - childSetEnabled("ac_list_show",selected); - childSetEnabled("ac_list_style",selected); - childSetEnabled("ac_deletelist",selected); - childSetEnabled("ac_exportlist",selected); - childSetEnabled("ac_addentry",selected); - childSetEnabled("ac_rementry",selected); - childSetEnabled("ac_priority",selected); - -} -void AutoReplaceFloater::updateEnabledStuff() -{ - BOOL autoreplace = gSavedSettings.getBOOL("AutoReplace"); - if(autoreplace) - { - LLCheckBoxCtrl *enBox = getChild("ac_enable"); - enBox->setDisabledColor(LLColor4::red); - getChild("ac_enable")->setEnabledColor(LLColor4(1.0f,0.0f,0.0f,1.0f)); - }else - { - getChild("ac_enable")->setEnabledColor( - LLUIColorTable::instance().getColor( "LabelTextColor" )); - } - - childSetEnabled("ac_list_name", autoreplace); - childSetEnabled("ac_list_entry", autoreplace); - updateListControlsEnabled(autoreplace); - updateNamesList(); - AutoReplace::getInstance()->save(); - -} -void AutoReplaceFloater::setData(void * data) -{ -} -void AutoReplaceFloater::onBoxCommitEnabled(LLUICtrl* caller, void* user_data) -{ - if ( user_data ) - { - AutoReplaceFloater* self = ( AutoReplaceFloater* )user_data; - if ( self ) - { - self->updateEnabledStuff(); - } - } -} -void AutoReplaceFloater::onEntrySettingChange(LLUICtrl* caller, void* user_data) -{ - if ( user_data ) - { - AutoReplaceFloater* self = ( AutoReplaceFloater* )user_data; - if ( self ) - { - std::string listName= self->namesList->getFirstSelected()->getColumn(0)->getValue().asString(); - AutoReplace::getInstance()->setListEnabled(listName,self->childGetValue("ac_list_enabled").asBoolean()); - AutoReplace::getInstance()->setListPriority(listName,self->childGetValue("ac_priority").asInteger()); - - //sInstance->updateEnabledStuff(); - self->updateItemsList(); - AutoReplace::getInstance()->save(); - } - } -} -void AutoReplaceFloater::deleteEntry(void* data) -{ - if ( data ) - { - AutoReplaceFloater* self = ( AutoReplaceFloater* )data; - if ( self ) - { - - std::string listName=self->namesList->getFirstSelected()->getColumn(0)->getValue().asString(); - - if((self->entryList->getAllSelected().size())>0) - { - std::string wrong= self->entryList->getFirstSelected()->getColumn(0)->getValue().asString(); - AutoReplace::getInstance()->removeEntryFromList(wrong,listName); - self->updateItemsList(); - AutoReplace::getInstance()->save(); - } - } - } -} -void AutoReplaceFloater::loadList(void* data) -{ - LLFilePicker& picker = LLFilePicker::instance(); - - if(!picker.getOpenFile( LLFilePicker::FFLOAD_XML) ) - {return; - } - llifstream file; - file.open(picker.getFirstFile().c_str()); - LLSD blankllsd; - if (file.is_open()) - { - LLSDSerialize::fromXMLDocument(blankllsd, file); - } - file.close(); - gSavedSettings.setBOOL("AutoReplace",true); - AutoReplace::getInstance()->addReplacementList(blankllsd); - if ( data ) - { - AutoReplaceFloater* self = ( AutoReplaceFloater* )data; - if ( self ) - self->updateEnabledStuff(); - } -} -void AutoReplaceFloater::removeList(void* data) -{ - if ( data ) - { - AutoReplaceFloater* self = ( AutoReplaceFloater* )data; - if ( self ) - { - std::string listName= self->namesList->getFirstSelected()->getColumn(0)->getValue().asString(); - AutoReplace::getInstance()->removeReplacementList(listName); - self->updateEnabledStuff(); - } - - } -} -void AutoReplaceFloater::exportList(void *data) -{ - if ( data ) - { - AutoReplaceFloater* self = ( AutoReplaceFloater* )data; - if ( self ) - { - std::string listName=self->namesList->getFirstSelected()->getColumn(0)->getValue().asString(); - - LLFilePicker& picker = LLFilePicker::instance(); - - if(!picker.getSaveFile( LLFilePicker::FFSAVE_XML) ) - {return; - } - llofstream file; - file.open(picker.getFirstFile().c_str()); - LLSDSerialize::toPrettyXML(AutoReplace::getInstance()->exportList(listName), file); - file.close(); - } - - } -} -void AutoReplaceFloater::addEntry(void* data) -{ - if ( data ) - { - AutoReplaceFloater* self = ( AutoReplaceFloater* )data; - if ( self ) - { - std::string listName= self->namesList->getFirstSelected()->getColumn(0)->getValue().asString(); - std::string wrong = self->mOldText->getText(); - std::string right = self->mNewText->getText(); - if(wrong != "" && right != "") - { - AutoReplace::getInstance()->addEntryToList(wrong, right, listName); - self->updateItemsList(); - AutoReplace::getInstance()->save(); - } - } - } -} -AutoReplaceFloater* AutoReplaceFloater::showFloater() -{ - AutoReplaceFloater *floater = dynamic_cast(LLFloaterReg::getInstance("autoreplace")); - if(floater) - { - floater->setVisible(true); - floater->setFrontmost(true); - floater->center(); - return floater; - } - else - { - LL_WARNS("AutoReplace") << "Can't find floater!" << LL_ENDL; - return NULL; - } -} diff --git a/indra/newview/llautoreplacefloater.h b/indra/newview/llautoreplacefloater.h deleted file mode 100644 index 213cf93a30..0000000000 --- a/indra/newview/llautoreplacefloater.h +++ /dev/null @@ -1,75 +0,0 @@ -/** - * @file llautoreplacefloater.h - * @brief Auto Replace List floater - * @copyright Copyright (c) 2011 LordGregGreg Back - * - * $LicenseInfo:firstyear=2012&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2012, 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; either - * version 2.1 of the License, or (at your option) any later version. - * - * 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 - * $/LicenseInfo$ - */ - -#ifndef AUTOREPLACEFLOATER_H -#define AUTOREPLACEFLOATER_H - -#include "llfloater.h" -#include "llmediactrl.h" -#include "llscrolllistctrl.h" -#include "lllineeditor.h" - -#include "llviewerinventory.h" -#include - -class AutoReplaceFloater : -public LLFloater -{ -public: - AutoReplaceFloater(const LLSD& key); - - /*virtual*/ BOOL postBuild(); - /*virtual*/ void onClose(bool app_quitting); - - static AutoReplaceFloater* showFloater(); - - void setData(void * data); - void updateEnabledStuff(); - void updateNamesList(); - void updateListControlsEnabled(BOOL selected); - void updateItemsList(); - - LLScrollListCtrl *namesList; - LLScrollListCtrl *entryList; - LLLineEditor* mOldText; - LLLineEditor* mNewText; - //LLPanel * empanel; -private: - //static JCInvDropTarget* mNotecardDropTarget; - static void onBoxCommitEnabled(LLUICtrl* caller, void* user_data); - static void onEntrySettingChange(LLUICtrl* caller, void* user_data); - static void onSelectName(LLUICtrl* caller, void* user_data); - //static void ResponseItemDrop(LLViewerInventoryItem* item); - //static void onNotecardLoadComplete(LLVFS *vfs,const LLUUID& asset_uuid,LLAssetType::EType type,void* user_data, S32 status, LLExtStat ext_status); - - - static void deleteEntry(void* data); - static void addEntry(void* data); - static void exportList(void* data); - static void removeList(void* data); - static void loadList(void* data); -}; - -#endif // AUTOREPLACEFLOATER_H diff --git a/indra/newview/llfloaterautoreplacesettings.cpp b/indra/newview/llfloaterautoreplacesettings.cpp new file mode 100644 index 0000000000..3dfcfba936 --- /dev/null +++ b/indra/newview/llfloaterautoreplacesettings.cpp @@ -0,0 +1,367 @@ +/** + * @file llautoreplacefloater.cpp + * @brief Auto Replace List floater + * + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, 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; either + * version 2.1 of the License, or (at your option) any later version. + * + * 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 + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llfloaterautoreplacesettings.h" + +#include "llagentdata.h" +#include "llcommandhandler.h" +#include "llfloater.h" +#include "lluictrlfactory.h" +#include "llagent.h" +#include "llpanel.h" +#include "llbutton.h" +#include "llcolorswatch.h" +#include "llcombobox.h" +#include "llview.h" +#include "llhttpclient.h" +#include "llbufferstream.h" +#include "llcheckboxctrl.h" +#include "llviewercontrol.h" + +#include "llui.h" +#include "llcontrol.h" +#include "llscrollingpanellist.h" +#include "llautoreplace.h" +#include "llfilepicker.h" +#include "llfile.h" +#include "llsdserialize.h" +//#include "llfloaterchat.h" +#include "llchat.h" +#include "llinventorymodel.h" +#include "llhost.h" +#include "llassetstorage.h" +#include "roles_constants.h" +#include "llviewertexteditor.h" +#include + +#include +#include "llfloaterreg.h" +#include "llinspecttoast.h" +#include "llnotificationhandler.h" +#include "llnotificationmanager.h" + + +LLFloaterAutoReplaceSettings::LLFloaterAutoReplaceSettings(const LLSD& key) + : LLFloater(key) + , namesList(NULL) + , entryList(NULL) + , mOldText(NULL) + , mNewText(NULL) +{ +} +void LLFloaterAutoReplaceSettings::onClose(bool app_quitting) +{ + destroy(); +} + +BOOL LLFloaterAutoReplaceSettings::postBuild(void) +{ + + namesList = getChild("ac_list_name"); + entryList = getChild("ac_list_entry"); + mOldText = getChild("ac_old_text"); + mNewText = getChild("ac_new_text"); + + childSetCommitCallback("ac_enable",onBoxCommitEnabled,this); + + childSetCommitCallback("ac_list_enabled",onEntrySettingChange,this); + childSetCommitCallback("ac_list_show",onEntrySettingChange,this); + childSetCommitCallback("ac_list_style",onEntrySettingChange,this); + childSetCommitCallback("ac_priority",onEntrySettingChange,this); + + updateEnabledStuff(); + updateNamesList(); + + namesList->setCommitOnSelectionChange(TRUE); + childSetCommitCallback("ac_list_name", onSelectName, this); + + childSetAction("ac_deletelist",removeList,this); + childSetAction("ac_rementry",deleteEntry,this); + childSetAction("ac_exportlist",exportList,this); + childSetAction("ac_addentry",addEntry,this); + childSetAction("ac_loadlist",loadList,this); + + return true; +} + +void LLFloaterAutoReplaceSettings::onSelectName(LLUICtrl* ctrl, void* user_data) +{ + if ( user_data ) + { + LLFloaterAutoReplaceSettings* self = ( LLFloaterAutoReplaceSettings* )user_data; + if ( self ) + { + self->updateItemsList(); + } + } +} +void LLFloaterAutoReplaceSettings::updateItemsList() +{ + entryList->deleteAllItems(); + if((namesList->getAllSelected().size())<=0) + { + updateListControlsEnabled(FALSE); + return; + } + + updateListControlsEnabled(TRUE); + std::string listName= namesList->getFirstSelected()->getColumn(0)->getValue().asString(); + + LLSD listData = AutoReplace::getInstance()->getAutoReplaceEntries(listName); + childSetValue("ac_list_enabled",listData["enabled"].asBoolean()); + childSetValue("ac_text_name",listName); + childSetValue("ac_priority",listData["priority"]); + + LLSD autoReplaces = listData["data"]; + LLSD::map_const_iterator loc_it = autoReplaces.beginMap(); + LLSD::map_const_iterator loc_end = autoReplaces.endMap(); + for ( ; loc_it != loc_end; ++loc_it) + { + const std::string& wrong = (*loc_it).first; + const std::string& right = (*loc_it).second; + + LLSD element; + element["id"] = wrong; + LLSD& s_column = element["columns"][0]; + s_column["column"] = "Search"; + s_column["value"] = wrong; + s_column["font"] = "SANSSERIF"; + LLSD& r_column = element["columns"][1]; + r_column["column"] = "Replace"; + r_column["value"] = right; + r_column["font"] = "SANSSERIF"; + + entryList->addElement(element, ADD_BOTTOM); + } + +} +void LLFloaterAutoReplaceSettings::updateNamesList() +{ + namesList->deleteAllItems(); + if(!gSavedSettings.getBOOL("AutoReplace")) + { + updateItemsList(); + return; + } + LLSD autoReplaces = AutoReplace::getInstance()->getAutoReplaces(); + LLSD::map_const_iterator loc_it = autoReplaces.beginMap(); + LLSD::map_const_iterator loc_end = autoReplaces.endMap(); + for ( ; loc_it != loc_end; ++loc_it) + { + const std::string& listName = (*loc_it).first; + + LLSD element; + element["id"] = listName; + LLSD& friend_column = element["columns"][0]; + friend_column["column"] = "Entries"; + friend_column["value"] = listName; + //friend_column["font"] = "SANSSERIF"; + const LLSD& loc_map = (*loc_it).second; + if(loc_map["enabled"].asBoolean()) + { + friend_column["font"] = "SANSSERIF"; + } + else + { + friend_column["font"] = "SANSSERIF_SMALL"; + } + if(namesList) + { + namesList->addElement(element, ADD_BOTTOM); + } + } + updateItemsList(); +} +void LLFloaterAutoReplaceSettings::updateListControlsEnabled(BOOL selected) +{ + + childSetEnabled("ac_text1",selected); + childSetEnabled("ac_text2",selected); + childSetEnabled("ac_text_name",selected); + childSetEnabled("ac_list_enabled",selected); + childSetEnabled("ac_list_show",selected); + childSetEnabled("ac_list_style",selected); + childSetEnabled("ac_deletelist",selected); + childSetEnabled("ac_exportlist",selected); + childSetEnabled("ac_addentry",selected); + childSetEnabled("ac_rementry",selected); + childSetEnabled("ac_priority",selected); + +} +void LLFloaterAutoReplaceSettings::updateEnabledStuff() +{ + BOOL autoreplace = gSavedSettings.getBOOL("AutoReplace"); + if(autoreplace) + { + LLCheckBoxCtrl *enBox = getChild("ac_enable"); + enBox->setDisabledColor(LLColor4::red); + getChild("ac_enable")->setEnabledColor(LLColor4(1.0f,0.0f,0.0f,1.0f)); + } + else + { + getChild("ac_enable")->setEnabledColor( + LLUIColorTable::instance().getColor( "LabelTextColor" )); + } + + childSetEnabled("ac_list_name", autoreplace); + childSetEnabled("ac_list_entry", autoreplace); + updateListControlsEnabled(autoreplace); + updateNamesList(); + AutoReplace::getInstance()->save(); + +} +void LLFloaterAutoReplaceSettings::setData(void * data) +{ +} +void LLFloaterAutoReplaceSettings::onBoxCommitEnabled(LLUICtrl* caller, void* user_data) +{ + if ( user_data ) + { + LLFloaterAutoReplaceSettings* self = ( LLFloaterAutoReplaceSettings* )user_data; + if ( self ) + { + self->updateEnabledStuff(); + } + } +} +void LLFloaterAutoReplaceSettings::onEntrySettingChange(LLUICtrl* caller, void* user_data) +{ + if ( user_data ) + { + LLFloaterAutoReplaceSettings* self = ( LLFloaterAutoReplaceSettings* )user_data; + if ( self ) + { + std::string listName= self->namesList->getFirstSelected()->getColumn(0)->getValue().asString(); + AutoReplace::getInstance()->setListEnabled(listName,self->childGetValue("ac_list_enabled").asBoolean()); + AutoReplace::getInstance()->setListPriority(listName,self->childGetValue("ac_priority").asInteger()); + + //sInstance->updateEnabledStuff(); + self->updateItemsList(); + AutoReplace::getInstance()->save(); + } + } +} +void LLFloaterAutoReplaceSettings::deleteEntry(void* data) +{ + if ( data ) + { + LLFloaterAutoReplaceSettings* self = ( LLFloaterAutoReplaceSettings* )data; + if ( self ) + { + + std::string listName=self->namesList->getFirstSelected()->getColumn(0)->getValue().asString(); + + if((self->entryList->getAllSelected().size())>0) + { + std::string wrong= self->entryList->getFirstSelected()->getColumn(0)->getValue().asString(); + AutoReplace::getInstance()->removeEntryFromList(wrong,listName); + self->updateItemsList(); + AutoReplace::getInstance()->save(); + } + } + } +} +void LLFloaterAutoReplaceSettings::loadList(void* data) +{ + LLFilePicker& picker = LLFilePicker::instance(); + + if(!picker.getOpenFile( LLFilePicker::FFLOAD_XML) ) + { + return; + } + llifstream file; + file.open(picker.getFirstFile().c_str()); + LLSD blankllsd; + if (file.is_open()) + { + LLSDSerialize::fromXMLDocument(blankllsd, file); + } + file.close(); + gSavedSettings.setBOOL("AutoReplace",true); + AutoReplace::getInstance()->addReplacementList(blankllsd); + if ( data ) + { + LLFloaterAutoReplaceSettings* self = ( LLFloaterAutoReplaceSettings* )data; + if ( self ) + { + self->updateEnabledStuff(); + } + } +} +void LLFloaterAutoReplaceSettings::removeList(void* data) +{ + if ( data ) + { + LLFloaterAutoReplaceSettings* self = ( LLFloaterAutoReplaceSettings* )data; + if ( self ) + { + std::string listName= self->namesList->getFirstSelected()->getColumn(0)->getValue().asString(); + AutoReplace::getInstance()->removeReplacementList(listName); + self->updateEnabledStuff(); + } + + } +} +void LLFloaterAutoReplaceSettings::exportList(void *data) +{ + if ( data ) + { + LLFloaterAutoReplaceSettings* self = ( LLFloaterAutoReplaceSettings* )data; + if ( self ) + { + std::string listName=self->namesList->getFirstSelected()->getColumn(0)->getValue().asString(); + + LLFilePicker& picker = LLFilePicker::instance(); + if(picker.getSaveFile( LLFilePicker::FFSAVE_XML) ) + { + llofstream file; + file.open(picker.getFirstFile().c_str()); + LLSDSerialize::toPrettyXML(AutoReplace::getInstance()->exportList(listName), file); + file.close(); + } + } + } +} +void LLFloaterAutoReplaceSettings::addEntry(void* data) +{ + if ( data ) + { + LLFloaterAutoReplaceSettings* self = ( LLFloaterAutoReplaceSettings* )data; + if ( self ) + { + std::string listName= self->namesList->getFirstSelected()->getColumn(0)->getValue().asString(); + std::string wrong = self->mOldText->getText(); + std::string right = self->mNewText->getText(); + if(wrong != "" && right != "") + { + AutoReplace::getInstance()->addEntryToList(wrong, right, listName); + self->updateItemsList(); + AutoReplace::getInstance()->save(); + } + } + } +} + diff --git a/indra/newview/llfloaterautoreplacesettings.h b/indra/newview/llfloaterautoreplacesettings.h new file mode 100644 index 0000000000..dd0acb613b --- /dev/null +++ b/indra/newview/llfloaterautoreplacesettings.h @@ -0,0 +1,70 @@ +/** + * @file llfloaterautoreplacesettings.h + * @brief Auto Replace List floater + * @copyright Copyright (c) 2011 LordGregGreg Back + * + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, 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; either + * version 2.1 of the License, or (at your option) any later version. + * + * 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 + * $/LicenseInfo$ + */ + +#ifndef LLFLOATERAUTOREPLACESETTINGS_H +#define LLFLOATERAUTOREPLACESETTINGS_H + +#include "llfloater.h" +#include "llmediactrl.h" +#include "llscrolllistctrl.h" +#include "lllineeditor.h" + +#include "llviewerinventory.h" +#include + +class LLFloaterAutoReplaceSettings : +public LLFloater +{ +public: + LLFloaterAutoReplaceSettings(const LLSD& key); + + /*virtual*/ BOOL postBuild(); + /*virtual*/ void onClose(bool app_quitting); + + void setData(void * data); + void updateEnabledStuff(); + void updateNamesList(); + void updateListControlsEnabled(BOOL selected); + void updateItemsList(); + + LLScrollListCtrl *namesList; + LLScrollListCtrl *entryList; + LLLineEditor* mOldText; + LLLineEditor* mNewText; + +private: + + static void onBoxCommitEnabled(LLUICtrl* caller, void* user_data); + static void onEntrySettingChange(LLUICtrl* caller, void* user_data); + static void onSelectName(LLUICtrl* caller, void* user_data); + + static void deleteEntry(void* data); + static void addEntry(void* data); + static void exportList(void* data); + static void removeList(void* data); + static void loadList(void* data); +}; + +#endif // LLFLOATERAUTOREPLACESETTINGS_H diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 7ef8125896..2c383f09ba 100755 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -35,7 +35,7 @@ #include "llfloaterpreference.h" #include "message.h" -#include "llautoreplacefloater.h" +#include "llfloaterautoreplacesettings.h" #include "llagent.h" #include "llavatarconstants.h" #include "llcheckboxctrl.h" @@ -346,7 +346,7 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key) mCommitCallbackRegistrar.add("Pref.BlockList", boost::bind(&LLFloaterPreference::onClickBlockList, this)); mCommitCallbackRegistrar.add("Pref.Proxy", boost::bind(&LLFloaterPreference::onClickProxySettings, this)); mCommitCallbackRegistrar.add("Pref.TranslationSettings", boost::bind(&LLFloaterPreference::onClickTranslationSettings, this)); - mCommitCallbackRegistrar.add("Pref.AutoReplace.", boost::bind(&AutoReplaceFloater::showFloater, this)); + mCommitCallbackRegistrar.add("Pref.AutoReplace", boost::bind(&LLFloaterPreference::onClickAutoReplace, this)); sSkin = gSavedSettings.getString("SkinCurrent"); @@ -605,6 +605,9 @@ void LLFloaterPreference::cancel() // hide translation settings floater LLFloaterReg::hideInstance("prefs_translation"); + // hide translation settings floater + LLFloaterReg::hideInstance("prefs_autoreplace"); + // cancel hardware menu LLFloaterHardwareSettings* hardware_settings = LLFloaterReg::getTypedInstance("prefs_hardware_settings"); if (hardware_settings) @@ -1516,6 +1519,11 @@ void LLFloaterPreference::onClickTranslationSettings() LLFloaterReg::showInstance("prefs_translation"); } +void LLFloaterPreference::onClickAutoReplace() +{ + LLFloaterReg::showInstance("prefs_autoreplace"); +} + void LLFloaterPreference::onClickActionChange() { mClickActionDirty = true; diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h index ec5994e917..0b63002345 100644 --- a/indra/newview/llfloaterpreference.h +++ b/indra/newview/llfloaterpreference.h @@ -157,6 +157,7 @@ public: void onClickBlockList(); void onClickProxySettings(); void onClickTranslationSettings(); + void onClickAutoReplace(); void applyUIColor(LLUICtrl* ctrl, const LLSD& param); void getUIColor(LLUICtrl* ctrl, const LLSD& param); diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index b2480a1805..d66f742a70 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -30,7 +30,7 @@ #include "llfloaterreg.h" #include "llviewerfloaterreg.h" -#include "llautoreplacefloater.h" +#include "llfloaterautoreplacesettings.h" #include "llcompilequeue.h" #include "llcallfloater.h" #include "llfasttimerview.h" @@ -170,7 +170,6 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("about_land", "floater_about_land.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("appearance", "floater_my_appearance.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("auction", "floater_auction.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); - LLFloaterReg::add("settings_autoreplace", "floater_autoreplace.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("avatar", "floater_avatar.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("avatar_picker", "floater_avatar_picker.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("avatar_textures", "floater_avatar_textures.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); @@ -250,6 +249,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("prefs_proxy", "floater_preferences_proxy.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("prefs_hardware_settings", "floater_hardware_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("prefs_translation", "floater_translation_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + LLFloaterReg::add("prefs_autoreplace", "floater_autoreplace.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("perm_prefs", "floater_perm_prefs.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("picks", "floater_picks.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("pref_joystick", "floater_joystick.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); diff --git a/indra/newview/skins/default/xui/en/floater_autoreplace.xml b/indra/newview/skins/default/xui/en/floater_autoreplace.xml index f68aeacb97..17f64c1433 100644 --- a/indra/newview/skins/default/xui/en/floater_autoreplace.xml +++ b/indra/newview/skins/default/xui/en/floater_autoreplace.xml @@ -96,7 +96,7 @@ -- cgit v1.2.3