diff options
author | Maxim Nikolenko <maximnproductengine@lindenlab.com> | 2023-05-04 19:19:32 +0300 |
---|---|---|
committer | Maxim Nikolenko <maximnproductengine@lindenlab.com> | 2023-05-04 19:19:32 +0300 |
commit | 25277a773db9311ecddb80febe623240769c0636 (patch) | |
tree | 2cc34bc03d4be862466007f92feebd5fa1ca3510 /indra/newview/llpanelmaininventory.cpp | |
parent | b3e02c4264a8a3b9d189b347d0faddf3ac21e87b (diff) |
SL-19683 Add menu items should be disabled for some folders in single-folder view
Diffstat (limited to 'indra/newview/llpanelmaininventory.cpp')
-rw-r--r-- | indra/newview/llpanelmaininventory.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index 3110adff15..b0422b7bd9 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -1494,6 +1494,7 @@ void LLPanelMainInventory::onAddButtonClick() LLMenuGL* menu = (LLMenuGL*)mMenuAddHandle.get(); if (menu) { + disableAddIfNeeded(); menu->getChild<LLMenuItemGL>("New Folder")->setEnabled(!isRecentItemsPanelSelected()); setUploadCostIfNeeded(); @@ -2199,6 +2200,55 @@ void LLPanelMainInventory::setUploadCostIfNeeded() } } +bool is_add_allowed(LLUUID folder_id) +{ + if(!gInventory.isObjectDescendentOf(folder_id, gInventory.getRootFolderID())) + { + return false; + } + + std::vector<LLFolderType::EType> not_allowed_types; + not_allowed_types.push_back(LLFolderType::FT_LOST_AND_FOUND); + not_allowed_types.push_back(LLFolderType::FT_FAVORITE); + not_allowed_types.push_back(LLFolderType::FT_MARKETPLACE_LISTINGS); + not_allowed_types.push_back(LLFolderType::FT_TRASH); + not_allowed_types.push_back(LLFolderType::FT_CURRENT_OUTFIT); + not_allowed_types.push_back(LLFolderType::FT_INBOX); + + for (std::vector<LLFolderType::EType>::const_iterator it = not_allowed_types.begin(); + it != not_allowed_types.end(); ++it) + { + if(gInventory.isObjectDescendentOf(folder_id, gInventory.findCategoryUUIDForType(*it))) + { + return false; + } + } + + LLViewerInventoryCategory* cat = gInventory.getCategory(folder_id); + if (cat && (cat->getPreferredType() == LLFolderType::FT_OUTFIT)) + { + return false; + } + return true; +} + +void LLPanelMainInventory::disableAddIfNeeded() +{ + LLMenuGL* menu = (LLMenuGL*)mMenuAddHandle.get(); + if (menu) + { + bool enable = !mSingleFolderMode || is_add_allowed(getCurrentSFVRoot()); + + menu->getChild<LLMenuItemGL>("New Folder")->setEnabled(enable); + menu->getChild<LLMenuItemGL>("New Script")->setEnabled(enable); + menu->getChild<LLMenuItemGL>("New Note")->setEnabled(enable); + menu->getChild<LLMenuItemGL>("New Gesture")->setEnabled(enable); + menu->setItemEnabled("New Clothes", enable); + menu->setItemEnabled("New Body Parts", enable); + menu->setItemEnabled("New Settings", enable); + } +} + bool LLPanelMainInventory::hasSettingsInventory() { return LLEnvironment::instance().isInventoryEnabled(); |