From 434f2ee512dc6edf4a6dfbafd7265d121038bf0b Mon Sep 17 00:00:00 2001
From: Maxim Nikolenko <maximnproductengine@lindenlab.com>
Date: Mon, 26 Jun 2023 18:39:51 +0300
Subject: [PATCH] SL-19918 "Save as" menu item is missing for textures in
 Gallery view

---
 indra/newview/llinventorygallerymenu.cpp | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp
index 541fed8172b..bca10b9c0ee 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<LLPreviewTexture>("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"));
-- 
GitLab