summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Nikolenko <maximnproductengine@lindenlab.com>2023-05-26 19:45:46 +0300
committerMaxim Nikolenko <maximnproductengine@lindenlab.com>2023-05-26 19:45:46 +0300
commit67e17bd822f146f333b91d353df6f55174ce4db6 (patch)
treea398e3bc373c0d2d8524786bf293aa2f6d5cc59f
parent572e8269bcd5320daa66f4074e927c79869bf7de (diff)
SL-19774 add context menu for root folder (without any selection); show paste menu when right clicking any item
-rw-r--r--indra/newview/llinventorygallery.cpp24
-rw-r--r--indra/newview/llinventorygallery.h2
-rw-r--r--indra/newview/llinventorygallerymenu.cpp54
-rw-r--r--indra/newview/llinventorygallerymenu.h7
4 files changed, 63 insertions, 24 deletions
diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp
index 18a7068b66..c6fee42297 100644
--- a/indra/newview/llinventorygallery.cpp
+++ b/indra/newview/llinventorygallery.cpp
@@ -126,12 +126,15 @@ BOOL LLInventoryGallery::postBuild()
mGalleryPanel = LLUICtrlFactory::create<LLPanel>(params);
mMessageTextBox = getChild<LLTextBox>("empty_txt");
mInventoryGalleryMenu = new LLInventoryGalleryContextMenu(this);
+ mRootGalleryMenu = new LLInventoryGalleryContextMenu(this);
+ mRootGalleryMenu->setRootFolder(true);
return TRUE;
}
LLInventoryGallery::~LLInventoryGallery()
{
delete mInventoryGalleryMenu;
+ delete mRootGalleryMenu;
delete mFilter;
while (!mUnusedRowPanels.empty())
@@ -837,6 +840,27 @@ void LLInventoryGallery::onThumbnailAdded(LLUUID item_id)
}
}
+BOOL LLInventoryGallery::handleRightMouseDown(S32 x, S32 y, MASK mask)
+{
+ if(mItemMap[mSelectedItemID])
+ {
+ mItemMap[mSelectedItemID]->setFocus(false);
+ }
+ clearSelection();
+ BOOL res = LLPanel::handleRightMouseDown(x, y, mask);
+ if (mSelectedItemID.isNull())
+ {
+ if (mInventoryGalleryMenu && mFolderID.notNull())
+ {
+ uuid_vec_t selected_uuids;
+ selected_uuids.push_back(mFolderID);
+ mRootGalleryMenu->show(this, selected_uuids, x, y);
+ return TRUE;
+ }
+ }
+ return res;
+}
+
void LLInventoryGallery::showContextMenu(LLUICtrl* ctrl, S32 x, S32 y, const LLUUID& item_id)
{
if (mInventoryGalleryMenu && item_id.notNull())
diff --git a/indra/newview/llinventorygallery.h b/indra/newview/llinventorygallery.h
index 473d1a1db4..7e4ed9725b 100644
--- a/indra/newview/llinventorygallery.h
+++ b/indra/newview/llinventorygallery.h
@@ -78,6 +78,7 @@ public:
void draw();
BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type,
void* cargo_data, EAcceptance* accept, std::string& tooltip_msg);
+ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
void setFilterSubString(const std::string& string);
std::string getFilterSubString() { return mFilterSubString; }
@@ -204,6 +205,7 @@ private:
int mGalleryWidthFactor;
LLInventoryGalleryContextMenu* mInventoryGalleryMenu;
+ LLInventoryGalleryContextMenu* mRootGalleryMenu;
std::string mFilterSubString;
LLInventoryFilter* mFilter;
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<LLUUID> objects;
LLClipboard::instance().pasteFromClipboard(objects);
for (std::vector<LLUUID>::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<LLInventoryCallback>(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<LLInventoryCallback>(NULL));
}
@@ -264,7 +266,7 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU
{
return;
}
-
+ LLUUID dest = is_folder ? selected_id : obj->getParentUUID();
std::vector<LLUUID> objects;
LLClipboard::instance().pasteFromClipboard(objects);
for (std::vector<LLUUID>::const_iterator iter = objects.begin();
@@ -274,7 +276,7 @@ void LLInventoryGalleryContextMenu::doToSelected(const LLSD& userdata, const LLU
const LLUUID &object_id = (*iter);
if (LLConstPointer<LLInventoryObject> link_obj = gInventory.getObject(object_id))
{
- link_inventory_object(selected_id, link_obj, LLPointer<LLInventoryCallback>(NULL));
+ link_inventory_object(dest, link_obj, LLPointer<LLInventoryCallback>(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<bool> 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<bool> 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"));
diff --git a/indra/newview/llinventorygallerymenu.h b/indra/newview/llinventorygallerymenu.h
index 1768c07e6e..fd542e7d79 100644
--- a/indra/newview/llinventorygallerymenu.h
+++ b/indra/newview/llinventorygallerymenu.h
@@ -33,9 +33,13 @@ class LLInventoryGalleryContextMenu : public LLListContextMenu
public:
LLInventoryGalleryContextMenu(LLInventoryGallery* gallery)
: LLListContextMenu(),
- mGallery(gallery){}
+ mGallery(gallery),
+ mRootFolder(false){}
/*virtual*/ LLContextMenu* createMenu();
+ bool isRootFolder() { return mRootFolder; }
+ void setRootFolder(bool is_root) { mRootFolder = is_root; }
+
protected:
//virtual void buildContextMenu(class LLMenuGL& menu, U32 flags);
void updateMenuItemsVisibility(LLContextMenu* menu);
@@ -50,6 +54,7 @@ private:
bool checkContextMenuItem(const LLSD& userdata);
LLInventoryGallery* mGallery;
+ bool mRootFolder;
};
#endif