← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2141: add user commands to the PM chat menu

 

------------------------------------------------------------
revno: 2141
committer: poy <poy@xxxxxxxxxx>
branch nick: repo
timestamp: Mon 2010-05-10 18:15:25 +0200
message:
  add user commands to the PM chat menu
modified:
  win32/PrivateFrame.cpp
  win32/PrivateFrame.h


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'win32/PrivateFrame.cpp'
--- win32/PrivateFrame.cpp	2010-03-26 22:49:37 +0000
+++ win32/PrivateFrame.cpp	2010-05-10 16:15:25 +0000
@@ -120,6 +120,7 @@
 {
 	chat->setHelpId(IDH_PM_CHAT);
 	addWidget(chat);
+	chat->onContextMenu(std::tr1::bind(&PrivateFrame::handleChatContextMenu, this, _1));
 
 	message->setHelpId(IDH_PM_MESSAGE);
 	addWidget(message, true);
@@ -318,6 +319,22 @@
 	menu->appendSeparator();
 }
 
+bool PrivateFrame::handleChatContextMenu(dwt::ScreenCoordinate pt) {
+	if(pt.x() == -1 || pt.y() == -1) {
+		pt = chat->getContextMenuPos();
+	}
+
+	// imitate TextBoxBase's menu creation
+	MenuPtr menu(dwt::WidgetCreator<Menu>::create(chat->getParent(), WinUtil::Seeds::menu));
+	chat->addCommands(menu);
+
+	prepareMenu(menu, UserCommand::CONTEXT_USER, ClientManager::getInstance()->getHubs(replyTo.getUser().user->getCID(),
+		replyTo.getUser().hint, priv));
+
+	menu->open(pt);
+	return true;
+}
+
 void PrivateFrame::runUserCommand(const UserCommand& uc) {
 	if(!WinUtil::getUCParams(this, uc, ucLineParams))
 		return;

=== modified file 'win32/PrivateFrame.h'
--- win32/PrivateFrame.h	2010-02-11 21:44:13 +0000
+++ win32/PrivateFrame.h	2010-05-10 16:15:25 +0000
@@ -93,6 +93,8 @@
 	void addStatus(const tstring& aLine, bool log = true);
 	void updateOnlineStatus();
 
+	bool handleChatContextMenu(dwt::ScreenCoordinate pt);
+
 	void runUserCommand(const UserCommand& uc);
 
 	// MDIChildFrame