From f97f281c4f7d1407d2518067ff73c77fa975132c Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Wed, 8 Jun 2011 08:08:14 -0700 Subject: Added copy group link button to create clickable links to groups in the viewer (cherry picked from commit 18464593de52a31fa098f5ee5e543d9a44f1889e) --- linden/indra/newview/llpanelgroupgeneral.cpp | 44 ++++++++++++++++++++++ linden/indra/newview/llpanelgroupgeneral.h | 2 + linden/indra/newview/llurldispatcher.cpp | 12 ++++++ linden/indra/newview/llurldispatcher.h | 2 + .../default/xui/en-us/panel_group_general.xml | 10 ++++- 5 files changed, 68 insertions(+), 2 deletions(-) (limited to 'linden') diff --git a/linden/indra/newview/llpanelgroupgeneral.cpp b/linden/indra/newview/llpanelgroupgeneral.cpp index 8c522cc..e466f05 100644 --- a/linden/indra/newview/llpanelgroupgeneral.cpp +++ b/linden/indra/newview/llpanelgroupgeneral.cpp @@ -38,6 +38,8 @@ #include "lluictrlfactory.h" #include "llagent.h" +#include "llchat.h" +#include "llfloaterchat.h" #include "roles_constants.h" #include "llfloateravatarinfo.h" #include "llfloatergroupinfo.h" @@ -56,6 +58,7 @@ #include "lltextbox.h" #include "lltexteditor.h" #include "lltexturectrl.h" +#include "llurldispatcher.h" #include "llviewercontrol.h" #include "llviewerwindow.h" @@ -144,6 +147,13 @@ BOOL LLPanelGroupGeneral::postBuild() mBtnInfo->setCallbackUserData(this); } + mBtnCopyLink = getChild("copy_link_button", recurse); + if ( mBtnCopyLink ) + { + mBtnCopyLink->setClickedCallback(onClickCopyLink); + mBtnCopyLink->setCallbackUserData(this); + } + LLTextBox* founder = getChild("founder_name"); if (founder) { @@ -269,6 +279,7 @@ BOOL LLPanelGroupGeneral::postBuild() mBtnJoinGroup->setVisible(FALSE); mBtnInfo->setVisible(FALSE); + mBtnCopyLink->setVisible(FALSE); mGroupName->setVisible(FALSE); } @@ -404,6 +415,39 @@ bool LLPanelGroupGeneral::joinDlgCB(const LLSD& notification, const LLSD& respon } // static +void LLPanelGroupGeneral::onClickCopyLink(void* userdata) +{ + LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)userdata; + + if (!self || (self->mGroupID).isNull()) return; + + LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(self->mGroupID); + + // make sure we don't have junk + if (gdatap) + { + std::string buffer = LLURLDispatcher::createGroupJoinLink(gdatap->getID()); + + // Say same info in chat -- MC + LLStringUtil::format_map_t targs; + targs["[SLURL]"] = buffer; + std::string msg = self->getString("copy_group_link_info"); + LLStringUtil::format(msg, targs); + + LLChat chat; + chat.mSourceType = CHAT_SOURCE_SYSTEM; + chat.mText = msg; + LLFloaterChat::addChat(chat); + + gViewerWindow->mWindow->copyTextToClipboard(utf8str_to_wstring(buffer)); + } + else + { + llwarns << "Trying to copy group slurl link with no group data!" << llendl; + } +} + +// static void LLPanelGroupGeneral::openProfile(void* data) { LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)data; diff --git a/linden/indra/newview/llpanelgroupgeneral.h b/linden/indra/newview/llpanelgroupgeneral.h index c4572e2..9e39125 100644 --- a/linden/indra/newview/llpanelgroupgeneral.h +++ b/linden/indra/newview/llpanelgroupgeneral.h @@ -76,6 +76,7 @@ private: static void onClickInfo(void* userdata); static void onReceiveNotices(LLUICtrl* ctrl, void* data); static void openProfile(void* data); + static void onClickCopyLink(void* userdata); static bool joinDlgCB(const LLSD& notification, const LLSD& response); @@ -98,6 +99,7 @@ private: LLTextEditor *mEditCharter; LLButton *mBtnJoinGroup; LLButton *mBtnInfo; + LLButton *mBtnCopyLink; LLNameListCtrl *mListVisibleMembers; diff --git a/linden/indra/newview/llurldispatcher.cpp b/linden/indra/newview/llurldispatcher.cpp index 460ffb2..0d6f6d7 100644 --- a/linden/indra/newview/llurldispatcher.cpp +++ b/linden/indra/newview/llurldispatcher.cpp @@ -402,6 +402,18 @@ std::string LLURLDispatcherImpl::stripProtocol(const std::string& url) return stripped; } +// static +std::string LLURLDispatcher::createGroupJoinLink(const LLUUID& group_id) +{ + std::string slurl = ""; + if (group_id.notNull()) + { + //secondlife:///app/group/uuid/about + slurl = SLURL_SECONDLIFE_PREFIX + "/" + SLURL_APP_TOKEN + "group/" + group_id.asString() + "/about"; + } + return slurl; +} + //--------------------------------------------------------------------------- // Teleportation links are handled here because they are tightly coupled // to URL parsing and sim-fragment parsing diff --git a/linden/indra/newview/llurldispatcher.h b/linden/indra/newview/llurldispatcher.h index c947e5e..cfdc2db 100644 --- a/linden/indra/newview/llurldispatcher.h +++ b/linden/indra/newview/llurldispatcher.h @@ -66,6 +66,8 @@ public: static std::string buildSLURL(const std::string& regionname, S32 x, S32 y, S32 z); // builds: http://slurl.com/secondlife/RegionName/x/y/z/ + + static std::string createGroupJoinLink(const LLUUID& group_id); }; #endif diff --git a/linden/indra/newview/skins/default/xui/en-us/panel_group_general.xml b/linden/indra/newview/skins/default/xui/en-us/panel_group_general.xml index b032b09..2974490 100644 --- a/linden/indra/newview/skins/default/xui/en-us/panel_group_general.xml +++ b/linden/indra/newview/skins/default/xui/en-us/panel_group_general.xml @@ -8,9 +8,12 @@ general Group Preferences and member options. Hover your mouse over the options for more help. - + General group information has changed. + + Copied group link: [SLURL] +