From 216726dd23ef925f5bd6cccbdeb09cfca5400a7a Mon Sep 17 00:00:00 2001 From: Eugene Mutavchi Date: Fri, 18 Dec 2009 18:41:14 +0200 Subject: Implemented major sub-task EXT-3524 (Context menu for IM well) --HG-- branch : product-engine --- indra/newview/llchiclet.cpp | 38 ++++++++++- indra/newview/llchiclet.h | 10 +++ indra/newview/llsyswellwindow.cpp | 78 ++++++++++++++++++++++ indra/newview/llsyswellwindow.h | 5 +- .../skins/default/xui/en/menu_im_well_button.xml | 16 +++++ .../newview/skins/default/xui/en/notifications.xml | 11 +++ 6 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 indra/newview/skins/default/xui/en/menu_im_well_button.xml diff --git a/indra/newview/llchiclet.cpp b/indra/newview/llchiclet.cpp index 84722db384..21a0381495 100644 --- a/indra/newview/llchiclet.cpp +++ b/indra/newview/llchiclet.cpp @@ -267,9 +267,45 @@ LLIMWellChiclet::~LLIMWellChiclet() LLIMMgr::getInstance()->removeSessionObserver(this); } +void LLIMWellChiclet::onMenuItemClicked(const LLSD& user_data) +{ + std::string action = user_data.asString(); + if("close all" == action) + { + LLIMWellWindow::getInstance()->closeAll(); + } +} + +bool LLIMWellChiclet::enableMenuItem(const LLSD& user_data) +{ + std::string item = user_data.asString(); + if (item == "can close all") + { + return !LLIMWellWindow::getInstance()->isWindowEmpty(); + } + return true; +} + void LLIMWellChiclet::createMenu() { - // TODO: implement context menu for IM well + if(mContextMenu) + { + llwarns << "Menu already exists" << llendl; + return; + } + + LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; + registrar.add("IMWellChicletMenu.Action", + boost::bind(&LLIMWellChiclet::onMenuItemClicked, this, _2)); + + LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; + enable_registrar.add("IMWellChicletMenu.EnableItem", + boost::bind(&LLIMWellChiclet::enableMenuItem, this, _2)); + + mContextMenu = LLUICtrlFactory::getInstance()->createFromFile + ("menu_im_well_button.xml", + LLMenuGL::sMenuContainer, + LLViewerMenuHolderGL::child_registry_t::instance()); } void LLIMWellChiclet::messageCountChanged(const LLSD& session_data) diff --git a/indra/newview/llchiclet.h b/indra/newview/llchiclet.h index c60d06bc97..259476c2ad 100644 --- a/indra/newview/llchiclet.h +++ b/indra/newview/llchiclet.h @@ -860,6 +860,16 @@ public: protected: LLIMWellChiclet(const Params& p); + /** + * Processes clicks on chiclet popup menu. + */ + virtual void onMenuItemClicked(const LLSD& user_data); + + /** + * Enables chiclet menu items. + */ + bool enableMenuItem(const LLSD& user_data); + /** * Creates menu. */ diff --git a/indra/newview/llsyswellwindow.cpp b/indra/newview/llsyswellwindow.cpp index 1aeafaea5a..26f9824f9c 100644 --- a/indra/newview/llsyswellwindow.cpp +++ b/indra/newview/llsyswellwindow.cpp @@ -48,6 +48,8 @@ #include "llchiclet.h" #include "lltoastpanel.h" #include "llnotificationmanager.h" +#include "llnotificationsutil.h" +#include "llspeakers.h" //--------------------------------------------------------------------------------- LLSysWellWindow::LLSysWellWindow(const LLSD& key) : LLDockableFloater(NULL, key), @@ -920,4 +922,80 @@ void LLIMWellWindow::onNewIM(const LLSD& data) } +void LLIMWellWindow::closeAll() +{ + // Generate an ignorable alert dialog if there is an active voice IM sesion + bool need_confirmation = false; + const LLIMModel& im_model = LLIMModel::instance(); + std::vector values; + mMessageList->getValues(values); + for (std::vector::iterator + iter = values.begin(), + iter_end = values.end(); + iter != iter_end; ++iter) + { + LLIMSpeakerMgr* speaker_mgr = im_model.getSpeakerManager(*iter); + if (speaker_mgr && speaker_mgr->isVoiceActive()) + { + need_confirmation = true; + break; + } + } + if ( need_confirmation ) + { + //Bring up a confirmation dialog + LLNotificationsUtil::add + ("ConfirmCloseAll", LLSD(), LLSD(), + boost::bind(&LLIMWellWindow::confirmCloseAll, this, _1, _2)); + } + else + { + closeAllImpl(); + } +} + +void LLIMWellWindow::closeAllImpl() +{ + std::vector values; + mMessageList->getValues(values); + + for (std::vector::iterator + iter = values.begin(), + iter_end = values.end(); + iter != iter_end; ++iter) + { + LLPanel* panel = mMessageList->getItemByValue(*iter); + + RowPanel* im_panel = dynamic_cast (panel); + if (im_panel) + { + gIMMgr->leaveSession(*iter); + continue; + } + + ObjectRowPanel* obj_panel = dynamic_cast (panel); + if (obj_panel) + { + LLScriptFloaterManager::instance() + .removeNotificationByObjectId(*iter); + } + } +} + +bool LLIMWellWindow::confirmCloseAll(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + switch(option) + { + case 0: + { + closeAllImpl(); + return true; + } + default: + break; + } + return false; +} + // EOF diff --git a/indra/newview/llsyswellwindow.h b/indra/newview/llsyswellwindow.h index 0b95c8decd..6cfa25b84d 100644 --- a/indra/newview/llsyswellwindow.h +++ b/indra/newview/llsyswellwindow.h @@ -199,6 +199,8 @@ public: void addIMRow(const LLUUID& session_id); bool hasIMRow(const LLUUID& session_id); + void closeAll(); + protected: /*virtual*/ const std::string& getAnchorViewName() { return IM_WELL_ANCHOR_NAME; } @@ -208,7 +210,8 @@ private: void addIMRow(const LLUUID& sessionId, S32 chicletCounter, const std::string& name, const LLUUID& otherParticipantId); void delIMRow(const LLUUID& sessionId); - + bool confirmCloseAll(const LLSD& notification, const LLSD& response); + void closeAllImpl(); /** * Scrolling row panel. diff --git a/indra/newview/skins/default/xui/en/menu_im_well_button.xml b/indra/newview/skins/default/xui/en/menu_im_well_button.xml new file mode 100644 index 0000000000..f8dfba91ff --- /dev/null +++ b/indra/newview/skins/default/xui/en/menu_im_well_button.xml @@ -0,0 +1,16 @@ + + + + + + + diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index bcf006f1a0..3320a2dcce 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -5761,6 +5761,17 @@ They will be blocked for a few seconds for your security. + +Are you sure you want to close all IMs? + + + Attachment has been saved. -- cgit v1.2.3