From e989f521debb22cbafa56972dffa7afcd2c629fe Mon Sep 17 00:00:00 2001 From: Ansariel Date: Tue, 14 Apr 2020 18:57:56 +0200 Subject: [PATCH] FIRE-20414 / FIRE-29342: Add management floater for protect folders --- indra/newview/CMakeLists.txt | 2 + indra/newview/fsfloaterprotectedfolders.cpp | 190 ++++++++++++++++++ indra/newview/fsfloaterprotectedfolders.h | 68 +++++++ indra/newview/llviewerfloaterreg.cpp | 2 + .../xui/de/floater_fs_protectedfolders.xml | 15 ++ .../skins/default/xui/de/menu_viewer.xml | 1 + .../xui/en/floater_fs_protectedfolders.xml | 81 ++++++++ .../skins/default/xui/en/menu_viewer.xml | 11 + 8 files changed, 370 insertions(+) create mode 100644 indra/newview/fsfloaterprotectedfolders.cpp create mode 100644 indra/newview/fsfloaterprotectedfolders.h create mode 100644 indra/newview/skins/default/xui/de/floater_fs_protectedfolders.xml create mode 100644 indra/newview/skins/default/xui/en/floater_fs_protectedfolders.xml diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index e67cfcedc2..abed07e723 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -173,6 +173,7 @@ set(viewer_SOURCE_FILES fsfloaterplacedetails.cpp fsfloaterposestand.cpp fsfloaterprofile.cpp + fsfloaterprotectedfolders.cpp fsfloaterradar.cpp fsfloatersearch.cpp fsfloaterstatistics.cpp @@ -931,6 +932,7 @@ set(viewer_HEADER_FILES fsfloaterplacedetails.h fsfloaterposestand.h fsfloaterprofile.h + fsfloaterprotectedfolders.h fsfloaterradar.h fsfloatersearch.h fsfloaterstatistics.h diff --git a/indra/newview/fsfloaterprotectedfolders.cpp b/indra/newview/fsfloaterprotectedfolders.cpp new file mode 100644 index 0000000000..e83e7037bc --- /dev/null +++ b/indra/newview/fsfloaterprotectedfolders.cpp @@ -0,0 +1,190 @@ +/** + * @file fsfloaterprotectedfolders.cpp + * @brief Class for the protected folders floater + * + * $LicenseInfo:firstyear=2020&license=viewerlgpl$ + * Phoenix Firestorm Viewer Source Code + * Copyright (c) 2020 Ansariel Hiller @ Second Life + * + * 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 + * + * The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA + * http://www.firestormviewer.org + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "fsfloaterprotectedfolders.h" +#include "fscommon.h" +#include "llbutton.h" +#include "llfiltereditor.h" +#include "llinventoryfunctions.h" +#include "llinventorymodel.h" +#include "llscrolllistctrl.h" +#include "llviewercontrol.h" // for gSavedSettings +#include "rlvactions.h" + + +FSFloaterProtectedFolders::FSFloaterProtectedFolders(const LLSD& key) + : LLFloater(key), + mFolderList(NULL), + mFilterSubString(LLStringUtil::null), + mFilterSubStringOrig(LLStringUtil::null), + mProtectedCategoriesChangedCallbackConnection(), + mInitialized(false) +{ +} + +FSFloaterProtectedFolders::~FSFloaterProtectedFolders() +{ + if (mProtectedCategoriesChangedCallbackConnection.connected()) + { + mProtectedCategoriesChangedCallbackConnection.disconnect(); + } +} + +//virtual +BOOL FSFloaterProtectedFolders::postBuild() +{ + mFolderList = getChild("folder_list"); + mFolderList->setFilterColumn(0); + mFolderList->setDoubleClickCallback(boost::bind(&FSFloaterProtectedFolders::onDoubleClick, this)); + + mRemoveFolderBtn = getChild("remove_btn"); + mRemoveFolderBtn->setCommitCallback(boost::bind(&FSFloaterProtectedFolders::handleRemove, this)); + + mFilterEditor = getChild("filter_input"); + mFilterEditor->setCommitCallback(boost::bind(&FSFloaterProtectedFolders::onFilterEdit, this, _2)); + + return TRUE; +} + +//virtual +void FSFloaterProtectedFolders::onOpen(const LLSD& /*info*/) +{ + if (!mInitialized) + { + if (!gInventory.isInventoryUsable()) + { + return; + } + + mProtectedCategoriesChangedCallbackConnection = gSavedPerAccountSettings.getControl("FSProtectedFolders")->getCommitSignal()->connect(boost::bind(&FSFloaterProtectedFolders::updateList, this)); + + updateList(); + + mInitialized = true; + } +} + +//virtual +void FSFloaterProtectedFolders::draw() +{ + LLFloater::draw(); + + mRemoveFolderBtn->setEnabled(mFolderList->getNumSelected() > 0); +} + +//virtual +BOOL FSFloaterProtectedFolders::handleKeyHere(KEY key, MASK mask) +{ + if (FSCommon::isFilterEditorKeyCombo(key, mask)) + { + mFilterEditor->setFocus(TRUE); + return TRUE; + } + + return LLFloater::handleKeyHere(key, mask); +} + +void FSFloaterProtectedFolders::updateList() +{ + bool needs_sort = mFolderList->isSorted(); + mFolderList->setNeedsSort(false); + mFolderList->clearRows(); + + LLSD protected_folders = gSavedPerAccountSettings.getLLSD("FSProtectedFolders"); + for (LLSD::array_const_iterator it = protected_folders.beginArray(); it != protected_folders.endArray(); ++it) + { + LLUUID id = (*it).asUUID(); + LLViewerInventoryCategory* cat = gInventory.getCategory(id); + + LLSD row_data; + row_data["value"] = id; + row_data["columns"][0]["column"] = "name"; + row_data["columns"][0]["value"] = cat ? cat->getName() : getString("UnknownFolder"); + + LLScrollListItem* row = mFolderList->addElement(row_data); + if (!cat) + { + LLScrollListText* name_column = (LLScrollListText*)row->getColumn(0); + name_column->setFontStyle(LLFontGL::NORMAL | LLFontGL::ITALIC); + } + } + + mFolderList->setNeedsSort(needs_sort); + mFolderList->updateSort(); +} + +void FSFloaterProtectedFolders::handleRemove() +{ + uuid_set_t selected_ids; + std::vector selected_items = mFolderList->getAllSelected(); + + for (std::vector::iterator it = selected_items.begin(); it != selected_items.end(); ++it) + { + selected_ids.insert((*it)->getUUID()); + } + + LLSD protected_folders = gSavedPerAccountSettings.getLLSD("FSProtectedFolders"); + LLSD new_protected_folders; + for (LLSD::array_const_iterator it = protected_folders.beginArray(); it != protected_folders.endArray(); ++it) + { + if (selected_ids.find((*it).asUUID()) == selected_ids.end()) + { + new_protected_folders.append(*it); + } + } + gSavedPerAccountSettings.setLLSD("FSProtectedFolders", new_protected_folders); +} + +void FSFloaterProtectedFolders::onFilterEdit(const std::string& search_string) +{ + mFilterSubStringOrig = search_string; + LLStringUtil::trimHead(mFilterSubStringOrig); + // Searches are case-insensitive + std::string search_upper = mFilterSubStringOrig; + LLStringUtil::toUpper(search_upper); + + if (mFilterSubString == search_upper) + { + return; + } + + mFilterSubString = search_upper; + + // Apply new filter. + mFolderList->setFilterString(mFilterSubStringOrig); +} + +void FSFloaterProtectedFolders::onDoubleClick() +{ + LLUUID selected_item_id = mFolderList->getStringUUIDSelectedItem(); + if (selected_item_id.notNull() && (!RlvActions::isRlvEnabled() || !RlvActions::hasBehaviour(RLV_BHVR_SHOWINV))) + { + show_item_original(selected_item_id); + } +} diff --git a/indra/newview/fsfloaterprotectedfolders.h b/indra/newview/fsfloaterprotectedfolders.h new file mode 100644 index 0000000000..65d17f2bc6 --- /dev/null +++ b/indra/newview/fsfloaterprotectedfolders.h @@ -0,0 +1,68 @@ +/** + * @file fsfloaterprotectedfolders.h + * @brief Class for the protected folders floater + * + * $LicenseInfo:firstyear=2020&license=viewerlgpl$ + * Phoenix Firestorm Viewer Source Code + * Copyright (c) 2020 Ansariel Hiller @ Second Life + * + * 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 + * + * The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA + * http://www.firestormviewer.org + * $/LicenseInfo$ + */ + +#ifndef FS_FLOATERPROTECTEDFOLDERS_H +#define FS_FLOATERPROTECTEDFOLDERS_H + +#include "llfloater.h" + +class LLButton; +class LLFilterEditor; +class LLScrollListCtrl; + +class FSFloaterProtectedFolders : public LLFloater +{ +public: + FSFloaterProtectedFolders(const LLSD& key); + virtual ~FSFloaterProtectedFolders(); + + /*virtual*/ BOOL postBuild(); + /*virtual*/ void onOpen(const LLSD& info); + /*virtual*/ void draw(); + /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask); + /*virtual*/ bool hasAccelerators() const { return true; } + +private: + void updateList(); + + void handleRemove(); + void onFilterEdit(const std::string& search_string); + void onDoubleClick(); + + bool mInitialized; + + std::string mFilterSubString; + std::string mFilterSubStringOrig; + + boost::signals2::connection mProtectedCategoriesChangedCallbackConnection; + + LLScrollListCtrl* mFolderList; + LLButton* mRemoveFolderBtn; + LLFilterEditor* mFilterEditor; +}; + +#endif // FS_FLOATERPROTECTEDFOLDERS_H diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index f79fe5b6ec..6e7292ff50 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -189,6 +189,7 @@ #include "fsfloaterplacedetails.h" #include "fsfloaterposestand.h" #include "fsfloaterprofile.h" +#include "fsfloaterprotectedfolders.h" #include "fsfloaterradar.h" #include "fsfloatersearch.h" #include "fsfloaterstatistics.h" @@ -467,6 +468,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("fs_import", "floater_fs_import.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("fs_posestand", "floater_fs_posestand.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("fs_placedetails", "floater_fs_placedetails.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + LLFloaterReg::add("fs_protectedfolders", "floater_fs_protectedfolders.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("fs_radar", "floater_fs_radar.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("fs_teleporthistory", "floater_fs_teleporthistory.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("fs_voice_controls", "floater_fs_voice_controls.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); diff --git a/indra/newview/skins/default/xui/de/floater_fs_protectedfolders.xml b/indra/newview/skins/default/xui/de/floater_fs_protectedfolders.xml new file mode 100644 index 0000000000..672fa4f443 --- /dev/null +++ b/indra/newview/skins/default/xui/de/floater_fs_protectedfolders.xml @@ -0,0 +1,15 @@ + + + + (Unbekannter Ordner) + + + +