From 6ba527aba9a09cde627309a4acd73b161b65e185 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Fri, 24 Apr 2009 15:40:59 -0700 Subject: Communicate window now shows the number of unread IMs --- linden/indra/newview/llfloaterchatterbox.cpp | 54 ++++++++++++++++++++++ linden/indra/newview/llfloaterchatterbox.h | 2 + linden/indra/newview/llimpanel.cpp | 36 +++++++++++---- .../skins/default/xui/en-us/floater_chatterbox.xml | 6 +++ 4 files changed, 90 insertions(+), 8 deletions(-) (limited to 'linden/indra/newview') diff --git a/linden/indra/newview/llfloaterchatterbox.cpp b/linden/indra/newview/llfloaterchatterbox.cpp index 1114635..e7de62c 100644 --- a/linden/indra/newview/llfloaterchatterbox.cpp +++ b/linden/indra/newview/llfloaterchatterbox.cpp @@ -88,6 +88,10 @@ void* LLFloaterMyFriends::createGroupsPanel(void* data) // // LLFloaterChatterBox // + +static std::string sTitle = "Communicate"; +static int sUnreadCount = 0; + LLFloaterChatterBox::LLFloaterChatterBox(const LLSD& seed) : mActiveVoiceFloater(NULL) { @@ -122,6 +126,9 @@ LLFloaterChatterBox::LLFloaterChatterBox(const LLSD& seed) : addFloater(LLFloaterChat::getInstance(LLSD()), FALSE); } mTabContainer->lockTabs(); + + sUnreadCount = 0; + sTitle = getTitle(); } LLFloaterChatterBox::~LLFloaterChatterBox() @@ -217,6 +224,53 @@ void LLFloaterChatterBox::setMinimized(BOOL minimized) LLFloaterChat::getInstance()->updateConsoleVisibility(); } +void LLFloaterChatterBox::markAsUnread(bool unread) +{ + LLFloaterChatterBox* floater = LLFloaterChatterBox::getInstance(); + + // Update IM unread count + if (unread) + { + sUnreadCount++; + } + else if (!unread) + { + sUnreadCount--; + } + + if (floater) + { + // Update the title message with the number of unread IMs. + // Remove the message when we hit 0. + if (sUnreadCount > 0) + { + // Check for plurals + std::string unread_string; + if (sUnreadCount == 1) + { + unread_string = floater->getString("unread_count_string_singular"); + } + else + { + unread_string = floater->getString("unread_count_string_plural"); + } + + std::ostringstream unread_count_message; + unread_count_message << sTitle << " (" << sUnreadCount << " " << unread_string << ")"; + + // Update the floater title + floater->setTitle(unread_count_message.str()); + } + else + { + sUnreadCount = 0; + + // Update the floater title + floater->setTitle(sTitle); + } + } +} + void LLFloaterChatterBox::removeFloater(LLFloater* floaterp) { if (floaterp->getName() == "chat floater") diff --git a/linden/indra/newview/llfloaterchatterbox.h b/linden/indra/newview/llfloaterchatterbox.h index ac494d1..197c735 100644 --- a/linden/indra/newview/llfloaterchatterbox.h +++ b/linden/indra/newview/llfloaterchatterbox.h @@ -90,6 +90,8 @@ public: VisibilityPolicy::hide(instance, key); } + static void markAsUnread(bool unread); + private: LLFloater* getFloater(const LLSD& key) { diff --git a/linden/indra/newview/llimpanel.cpp b/linden/indra/newview/llimpanel.cpp index dede746..5a563a4 100644 --- a/linden/indra/newview/llimpanel.cpp +++ b/linden/indra/newview/llimpanel.cpp @@ -49,6 +49,7 @@ #include "llconsole.h" #include "llfloater.h" #include "llfloatergroupinfo.h" +#include "llfloaterchatterbox.h" #include "llimview.h" #include "llinventory.h" #include "llinventorymodel.h" @@ -1160,6 +1161,7 @@ void LLFloaterIMPanel::init(const std::string& session_label) FALSE); setTitle(mSessionLabel); + mInputEditor->setMaxTextLength(1023); // enable line history support for instant message bar mInputEditor->setEnableLineHistory(TRUE); @@ -1472,7 +1474,21 @@ void LLFloaterIMPanel::addHistoryLine(const std::string &utf8msg, const LLColor4 && hostp && source != gAgent.getID()) { - hostp->setFloaterFlashing(this, TRUE); + // Only start flashing on first update so we can + // get the proper unread number of unread tabs here + if (!hostp->isFloaterFlashing(this)) + { + hostp->setFloaterFlashing(this, TRUE); + LLFloaterChatterBox::markAsUnread(true); + } + + //// Only increment the number of unread IMs if they're from individuals + //// We increment the first received for the rest during new IM creation. + //if (mDialog == IM_SESSION_P2P_INVITE || + // mDialog == IM_NOTHING_SPECIAL) + //{ + // LLFloaterChatterBox::markAsUnread(true); + //} } } @@ -1540,13 +1556,17 @@ void LLFloaterIMPanel::setVisible(BOOL b) LLMultiFloater* hostp = getHost(); if( b && hostp ) { - hostp->setFloaterFlashing(this, FALSE); - - /* Don't change containing floater title - leave it "Instant Message" JC - LLUIString title = sTitleString; - title.setArg("[NAME]", mSessionLabel); - hostp->setTitle( title ); - */ + if (hostp->isFloaterFlashing(this)) + { + hostp->setFloaterFlashing(this, FALSE); + LLFloaterChatterBox::markAsUnread(false); + + /* Don't change containing floater title - leave it "Instant Message" JC + LLUIString title = sTitleString; + title.setArg("[NAME]", mSessionLabel); + hostp->setTitle( title ); + */ + } } } diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_chatterbox.xml b/linden/indra/newview/skins/default/xui/en-us/floater_chatterbox.xml index 69f8286..96904d7 100644 --- a/linden/indra/newview/skins/default/xui/en-us/floater_chatterbox.xml +++ b/linden/indra/newview/skins/default/xui/en-us/floater_chatterbox.xml @@ -8,5 +8,11 @@ mouse_opaque="false" name="chatterbox_tab_container" width="391"> + + unread IM + + + unread IMs + -- cgit v1.1