MAINT-5463 FIXED Add hovertext to the official link badge in chat/IM, etc.

meow-7.2.2
Mnikolenko ProductEngine 2015-08-10 11:15:50 +03:00
parent 96e641b329
commit 4ab4c6da02
3 changed files with 42 additions and 14 deletions

View File

@ -37,6 +37,7 @@
#include "lltextparser.h"
#include "lltextutil.h"
#include "lltooltip.h"
#include "lltrans.h"
#include "lluictrl.h"
#include "llurlaction.h"
#include "llurlregistry.h"
@ -2060,6 +2061,10 @@ void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Para
// add icon before url if need
LLTextUtil::processUrlMatch(&match, this, isContentTrusted() || match.isTrusted());
if ((isContentTrusted() || match.isTrusted()) && !match.getIcon().empty() )
{
setLastSegmentToolTip(LLTrans::getString("TooltipSLIcon"));
}
// output the styled Url
appendAndHighlightTextImpl(match.getLabel(), part, link_params, match.underlineOnHoverOnly());
@ -2068,16 +2073,9 @@ void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Para
// set the tooltip for the Url label
if (tooltip_required)
{
segment_set_t::iterator it = getSegIterContaining(getLength()-1);
if (it != mSegments.end())
{
LLTextSegmentPtr segment = *it;
segment->setToolTip(match.getTooltip());
}
setLastSegmentToolTip(match.getTooltip());
}
// show query part of url with gray color only for LLUrlEntryHTTP url entries
std::string label = match.getQuery();
if (label.size())
@ -2089,12 +2087,7 @@ void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Para
// set the tooltip for the query part of url
if (tooltip_required)
{
segment_set_t::iterator it = getSegIterContaining(getLength()-1);
if (it != mSegments.end())
{
LLTextSegmentPtr segment = *it;
segment->setToolTip(match.getTooltip());
}
setLastSegmentToolTip(match.getTooltip());
}
}
@ -2121,6 +2114,16 @@ void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Para
}
}
void LLTextBase::setLastSegmentToolTip(const std::string &tooltip)
{
segment_set_t::iterator it = getSegIterContaining(getLength()-1);
if (it != mSegments.end())
{
LLTextSegmentPtr segment = *it;
segment->setToolTip(tooltip);
}
}
static LLTrace::BlockTimerStatHandle FTM_APPEND_TEXT("Append Text");
void LLTextBase::appendText(const std::string &new_text, bool prepend_newline, const LLStyle::Params& input_params)
@ -3571,6 +3574,22 @@ S32 LLImageTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 lin
return 0;
}
BOOL LLImageTextSegment::handleToolTip(S32 x, S32 y, MASK mask)
{
if (!mTooltip.empty())
{
LLToolTipMgr::instance().show(mTooltip);
return TRUE;
}
return FALSE;
}
void LLImageTextSegment::setToolTip(const std::string& tooltip)
{
mTooltip = tooltip;
}
F32 LLImageTextSegment::draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRect& draw_rect)
{
if ( (start >= 0) && (end <= mEnd - mStart))

View File

@ -241,9 +241,15 @@ public:
S32 getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars) const;
F32 draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRect& draw_rect);
/*virtual*/ BOOL handleToolTip(S32 x, S32 y, MASK mask);
/*virtual*/ void setToolTip(const std::string& tooltip);
private:
class LLTextBase& mEditor;
LLStyleConstSP mStyle;
protected:
std::string mTooltip;
};
typedef LLPointer<LLTextSegment> LLTextSegmentPtr;
@ -392,6 +398,8 @@ public:
const std::string& getLabel() { return mLabel.getString(); }
const LLWString& getWlabel() { return mLabel.getWString();}
void setLastSegmentToolTip(const std::string &tooltip);
/**
* If label is set, draws text label (which is LLLabelTextSegment)
* that is visible when no user text provided

View File

@ -238,6 +238,7 @@ Please try logging in again in a minute.</string>
<string name="TooltipMustSingleDrop">Only a single item can be dragged here</string>
<string name="TooltipTooManyWearables">You can't wear a folder containing more than [AMOUNT] items. You can change this limit in Advanced > Show Debug Settings > WearFolderLimit.</string>
<string name="TooltipPrice" value="L$[AMOUNT]: "/>
<string name="TooltipSLIcon">This links to a page on the official SecondLife.com or LindenLab.com domain.</string>
<string name="TooltipOutboxDragToWorld">You can't rez items from the Marketplace Listings folder</string>
<string name="TooltipOutboxWorn">You can't put items you are wearing in the Marketplace Listings folder</string>