diff options
| author | mberezhnoy <mberezhnoy@productengine.com> | 2013-06-13 20:21:24 +0300 | 
|---|---|---|
| committer | mberezhnoy <mberezhnoy@productengine.com> | 2013-06-13 20:21:24 +0300 | 
| commit | 882ab04ef3e412716f0f034e348007b5f3016f3c (patch) | |
| tree | 99f75c9b55a652f0709e64193512b4c43fe180c5 | |
| parent | 452832b26f0d4c4e94da7ebd9b98f2fc337950c3 (diff) | |
CHUI-809 (Right-click menu on user name in compat chat mode doesn't have "IM")
Added callback for friendship checking
| -rwxr-xr-x | indra/llui/lltextbase.cpp | 24 | ||||
| -rwxr-xr-x | indra/llui/lltextbase.h | 6 | ||||
| -rwxr-xr-x | indra/llui/llurlaction.cpp | 8 | ||||
| -rwxr-xr-x | indra/llui/llurlaction.h | 1 | ||||
| -rwxr-xr-x | indra/llui/llurlentry.cpp | 4 | ||||
| -rwxr-xr-x | indra/newview/llchathistory.cpp | 1 | ||||
| -rwxr-xr-x | indra/newview/llpanelprofile.cpp | 6 | ||||
| -rwxr-xr-x | indra/newview/skins/default/xui/en/menu_url_agent.xml | 9 | ||||
| -rwxr-xr-x | indra/newview/skins/default/xui/en/strings.xml | 3 | 
9 files changed, 60 insertions, 2 deletions
| diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index a53a38124c..e2a39d89e4 100755 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -180,6 +180,7 @@ LLTextBase::Params::Params()  LLTextBase::LLTextBase(const LLTextBase::Params &p)   :	LLUICtrl(p, LLTextViewModelPtr(new LLTextViewModel)),  	mURLClickSignal(NULL), +	mIsFriendSignal(NULL),  	mMaxTextByteLength( p.max_text_length ),  	mFont(p.font),  	mFontShadow(p.font_shadow), @@ -1943,6 +1944,7 @@ void LLTextBase::createUrlContextMenu(S32 x, S32 y, const std::string &in_url)  	registrar.add("Url.Teleport", boost::bind(&LLUrlAction::teleportToLocation, url));  	registrar.add("Url.ShowProfile", boost::bind(&LLUrlAction::showProfile, url));  	registrar.add("Url.AddFriend", boost::bind(&LLUrlAction::addFriend, url)); +	registrar.add("Url.RemoveFriend", boost::bind(&LLUrlAction::removeFriend, url));  	registrar.add("Url.SendIM", boost::bind(&LLUrlAction::sendIM, url));  	registrar.add("Url.ShowOnMap", boost::bind(&LLUrlAction::showLocationOnMap, url));  	registrar.add("Url.CopyLabel", boost::bind(&LLUrlAction::copyLabelToClipboard, url)); @@ -1952,6 +1954,19 @@ void LLTextBase::createUrlContextMenu(S32 x, S32 y, const std::string &in_url)  	delete mPopupMenu;  	mPopupMenu = LLUICtrlFactory::getInstance()->createFromFile<LLContextMenu>(xui_file, LLMenuGL::sMenuContainer,  																		 LLMenuHolderGL::child_registry_t::instance());	 +	if (mIsFriendSignal) +	{ +		bool isFriend = (*mIsFriendSignal)(LLUUID(LLUrlAction::getUserID(url))); +		LLView* addFriendButton = mPopupMenu->getChild<LLView>("add_friend"); +		LLView* removeFriendButton = mPopupMenu->getChild<LLView>("remove_friend"); + +		if (addFriendButton && removeFriendButton) +		{ +			addFriendButton->setEnabled(!isFriend); +			removeFriendButton->setEnabled(isFriend); +		} +	} +	  	if (mPopupMenu)  	{  		mPopupMenu->show(x, y); @@ -2932,6 +2947,15 @@ boost::signals2::connection LLTextBase::setURLClickedCallback(const commit_signa  	return mURLClickSignal->connect(cb);  } +boost::signals2::connection LLTextBase::setIsFriendCallback(const is_friend_signal_t::slot_type& cb) +{ +	if (!mIsFriendSignal) +	{ +		mIsFriendSignal = new is_friend_signal_t(); +	} +	return mIsFriendSignal->connect(cb); +} +  //  // LLTextSegment  // diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index 2fb58d468a..a74e97cac8 100755 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -258,6 +258,8 @@ public:  	friend class LLNormalTextSegment;  	friend class LLUICtrlFactory; +	typedef boost::signals2::signal<bool (const LLUUID& user_id)> is_friend_signal_t; +  	struct LineSpacingParams : public LLInitParam::ChoiceBlock<LineSpacingParams>  	{  		Alternative<F32>	multiple; @@ -434,6 +436,7 @@ public:  	virtual void			appendImageSegment(const LLStyle::Params& style_params);  	virtual void			appendWidget(const LLInlineViewSegment::Params& params, const std::string& text, bool allow_undo);  	boost::signals2::connection setURLClickedCallback(const commit_signal_t::slot_type& cb); +	boost::signals2::connection setIsFriendCallback(const is_friend_signal_t::slot_type& cb);  	void					setWordWrap(bool wrap);  	LLScrollContainer*		getScrollContainer() const { return mScroller; } @@ -648,6 +651,9 @@ protected:  	// Fired when a URL link is clicked  	commit_signal_t*			mURLClickSignal; +	// Used to check if user with given ID is avatar's friend +	is_friend_signal_t*         mIsFriendSignal; +  	LLUIString					mLabel;	// text label that is visible when no user text provided  }; diff --git a/indra/llui/llurlaction.cpp b/indra/llui/llurlaction.cpp index f51aeaec13..cf707d87dc 100755 --- a/indra/llui/llurlaction.cpp +++ b/indra/llui/llurlaction.cpp @@ -188,3 +188,11 @@ void LLUrlAction::addFriend(std::string url)  	}  } +void LLUrlAction::removeFriend(std::string url) +{ +	std::string id_str = getUserID(url); +	if (LLUUID::validate(id_str)) +	{ +		executeSLURL("secondlife:///app/agent/" + id_str + "/removefriend"); +	} +} diff --git a/indra/llui/llurlaction.h b/indra/llui/llurlaction.h index e31cd71a20..65283394a0 100755 --- a/indra/llui/llurlaction.h +++ b/indra/llui/llurlaction.h @@ -79,6 +79,7 @@ public:  	static std::string getUserID(std::string url);  	static void sendIM(std::string url);  	static void addFriend(std::string url); +	static void LLUrlAction::removeFriend(std::string url);  	/// specify the callbacks to enable this class's functionality  	typedef boost::function<void (const std::string&)> url_callback_t; diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp index 99ee688888..b1cc502c4b 100755 --- a/indra/llui/llurlentry.cpp +++ b/indra/llui/llurlentry.cpp @@ -504,6 +504,10 @@ std::string localize_slapp_label(const std::string& url, const std::string& full  	{  		return LLTrans::getString("SLappAgentRequestFriend") + " " + full_name;  	} +	if (LLStringUtil::endsWith(url, "/removefriend")) +	{ +		return LLTrans::getString("SLappAgentRemoveFriend") + " " + full_name; +	}  	return full_name;  } diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp index 0f138873ac..af3c6eff11 100755 --- a/indra/newview/llchathistory.cpp +++ b/indra/newview/llchathistory.cpp @@ -628,6 +628,7 @@ LLChatHistory::LLChatHistory(const LLChatHistory::Params& p)  	editor_params.enabled = false; // read only  	editor_params.show_context_menu = "true";  	mEditor = LLUICtrlFactory::create<LLTextEditor>(editor_params, this); +	mEditor->setIsFriendCallback(LLAvatarActions::isFriend);  }  LLSD LLChatHistory::getValue() const diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index e2e7006773..3b95b46476 100755 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -137,6 +137,12 @@ public:  			return true;  		} +		if (verb == "removefriend") +		{ +			LLAvatarActions::removeFriendDialog(avatar_id); +			return true; +		} +  		if (verb == "mute")  		{  			if (! LLAvatarActions::isBlocked(avatar_id)) diff --git a/indra/newview/skins/default/xui/en/menu_url_agent.xml b/indra/newview/skins/default/xui/en/menu_url_agent.xml index 7cd56f257a..e8b6116026 100755 --- a/indra/newview/skins/default/xui/en/menu_url_agent.xml +++ b/indra/newview/skins/default/xui/en/menu_url_agent.xml @@ -21,8 +21,15 @@       layout="topleft"       name="add_friend">          <menu_item_call.on_click -         function="Url.AddFriend" />         +         function="Url.AddFriend" />      </menu_item_call> +    <menu_item_call +     label="Remove Friend..." +     layout="topleft" +     name="remove_friend"> +        <menu_item_call.on_click +         function="Url.RemoveFriend" /> +        </menu_item_call>      <menu_item_separator       layout="topleft" />      <menu_item_call diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index 3b57ff5fd6..521aed698a 100755 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -209,7 +209,8 @@ Please try logging in again in a minute.</string>  	<string name="SLappAgentIM">IM</string>  	<string name="SLappAgentPay">Pay</string>  	<string name="SLappAgentOfferTeleport">Offer Teleport to </string> -	<string name="SLappAgentRequestFriend">Friend Request </string> +	<string name="SLappAgentRequestFriend">Friend Request</string> +  <string name="SLappAgentRemoveFriend">Friend Removal</string>  	<!-- ButtonToolTips, llfloater.cpp -->  	<string name="BUTTON_CLOSE_DARWIN">Close (⌘W)</string> | 
