Skip to content

Commit 50108bf

Browse files
#4011 Add conversation list highlight for chat mention
1 parent ed70509 commit 50108bf

File tree

12 files changed

+59
-11
lines changed

12 files changed

+59
-11
lines changed

indra/llui/llfolderviewitem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class LLFolderViewItem : public LLView
154154
virtual bool isHighlightActive();
155155
virtual bool isFadeItem();
156156
virtual bool isFlashing() { return false; }
157-
virtual void setFlashState(bool) { }
157+
virtual void setFlashState(bool, bool) { }
158158

159159
static LLFontGL* getLabelFontForStyle(U8 style);
160160
const LLFontGL* getLabelFont();

indra/llui/llurlentry.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,11 @@ LLUUID LLUrlEntryAgent::getID(const std::string &string) const
630630
return LLUUID(getIDStringFromUrl(string));
631631
}
632632

633+
bool LLUrlEntryAgent::isAgentID(const std::string& url) const
634+
{
635+
return sAgentID == getID(url);
636+
}
637+
633638
std::string LLUrlEntryAgent::getTooltip(const std::string &string) const
634639
{
635640
// return a tooltip corresponding to the URL type instead of the generic one

indra/llui/llurlentry.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class LLUrlEntryBase
103103
virtual bool getSkipProfileIcon(const std::string& string) const { return false; }
104104

105105
virtual LLUUID getID(const std::string &string) const { return LLUUID::null; }
106+
virtual bool isAgentID(const std::string& url) const { return false; }
106107

107108
bool isLinkDisabled() const;
108109

@@ -232,6 +233,8 @@ class LLUrlEntryAgent : public LLUrlEntryBase
232233
/*virtual*/ LLStyle::Params getStyle(const std::string &url) const;
233234
/*virtual*/ LLUUID getID(const std::string &string) const;
234235

236+
bool isAgentID(const std::string& url) const;
237+
235238
LLStyle::EUnderlineLink getUnderline(const std::string& string) const;
236239

237240
protected:

indra/llui/llurlregistry.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,3 +327,30 @@ void LLUrlRegistry::setKeybindingHandler(LLKeyBindingToStringHandler* handler)
327327
LLUrlEntryKeybinding *entry = (LLUrlEntryKeybinding*)mUrlEntryKeybinding;
328328
entry->setHandler(handler);
329329
}
330+
331+
bool LLUrlRegistry::containsAgentMention(const std::string& text)
332+
{
333+
// avoid costly regexes if there is clearly no URL in the text
334+
if (!stringHasUrl(text))
335+
{
336+
return false;
337+
}
338+
339+
try
340+
{
341+
boost::sregex_iterator it(text.begin(), text.end(), mUrlEntryAgentMention->getPattern());
342+
boost::sregex_iterator end;
343+
for (; it != end; ++it)
344+
{
345+
if (mUrlEntryAgentMention->isAgentID(it->str()))
346+
{
347+
return true;
348+
}
349+
}
350+
}
351+
catch (boost::regex_error&)
352+
{
353+
LL_INFOS() << "Regex error for: " << text << LL_ENDL;
354+
}
355+
return false;
356+
}

indra/llui/llurlregistry.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ class LLUrlRegistry : public LLSingleton<LLUrlRegistry>
9292
// Set handler for url registry to be capable of parsing and populating keybindings
9393
void setKeybindingHandler(LLKeyBindingToStringHandler* handler);
9494

95+
bool containsAgentMention(const std::string& text);
96+
9597
private:
9698
std::vector<LLUrlEntryBase *> mUrlEntry;
9799
LLUrlEntryBase* mUrlEntryTrusted;

indra/newview/llconversationview.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ LLConversationViewSession::LLConversationViewSession(const LLConversationViewSes
8686
mHasArrow(true),
8787
mIsInActiveVoiceChannel(false),
8888
mFlashStateOn(false),
89-
mFlashStarted(false)
89+
mFlashStarted(false),
90+
mIsAltFlashColor(false)
9091
{
9192
mFlashTimer = new LLFlashTimer();
9293
mAreChildrenInited = true; // inventory only
@@ -157,7 +158,7 @@ void LLConversationViewSession::destroyView()
157158
LLFolderViewFolder::destroyView();
158159
}
159160

160-
void LLConversationViewSession::setFlashState(bool flash_state)
161+
void LLConversationViewSession::setFlashState(bool flash_state, bool alternate_color)
161162
{
162163
if (flash_state && !mFlashStateOn)
163164
{
@@ -170,6 +171,7 @@ void LLConversationViewSession::setFlashState(bool flash_state)
170171

171172
mFlashStateOn = flash_state;
172173
mFlashStarted = false;
174+
mIsAltFlashColor = mFlashStateOn && (alternate_color || mIsAltFlashColor);
173175
mFlashTimer->stopFlashing();
174176
}
175177

@@ -288,7 +290,8 @@ void LLConversationViewSession::draw()
288290
startFlashing();
289291

290292
// draw highlight for selected items
291-
drawHighlight(show_context, true, sHighlightBgColor, sFlashBgColor, sFocusOutlineColor, sMouseOverColor);
293+
static LLUIColor alt_color = LLUIColorTable::instance().getColor("MentionFlashBgColor", DEFAULT_WHITE);
294+
drawHighlight(show_context, true, sHighlightBgColor, mIsAltFlashColor ? alt_color : sFlashBgColor, sFocusOutlineColor, sMouseOverColor);
292295

293296
// Draw children if root folder, or any other folder that is open. Do not draw children when animating to closed state or you get rendering overlap.
294297
bool draw_children = getRoot() == static_cast<LLFolderViewFolder*>(this) || isOpen();

indra/newview/llconversationview.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class LLConversationViewSession : public LLFolderViewFolder
9090

9191
virtual void refresh();
9292

93-
/*virtual*/ void setFlashState(bool flash_state);
93+
/*virtual*/ void setFlashState(bool flash_state, bool alternate_color = false);
9494
void setHighlightState(bool hihglight_state);
9595

9696
LLFloater* getSessionFloater();
@@ -111,6 +111,7 @@ class LLConversationViewSession : public LLFolderViewFolder
111111
LLFlashTimer* mFlashTimer;
112112
bool mFlashStateOn;
113113
bool mFlashStarted;
114+
bool mIsAltFlashColor;
114115

115116
bool mCollapsedMode;
116117
bool mHasArrow;

indra/newview/llfloaterimcontainer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2302,14 +2302,14 @@ bool LLFloaterIMContainer::isConversationLoggingAllowed()
23022302
return gSavedPerAccountSettings.getS32("KeepConversationLogTranscripts") > 0;
23032303
}
23042304

2305-
void LLFloaterIMContainer::flashConversationItemWidget(const LLUUID& session_id, bool is_flashes)
2305+
void LLFloaterIMContainer::flashConversationItemWidget(const LLUUID& session_id, bool is_flashes, bool alternate_color)
23062306
{
23072307
//Finds the conversation line item to flash using the session_id
23082308
LLConversationViewSession * widget = dynamic_cast<LLConversationViewSession *>(get_ptr_in_map(mConversationsWidgets,session_id));
23092309

23102310
if (widget)
23112311
{
2312-
widget->setFlashState(is_flashes);
2312+
widget->setFlashState(is_flashes, alternate_color);
23132313
}
23142314
}
23152315

indra/newview/llfloaterimcontainer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ class LLFloaterIMContainer
208208
void reSelectConversation();
209209
void updateSpeakBtnState();
210210
static bool isConversationLoggingAllowed();
211-
void flashConversationItemWidget(const LLUUID& session_id, bool is_flashes);
211+
void flashConversationItemWidget(const LLUUID& session_id, bool is_flashes, bool alternate_color = false);
212212
void highlightConversationItemWidget(const LLUUID& session_id, bool is_highlighted);
213213
bool isScrolledOutOfSight(LLConversationViewSession* conversation_item_widget);
214214
boost::signals2::connection mMicroChangedSignal;

indra/newview/llimview.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
#include "llviewerregion.h"
7272
#include "llcorehttputil.h"
7373
#include "lluiusage.h"
74+
#include "llurlregistry.h"
7475

7576
#include <array>
7677

@@ -197,6 +198,7 @@ void notify_of_message(const LLSD& msg, bool is_dnd_msg)
197198
LLFloaterIMSessionTab* session_floater = LLFloaterIMSessionTab::getConversation(session_id);
198199
bool store_dnd_message = false; // flag storage of a dnd message
199200
bool is_session_focused = session_floater->isTornOff() && session_floater->hasFocus();
201+
bool contains_mention = LLUrlRegistry::getInstance()->containsAgentMention(msg["message"].asString());
200202
if (!LLFloater::isVisible(im_box) || im_box->isMinimized())
201203
{
202204
conversations_floater_status = CLOSED;
@@ -323,7 +325,7 @@ void notify_of_message(const LLSD& msg, bool is_dnd_msg)
323325
if ("openconversations" == user_preferences
324326
|| ON_TOP == conversations_floater_status
325327
|| ("toast" == user_preferences && ON_TOP != conversations_floater_status)
326-
|| ("flash" == user_preferences && (CLOSED == conversations_floater_status
328+
|| (("flash" == user_preferences || contains_mention) && (CLOSED == conversations_floater_status
327329
|| NOT_ON_TOP == conversations_floater_status))
328330
|| is_dnd_msg)
329331
{
@@ -343,7 +345,7 @@ void notify_of_message(const LLSD& msg, bool is_dnd_msg)
343345
}
344346
else
345347
{
346-
im_box->flashConversationItemWidget(session_id, true);
348+
im_box->flashConversationItemWidget(session_id, true, contains_mention);
347349
}
348350
}
349351
}
@@ -3269,7 +3271,7 @@ void LLIMMgr::addMessage(
32693271
{
32703272
LLFloaterReg::showInstance("im_container");
32713273
LLFloaterReg::getTypedInstance<LLFloaterIMContainer>("im_container")->
3272-
flashConversationItemWidget(new_session_id, true);
3274+
flashConversationItemWidget(new_session_id, true, LLUrlRegistry::getInstance()->containsAgentMention(msg));
32733275
}
32743276
}
32753277

0 commit comments

Comments
 (0)