diff --git a/indra/llui/lfidbearer.h b/indra/llui/lfidbearer.h index 90a485b30..e56ba8560 100644 --- a/indra/llui/lfidbearer.h +++ b/indra/llui/lfidbearer.h @@ -1,6 +1,7 @@ /* Copyright (C) 2019 Liru Færs * * LFIDBearer is a class that holds an ID or IDs that menus can use + * This class also bears the type of ID/IDs that it is holding * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -26,15 +27,27 @@ class LLView; struct LFIDBearer { + enum Type : S8 + { + MULTIPLE = -2, + NONE = -1, + AVATAR = 0, + GROUP, + OBJECT, + COUNT + }; + virtual ~LFIDBearer() { if (sActive == this) sActive = nullptr; } virtual LLUUID getStringUUIDSelectedItem() const = 0; virtual uuid_vec_t getSelectedIDs() const { return { getStringUUIDSelectedItem() }; } virtual S32 getNumSelected() const { return getStringUUIDSelectedItem().notNull(); } + virtual Type getSelectedType() const { return AVATAR; } template static T* getActive() { return static_cast(sActive); } static LLUUID getActiveSelectedID() { return sActive->getStringUUIDSelectedItem(); } static uuid_vec_t getActiveSelectedIDs() { return sActive->getSelectedIDs(); } static S32 getActiveNumSelected() { return sActive->getNumSelected(); } + static Type getActiveType() { return sActive->getSelectedType(); } void showMenu(LLView* self, LLMenuGL* menu, S32 x, S32 y); static void addCommonMenu(LLMenuGL* menu) { sMenus.push_back(menu); } diff --git a/indra/newview/llimpanel.cpp b/indra/newview/llimpanel.cpp index 9bc06a915..16c605dfa 100644 --- a/indra/newview/llimpanel.cpp +++ b/indra/newview/llimpanel.cpp @@ -1128,7 +1128,7 @@ void LLFloaterIMPanel::removeDynamicFocus() findChild("instant_message_flyout")->remove(getString("focus")); } -void copy_profile_uri(const LLUUID& id, bool group = false); +void copy_profile_uri(const LLUUID& id, LFIDBearer::Type type = LFIDBearer::AVATAR); void LLFloaterIMPanel::onFlyoutCommit(LLComboBox* flyout, const LLSD& value) { diff --git a/indra/newview/llnamelistctrl.cpp b/indra/newview/llnamelistctrl.cpp index cf9e47390..2cb3ba96b 100644 --- a/indra/newview/llnamelistctrl.cpp +++ b/indra/newview/llnamelistctrl.cpp @@ -142,6 +142,32 @@ BOOL LLNameListCtrl::handleDoubleClick(S32 x, S32 y, MASK mask) return handled; } +#define CONVERT_TO_RETTYPE(nametype, rettype) \ +nametype: \ +{ \ + if (ret == NONE) \ + ret = rettype; \ + else if (ret != rettype) \ + return MULTIPLE; \ + break; \ +} + +LFIDBearer::Type LLNameListCtrl::getSelectedType() const +{ + auto ret = NONE; + for (const auto& item : getAllSelected()) + { + switch (static_cast(item)->getNameType()) + { + CONVERT_TO_RETTYPE(case LLNameListItem::INDIVIDUAL, AVATAR); + CONVERT_TO_RETTYPE(case LLNameListItem::GROUP, GROUP) + CONVERT_TO_RETTYPE(default, COUNT) // Invalid, but just use count instead + } + } + return ret; +} +#undef CONVERT_TO_RETTYPE + // public void LLNameListCtrl::addGroupNameItem(const LLUUID& group_id, EAddPosition pos, BOOL enabled) diff --git a/indra/newview/llnamelistctrl.h b/indra/newview/llnamelistctrl.h index ba0e6ebb4..4cb426dfe 100644 --- a/indra/newview/llnamelistctrl.h +++ b/indra/newview/llnamelistctrl.h @@ -149,6 +149,8 @@ public: std::string& tooltip_msg); BOOL handleDoubleClick(S32 x, S32 y, MASK mask) override; + Type getSelectedType() const override final; + void setAllowCallingCardDrop(BOOL b) { mAllowCallingCardDrop = b; } void sortByName(BOOL ascending); diff --git a/indra/newview/llnameui.h b/indra/newview/llnameui.h index d5854fb0a..842f79712 100644 --- a/indra/newview/llnameui.h +++ b/indra/newview/llnameui.h @@ -49,6 +49,7 @@ struct LLNameUI : public LFIDBearer LLUUID getStringUUIDSelectedItem() const override final { return mNameID; } S32 getNumSelected() const override final { return 1; } + Type getSelectedType() const override final { return mIsGroup ? GROUP : AVATAR; } void setIsGroup(bool is_group); void setNameID(const LLUUID& name_id, bool is_group); diff --git a/indra/newview/llpanelavatar.cpp b/indra/newview/llpanelavatar.cpp index c48abdf58..dfad5f071 100644 --- a/indra/newview/llpanelavatar.cpp +++ b/indra/newview/llpanelavatar.cpp @@ -1399,7 +1399,7 @@ void LLPanelAvatar::onClickCopy(const LLSD& val) } else { - void copy_profile_uri(const LLUUID& id, bool group = false); + void copy_profile_uri(const LLUUID& id, LFIDBearer::Type type = LFIDBearer::AVATAR); copy_profile_uri(mAvatarID); } } diff --git a/indra/newview/llpanelgroup.cpp b/indra/newview/llpanelgroup.cpp index 4e65628bb..55841cd17 100644 --- a/indra/newview/llpanelgroup.cpp +++ b/indra/newview/llpanelgroup.cpp @@ -34,6 +34,7 @@ #include "llpanelgroup.h" // Library includes +#include "lfidbearer.h" #include "llbutton.h" #include "lltabcontainer.h" #include "lltextbox.h" @@ -129,7 +130,7 @@ void LLPanelGroupTab::handleClickHelp() } } -void copy_profile_uri(const LLUUID& id, bool group); +void copy_profile_uri(const LLUUID& id, LFIDBearer::Type type); LLPanelGroup::LLPanelGroup(const LLUUID& group_id) : LLPanel("PanelGroup", LLRect(), FALSE), @@ -161,7 +162,7 @@ LLPanelGroup::LLPanelGroup(const LLUUID& group_id) LLGroupMgr::getInstance()->addObserver(this); - mCommitCallbackRegistrar.add("Group.CopyURI", boost::bind(copy_profile_uri, boost::ref(mID), true)); + mCommitCallbackRegistrar.add("Group.CopyURI", boost::bind(copy_profile_uri, boost::ref(mID), LFIDBearer::GROUP)); // Pass on construction of this panel to the control factory. LLUICtrlFactory::getInstance()->buildPanel(this, "panel_group.xml", &getFactoryMap()); } diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 47a6e2223..1d5dcad4b 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -94,6 +94,7 @@ #include "llframestats.h" #include "llavataractions.h" #include "llgivemoney.h" +#include "llgroupactions.h" #include "llgroupmgr.h" #include "llhoverview.h" #include "llhudeffecttrail.h" @@ -9034,16 +9035,19 @@ template T* get_focused() return t; } -const LLWString get_slurl_for(const LLUUID& id, bool group) +const std::string get_slurl_for(const LLUUID& id, LFIDBearer::Type type) { - std::string str("secondlife:///app/"); - str += group ? "group/" : "agent/"; - return utf8str_to_wstring(str + id.asString() + "/about"); + return type == LFIDBearer::GROUP ? LLGroupActions::getSLURL(id) : LLAvatarActions::getSLURL(id); } -void copy_profile_uri(const LLUUID& id, bool group) +const LLWString get_wslurl_for(const LLUUID& id, LFIDBearer::Type type) { - gViewerWindow->getWindow()->copyTextToClipboard(get_slurl_for(id, group)); + return utf8str_to_wstring(get_slurl_for(id, type)); +} + +void copy_profile_uri(const LLUUID& id, LFIDBearer::Type type) +{ + gViewerWindow->getWindow()->copyTextToClipboard(get_wslurl_for(id, type)); } class ListEnableAnySelected : public view_listener_t @@ -9145,7 +9149,7 @@ class ListCopySLURL : public view_listener_t { bool handleEvent(LLPointer event, const LLSD& userdata) { - copy_profile_uri(LFIDBearer::getActiveSelectedID(), false); + copy_profile_uri(LFIDBearer::getActiveSelectedID(), LFIDBearer::getActiveType()); return true; } }; @@ -9242,7 +9246,12 @@ class ListShowProfile : public view_listener_t { bool handleEvent(LLPointer event, const LLSD& userdata) { - LLAvatarActions::showProfiles(LFIDBearer::getActiveSelectedIDs()); + switch (LFIDBearer::getActiveType()) + { + case LFIDBearer::AVATAR: LLAvatarActions::showProfiles(LFIDBearer::getActiveSelectedIDs()); break; + case LFIDBearer::GROUP: LLGroupActions::showProfiles(LFIDBearer::getActiveSelectedIDs()); break; + default: break; + } return true; } };