summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2023-06-09 00:34:03 +0300
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2023-06-09 00:34:03 +0300
commita358acf86ddf19aab96ad26a8f4db9cf609bdce7 (patch)
tree1023b199150ab04101e34063ea3cba2532289462 /indra
parentf8823a426383949fb1609fa82b5ebb98ef2c295b (diff)
SL-19845 Show delete confirmation for 'delete' key
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llinventorygallery.cpp59
-rw-r--r--indra/newview/llinventorygallery.h3
-rw-r--r--indra/newview/llinventorygallerymenu.cpp37
-rw-r--r--indra/newview/llinventorygallerymenu.h1
4 files changed, 46 insertions, 54 deletions
diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp
index eff43e33ca..189fb33334 100644
--- a/indra/newview/llinventorygallery.cpp
+++ b/indra/newview/llinventorygallery.cpp
@@ -46,6 +46,7 @@
#include "llfriendcard.h"
#include "llgesturemgr.h"
#include "llmarketplacefunctions.h"
+#include "llnotificationsutil.h"
#include "lloutfitobserver.h"
#include "lltrans.h"
#include "llviewerassettype.h"
@@ -901,23 +902,7 @@ BOOL LLInventoryGallery::handleKeyHere(KEY key, MASK mask)
// Note: on Mac laptop keyboards, backspace and delete are one and the same
if (mSelectedItemID.notNull())
{
- LLViewerInventoryCategory* category = gInventory.getCategory(mSelectedItemID);
- if (category)
- {
- if (get_is_category_removable(&gInventory, mSelectedItemID))
- {
- gInventory.removeCategory(mSelectedItemID);
- handled = TRUE;
- }
- }
- else
- {
- if (get_is_item_removable(&gInventory, mSelectedItemID))
- {
- gInventory.removeItem(mSelectedItemID);
- handled = TRUE;
- }
- }
+ deleteSelection();
}
break;
@@ -1325,6 +1310,46 @@ BOOL LLInventoryGallery::canPaste() const
return TRUE;
}
+void LLInventoryGallery::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 LLInventoryGallery::deleteSelection()
+{
+ 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(&LLInventoryGallery::onDelete, _1, _2, mSelectedItemID));
+}
+
void LLInventoryGallery::claimEditHandler()
{
gEditMenuHandler = this;
diff --git a/indra/newview/llinventorygallery.h b/indra/newview/llinventorygallery.h
index ac4811adec..54588a3907 100644
--- a/indra/newview/llinventorygallery.h
+++ b/indra/newview/llinventorygallery.h
@@ -149,6 +149,9 @@ public:
void paste() override;
BOOL canPaste() const override;
+ static void onDelete(const LLSD& notification, const LLSD& response, const LLUUID& selected_id);
+ void deleteSelection();
+
void claimEditHandler();
static bool isItemCopyable(const LLUUID & item_id);
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);
diff --git a/indra/newview/llinventorygallerymenu.h b/indra/newview/llinventorygallerymenu.h
index 1c56266310..67cf9a569a 100644
--- a/indra/newview/llinventorygallerymenu.h
+++ b/indra/newview/llinventorygallerymenu.h
@@ -47,7 +47,6 @@ protected:
void fileUploadLocation(const LLSD& userdata, const LLUUID& selected_id);
- static void onDelete(const LLSD& notification, const LLSD& response, const LLUUID& selected_id);
static void onRename(const LLSD& notification, const LLSD& response);
private: