merged with latest master before creating PR

This commit is contained in:
csoler 2015-12-04 21:24:51 -05:00
commit 9193d3579b
294 changed files with 13080 additions and 8470 deletions

View file

@ -34,6 +34,7 @@
#include "gui/settings/RsharePeerSettings.h"
#include "gui/MainWindow.h"
#include "gui/FriendsDialog.h"
#include "gui/msgs/MessageComposer.h"
#include <gui/common/html.h>
#include "gui/common/RSTreeWidgetItem.h"
#include "gui/common/FriendSelectionDialog.h"
@ -52,6 +53,8 @@
#define COLUMN_ID 3
#define COLUMN_COUNT 4
const static uint32_t timeToInactivity = 60 * 10; // in seconds
/** Default constructor */
ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::WindowFlags flags)
: ChatDialog(parent, flags), lobbyId(lid)
@ -66,18 +69,20 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
connect(ui.participantsList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(participantsTreeWidgetDoubleClicked(QTreeWidgetItem*,int)));
int S = QFontMetricsF(font()).height() ;
ui.participantsList->setIconSize(QSize(S,S));
ui.participantsList->setIconSize(QSize(1.3*S,1.3*S));
ui.participantsList->setColumnCount(COLUMN_COUNT);
ui.participantsList->setColumnWidth(COLUMN_ICON, 1.25*S);
ui.participantsList->setColumnWidth(COLUMN_ICON, 1.4*S);
ui.participantsList->setColumnHidden(COLUMN_ACTIVITY,true);
ui.participantsList->setColumnHidden(COLUMN_ID,true);
muteAct = new QAction(QIcon(), tr("Mute participant"), this);
distantChatAct = new QAction(QIcon(), tr("Start private chat"), this);
muteAct = new QAction(QIcon(), tr("Mute participant"), 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(distantChatAct, SIGNAL(triggered()), this, SLOT(distantChatParticipant()));
connect(sendMessageAct, SIGNAL(triggered()), this, SLOT(sendMessage()));
// Add a button to invite friends.
//
@ -170,12 +175,15 @@ void ChatLobbyDialog::participantsTreeWidgetCustomPopupMenu(QPoint)
QMenu contextMnu(this);
contextMnu.addAction(muteAct);
contextMnu.addAction(distantChatAct);
contextMnu.addAction(sendMessageAct);
contextMnu.addSeparator();
contextMnu.addAction(muteAct);
muteAct->setCheckable(true);
muteAct->setEnabled(false);
muteAct->setChecked(false);
muteAct->setChecked(false);
if (selectedItems.size())
{
@ -362,7 +370,7 @@ void ChatLobbyDialog::addChatMsg(const ChatMessage& msg)
else
name = QString::fromUtf8(msg.peer_alternate_nickname.c_str()) + " (" + QString::fromStdString(gxs_id.toStdString()) + ")" ;
ui.chatWidget->addChatMsg(msg.incoming, name, sendTime, recvTime, message, ChatWidget::MSGTYPE_NORMAL);
ui.chatWidget->addChatMsg(msg.incoming, name, gxs_id, sendTime, recvTime, message, ChatWidget::MSGTYPE_NORMAL);
emit messageReceived(msg.incoming, id(), sendTime, name, message) ;
// This is a trick to translate HTML into text.
@ -425,7 +433,8 @@ void ChatLobbyDialog::updateParticipantsList()
widgetitem = new GxsIdRSTreeWidgetItem(mParticipantCompareRole,GxsIdDetails::ICON_TYPE_AVATAR);
widgetitem->setId(it2->first,COLUMN_NAME, true) ;
//widgetitem->setText(COLUMN_NAME, participant);
widgetitem->setText(COLUMN_ACTIVITY,QString::number(time(NULL)));
// set activity time to the oast so that the peer is marked as inactive
widgetitem->setText(COLUMN_ACTIVITY,QString::number(time(NULL) - timeToInactivity));
widgetitem->setText(COLUMN_ID,QString::fromStdString(it2->first.toStdString()));
ui.participantsList->addTopLevelItem(widgetitem);
@ -443,16 +452,16 @@ void ChatLobbyDialog::updateParticipantsList()
time_t now = time(NULL);
if(isParticipantMuted(it2->first))
widgetitem->setIcon(COLUMN_ICON, QIcon(":/icons/bullet_red_64.png"));
else if (tLastAct<now-60*30)
widgetitem->setIcon(COLUMN_ICON, QIcon(":/icons/bullet_grey_64.png"));
else
widgetitem->setIcon(COLUMN_ICON, QIcon(":/icons/bullet_green_64.png"));
widgetitem->setIcon(COLUMN_ICON, QIcon(":/icons/bullet_red_128.png"));
else if (tLastAct + timeToInactivity < now)
widgetitem->setIcon(COLUMN_ICON, QIcon(":/icons/bullet_grey_128.png"));
else
widgetitem->setIcon(COLUMN_ICON, QIcon(":/icons/bullet_green_128.png"));
RsGxsId gxs_id;
rsMsgs->getIdentityForChatLobby(lobbyId, gxs_id);
if (RsGxsId(participant.toStdString()) == gxs_id) widgetitem->setIcon(COLUMN_ICON, QIcon(":/icons/bullet_yellow_64.png"));
if (RsGxsId(participant.toStdString()) == gxs_id) widgetitem->setIcon(COLUMN_ICON, QIcon(":/icons/bullet_yellow_128.png"));
QTime qtLastAct=QTime(0,0,0).addSecs(now-tLastAct);
widgetitem->setToolTip(COLUMN_ICON,tr("Right click to mute/unmute participants<br/>Double click to address this person<br/>")
@ -572,6 +581,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)
{