From 747eccd63faa8595803b253a2dcf4d1732d924ce Mon Sep 17 00:00:00 2001
From: AndreyL ProductEngine <alihatskiy@productengine.com>
Date: Thu, 6 Sep 2018 03:24:06 +0300
Subject: [PATCH] MAINT-8777 added ability to copy access lists to clipboard

---
 indra/newview/llfloaterregioninfo.cpp         | 48 +++++++++++++++++++
 indra/newview/llfloaterregioninfo.h           |  4 ++
 .../default/xui/en/panel_region_access.xml    | 30 ++++++++++--
 3 files changed, 79 insertions(+), 3 deletions(-)

diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp
index 98e718fadbe..6d585f96303 100644
--- a/indra/newview/llfloaterregioninfo.cpp
+++ b/indra/newview/llfloaterregioninfo.cpp
@@ -51,6 +51,7 @@
 #include "llfloateravatarpicker.h"
 #include "llbutton.h" 
 #include "llcheckboxctrl.h"
+#include "llclipboard.h"
 #include "llcombobox.h"
 #include "lldaycyclemanager.h"
 #include "llenvmanager.h"
@@ -3288,6 +3289,7 @@ BOOL LLPanelEstateAccess::postBuild()
 	getChild<LLUICtrl>("allowed_search_input")->setCommitCallback(boost::bind(&LLPanelEstateAccess::onAllowedSearchEdit, this, _2));
 	childSetAction("add_allowed_avatar_btn", boost::bind(&LLPanelEstateAccess::onClickAddAllowedAgent, this));
 	childSetAction("remove_allowed_avatar_btn", boost::bind(&LLPanelEstateAccess::onClickRemoveAllowedAgent, this));
+	childSetAction("copy_allowed_list_btn", boost::bind(&LLPanelEstateAccess::onClickCopyAllowedList, this));
 
 	getChild<LLUICtrl>("allowed_group_name_list")->setCommitCallback(boost::bind(&LLPanelEstateInfo::onChangeChildCtrl, this, _1));
 	LLNameListCtrl* group_name_list = getChild<LLNameListCtrl>("allowed_group_name_list");
@@ -3300,6 +3302,7 @@ BOOL LLPanelEstateAccess::postBuild()
 	getChild<LLUICtrl>("allowed_group_search_input")->setCommitCallback(boost::bind(&LLPanelEstateAccess::onAllowedGroupsSearchEdit, this, _2));
 	getChild<LLUICtrl>("add_allowed_group_btn")->setCommitCallback(boost::bind(&LLPanelEstateAccess::onClickAddAllowedGroup, this));
 	childSetAction("remove_allowed_group_btn", boost::bind(&LLPanelEstateAccess::onClickRemoveAllowedGroup, this));
+	childSetAction("copy_allowed_group_list_btn", boost::bind(&LLPanelEstateAccess::onClickCopyAllowedGroupList, this));
 
 	getChild<LLUICtrl>("banned_avatar_name_list")->setCommitCallback(boost::bind(&LLPanelEstateInfo::onChangeChildCtrl, this, _1));
 	LLNameListCtrl* banned_name_list = getChild<LLNameListCtrl>("banned_avatar_name_list");
@@ -3312,6 +3315,7 @@ BOOL LLPanelEstateAccess::postBuild()
 	getChild<LLUICtrl>("banned_search_input")->setCommitCallback(boost::bind(&LLPanelEstateAccess::onBannedSearchEdit, this, _2));
 	childSetAction("add_banned_avatar_btn", boost::bind(&LLPanelEstateAccess::onClickAddBannedAgent, this));
 	childSetAction("remove_banned_avatar_btn", boost::bind(&LLPanelEstateAccess::onClickRemoveBannedAgent, this));
+	childSetAction("copy_banned_list_btn", boost::bind(&LLPanelEstateAccess::onClickCopyBannedList, this));
 
 	getChild<LLUICtrl>("estate_manager_name_list")->setCommitCallback(boost::bind(&LLPanelEstateInfo::onChangeChildCtrl, this, _1));
 	LLNameListCtrl* manager_name_list = getChild<LLNameListCtrl>("estate_manager_name_list");
@@ -3457,6 +3461,21 @@ void LLPanelEstateAccess::onClickRemoveBannedAgent()
 	accessRemoveCore(ESTATE_ACCESS_BANNED_AGENT_REMOVE, "EstateBannedAgentRemove", "banned_avatar_name_list");
 }
 
+void LLPanelEstateAccess::onClickCopyAllowedList()
+{
+	copyListToClipboard("allowed_avatar_name_list");
+}
+
+void LLPanelEstateAccess::onClickCopyAllowedGroupList()
+{
+	copyListToClipboard("allowed_group_name_list");
+}
+
+void LLPanelEstateAccess::onClickCopyBannedList()
+{
+	copyListToClipboard("banned_avatar_name_list");
+}
+
 // static
 void LLPanelEstateAccess::onClickAddEstateManager()
 {
@@ -4164,6 +4183,35 @@ void LLPanelEstateAccess::searchAgent(LLNameListCtrl* listCtrl, const std::strin
 	}
 }
 
+void LLPanelEstateAccess::copyListToClipboard(std::string list_name)
+{
+	LLPanelEstateAccess* panel = LLFloaterRegionInfo::getPanelAccess();
+	if (!panel) return;
+	LLNameListCtrl* name_list = panel->getChild<LLNameListCtrl>(list_name);
+	if (!name_list) return;
+
+	std::vector<LLScrollListItem*> list_vector = name_list->getAllData();
+	if (list_vector.size() == 0) return;
+
+	LLSD::String list_to_copy;
+	for (std::vector<LLScrollListItem*>::const_iterator iter = list_vector.begin();
+		 iter != list_vector.end();
+		 iter++)
+	{
+		LLScrollListItem *item = (*iter);
+		if (item)
+		{
+			list_to_copy += item->getColumn(0)->getValue().asString();
+		}
+		if (std::next(iter) != list_vector.end())
+		{
+			list_to_copy += "\n";
+		}
+	}
+
+	LLClipboard::instance().copyToClipboard(utf8str_to_wstring(list_to_copy), 0, list_to_copy.length());
+}
+
 bool LLPanelEstateAccess::refreshFromRegion(LLViewerRegion* region)
 {
 	updateLists();
diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h
index 5b4c81000e1..e2453181d27 100644
--- a/indra/newview/llfloaterregioninfo.h
+++ b/indra/newview/llfloaterregioninfo.h
@@ -512,10 +512,13 @@ class LLPanelEstateAccess : public LLPanelRegionInfo
 private:
 	void onClickAddAllowedAgent();
 	void onClickRemoveAllowedAgent();
+	void onClickCopyAllowedList();
 	void onClickAddAllowedGroup();
 	void onClickRemoveAllowedGroup();
+	void onClickCopyAllowedGroupList();
 	void onClickAddBannedAgent();
 	void onClickRemoveBannedAgent();
+    void onClickCopyBannedList();
 	void onClickAddEstateManager();
 	void onClickRemoveEstateManager();
 	void onAllowedSearchEdit(const std::string& search_string);
@@ -543,6 +546,7 @@ class LLPanelEstateAccess : public LLPanelRegionInfo
 	static void requestEstateGetAccessCoro(std::string url);
 
 	void searchAgent(LLNameListCtrl* listCtrl, const std::string& search_string);
+	void copyListToClipboard(std::string list_name);
 
 	bool mPendingUpdate;
 };
diff --git a/indra/newview/skins/default/xui/en/panel_region_access.xml b/indra/newview/skins/default/xui/en/panel_region_access.xml
index 4a78cdacf0d..4be073195b7 100644
--- a/indra/newview/skins/default/xui/en/panel_region_access.xml
+++ b/indra/newview/skins/default/xui/en/panel_region_access.xml
@@ -133,7 +133,15 @@
             text_color="Black"
             text_pad_left="10"
             top="4"
-            width="498" />
+            width="440" />
+           <button
+            follows="left|top"
+            height="23"
+            label="Copy"
+            layout="topleft"
+            left_pad="10"
+            name="copy_allowed_list_btn"
+            width="40" />
         </panel>
    <text
      type="string"
@@ -227,7 +235,15 @@
             text_color="Black"
             text_pad_left="10"
             top="4"
-            width="498" />
+            width="440" />
+           <button
+            follows="left|top"
+            height="23"
+            label="Copy"
+            layout="topleft"
+            left_pad="10"
+            name="copy_allowed_group_list_btn"
+            width="40" />
         </panel>
     <text
      type="string"
@@ -321,7 +337,15 @@
             text_color="Black"
             text_pad_left="10"
             top="4"
-            width="498" />
+            width="440" />
+               <button
+                follows="left|top"
+                height="23"
+                label="Copy"
+                layout="topleft"
+                left_pad="10"
+                name="copy_banned_list_btn"
+                width="40" />
         </panel>
     <text
      type="string"
-- 
GitLab