[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdenetwork/kopete/protocols/jabber
From:       Pali Rohár <pali.rohar () gmail ! com>
Date:       2013-05-23 22:37:09
Message-ID: 20130523223709.B4A62AC85D () svn ! kde ! org
[Download RAW message or body]

SVN commit 1356131 by pali:

Implement invite button in jabber group chat window

CCBUG: 214780


 M  +6 -1      jabberchatui.rc  
 M  +30 -0     jabbergroupchatmanager.cpp  
 M  +9 -0      jabbergroupchatmanager.h  


--- trunk/KDE/kdenetwork/kopete/protocols/jabber/jabberchatui.rc #1356130:1356131
@@ -1,5 +1,5 @@
 <!DOCTYPE kpartgui>
-<kpartgui version="12" name="kopete_jabber_chat">
+<kpartgui version="13" name="kopete_jabber_chat">
 	<MenuBar>
 		<Menu noMerge="1" name="file">
 			<text>&amp;Chat</text>
@@ -16,4 +16,9 @@
 	</ToolBar>
 
 
+	<ToolBar name="chatToolBar" fullWidth="true">
+		<Action name="jabberInvite" />
+	</ToolBar>
+
+
 </kpartgui>
--- trunk/KDE/kdenetwork/kopete/protocols/jabber/jabbergroupchatmanager.cpp \
#1356130:1356131 @@ -19,8 +19,12 @@
 
 #include <kdebug.h>
 #include <klocale.h>
+#include <kmenu.h>
+#include <kactionmenu.h>
+#include <kactioncollection.h>
 #include "kopetechatsessionmanager.h"
 #include "kopeteview.h"
+#include "kopetecontactaction.h"
 #include "jabberprotocol.h"
 #include "jabberaccount.h"
 #include "jabberclient.h"
@@ -32,8 +36,16 @@
 {
 	kDebug ( JABBER_DEBUG_GLOBAL ) << "New message manager for " << user->contactId ();
 
+	setComponentData(protocol->componentData());
+
 	mRoomJid = roomJid;
 	
+	mInviteAction = new KActionMenu (KIcon("system-users"), i18n ("&Invite"), this);
+	mInviteAction->setDelayed(false);
+	connect( mInviteAction->menu(), SIGNAL(aboutToShow()), this, SLOT(showInviteMenu()) \
); +	connect( mInviteAction->menu(), SIGNAL(aboutToHide()), this, \
SLOT(hideInviteMenu()) ); +	actionCollection()->addAction("jabberInvite", \
mInviteAction); +
 	setMayInvite( true );
 
 	// make sure Kopete knows about this instance
@@ -43,6 +55,8 @@
 			  this, SLOT (slotMessageSent(Kopete::Message&,Kopete::ChatSession*)) );
 
 	updateDisplayName ();
+
+	setXMLFile("jabberchatui.rc");
 }
 
 JabberGroupChatManager::~JabberGroupChatManager()
@@ -173,7 +187,23 @@
 	}
 }
 
+void JabberGroupChatManager::showInviteMenu() {
+	QHash <QString, Kopete::Contact *> contactList = account()->contacts();
+	for ( QHash <QString, Kopete::Contact *>::Iterator it = contactList.begin(); it != \
contactList.end(); ++it ) { +		if ( ! members().contains(it.value()) && \
it.value()->isOnline() && it.value()->onlineStatus().status() != \
Kopete::OnlineStatus::Offline ) { +			KAction *a = new \
Kopete::UI::ContactAction(it.value(), actionCollection()); +			connect( a, \
SIGNAL(triggered(QString,bool)), this, SLOT(inviteContact(QString)) ); \
+			mInviteAction->addAction(a); +		}
+	}
+}
 
+void JabberGroupChatManager::hideInviteMenu() {
+	//Clear menu
+	mInviteAction->menu()->clear();
+}
+
+
 #include "jabbergroupchatmanager.moc"
 
 // vim: set noet ts=4 sts=4 sw=4:
--- trunk/KDE/kdenetwork/kopete/protocols/jabber/jabbergroupchatmanager.h \
#1356130:1356131 @@ -26,6 +26,7 @@
 class JabberBaseContact;
 namespace Kopete { class Message; }
 class QString;
+class KActionMenu;
 
 /**
  * @author Till Gerken
@@ -57,6 +58,8 @@
 	 */
 	void updateDisplayName ();
 	
+public slots:
+
 	/**
 	 * reimplemented from Kopete::ChatSession
 	 * called when a contact is dropped in the window
@@ -64,12 +67,18 @@
 	virtual void inviteContact(const QString &contactId);
 
 private slots:
+	///Slot to show invite menu for other user to chat
+	void showInviteMenu();
+	///Slot to hide invite menu
+	void hideInviteMenu();
 	void slotMessageSent ( Kopete::Message &message, Kopete::ChatSession *kmm );
 	
 
 
 private:
 	XMPP::Jid mRoomJid;
+	///The action to invite the user
+	KActionMenu *mInviteAction;
 };
 
 #endif


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic