diff options
author | andreykproductengine <andreykproductengine@lindenlab.com> | 2019-04-18 19:26:37 +0300 |
---|---|---|
committer | andreykproductengine <andreykproductengine@lindenlab.com> | 2019-04-18 19:26:37 +0300 |
commit | 8a3fce881fbf971046be50d9d7198e58772e3164 (patch) | |
tree | 7dd98d630eb24559a36190dbb36c6eba4266c104 /indra/newview/llpanelprofile.cpp | |
parent | b5f842183958f5de8a09156510ede53ac34a5310 (diff) |
SL-10791 [Legacy Profiles] Functionality to copy agent id and name from profile
Diffstat (limited to 'indra/newview/llpanelprofile.cpp')
-rw-r--r-- | indra/newview/llpanelprofile.cpp | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index e5fa8de6a0..d40f874f24 100644 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -34,7 +34,7 @@ // UI #include "llavatariconctrl.h" -// #include "llclipboard.h" //gClipboard +#include "llclipboard.h" #include "llcheckboxctrl.h" #include "lllineeditor.h" #include "llloadingindicator.h" @@ -269,8 +269,10 @@ BOOL LLPanelProfileSecondLife::postBuild() mGroupInviteButton = getChild<LLButton>("group_invite"); mPayButton = getChild<LLButton>("pay"); mIMButton = getChild<LLButton>("im"); + mCopyMenuButton = getChild<LLMenuButton>("copy_btn"); mStatusText->setVisible(FALSE); + mCopyMenuButton->setVisible(FALSE); mAddFriendButton->setCommitCallback(boost::bind(&LLPanelProfileSecondLife::onAddFriendButtonClick, this)); mIMButton->setCommitCallback(boost::bind(&LLPanelProfileSecondLife::onIMButtonClick, this)); @@ -283,6 +285,9 @@ BOOL LLPanelProfileSecondLife::postBuild() mDisplayNameButton->setCommitCallback(boost::bind(&LLPanelProfileSecondLife::onClickSetName, this)); mSecondLifePic->setCommitCallback(boost::bind(&LLPanelProfileSecondLife::onCommitTexture, this)); + LLUICtrl::CommitCallbackRegistry::ScopedRegistrar commit; + commit.add("Profile.CopyName", [this](LLUICtrl*, const LLSD& userdata) { onCommitMenu(userdata); }); + LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable; enable.add("Profile.EnableCall", [this](LLUICtrl*, const LLSD&) { return mVoiceStatus; }); enable.add("Profile.EnableGod", [](LLUICtrl*, const LLSD&) { return gAgent.isGodlike(); }); @@ -291,6 +296,7 @@ BOOL LLPanelProfileSecondLife::postBuild() mGroupList->setReturnCallback(boost::bind(&LLPanelProfileSecondLife::openGroupProfile, this)); LLVoiceClient::getInstance()->addObserver((LLVoiceClientStatusObserver*)this); + mCopyMenuButton->setMenu("menu_name_field.xml", LLMenuButton::MP_BOTTOM_RIGHT); return TRUE; } @@ -407,6 +413,7 @@ void LLPanelProfileSecondLife::resetData() mDescriptionEdit->setValue(LLStringUtil::null); mStatusText->setVisible(FALSE); + mCopyMenuButton->setVisible(FALSE); mGroups.clear(); mGroupList->setGroups(mGroups); } @@ -467,6 +474,7 @@ void LLPanelProfileSecondLife::onAvatarNameCache(const LLUUID& agent_id, const L mAvatarNameCacheConnection.disconnect(); getChild<LLUICtrl>("complete_name")->setValue( av_name.getCompleteName() ); + mCopyMenuButton->setVisible(TRUE); } void LLPanelProfileSecondLife::fillCommonData(const LLAvatarData* avatar_data) @@ -763,6 +771,33 @@ void LLPanelProfileSecondLife::onCommitTexture() } } +void LLPanelProfileSecondLife::onCommitMenu(const LLSD& userdata) +{ + LLAvatarName av_name; + if (!LLAvatarNameCache::get(getAvatarId(), &av_name)) + { + // shouldn't happen, button(menu) is supposed to be invisible while name is fetching + LL_WARNS() << "Failed to get agent data" << LL_ENDL; + return; + } + + const std::string item_name = userdata.asString(); + LLWString wstr; + if (item_name == "display") + { + wstr = utf8str_to_wstring(av_name.getDisplayName()); + } + else if (item_name == "name") + { + wstr = utf8str_to_wstring(av_name.getAccountName()); + } + else if (item_name == "id") + { + wstr = utf8str_to_wstring(getAvatarId().asString()); + } + LLClipboard::instance().copyToClipboard(wstr, 0, wstr.size()); +} + void LLPanelProfileSecondLife::onAvatarNameCacheSetName(const LLUUID& agent_id, const LLAvatarName& av_name) { if (av_name.getDisplayName().empty()) |