diff options
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llchiclet.cpp | 38 | ||||
-rw-r--r-- | indra/newview/llchiclet.h | 10 | ||||
-rw-r--r-- | indra/newview/llsyswellwindow.cpp | 78 | ||||
-rw-r--r-- | indra/newview/llsyswellwindow.h | 5 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/menu_im_well_button.xml | 16 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/notifications.xml | 11 |
6 files changed, 156 insertions, 2 deletions
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<LLContextMenu> + ("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 @@ -861,6 +861,16 @@ 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. */ /*virtual*/ void createMenu(); 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<LLSD> values; + mMessageList->getValues(values); + for (std::vector<LLSD>::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<LLSD> values; + mMessageList->getValues(values); + + for (std::vector<LLSD>::iterator + iter = values.begin(), + iter_end = values.end(); + iter != iter_end; ++iter) + { + LLPanel* panel = mMessageList->getItemByValue(*iter); + + RowPanel* im_panel = dynamic_cast <RowPanel*> (panel); + if (im_panel) + { + gIMMgr->leaveSession(*iter); + continue; + } + + ObjectRowPanel* obj_panel = dynamic_cast <ObjectRowPanel*> (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 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<context_menu + layout="topleft" + name="IM Well Button Context Menu"> + <menu_item_call + label="Close All" + layout="topleft" + name="Close All"> + <menu_item_call.on_click + function="IMWellChicletMenu.Action" + parameter="close all" /> + <menu_item_call.on_enable + function="IMWellChicletMenu.EnableItem" + parameter="can close all" /> + </menu_item_call> +</context_menu> 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. </form> </notification> + <notification + icon="alert.tga" + name="ConfirmCloseAll" + type="alertmodal"> +Are you sure you want to close all IMs? + <usetemplate + name="okcancelignore" + notext="Cancel" + yestext="Ok"/> + </notification> + <notification icon="notifytip.tga" name="AttachmentSaved" type="notifytip"> Attachment has been saved. |