Added send message function for Participants list.

This commit is contained in:
defnax 2015-09-07 15:13:32 +02:00
parent cc4be39025
commit 2c1743f5bb
2 changed files with 43 additions and 5 deletions

View file

@ -34,6 +34,7 @@
#include "gui/settings/RsharePeerSettings.h" #include "gui/settings/RsharePeerSettings.h"
#include "gui/MainWindow.h" #include "gui/MainWindow.h"
#include "gui/FriendsDialog.h" #include "gui/FriendsDialog.h"
#include "gui/msgs/MessageComposer.h"
#include <gui/common/html.h> #include <gui/common/html.h>
#include "gui/common/RSTreeWidgetItem.h" #include "gui/common/RSTreeWidgetItem.h"
#include "gui/common/FriendSelectionDialog.h" #include "gui/common/FriendSelectionDialog.h"
@ -74,10 +75,12 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
ui.participantsList->setColumnHidden(COLUMN_ID,true); ui.participantsList->setColumnHidden(COLUMN_ID,true);
muteAct = new QAction(QIcon(), tr("Mute participant"), this); muteAct = new QAction(QIcon(), tr("Mute participant"), this);
distantChatAct = new QAction(QIcon(), tr("Start private chat"), this); distantChatAct = new QAction(QIcon(":/images/chat_24.png"), tr("Start private chat"), this);
sendMessageAct = new QAction(QIcon(":/images/mail_new.png"), tr("Send Message"), this);
connect(muteAct, SIGNAL(triggered()), this, SLOT(changePartipationState())); connect(muteAct, SIGNAL(triggered()), this, SLOT(changePartipationState()));
connect(distantChatAct, SIGNAL(triggered()), this, SLOT(distantChatParticipant())); connect(distantChatAct, SIGNAL(triggered()), this, SLOT(distantChatParticipant()));
connect(sendMessageAct, SIGNAL(triggered()), this, SLOT(sendMessage()));
// Add a button to invite friends. // Add a button to invite friends.
// //
@ -170,8 +173,11 @@ void ChatLobbyDialog::participantsTreeWidgetCustomPopupMenu(QPoint)
QMenu contextMnu(this); QMenu contextMnu(this);
contextMnu.addAction(muteAct);
contextMnu.addAction(distantChatAct); contextMnu.addAction(distantChatAct);
contextMnu.addAction(sendMessageAct);
contextMnu.addSeparator();
contextMnu.addAction(muteAct);
muteAct->setCheckable(true); muteAct->setCheckable(true);
muteAct->setEnabled(false); muteAct->setEnabled(false);
@ -571,6 +577,36 @@ void ChatLobbyDialog::distantChatParticipant()
} }
} }
void ChatLobbyDialog::sendMessage()
{
QList<QTreeWidgetItem*> selectedItems = ui.participantsList->selectedItems();
if (selectedItems.isEmpty())
return;
QList<QTreeWidgetItem*>::iterator item;
for (item = selectedItems.begin(); item != selectedItems.end(); ++item) {
RsGxsId gxs_id ;
dynamic_cast<GxsIdRSTreeWidgetItem*>(*item)->getId(gxs_id) ;
MessageComposer *nMsgDialog = MessageComposer::newMsg();
if (nMsgDialog == NULL) {
return;
}
nMsgDialog->addRecipient(MessageComposer::TO, RsGxsId(gxs_id));
nMsgDialog->show();
nMsgDialog->activateWindow();
/* window will destroy itself! */
}
}
void ChatLobbyDialog::muteParticipant(const RsGxsId& nickname) void ChatLobbyDialog::muteParticipant(const RsGxsId& nickname)
{ {

View file

@ -77,6 +77,7 @@ protected slots:
void changePartipationState(); void changePartipationState();
void distantChatParticipant(); void distantChatParticipant();
void participantsTreeWidgetDoubleClicked(QTreeWidgetItem *item, int column); void participantsTreeWidgetDoubleClicked(QTreeWidgetItem *item, int column);
void sendMessage();
private: private:
void updateParticipantsList(); void updateParticipantsList();
@ -104,6 +105,7 @@ private:
QAction *muteAct; QAction *muteAct;
QAction *distantChatAct; QAction *distantChatAct;
QWidgetAction *checkableAction; QWidgetAction *checkableAction;
QAction *sendMessageAct;
GxsIdChooser *ownIdChooser ; GxsIdChooser *ownIdChooser ;
}; };