Anonymous avatar Anonymous committed f08f4fa

STORM-1898 Add "Copy SLURL" to context menu when right clicking Landmarks in Inventory

Comments (0)

Files changed (3)

indra/newview/llinventorybridge.cpp

 #include "llviewerwindow.h"
 #include "llvoavatarself.h"
 #include "llwearablelist.h"
+#include "lllandmarkactions.h"
+
+void copy_slurl_to_clipboard_callback_inv(const std::string& slurl);
 
 // Marketplace outbox current disabled
 #define ENABLE_MERCHANT_OUTBOX_CONTEXT_MENU	1
 		const LLUUID outbox_id = getInventoryModel()->findCategoryUUIDForType(LLFolderType::FT_OUTBOX, false, false);
 		copy_item_to_outbox(itemp, outbox_id, LLUUID::null, LLToolDragAndDrop::getOperationId());
 	}
+	else if ("copy_slurl" == action)
+	{
+		LLViewerInventoryItem* item = static_cast<LLViewerInventoryItem*>(getItem());
+		if(item)
+		{
+			LLUUID asset_id = item->getAssetUUID();
+			LLLandmark* landmark = gLandmarkList.getAsset(asset_id);
+			if (landmark)
+			{
+				LLVector3d global_pos;
+				landmark->getGlobalPos(global_pos);
+				LLLandmarkActions::getSLURLfromPosGlobal(global_pos, &copy_slurl_to_clipboard_callback_inv, true);
+			}
+		}
+	}
+}
+
+void copy_slurl_to_clipboard_callback_inv(const std::string& slurl)
+{
+	gViewerWindow->getWindow()->copyTextToClipboard(utf8str_to_wstring(slurl));
+	LLSD args;
+	args["SLURL"] = slurl;
+	LLNotificationsUtil::add("CopySLURL", args);
 }
 
 void LLItemBridge::selectItem()
 		}
 
 		items.push_back(std::string("Landmark Separator"));
+		items.push_back(std::string("url_copy"));
 		items.push_back(std::string("About Landmark"));
 	}
 
 	// info panel can be shown at a time.
 	if ((flags & FIRST_SELECTED_ITEM) == 0)
 	{
+		disabled_items.push_back(std::string("url_copy"));
 		disabled_items.push_back(std::string("About Landmark"));
 	}
 

indra/newview/llinventorybridge.h

 				 const LLUUID& uuid) :
 		LLInvFVBridge(inventory, root, uuid) {}
 
+	typedef boost::function<void(std::string& slurl)> slurl_callback_t;
+
 	virtual void performAction(LLInventoryModel* model, std::string action);
 	virtual void selectItem();
 	virtual void restoreItem();
 	virtual BOOL isItemCopyable() const;
 	virtual BOOL hasChildren() const { return FALSE; }
 	virtual BOOL isUpToDate() const { return TRUE; }
-
 	/*virtual*/ void clearDisplayName() { mDisplayName.clear(); }
 
 	LLViewerInventoryItem* getItem() const;

indra/newview/skins/default/xui/en/menu_inventory.xml

      layout="topleft"
      name="Landmark Separator" />
     <menu_item_call
+    label="Copy SLurl"
+    layout="topleft"
+    name="url_copy">
+       <menu_item_call.on_click
+        function="Inventory.DoToSelected"
+        parameter="copy_slurl" />
+   </menu_item_call> 
+   <menu_item_call
      label="About Landmark"
      layout="topleft"
      name="About Landmark">
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.