From e5b8b799cc75f3b9cd259403c323cd47b59453d8 Mon Sep 17 00:00:00 2001 From: Maxim Nikolenko Date: Wed, 29 Mar 2023 13:51:40 +0300 Subject: SL-19379 WIP add basic context menu --- indra/newview/llinventorygallerymenu.cpp | 616 +++++++++++++++++++++++++++++++ 1 file changed, 616 insertions(+) create mode 100644 indra/newview/llinventorygallerymenu.cpp (limited to 'indra/newview/llinventorygallerymenu.cpp') diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp new file mode 100644 index 0000000000..11dd5e6690 --- /dev/null +++ b/indra/newview/llinventorygallerymenu.cpp @@ -0,0 +1,616 @@ +/** + * @file llinventorygallerymenu.cpp + * + * $LicenseInfo:firstyear=2023&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2023, 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 "llinventorygallery.h" +#include "llinventorygallerymenu.h" + +#include "llagent.h" +#include "llappearancemgr.h" +#include "llavataractions.h" +#include "llclipboard.h" +#include "llfloaterreg.h" +#include "llgiveinventory.h" +#include "llinventorybridge.h" +#include "llinventoryfunctions.h" +#include "llinventorymodel.h" +#include "llmarketplacefunctions.h" +#include "llmenugl.h" +#include "llnotificationsutil.h" +#include "llviewerfoldertype.h" +#include "llviewerwindow.h" + +LLContextMenu* LLInventoryGalleryContextMenu::createMenu() +{ + LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; + //LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; + LLUUID selected_id = mUUIDs.front(); + + registrar.add("Inventory.DoToSelected", boost::bind(&LLInventoryGalleryContextMenu::doToSelected, this, _2, selected_id)); + registrar.add("Inventory.FileUploadLocation", boost::bind(&LLInventoryGalleryContextMenu::fileUploadLocation, this, _2, selected_id)); + registrar.add("Inventory.EmptyTrash", boost::bind(&LLInventoryModel::emptyFolderType, &gInventory, "ConfirmEmptyTrash", LLFolderType::FT_TRASH)); + registrar.add("Inventory.EmptyLostAndFound", boost::bind(&LLInventoryModel::emptyFolderType, &gInventory, "ConfirmEmptyLostAndFound", LLFolderType::FT_LOST_AND_FOUND)); + + std::set uuids{selected_id}; + registrar.add("Inventory.Share", boost::bind(&LLAvatarActions::shareWithAvatars, uuids, gFloaterView->getParentFloater(mGallery))); + + LLContextMenu* menu = createFromFile("menu_gallery_inventory.xml"); + + updateMenuItemsVisibility(menu); + + return menu; +} + +void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLUUID& selected_id) +{ + std::string action = userdata.asString(); + LLInventoryObject* obj = gInventory.getObject(selected_id); + if(!obj) return; + + bool is_folder = (obj->getType() == LLAssetType::AT_CATEGORY); + + if ("open_selected_folder" == action) + { + mGallery->setRootFolder(selected_id); + } + else if ("open_in_new_window" == action) + { + new_folder_window(selected_id); + } + else if ("properties" == action) + { + show_item_profile(selected_id); + } + else if ("restore" == action) + { + LLViewerInventoryCategory* cat = gInventory.getCategory(selected_id); + if(cat) + { + const LLUUID new_parent = gInventory.findCategoryUUIDForType(LLFolderType::assetTypeToFolderType(cat->getType())); + // do not restamp children on restore + gInventory.changeCategoryParent(cat, new_parent, false); + } + else + { + LLViewerInventoryItem* item = gInventory.getItem(selected_id); + if(item) + { + bool is_snapshot = (item->getInventoryType() == LLInventoryType::IT_SNAPSHOT); + + const LLUUID new_parent = gInventory.findCategoryUUIDForType(is_snapshot? LLFolderType::FT_SNAPSHOT_CATEGORY : LLFolderType::assetTypeToFolderType(item->getType())); + // do not restamp children on restore + gInventory.changeItemParent(item, new_parent, false); + } + } + } + else if ("copy_uuid" == action) + { + LLViewerInventoryItem* item = gInventory.getItem(selected_id); + if(item) + { + LLUUID asset_id = item->getProtectedAssetUUID(); + std::string buffer; + asset_id.toString(buffer); + + gViewerWindow->getWindow()->copyTextToClipboard(utf8str_to_wstring(buffer)); + } + } + else if ("purge" == action) + { + remove_inventory_object(selected_id, NULL); + } + else if ("goto" == action) + { + show_item_original(selected_id); + } + else if ("thumbnail" == action) + { + LLSD data(selected_id); + LLFloaterReg::showInstance("change_item_thumbnail", data); + } + else if ("cut" == action) + { + bool allow = false; + if(is_folder) + { + allow = get_is_category_removable(&gInventory, selected_id); + } + else + { + allow = get_is_item_removable(&gInventory, selected_id); + } + if(allow) + { + LLClipboard::instance().setCutMode(true); + LLClipboard::instance().addToClipboard(selected_id); + } + } + else if ("paste" == action) + { + { + const LLUUID &marketplacelistings_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS); + if(gInventory.isObjectDescendentOf(selected_id, marketplacelistings_id)) + { + return; + } + + bool is_cut_mode = (LLClipboard::instance().isCutMode()); + { + std::vector objects; + LLClipboard::instance().pasteFromClipboard(objects); + for (std::vector::const_iterator iter = objects.begin(); iter != objects.end(); ++iter) + { + const LLUUID& item_id = (*iter); + if(gInventory.isObjectDescendentOf(item_id, marketplacelistings_id) && (LLMarketplaceData::instance().isInActiveFolder(item_id) || + LLMarketplaceData::instance().isListedAndActive(item_id))) + { + return; + } + LLViewerInventoryCategory* cat = gInventory.getCategory(item_id); + if (cat) + { + if(is_cut_mode) + { + gInventory.changeCategoryParent(cat, selected_id, false); + } + else + { + copy_inventory_category(&gInventory, cat, selected_id); + } + } + else + { + LLViewerInventoryItem* item = gInventory.getItem(item_id); + if (item) + { + if(is_cut_mode) + { + gInventory.changeItemParent(item, selected_id, false); + } + else + { + if (item->getIsLinkType()) + { + link_inventory_object(selected_id, item_id, + LLPointer(NULL)); + } + else + { + copy_inventory_item( + gAgent.getID(), + item->getPermissions().getOwner(), + item->getUUID(), + selected_id, + std::string(), + LLPointer(NULL)); + } + } + } + } + } + LLClipboard::instance().setCutMode(false); + } + + } + } + else if ("delete" == action) + { + if (is_folder) + { + if(get_is_category_removable(&gInventory, selected_id)) + { + gInventory.removeCategory(selected_id); + } + } + else + { + if(get_is_item_removable(&gInventory, selected_id)) + { + gInventory.removeItem(selected_id); + } + } + } + else if ("copy" == action) + { + if(is_folder) + { + LLClipboard::instance().reset(); + LLClipboard::instance().addToClipboard(selected_id); + } + else + { + LLViewerInventoryItem* inv_item = gInventory.getItem(selected_id); + if (inv_item && inv_item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID()) && !get_is_item_worn(selected_id)) + { + LLClipboard::instance().reset(); + LLClipboard::instance().addToClipboard(selected_id); + } + } + } + else if ("paste_as_link" == action) + { + link_inventory_object(selected_id, obj, LLPointer(NULL)); + } + else if ("rename" == action) + { + LLSD args; + args["NAME"] = obj->getName(); + + LLSD payload; + payload["id"] = selected_id; + + LLNotificationsUtil::add("RenameItem", args, payload, boost::bind(onRename, _1, _2)); + } + else if ("open" == action || "open_original" == action) + { + LLViewerInventoryItem* item = gInventory.getItem(selected_id); + if (item) + { + LLInvFVBridgeAction::doAction(item->getType(), selected_id , &gInventory); + } + } + else if ("ungroup_folder_items" == action) + { + ungroup_folder_items(selected_id); + } +} + +void LLInventoryGalleryContextMenu::onRename(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if (option != 0) return; // canceled + + std::string new_name = response["new_name"].asString(); + LLStringUtil::trim(new_name); + if (!new_name.empty()) + { + LLUUID id = notification["payload"]["id"].asUUID(); + + LLViewerInventoryCategory* cat = gInventory.getCategory(id); + if(cat && (cat->getName() != new_name)) + { + LLSD updates; + updates["name"] = new_name; + update_inventory_category(cat->getUUID(),updates, NULL); + return; + } + + LLViewerInventoryItem* item = gInventory.getItem(id); + if(item && (item->getName() != new_name)) + { + LLSD updates; + updates["name"] = new_name; + update_inventory_item(item->getUUID(),updates, NULL); + } + } +} + +void LLInventoryGalleryContextMenu::fileUploadLocation(const LLSD& userdata, const LLUUID& selected_id) +{ + const std::string param = userdata.asString(); + if (param == "model") + { + gSavedPerAccountSettings.setString("ModelUploadFolder", selected_id.asString()); + } + else if (param == "texture") + { + gSavedPerAccountSettings.setString("TextureUploadFolder", selected_id.asString()); + } + else if (param == "sound") + { + gSavedPerAccountSettings.setString("SoundUploadFolder", selected_id.asString()); + } + else if (param == "animation") + { + gSavedPerAccountSettings.setString("AnimationUploadFolder", selected_id.asString()); + } +} + +bool can_share_item(LLUUID item_id) +{ + bool can_share = false; + + if (gInventory.isObjectDescendentOf(item_id, gInventory.getRootFolderID())) + { + const LLViewerInventoryItem *item = gInventory.getItem(item_id); + if (item) + { + if (LLInventoryCollectFunctor::itemTransferCommonlyAllowed(item)) + { + can_share = LLGiveInventory::isInventoryGiveAcceptable(item); + } + } + else + { + can_share = (gInventory.getCategory(item_id) != NULL); + } + + const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH); + if ((item_id == trash_id) || gInventory.isObjectDescendentOf(item_id, trash_id)) + { + can_share = false; + } + } + + return can_share; +} + +bool is_inbox_folder(LLUUID item_id) +{ + const LLUUID inbox_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_INBOX); + + if (inbox_id.isNull()) + { + return false; + } + + return gInventory.isObjectDescendentOf(item_id, inbox_id); +} + +void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* menu) +{ + LLUUID selected_id = mUUIDs.front(); + LLInventoryObject* obj = gInventory.getObject(selected_id); + if (!obj) + { + return; + } + + std::vector items; + std::vector disabled_items; + + bool is_agent_inventory = gInventory.isObjectDescendentOf(selected_id, gInventory.getRootFolderID()); + bool is_link = obj->getIsLinkType(); + bool is_folder = (obj->getType() == LLAssetType::AT_CATEGORY); + bool is_cof = LLAppearanceMgr::instance().getIsInCOF(selected_id); + bool is_inbox = is_inbox_folder(selected_id); + bool is_trash = (selected_id == gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH)); + bool is_in_trash = gInventory.isObjectDescendentOf(selected_id, gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH)); + bool is_lost_and_found = (selected_id == gInventory.findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND)); + bool is_outfits= (selected_id == gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS)); + //bool is_favorites= (selected_id == gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE)); + + bool is_system_folder = false; + LLFolderType::EType folder_type(LLFolderType::FT_NONE); + bool has_children = false; + bool is_full_perm_item = false; + bool is_copyable = false; + LLViewerInventoryItem* selected_item = gInventory.getItem(selected_id); + + if(is_folder) + { + LLInventoryCategory* category = gInventory.getCategory(selected_id); + if (category) + { + folder_type = category->getPreferredType(); + is_system_folder = LLFolderType::lookupIsProtectedType(folder_type); + has_children = (gInventory.categoryHasChildren(selected_id) != LLInventoryModel::CHILDREN_NO); + } + } + else + { + if (selected_item) + { + is_full_perm_item = selected_item->getIsFullPerm(); + is_copyable = selected_item->getPermissions().allowCopyBy(gAgent.getID()); + } + } + + if(!is_link) + { + items.push_back(std::string("thumbnail")); + LLViewerInventoryItem* inv_item = gInventory.getItem(selected_id); + if (inv_item && !inv_item->getPermissions().allowOperationBy(PERM_MODIFY, gAgent.getID())) + { + disabled_items.push_back(std::string("thumbnail")); + } + } + + if (is_folder) + { + items.push_back(std::string("Copy Separator")); + + items.push_back(std::string("open_in_current_window")); + items.push_back(std::string("open_in_new_window")); + items.push_back(std::string("Open Folder Separator")); + } + + if(is_trash) + { + items.push_back(std::string("Empty Trash")); + + LLInventoryModel::cat_array_t* cat_array; + LLInventoryModel::item_array_t* item_array; + gInventory.getDirectDescendentsOf(selected_id, cat_array, item_array); + if (0 == cat_array->size() && 0 == item_array->size()) + { + disabled_items.push_back(std::string("Empty Trash")); + } + } + else if(is_in_trash) + { + if (is_link) + { + items.push_back(std::string("Find Original")); + if (LLAssetType::lookupIsLinkType(obj->getType())) + { + disabled_items.push_back(std::string("Find Original")); + } + } + items.push_back(std::string("Purge Item")); + if (!get_is_category_removable(&gInventory, selected_id)) + { + disabled_items.push_back(std::string("Purge Item")); + } + items.push_back(std::string("Restore Item")); + } + else + { + if(can_share_item(selected_id)) + { + items.push_back(std::string("Share")); + } + if (is_folder && is_agent_inventory) + { + if (!is_cof && (folder_type != LLFolderType::FT_OUTFIT) && !is_outfits && !is_inbox_folder(selected_id)) + { + if (!gInventory.isObjectDescendentOf(selected_id, gInventory.findCategoryUUIDForType(LLFolderType::FT_CALLINGCARD))) + { + items.push_back(std::string("New Folder")); + } + items.push_back(std::string("upload_def")); + } + + if(is_outfits) + { + items.push_back(std::string("New Outfit")); + } + + items.push_back(std::string("Subfolder Separator")); + if (!is_system_folder) + { + if(has_children && (folder_type != LLFolderType::FT_OUTFIT)) + { + items.push_back(std::string("Ungroup folder items")); + } + items.push_back(std::string("Cut")); + items.push_back(std::string("Delete")); + if(!get_is_category_removable(&gInventory, selected_id)) + { + disabled_items.push_back(std::string("Delete")); + disabled_items.push_back(std::string("Cut")); + } + if(!is_inbox) + { + items.push_back(std::string("Rename")); + } + } + if (LLClipboard::instance().hasContents() && is_agent_inventory && !is_cof && !is_inbox_folder(selected_id)) + { + items.push_back(std::string("Paste")); + + static LLCachedControl inventory_linking(gSavedSettings, "InventoryLinking", true); + if (inventory_linking) + { + items.push_back(std::string("Paste As Link")); + } + } + if(!is_system_folder) + { + items.push_back(std::string("Copy")); + } + } + else if(!is_folder) + { + items.push_back(std::string("Properties")); + items.push_back(std::string("Copy Asset UUID")); + items.push_back(std::string("Copy Separator")); + + bool is_asset_knowable = is_asset_knowable = LLAssetType::lookupIsAssetIDKnowable(obj->getType()); + if ( !is_asset_knowable // disable menu item for Inventory items with unknown asset. EXT-5308 + || (! ( is_full_perm_item || gAgent.isGodlike()))) + { + disabled_items.push_back(std::string("Copy Asset UUID")); + } + if(is_agent_inventory) + { + items.push_back(std::string("Cut")); + if (!is_link || !is_cof || !get_is_item_worn(selected_id)) + { + items.push_back(std::string("Delete")); + } + if(!get_is_item_removable(&gInventory, selected_id)) + { + disabled_items.push_back(std::string("Delete")); + disabled_items.push_back(std::string("Cut")); + } + + if (selected_item && (selected_item->getInventoryType() != LLInventoryType::IT_CALLINGCARD) && !is_inbox && selected_item->getPermissions().allowOperationBy(PERM_MODIFY, gAgent.getID())) + { + items.push_back(std::string("Rename")); + } + } + items.push_back(std::string("Copy")); + if (!is_copyable) + { + disabled_items.push_back(std::string("Copy")); + } + } + if((obj->getType() == LLAssetType::AT_SETTINGS) + || ((obj->getType() <= LLAssetType::AT_GESTURE) + && obj->getType() != LLAssetType::AT_OBJECT + && obj->getType() != LLAssetType::AT_CLOTHING + && obj->getType() != LLAssetType::AT_CATEGORY + && obj->getType() != LLAssetType::AT_BODYPART)) + { + bool can_open = !LLAssetType::lookupIsLinkType(obj->getType()); + + if (can_open) + { + if (is_link) + items.push_back(std::string("Open Original")); + else + items.push_back(std::string("Open")); + } + else + { + disabled_items.push_back(std::string("Open")); + disabled_items.push_back(std::string("Open Original")); + } + } + else if(LLAssetType::AT_LANDMARK == obj->getType()) + { + items.push_back(std::string("Landmark Open")); + } + if (is_link) + { + items.push_back(std::string("Find Original")); + if (LLAssetType::lookupIsLinkType(obj->getType())) + { + disabled_items.push_back(std::string("Find Original")); + } + } + if (is_lost_and_found) + { + items.push_back(std::string("Empty Lost And Found")); + + LLInventoryModel::cat_array_t* cat_array; + LLInventoryModel::item_array_t* item_array; + gInventory.getDirectDescendentsOf(selected_id, cat_array, item_array); + // Enable Empty menu item only when there is something to act upon. + if (0 == cat_array->size() && 0 == item_array->size()) + { + disabled_items.push_back(std::string("Empty Lost And Found")); + } + + disabled_items.push_back(std::string("New Folder")); + disabled_items.push_back(std::string("upload_def")); + } + } + + hide_context_entries(*menu, items, disabled_items); +} + -- cgit v1.2.3 From e161b128c7eac6df63b6d9210f3bca6c3cbc77ea Mon Sep 17 00:00:00 2001 From: Maxim Nikolenko Date: Thu, 30 Mar 2023 02:36:14 +0300 Subject: SL-19379 WIP one more batch of context menu items --- indra/newview/llinventorygallerymenu.cpp | 54 ++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'indra/newview/llinventorygallerymenu.cpp') diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index 11dd5e6690..a501f02e00 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -42,6 +42,7 @@ #include "llnotificationsutil.h" #include "llviewerfoldertype.h" #include "llviewerwindow.h" +#include "llvoavatarself.h" LLContextMenu* LLInventoryGalleryContextMenu::createMenu() { @@ -276,6 +277,18 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU { ungroup_folder_items(selected_id); } + else if ("take_off" == action || "detach" == action) + { + LLAppearanceMgr::instance().removeItemFromAvatar(selected_id); + } + else if ("wear_add" == action) + { + LLAppearanceMgr::instance().wearItemOnAvatar(selected_id, true, false); // Don't replace if adding. + } + else if ("wear" == action) + { + LLAppearanceMgr::instance().wearItemOnAvatar(selected_id, true, true); + } } void LLInventoryGalleryContextMenu::onRename(const LLSD& notification, const LLSD& response) @@ -564,6 +577,7 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men && obj->getType() != LLAssetType::AT_OBJECT && obj->getType() != LLAssetType::AT_CLOTHING && obj->getType() != LLAssetType::AT_CATEGORY + && obj->getType() != LLAssetType::AT_LANDMARK && obj->getType() != LLAssetType::AT_BODYPART)) { bool can_open = !LLAssetType::lookupIsLinkType(obj->getType()); @@ -585,6 +599,46 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men { items.push_back(std::string("Landmark Open")); } + else if (obj->getType() == LLAssetType::AT_OBJECT || obj->getType() == LLAssetType::AT_CLOTHING || obj->getType() == LLAssetType::AT_BODYPART) + { + items.push_back(std::string("Wearable And Object Separator")); + if(obj->getType() == LLAssetType::AT_CLOTHING) + { + items.push_back(std::string("Take Off")); + } + if(get_is_item_worn(selected_id)) + { + if(obj->getType() == LLAssetType::AT_OBJECT) + { + items.push_back(std::string("Detach From Yourself")); + } + disabled_items.push_back(std::string("Wearable And Object Wear")); + disabled_items.push_back(std::string("Wearable Add")); + } + else + { + if(obj->getType() == LLAssetType::AT_OBJECT) + { + items.push_back(std::string("Wearable Add")); + } + items.push_back(std::string("Wearable And Object Wear")); + disabled_items.push_back(std::string("Take Off")); + } + + if (!gAgentAvatarp->canAttachMoreObjects() && (obj->getType() == LLAssetType::AT_OBJECT)) + { + disabled_items.push_back(std::string("Wearable And Object Wear")); + disabled_items.push_back(std::string("Wearable Add")); + } + if (selected_item && (obj->getType() != LLAssetType::AT_OBJECT) && LLWearableType::getInstance()->getAllowMultiwear(selected_item->getWearableType())) + { + items.push_back(std::string("Wearable Add")); + if (!gAgentWearables.canAddWearable(selected_item->getWearableType())) + { + disabled_items.push_back(std::string("Wearable Add")); + } + } + } if (is_link) { items.push_back(std::string("Find Original")); -- cgit v1.2.3 From ae3e3662159ca26db5b2efe36d91a9ccdfcec256 Mon Sep 17 00:00:00 2001 From: Maxim Nikolenko Date: Thu, 30 Mar 2023 21:39:43 +0300 Subject: SL-19379 WIP update gear menu with Gallery items --- indra/newview/llinventorygallerymenu.cpp | 30 ------------------------------ 1 file changed, 30 deletions(-) (limited to 'indra/newview/llinventorygallerymenu.cpp') diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index a501f02e00..21f7b06534 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -33,7 +33,6 @@ #include "llavataractions.h" #include "llclipboard.h" #include "llfloaterreg.h" -#include "llgiveinventory.h" #include "llinventorybridge.h" #include "llinventoryfunctions.h" #include "llinventorymodel.h" @@ -342,35 +341,6 @@ void LLInventoryGalleryContextMenu::fileUploadLocation(const LLSD& userdata, con } } -bool can_share_item(LLUUID item_id) -{ - bool can_share = false; - - if (gInventory.isObjectDescendentOf(item_id, gInventory.getRootFolderID())) - { - const LLViewerInventoryItem *item = gInventory.getItem(item_id); - if (item) - { - if (LLInventoryCollectFunctor::itemTransferCommonlyAllowed(item)) - { - can_share = LLGiveInventory::isInventoryGiveAcceptable(item); - } - } - else - { - can_share = (gInventory.getCategory(item_id) != NULL); - } - - const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH); - if ((item_id == trash_id) || gInventory.isObjectDescendentOf(item_id, trash_id)) - { - can_share = false; - } - } - - return can_share; -} - bool is_inbox_folder(LLUUID item_id) { const LLUUID inbox_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_INBOX); -- cgit v1.2.3 From 126bfa4877303b47abbc99f09c09a931c20cbd3b Mon Sep 17 00:00:00 2001 From: Maxim Nikolenko Date: Fri, 31 Mar 2023 15:23:11 +0300 Subject: SL-19379 WIP fix for displaying folder link items, added correct action for 'paste as link' --- indra/newview/llinventorygallerymenu.cpp | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'indra/newview/llinventorygallerymenu.cpp') diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index 21f7b06534..e91ec78730 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -250,9 +250,35 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU } } } - else if ("paste_as_link" == action) + else if ("paste_link" == action) { - link_inventory_object(selected_id, obj, LLPointer(NULL)); + const LLUUID ¤t_outfit_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); + const LLUUID &marketplacelistings_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS); + const LLUUID &my_outifts_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS); + + const BOOL move_is_into_current_outfit = (selected_id == current_outfit_id); + const BOOL move_is_into_my_outfits = (selected_id == my_outifts_id) || gInventory.isObjectDescendentOf(selected_id, my_outifts_id); + const BOOL move_is_into_marketplacelistings = gInventory.isObjectDescendentOf(selected_id, marketplacelistings_id); + + if (move_is_into_marketplacelistings || move_is_into_current_outfit || move_is_into_my_outfits) + { + return; + } + + std::vector objects; + LLClipboard::instance().pasteFromClipboard(objects); + for (std::vector::const_iterator iter = objects.begin(); + iter != objects.end(); + ++iter) + { + const LLUUID &object_id = (*iter); + if (LLConstPointer link_obj = gInventory.getObject(object_id)) + { + link_inventory_object(selected_id, link_obj, LLPointer(NULL)); + } + } + + LLClipboard::instance().setCutMode(false); } else if ("rename" == action) { -- cgit v1.2.3 From 107a7eb919bb0afadf6ad3f92482cf7e6d67c56e Mon Sep 17 00:00:00 2001 From: Maxim Nikolenko Date: Thu, 13 Apr 2023 17:49:26 +0300 Subject: SL-19544 WIP add active suffix for gestures and add appropriate context menu handling --- indra/newview/llinventorygallerymenu.cpp | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'indra/newview/llinventorygallerymenu.cpp') diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index e91ec78730..84b18c1517 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -314,6 +314,26 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU { LLAppearanceMgr::instance().wearItemOnAvatar(selected_id, true, true); } + else if ("activate" == action) + { + LLGestureMgr::instance().activateGesture(selected_id); + + LLViewerInventoryItem* item = gInventory.getItem(selected_id); + if (!item) return; + + gInventory.updateItem(item); + gInventory.notifyObservers(); + } + else if ("deactivate" == action) + { + LLGestureMgr::instance().deactivateGesture(selected_id); + + LLViewerInventoryItem* item = gInventory.getItem(selected_id); + if (!item) return; + + gInventory.updateItem(item); + gInventory.notifyObservers(); + } } void LLInventoryGalleryContextMenu::onRename(const LLSD& notification, const LLSD& response) @@ -590,6 +610,19 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men disabled_items.push_back(std::string("Open")); disabled_items.push_back(std::string("Open Original")); } + + if(LLAssetType::AT_GESTURE == obj->getType()) + { + items.push_back(std::string("Gesture Separator")); + if(!LLGestureMgr::instance().isGestureActive(selected_id)) + { + items.push_back(std::string("Activate")); + } + else + { + items.push_back(std::string("Deactivate")); + } + } } else if(LLAssetType::AT_LANDMARK == obj->getType()) { -- cgit v1.2.3 From a1d86ca8ab961eb35bfd62a7b7f1ba17d807efd4 Mon Sep 17 00:00:00 2001 From: Maxim Nikolenko Date: Fri, 21 Apr 2023 18:31:56 +0300 Subject: SL-19379 update for gallery context menu --- indra/newview/llinventorygallerymenu.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'indra/newview/llinventorygallerymenu.cpp') diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index 84b18c1517..43ddf4da63 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -334,6 +334,10 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU gInventory.updateItem(item); gInventory.notifyObservers(); } + else if ("replace_links" == action) + { + LLFloaterReg::showInstance("linkreplace", LLSD(selected_id)); + } } void LLInventoryGalleryContextMenu::onRename(const LLSD& notification, const LLSD& response) @@ -451,8 +455,7 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men if(!is_link) { items.push_back(std::string("thumbnail")); - LLViewerInventoryItem* inv_item = gInventory.getItem(selected_id); - if (inv_item && !inv_item->getPermissions().allowOperationBy(PERM_MODIFY, gAgent.getID())) + if (!is_agent_inventory) { disabled_items.push_back(std::string("thumbnail")); } @@ -466,6 +469,13 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men items.push_back(std::string("open_in_new_window")); items.push_back(std::string("Open Folder Separator")); } + else + { + if (is_agent_inventory && (obj->getType() != LLAssetType::AT_LINK_FOLDER)) + { + items.push_back(std::string("Replace Links")); + } + } if(is_trash) { @@ -490,7 +500,7 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men } } items.push_back(std::string("Purge Item")); - if (!get_is_category_removable(&gInventory, selected_id)) + if (is_folder && !get_is_category_removable(&gInventory, selected_id)) { disabled_items.push_back(std::string("Purge Item")); } -- cgit v1.2.3 From 67e17bd822f146f333b91d353df6f55174ce4db6 Mon Sep 17 00:00:00 2001 From: Maxim Nikolenko Date: Fri, 26 May 2023 19:45:46 +0300 Subject: SL-19774 add context menu for root folder (without any selection); show paste menu when right clicking any item --- indra/newview/llinventorygallerymenu.cpp | 54 ++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 23 deletions(-) (limited to 'indra/newview/llinventorygallerymenu.cpp') diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index 43ddf4da63..8a99b79e2b 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -159,6 +159,8 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU bool is_cut_mode = (LLClipboard::instance().isCutMode()); { + LLUUID dest = is_folder ? selected_id : obj->getParentUUID(); + std::vector objects; LLClipboard::instance().pasteFromClipboard(objects); for (std::vector::const_iterator iter = objects.begin(); iter != objects.end(); ++iter) @@ -174,11 +176,11 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU { if(is_cut_mode) { - gInventory.changeCategoryParent(cat, selected_id, false); + gInventory.changeCategoryParent(cat, dest, false); } else { - copy_inventory_category(&gInventory, cat, selected_id); + copy_inventory_category(&gInventory, cat, dest); } } else @@ -188,13 +190,13 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU { if(is_cut_mode) { - gInventory.changeItemParent(item, selected_id, false); + gInventory.changeItemParent(item, dest, false); } else { if (item->getIsLinkType()) { - link_inventory_object(selected_id, item_id, + link_inventory_object(dest, item_id, LLPointer(NULL)); } else @@ -203,7 +205,7 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU gAgent.getID(), item->getPermissions().getOwner(), item->getUUID(), - selected_id, + dest, std::string(), LLPointer(NULL)); } @@ -264,7 +266,7 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU { return; } - + LLUUID dest = is_folder ? selected_id : obj->getParentUUID(); std::vector objects; LLClipboard::instance().pasteFromClipboard(objects); for (std::vector::const_iterator iter = objects.begin(); @@ -274,7 +276,7 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU const LLUUID &object_id = (*iter); if (LLConstPointer link_obj = gInventory.getObject(object_id)) { - link_inventory_object(selected_id, link_obj, LLPointer(NULL)); + link_inventory_object(dest, link_obj, LLPointer(NULL)); } } @@ -463,11 +465,14 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men if (is_folder) { - items.push_back(std::string("Copy Separator")); + if(!isRootFolder()) + { + items.push_back(std::string("Copy Separator")); - items.push_back(std::string("open_in_current_window")); - items.push_back(std::string("open_in_new_window")); - items.push_back(std::string("Open Folder Separator")); + items.push_back(std::string("open_in_current_window")); + items.push_back(std::string("open_in_new_window")); + items.push_back(std::string("Open Folder Separator")); + } } else { @@ -512,18 +517,28 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men { items.push_back(std::string("Share")); } + if (LLClipboard::instance().hasContents() && is_agent_inventory && !is_cof && !is_inbox_folder(selected_id)) + { + items.push_back(std::string("Paste")); + + static LLCachedControl inventory_linking(gSavedSettings, "InventoryLinking", true); + if (inventory_linking) + { + items.push_back(std::string("Paste As Link")); + } + } if (is_folder && is_agent_inventory) { if (!is_cof && (folder_type != LLFolderType::FT_OUTFIT) && !is_outfits && !is_inbox_folder(selected_id)) { - if (!gInventory.isObjectDescendentOf(selected_id, gInventory.findCategoryUUIDForType(LLFolderType::FT_CALLINGCARD))) + if (!gInventory.isObjectDescendentOf(selected_id, gInventory.findCategoryUUIDForType(LLFolderType::FT_CALLINGCARD)) && !isRootFolder()) { items.push_back(std::string("New Folder")); } items.push_back(std::string("upload_def")); } - if(is_outfits) + if(is_outfits && !isRootFolder()) { items.push_back(std::string("New Outfit")); } @@ -531,6 +546,8 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men items.push_back(std::string("Subfolder Separator")); if (!is_system_folder) { + if(!isRootFolder()) + { if(has_children && (folder_type != LLFolderType::FT_OUTFIT)) { items.push_back(std::string("Ungroup folder items")); @@ -542,21 +559,12 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men disabled_items.push_back(std::string("Delete")); disabled_items.push_back(std::string("Cut")); } + } if(!is_inbox) { items.push_back(std::string("Rename")); } } - if (LLClipboard::instance().hasContents() && is_agent_inventory && !is_cof && !is_inbox_folder(selected_id)) - { - items.push_back(std::string("Paste")); - - static LLCachedControl inventory_linking(gSavedSettings, "InventoryLinking", true); - if (inventory_linking) - { - items.push_back(std::string("Paste As Link")); - } - } if(!is_system_folder) { items.push_back(std::string("Copy")); -- cgit v1.2.3 From 5c55adae47cab93a12793528373f639ea9e8efcf Mon Sep 17 00:00:00 2001 From: Maxim Nikolenko Date: Tue, 30 May 2023 13:10:36 +0300 Subject: SL-19773 add context menu for root folder in single folder mode --- indra/newview/llinventorygallerymenu.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'indra/newview/llinventorygallerymenu.cpp') diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index 8a99b79e2b..6dc749fab6 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -544,10 +544,8 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men } items.push_back(std::string("Subfolder Separator")); - if (!is_system_folder) + if (!is_system_folder && !isRootFolder()) { - if(!isRootFolder()) - { if(has_children && (folder_type != LLFolderType::FT_OUTFIT)) { items.push_back(std::string("Ungroup folder items")); @@ -559,7 +557,7 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men disabled_items.push_back(std::string("Delete")); disabled_items.push_back(std::string("Cut")); } - } + if(!is_inbox) { items.push_back(std::string("Rename")); -- cgit v1.2.3 From 29f52ad1a7c4f0d023c4b6a7dd0d43ea105e8fdb Mon Sep 17 00:00:00 2001 From: Maxim Nikolenko Date: Thu, 8 Jun 2023 12:44:35 +0300 Subject: SL-19845 Show confirmation before deleting an item in Gallery view --- indra/newview/llinventorygallerymenu.cpp | 45 ++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 14 deletions(-) (limited to 'indra/newview/llinventorygallerymenu.cpp') diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index 6dc749fab6..e7f8b10cca 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -39,6 +39,7 @@ #include "llmarketplacefunctions.h" #include "llmenugl.h" #include "llnotificationsutil.h" +#include "lltrans.h" #include "llviewerfoldertype.h" #include "llviewerwindow.h" #include "llvoavatarself.h" @@ -220,20 +221,9 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU } else if ("delete" == action) { - if (is_folder) - { - if(get_is_category_removable(&gInventory, selected_id)) - { - gInventory.removeCategory(selected_id); - } - } - else - { - if(get_is_item_removable(&gInventory, selected_id)) - { - gInventory.removeItem(selected_id); - } - } + LLSD args; + args["QUESTION"] = LLTrans::getString("DeleteItem"); + LLNotificationsUtil::add("DeleteItems", args, LLSD(), boost::bind(&LLInventoryGalleryContextMenu::onDelete, _1, _2, selected_id)); } else if ("copy" == action) { @@ -342,6 +332,33 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU } } +void LLInventoryGalleryContextMenu::onDelete(const LLSD& notification, const LLSD& response, const LLUUID& selected_id) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if (option == 0) + { + LLInventoryObject* obj = gInventory.getObject(selected_id); + if (!obj) + { + return; + } + if (obj->getType() == LLAssetType::AT_CATEGORY) + { + if(get_is_category_removable(&gInventory, selected_id)) + { + gInventory.removeCategory(selected_id); + } + } + else + { + if(get_is_item_removable(&gInventory, selected_id)) + { + gInventory.removeItem(selected_id); + } + } + } +} + void LLInventoryGalleryContextMenu::onRename(const LLSD& notification, const LLSD& response) { S32 option = LLNotificationsUtil::getSelectedOption(notification, response); -- cgit v1.2.3 From 53fc42fe032c2aef453f420645b0e46dea4c23db Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 8 Jun 2023 22:50:12 +0300 Subject: SL-19832 Inventory gallery should support CTRL+X, C and V --- indra/newview/llinventorygallerymenu.cpp | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) (limited to 'indra/newview/llinventorygallerymenu.cpp') diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index e7f8b10cca..bc4b28b584 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -134,20 +134,10 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU } else if ("cut" == action) { - bool allow = false; - if(is_folder) - { - allow = get_is_category_removable(&gInventory, selected_id); - } - else - { - allow = get_is_item_removable(&gInventory, selected_id); - } - if(allow) - { - LLClipboard::instance().setCutMode(true); - LLClipboard::instance().addToClipboard(selected_id); - } + if (mGallery->canCut()) + { + mGallery->cut(); + } } else if ("paste" == action) { @@ -227,19 +217,9 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU } else if ("copy" == action) { - if(is_folder) + if (mGallery->canCopy()) { - LLClipboard::instance().reset(); - LLClipboard::instance().addToClipboard(selected_id); - } - else - { - LLViewerInventoryItem* inv_item = gInventory.getItem(selected_id); - if (inv_item && inv_item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID()) && !get_is_item_worn(selected_id)) - { - LLClipboard::instance().reset(); - LLClipboard::instance().addToClipboard(selected_id); - } + mGallery->copy(); } } else if ("paste_link" == action) -- cgit v1.2.3 From f8823a426383949fb1609fa82b5ebb98ef2c295b Mon Sep 17 00:00:00 2001 From: Maxim Nikolenko Date: Thu, 8 Jun 2023 23:25:12 +0300 Subject: SL-19845 show delete confirmation at least once per session --- indra/newview/llinventorygallerymenu.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra/newview/llinventorygallerymenu.cpp') diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index bc4b28b584..b090434528 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -211,6 +211,12 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU } else if ("delete" == action) { + if (!LLInventoryAction::sDeleteConfirmationDisplayed) // ask for the confirmation at least once per session + { + LLNotifications::instance().setIgnored("DeleteItems", false); + LLInventoryAction::sDeleteConfirmationDisplayed = true; + } + LLSD args; args["QUESTION"] = LLTrans::getString("DeleteItem"); LLNotificationsUtil::add("DeleteItems", args, LLSD(), boost::bind(&LLInventoryGalleryContextMenu::onDelete, _1, _2, selected_id)); -- cgit v1.2.3 From a358acf86ddf19aab96ad26a8f4db9cf609bdce7 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 9 Jun 2023 00:34:03 +0300 Subject: SL-19845 Show delete confirmation for 'delete' key --- indra/newview/llinventorygallerymenu.cpp | 37 +------------------------------- 1 file changed, 1 insertion(+), 36 deletions(-) (limited to 'indra/newview/llinventorygallerymenu.cpp') diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index b090434528..54b9294ce1 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -211,15 +211,7 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU } else if ("delete" == action) { - if (!LLInventoryAction::sDeleteConfirmationDisplayed) // ask for the confirmation at least once per session - { - LLNotifications::instance().setIgnored("DeleteItems", false); - LLInventoryAction::sDeleteConfirmationDisplayed = true; - } - - LLSD args; - args["QUESTION"] = LLTrans::getString("DeleteItem"); - LLNotificationsUtil::add("DeleteItems", args, LLSD(), boost::bind(&LLInventoryGalleryContextMenu::onDelete, _1, _2, selected_id)); + mGallery->deleteSelection(); } else if ("copy" == action) { @@ -318,33 +310,6 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU } } -void LLInventoryGalleryContextMenu::onDelete(const LLSD& notification, const LLSD& response, const LLUUID& selected_id) -{ - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - if (option == 0) - { - LLInventoryObject* obj = gInventory.getObject(selected_id); - if (!obj) - { - return; - } - if (obj->getType() == LLAssetType::AT_CATEGORY) - { - if(get_is_category_removable(&gInventory, selected_id)) - { - gInventory.removeCategory(selected_id); - } - } - else - { - if(get_is_item_removable(&gInventory, selected_id)) - { - gInventory.removeItem(selected_id); - } - } - } -} - void LLInventoryGalleryContextMenu::onRename(const LLSD& notification, const LLSD& response) { S32 option = LLNotificationsUtil::getSelectedOption(notification, response); -- cgit v1.2.3 From 5c6a2779c498e69e36276700283ccfb4bdbfd438 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 9 Jun 2023 22:04:52 +0300 Subject: SL-19826 Pasting folders in Single folder should highlight pasted folder --- indra/newview/llinventorygallerymenu.cpp | 97 +------------------------------- 1 file changed, 3 insertions(+), 94 deletions(-) (limited to 'indra/newview/llinventorygallerymenu.cpp') diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index 54b9294ce1..68ead64839 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -71,8 +71,6 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU LLInventoryObject* obj = gInventory.getObject(selected_id); if(!obj) return; - bool is_folder = (obj->getType() == LLAssetType::AT_CATEGORY); - if ("open_selected_folder" == action) { mGallery->setRootFolder(selected_id); @@ -141,72 +139,9 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU } else if ("paste" == action) { + if (mGallery->canPaste()) { - const LLUUID &marketplacelistings_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS); - if(gInventory.isObjectDescendentOf(selected_id, marketplacelistings_id)) - { - return; - } - - bool is_cut_mode = (LLClipboard::instance().isCutMode()); - { - LLUUID dest = is_folder ? selected_id : obj->getParentUUID(); - - std::vector objects; - LLClipboard::instance().pasteFromClipboard(objects); - for (std::vector::const_iterator iter = objects.begin(); iter != objects.end(); ++iter) - { - const LLUUID& item_id = (*iter); - if(gInventory.isObjectDescendentOf(item_id, marketplacelistings_id) && (LLMarketplaceData::instance().isInActiveFolder(item_id) || - LLMarketplaceData::instance().isListedAndActive(item_id))) - { - return; - } - LLViewerInventoryCategory* cat = gInventory.getCategory(item_id); - if (cat) - { - if(is_cut_mode) - { - gInventory.changeCategoryParent(cat, dest, false); - } - else - { - copy_inventory_category(&gInventory, cat, dest); - } - } - else - { - LLViewerInventoryItem* item = gInventory.getItem(item_id); - if (item) - { - if(is_cut_mode) - { - gInventory.changeItemParent(item, dest, false); - } - else - { - if (item->getIsLinkType()) - { - link_inventory_object(dest, item_id, - LLPointer(NULL)); - } - else - { - copy_inventory_item( - gAgent.getID(), - item->getPermissions().getOwner(), - item->getUUID(), - dest, - std::string(), - LLPointer(NULL)); - } - } - } - } - } - LLClipboard::instance().setCutMode(false); - } - + mGallery->paste(); } } else if ("delete" == action) @@ -222,33 +157,7 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU } else if ("paste_link" == action) { - const LLUUID ¤t_outfit_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); - const LLUUID &marketplacelistings_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS); - const LLUUID &my_outifts_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS); - - const BOOL move_is_into_current_outfit = (selected_id == current_outfit_id); - const BOOL move_is_into_my_outfits = (selected_id == my_outifts_id) || gInventory.isObjectDescendentOf(selected_id, my_outifts_id); - const BOOL move_is_into_marketplacelistings = gInventory.isObjectDescendentOf(selected_id, marketplacelistings_id); - - if (move_is_into_marketplacelistings || move_is_into_current_outfit || move_is_into_my_outfits) - { - return; - } - LLUUID dest = is_folder ? selected_id : obj->getParentUUID(); - std::vector objects; - LLClipboard::instance().pasteFromClipboard(objects); - for (std::vector::const_iterator iter = objects.begin(); - iter != objects.end(); - ++iter) - { - const LLUUID &object_id = (*iter); - if (LLConstPointer link_obj = gInventory.getObject(object_id)) - { - link_inventory_object(dest, link_obj, LLPointer(NULL)); - } - } - - LLClipboard::instance().setCutMode(false); + mGallery->pasteAsLink(); } else if ("rename" == action) { -- cgit v1.2.3 From f608eafc3724899a16d01d4b9464a21f8fbc08d3 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 16 Jun 2023 22:22:59 +0300 Subject: SL-19496 Fix attempts to open trash for thumnail assigment do not work. --- indra/newview/llinventorygallerymenu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llinventorygallerymenu.cpp') diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index 68ead64839..e30883d564 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -334,7 +334,7 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men if(!is_link) { items.push_back(std::string("thumbnail")); - if (!is_agent_inventory) + if (!is_agent_inventory || (is_in_trash && !is_trash)) { disabled_items.push_back(std::string("thumbnail")); } -- cgit v1.2.3 From 6c0891473ff1d5f740e3d3624cec2f5c17da0ad6 Mon Sep 17 00:00:00 2001 From: Maxim Nikolenko Date: Tue, 20 Jun 2023 17:38:23 +0300 Subject: SL-19892 add missing menu items for Landmarks in Gallery view --- indra/newview/llinventorygallerymenu.cpp | 59 ++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'indra/newview/llinventorygallerymenu.cpp') diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index e30883d564..541fed8172 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -33,9 +33,12 @@ #include "llavataractions.h" #include "llclipboard.h" #include "llfloaterreg.h" +#include "llfloatersidepanelcontainer.h" +#include "llfloaterworldmap.h" #include "llinventorybridge.h" #include "llinventoryfunctions.h" #include "llinventorymodel.h" +#include "lllandmarkactions.h" #include "llmarketplacefunctions.h" #include "llmenugl.h" #include "llnotificationsutil.h" @@ -217,6 +220,55 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU { LLFloaterReg::showInstance("linkreplace", LLSD(selected_id)); } + else if ("copy_slurl" == action) + { + boost::function copy_slurl_cb = [](LLLandmark* landmark) + { + LLVector3d global_pos; + landmark->getGlobalPos(global_pos); + boost::function copy_slurl_to_clipboard_cb = [](const std::string& slurl) + { + gViewerWindow->getWindow()->copyTextToClipboard(utf8str_to_wstring(slurl)); + LLSD args; + args["SLURL"] = slurl; + LLNotificationsUtil::add("CopySLURL", args); + }; + LLLandmarkActions::getSLURLfromPosGlobal(global_pos, copy_slurl_to_clipboard_cb, true); + }; + LLLandmark* landmark = LLLandmarkActions::getLandmark(selected_id, copy_slurl_cb); + if (landmark) + { + copy_slurl_cb(landmark); + } + } + else if ("about" == action) + { + LLSD key; + key["type"] = "landmark"; + key["id"] = selected_id; + LLFloaterSidePanelContainer::showPanel("places", key); + } + else if ("show_on_map" == action) + { + boost::function show_on_map_cb = [](LLLandmark* landmark) + { + LLVector3d landmark_global_pos; + if (landmark->getGlobalPos(landmark_global_pos)) + { + LLFloaterWorldMap* worldmap_instance = LLFloaterWorldMap::getInstance(); + if (!landmark_global_pos.isExactlyZero() && worldmap_instance) + { + worldmap_instance->trackLocation(landmark_global_pos); + LLFloaterReg::showInstance("world_map", "center"); + } + } + }; + LLLandmark* landmark = LLLandmarkActions::getLandmark(selected_id, show_on_map_cb); + if(landmark) + { + show_on_map_cb(landmark); + } + } } void LLInventoryGalleryContextMenu::onRename(const LLSD& notification, const LLSD& response) @@ -357,6 +409,13 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men { items.push_back(std::string("Replace Links")); } + if (obj->getType() == LLAssetType::AT_LANDMARK) + { + items.push_back(std::string("Landmark Separator")); + items.push_back(std::string("url_copy")); + items.push_back(std::string("About Landmark")); + items.push_back(std::string("show_on_map")); + } } if(is_trash) -- cgit v1.2.3 From 434f2ee512dc6edf4a6dfbafd7265d121038bf0b Mon Sep 17 00:00:00 2001 From: Maxim Nikolenko Date: Mon, 26 Jun 2023 18:39:51 +0300 Subject: SL-19918 "Save as" menu item is missing for textures in Gallery view --- indra/newview/llinventorygallerymenu.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'indra/newview/llinventorygallerymenu.cpp') diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index 541fed8172..bca10b9c0e 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -42,6 +42,7 @@ #include "llmarketplacefunctions.h" #include "llmenugl.h" #include "llnotificationsutil.h" +#include "llpreviewtexture.h" #include "lltrans.h" #include "llviewerfoldertype.h" #include "llviewerwindow.h" @@ -269,6 +270,15 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU show_on_map_cb(landmark); } } + else if ("save_as" == action) + { + LLPreviewTexture* preview_texture = LLFloaterReg::getTypedInstance("preview_texture", selected_id); + if (preview_texture) + { + preview_texture->openToSave(); + preview_texture->saveAs(); + } + } } void LLInventoryGalleryContextMenu::onRename(const LLSD& notification, const LLSD& response) @@ -620,6 +630,15 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men } } } + if(obj->getType() == LLAssetType::AT_TEXTURE) + { + items.push_back(std::string("Save As")); + bool can_copy = selected_item && selected_item->checkPermissionsSet(PERM_ITEM_UNRESTRICTED); + if (!can_copy) + { + disabled_items.push_back(std::string("Save As")); + } + } if (is_link) { items.push_back(std::string("Find Original")); -- cgit v1.2.3 From f24f72d2f9db7490b169daea16f8ab8400ca12b4 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 6 Sep 2023 02:56:11 +0300 Subject: SL-19826 Gallery multiselect support Part#3 wip --- indra/newview/llinventorygallerymenu.cpp | 162 ++++++++++++++++++++----------- 1 file changed, 103 insertions(+), 59 deletions(-) (limited to 'indra/newview/llinventorygallerymenu.cpp') diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index bca10b9c0e..5f4b816b99 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -51,16 +51,17 @@ LLContextMenu* LLInventoryGalleryContextMenu::createMenu() { LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; - //LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; - LLUUID selected_id = mUUIDs.front(); + LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; - registrar.add("Inventory.DoToSelected", boost::bind(&LLInventoryGalleryContextMenu::doToSelected, this, _2, selected_id)); - registrar.add("Inventory.FileUploadLocation", boost::bind(&LLInventoryGalleryContextMenu::fileUploadLocation, this, _2, selected_id)); + registrar.add("Inventory.DoToSelected", boost::bind(&LLInventoryGalleryContextMenu::doToSelected, this, _2)); + registrar.add("Inventory.FileUploadLocation", boost::bind(&LLInventoryGalleryContextMenu::fileUploadLocation, this, _2)); registrar.add("Inventory.EmptyTrash", boost::bind(&LLInventoryModel::emptyFolderType, &gInventory, "ConfirmEmptyTrash", LLFolderType::FT_TRASH)); registrar.add("Inventory.EmptyLostAndFound", boost::bind(&LLInventoryModel::emptyFolderType, &gInventory, "ConfirmEmptyLostAndFound", LLFolderType::FT_LOST_AND_FOUND)); - std::set uuids{selected_id}; + std::set uuids(mUUIDs.begin(), mUUIDs.end()); registrar.add("Inventory.Share", boost::bind(&LLAvatarActions::shareWithAvatars, uuids, gFloaterView->getParentFloater(mGallery))); + + enable_registrar.add("Inventory.CanSetUploadLocation", boost::bind(&LLInventoryGalleryContextMenu::canSetUploadLocation, this, _2)); LLContextMenu* menu = createFromFile("menu_gallery_inventory.xml"); @@ -69,49 +70,52 @@ LLContextMenu* LLInventoryGalleryContextMenu::createMenu() return menu; } -void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLUUID& selected_id) +void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata) { std::string action = userdata.asString(); - LLInventoryObject* obj = gInventory.getObject(selected_id); + LLInventoryObject* obj = gInventory.getObject(mUUIDs.front()); if(!obj) return; if ("open_selected_folder" == action) { - mGallery->setRootFolder(selected_id); + mGallery->setRootFolder(mUUIDs.front()); } else if ("open_in_new_window" == action) { - new_folder_window(selected_id); + new_folder_window(mUUIDs.front()); } else if ("properties" == action) { - show_item_profile(selected_id); + show_item_profile(mUUIDs.front()); } else if ("restore" == action) { - LLViewerInventoryCategory* cat = gInventory.getCategory(selected_id); - if(cat) + for (LLUUID& selected_id : mUUIDs) { - const LLUUID new_parent = gInventory.findCategoryUUIDForType(LLFolderType::assetTypeToFolderType(cat->getType())); - // do not restamp children on restore - gInventory.changeCategoryParent(cat, new_parent, false); - } - else - { - LLViewerInventoryItem* item = gInventory.getItem(selected_id); - if(item) + LLViewerInventoryCategory* cat = gInventory.getCategory(selected_id); + if (cat) { - bool is_snapshot = (item->getInventoryType() == LLInventoryType::IT_SNAPSHOT); - - const LLUUID new_parent = gInventory.findCategoryUUIDForType(is_snapshot? LLFolderType::FT_SNAPSHOT_CATEGORY : LLFolderType::assetTypeToFolderType(item->getType())); + const LLUUID new_parent = gInventory.findCategoryUUIDForType(LLFolderType::assetTypeToFolderType(cat->getType())); // do not restamp children on restore - gInventory.changeItemParent(item, new_parent, false); + gInventory.changeCategoryParent(cat, new_parent, false); + } + else + { + LLViewerInventoryItem* item = gInventory.getItem(selected_id); + if (item) + { + bool is_snapshot = (item->getInventoryType() == LLInventoryType::IT_SNAPSHOT); + + const LLUUID new_parent = gInventory.findCategoryUUIDForType(is_snapshot ? LLFolderType::FT_SNAPSHOT_CATEGORY : LLFolderType::assetTypeToFolderType(item->getType())); + // do not restamp children on restore + gInventory.changeItemParent(item, new_parent, false); + } } } } else if ("copy_uuid" == action) { - LLViewerInventoryItem* item = gInventory.getItem(selected_id); + LLViewerInventoryItem* item = gInventory.getItem(mUUIDs.front()); if(item) { LLUUID asset_id = item->getProtectedAssetUUID(); @@ -123,15 +127,18 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU } else if ("purge" == action) { - remove_inventory_object(selected_id, NULL); + for (LLUUID& selected_id : mUUIDs) + { + remove_inventory_object(selected_id, NULL); + } } else if ("goto" == action) { - show_item_original(selected_id); + show_item_original(mUUIDs.front()); } else if ("thumbnail" == action) { - LLSD data(selected_id); + LLSD data(mUUIDs.front()); LLFloaterReg::showInstance("change_item_thumbnail", data); } else if ("cut" == action) @@ -165,61 +172,70 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU } else if ("rename" == action) { - LLSD args; - args["NAME"] = obj->getName(); - - LLSD payload; - payload["id"] = selected_id; - - LLNotificationsUtil::add("RenameItem", args, payload, boost::bind(onRename, _1, _2)); + rename(mUUIDs.front()); } else if ("open" == action || "open_original" == action) { - LLViewerInventoryItem* item = gInventory.getItem(selected_id); + LLViewerInventoryItem* item = gInventory.getItem(mUUIDs.front()); if (item) { - LLInvFVBridgeAction::doAction(item->getType(), selected_id , &gInventory); + LLInvFVBridgeAction::doAction(item->getType(), mUUIDs.front(), &gInventory); } } else if ("ungroup_folder_items" == action) { - ungroup_folder_items(selected_id); + ungroup_folder_items(mUUIDs.front()); } else if ("take_off" == action || "detach" == action) { - LLAppearanceMgr::instance().removeItemFromAvatar(selected_id); + for (LLUUID& selected_id : mUUIDs) + { + LLAppearanceMgr::instance().removeItemFromAvatar(selected_id); + } } else if ("wear_add" == action) { - LLAppearanceMgr::instance().wearItemOnAvatar(selected_id, true, false); // Don't replace if adding. + for (LLUUID& selected_id : mUUIDs) + { + LLAppearanceMgr::instance().wearItemOnAvatar(selected_id, true, false); // Don't replace if adding. + } } else if ("wear" == action) { - LLAppearanceMgr::instance().wearItemOnAvatar(selected_id, true, true); + for (LLUUID& selected_id : mUUIDs) + { + LLAppearanceMgr::instance().wearItemOnAvatar(selected_id, true, true); + } } else if ("activate" == action) { - LLGestureMgr::instance().activateGesture(selected_id); + for (LLUUID& selected_id : mUUIDs) + { + LLGestureMgr::instance().activateGesture(selected_id); - LLViewerInventoryItem* item = gInventory.getItem(selected_id); - if (!item) return; + LLViewerInventoryItem* item = gInventory.getItem(selected_id); + if (!item) return; - gInventory.updateItem(item); + gInventory.updateItem(item); + } gInventory.notifyObservers(); } else if ("deactivate" == action) { - LLGestureMgr::instance().deactivateGesture(selected_id); + for (LLUUID& selected_id : mUUIDs) + { + LLGestureMgr::instance().deactivateGesture(selected_id); - LLViewerInventoryItem* item = gInventory.getItem(selected_id); - if (!item) return; + LLViewerInventoryItem* item = gInventory.getItem(selected_id); + if (!item) return; - gInventory.updateItem(item); + gInventory.updateItem(item); + } gInventory.notifyObservers(); } else if ("replace_links" == action) { - LLFloaterReg::showInstance("linkreplace", LLSD(selected_id)); + LLFloaterReg::showInstance("linkreplace", LLSD(mUUIDs.front())); } else if ("copy_slurl" == action) { @@ -236,7 +252,7 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU }; LLLandmarkActions::getSLURLfromPosGlobal(global_pos, copy_slurl_to_clipboard_cb, true); }; - LLLandmark* landmark = LLLandmarkActions::getLandmark(selected_id, copy_slurl_cb); + LLLandmark* landmark = LLLandmarkActions::getLandmark(mUUIDs.front(), copy_slurl_cb); if (landmark) { copy_slurl_cb(landmark); @@ -246,7 +262,7 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU { LLSD key; key["type"] = "landmark"; - key["id"] = selected_id; + key["id"] = mUUIDs.front(); LLFloaterSidePanelContainer::showPanel("places", key); } else if ("show_on_map" == action) @@ -264,7 +280,7 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU } } }; - LLLandmark* landmark = LLLandmarkActions::getLandmark(selected_id, show_on_map_cb); + LLLandmark* landmark = LLLandmarkActions::getLandmark(mUUIDs.front(), show_on_map_cb); if(landmark) { show_on_map_cb(landmark); @@ -272,7 +288,7 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU } else if ("save_as" == action) { - LLPreviewTexture* preview_texture = LLFloaterReg::getTypedInstance("preview_texture", selected_id); + LLPreviewTexture* preview_texture = LLFloaterReg::getTypedInstance("preview_texture", mUUIDs.front()); if (preview_texture) { preview_texture->openToSave(); @@ -281,6 +297,20 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU } } +void LLInventoryGalleryContextMenu::rename(const LLUUID& item_id) +{ + LLInventoryObject* obj = gInventory.getObject(item_id); + if (!obj) return; + + LLSD args; + args["NAME"] = obj->getName(); + + LLSD payload; + payload["id"] = mUUIDs.front(); + + LLNotificationsUtil::add("RenameItem", args, payload, boost::bind(onRename, _1, _2)); +} + void LLInventoryGalleryContextMenu::onRename(const LLSD& notification, const LLSD& response) { S32 option = LLNotificationsUtil::getSelectedOption(notification, response); @@ -311,25 +341,39 @@ void LLInventoryGalleryContextMenu::onRename(const LLSD& notification, const LLS } } -void LLInventoryGalleryContextMenu::fileUploadLocation(const LLSD& userdata, const LLUUID& selected_id) +void LLInventoryGalleryContextMenu::fileUploadLocation(const LLSD& userdata) { const std::string param = userdata.asString(); if (param == "model") { - gSavedPerAccountSettings.setString("ModelUploadFolder", selected_id.asString()); + gSavedPerAccountSettings.setString("ModelUploadFolder", mUUIDs.front().asString()); } else if (param == "texture") { - gSavedPerAccountSettings.setString("TextureUploadFolder", selected_id.asString()); + gSavedPerAccountSettings.setString("TextureUploadFolder", mUUIDs.front().asString()); } else if (param == "sound") { - gSavedPerAccountSettings.setString("SoundUploadFolder", selected_id.asString()); + gSavedPerAccountSettings.setString("SoundUploadFolder", mUUIDs.front().asString()); } else if (param == "animation") { - gSavedPerAccountSettings.setString("AnimationUploadFolder", selected_id.asString()); + gSavedPerAccountSettings.setString("AnimationUploadFolder", mUUIDs.front().asString()); + } +} + +bool LLInventoryGalleryContextMenu::canSetUploadLocation(const LLSD& userdata) +{ + if (mUUIDs.size() != 1) + { + return false; + } + LLInventoryCategory* cat = gInventory.getCategory(mUUIDs.front()); + if (!cat) + { + return false; } + return true; } bool is_inbox_folder(LLUUID item_id) -- cgit v1.2.3