Implemented major sub-task EXT-3524 (Context menu for IM well)

--HG--
branch : product-engine
master
Eugene Mutavchi 2009-12-18 18:41:14 +02:00
parent 8083feada1
commit 216726dd23
6 changed files with 156 additions and 2 deletions

View File

@ -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)

View File

@ -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.
*/

View File

@ -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

View File

@ -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.

View File

@ -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>

View File

@ -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.