2014-07-07 00:19:45 +08:00
|
|
|
/*
|
|
|
|
Copyright (C) 2014 by Project Tox <https://tox.im>
|
|
|
|
|
|
|
|
This file is part of qTox, a Qt-based graphical interface for Tox.
|
|
|
|
|
|
|
|
This program is libre software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the COPYING file for more details.
|
|
|
|
*/
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
#include "chatform.h"
|
|
|
|
#include "friend.h"
|
2014-06-27 06:42:45 +08:00
|
|
|
#include "widget/friendwidget.h"
|
|
|
|
#include "widget/widget.h"
|
|
|
|
#include "widget/filetransfertwidget.h"
|
2014-06-25 04:11:11 +08:00
|
|
|
#include <QScrollBar>
|
2014-06-26 04:43:28 +08:00
|
|
|
#include <QFileDialog>
|
2014-08-29 01:06:51 +08:00
|
|
|
#include <QMessageBox>
|
2014-06-25 04:11:11 +08:00
|
|
|
|
|
|
|
ChatForm::ChatForm(Friend* chatFriend)
|
2014-09-05 02:09:55 +08:00
|
|
|
: f(chatFriend)
|
2014-06-25 04:11:11 +08:00
|
|
|
{
|
2014-09-05 02:09:55 +08:00
|
|
|
nameLabel->setText(f->getName());
|
|
|
|
avatarLabel->setPixmap(QPixmap(":/img/contact_dark.png"));
|
2014-06-27 07:49:48 +08:00
|
|
|
|
2014-09-05 02:09:55 +08:00
|
|
|
statusMessageLabel = new QLabel();
|
|
|
|
netcam = new NetCamView();
|
2014-08-16 04:08:19 +08:00
|
|
|
|
2014-09-05 02:09:55 +08:00
|
|
|
headTextLayout->addWidget(statusMessageLabel);
|
2014-06-25 04:11:11 +08:00
|
|
|
headTextLayout->addStretch();
|
|
|
|
|
2014-06-26 06:30:24 +08:00
|
|
|
connect(Widget::getInstance()->getCore(), &Core::fileSendStarted, this, &ChatForm::startFileSend);
|
2014-06-30 10:39:43 +08:00
|
|
|
connect(Widget::getInstance()->getCore(), &Core::videoFrameReceived, netcam, &NetCamView::updateDisplay);
|
2014-08-10 20:47:46 +08:00
|
|
|
connect(sendButton, &QPushButton::clicked, this, &ChatForm::onSendTriggered);
|
|
|
|
connect(fileButton, &QPushButton::clicked, this, &ChatForm::onAttachClicked);
|
|
|
|
connect(callButton, &QPushButton::clicked, this, &ChatForm::onCallTriggered);
|
|
|
|
connect(videoButton, &QPushButton::clicked, this, &ChatForm::onVideoCallTriggered);
|
|
|
|
connect(msgEdit, &ChatTextEdit::enterPressed, this, &ChatForm::onSendTriggered);
|
2014-08-19 23:20:20 +08:00
|
|
|
connect(micButton, SIGNAL(clicked()), this, SLOT(onMicMuteToggle()));
|
2014-06-25 04:11:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ChatForm::~ChatForm()
|
|
|
|
{
|
2014-06-30 10:39:43 +08:00
|
|
|
delete netcam;
|
2014-06-25 04:11:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ChatForm::setStatusMessage(QString newMessage)
|
|
|
|
{
|
2014-09-05 02:09:55 +08:00
|
|
|
statusMessageLabel->setText(newMessage);
|
|
|
|
statusMessageLabel->setToolTip(newMessage); // for overlength messsages
|
2014-06-25 04:11:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ChatForm::onSendTriggered()
|
|
|
|
{
|
|
|
|
QString msg = msgEdit->toPlainText();
|
|
|
|
if (msg.isEmpty())
|
|
|
|
return;
|
|
|
|
QString name = Widget::getInstance()->getUsername();
|
|
|
|
msgEdit->clear();
|
|
|
|
addMessage(name, msg);
|
|
|
|
emit sendMessage(f->friendId, msg);
|
|
|
|
}
|
|
|
|
|
2014-06-26 04:43:28 +08:00
|
|
|
void ChatForm::onAttachClicked()
|
|
|
|
{
|
2014-07-04 03:42:23 +08:00
|
|
|
QString path = QFileDialog::getOpenFileName(0,tr("Send a file"));
|
2014-06-26 04:43:28 +08:00
|
|
|
if (path.isEmpty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
QFile file(path);
|
|
|
|
if (!file.exists() || !file.open(QIODevice::ReadOnly))
|
|
|
|
return;
|
2014-08-29 01:06:51 +08:00
|
|
|
if (file.isSequential())
|
|
|
|
{
|
|
|
|
QMessageBox::critical(0, "Bad Idea", "You're trying to send a special (sequential) file, that's not going to work!");
|
|
|
|
return;
|
|
|
|
file.close();
|
|
|
|
}
|
2014-07-01 19:52:53 +08:00
|
|
|
long long filesize = file.size();
|
2014-06-26 04:43:28 +08:00
|
|
|
file.close();
|
|
|
|
QFileInfo fi(path);
|
|
|
|
|
2014-07-01 19:52:53 +08:00
|
|
|
emit sendFile(f->friendId, fi.fileName(), path, filesize);
|
2014-06-26 04:43:28 +08:00
|
|
|
}
|
|
|
|
|
2014-06-27 01:45:47 +08:00
|
|
|
void ChatForm::startFileSend(ToxFile file)
|
2014-06-26 06:30:24 +08:00
|
|
|
{
|
2014-06-27 01:45:47 +08:00
|
|
|
if (file.friendId != f->friendId)
|
2014-06-26 07:35:30 +08:00
|
|
|
return;
|
2014-08-30 01:28:22 +08:00
|
|
|
|
2014-06-26 07:35:30 +08:00
|
|
|
QLabel *author = new QLabel(Widget::getInstance()->getUsername());
|
2014-06-27 01:53:21 +08:00
|
|
|
QLabel *date = new QLabel(QTime::currentTime().toString("hh:mm"));
|
2014-06-26 06:30:24 +08:00
|
|
|
QScrollBar* scroll = chatArea->verticalScrollBar();
|
|
|
|
lockSliderToBottom = scroll && scroll->value() == scroll->maximum();
|
|
|
|
author->setAlignment(Qt::AlignTop | Qt::AlignRight);
|
|
|
|
date->setAlignment(Qt::AlignTop);
|
|
|
|
QPalette pal;
|
|
|
|
pal.setColor(QPalette::WindowText, Qt::gray);
|
|
|
|
author->setPalette(pal);
|
|
|
|
if (previousName.isEmpty() || previousName != author->text())
|
2014-06-27 01:45:47 +08:00
|
|
|
{
|
|
|
|
if (curRow)
|
|
|
|
{
|
|
|
|
mainChatLayout->setRowStretch(curRow, 0);
|
|
|
|
mainChatLayout->addItem(new QSpacerItem(0,AUTHOR_CHANGE_SPACING),curRow,0,1,3);
|
|
|
|
curRow++;
|
|
|
|
}
|
|
|
|
mainChatLayout->addWidget(author, curRow, 0);
|
|
|
|
}
|
|
|
|
FileTransfertWidget* fileTrans = new FileTransfertWidget(file);
|
|
|
|
previousName = author->text();
|
|
|
|
mainChatLayout->addWidget(fileTrans, curRow, 1);
|
|
|
|
mainChatLayout->addWidget(date, curRow, 3);
|
|
|
|
mainChatLayout->setRowStretch(curRow+1, 1);
|
|
|
|
mainChatLayout->setRowStretch(curRow, 0);
|
|
|
|
curRow++;
|
|
|
|
|
|
|
|
connect(Widget::getInstance()->getCore(), &Core::fileTransferInfo, fileTrans, &FileTransfertWidget::onFileTransferInfo);
|
|
|
|
connect(Widget::getInstance()->getCore(), &Core::fileTransferCancelled, fileTrans, &FileTransfertWidget::onFileTransferCancelled);
|
|
|
|
connect(Widget::getInstance()->getCore(), &Core::fileTransferFinished, fileTrans, &FileTransfertWidget::onFileTransferFinished);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChatForm::onFileRecvRequest(ToxFile file)
|
|
|
|
{
|
|
|
|
if (file.friendId != f->friendId)
|
|
|
|
return;
|
2014-08-30 01:28:22 +08:00
|
|
|
|
2014-06-27 01:45:47 +08:00
|
|
|
QLabel *author = new QLabel(f->getName());
|
2014-06-27 01:53:21 +08:00
|
|
|
QLabel *date = new QLabel(QTime::currentTime().toString("hh:mm"));
|
2014-06-27 01:45:47 +08:00
|
|
|
QScrollBar* scroll = chatArea->verticalScrollBar();
|
|
|
|
lockSliderToBottom = scroll && scroll->value() == scroll->maximum();
|
|
|
|
author->setAlignment(Qt::AlignTop | Qt::AlignRight);
|
|
|
|
date->setAlignment(Qt::AlignTop);
|
|
|
|
if (previousName.isEmpty() || previousName != author->text())
|
2014-06-26 06:30:24 +08:00
|
|
|
{
|
|
|
|
if (curRow)
|
|
|
|
{
|
|
|
|
mainChatLayout->setRowStretch(curRow, 0);
|
|
|
|
mainChatLayout->addItem(new QSpacerItem(0,AUTHOR_CHANGE_SPACING),curRow,0,1,3);
|
|
|
|
curRow++;
|
|
|
|
}
|
|
|
|
mainChatLayout->addWidget(author, curRow, 0);
|
|
|
|
}
|
|
|
|
FileTransfertWidget* fileTrans = new FileTransfertWidget(file);
|
|
|
|
previousName = author->text();
|
|
|
|
mainChatLayout->addWidget(fileTrans, curRow, 1);
|
|
|
|
mainChatLayout->addWidget(date, curRow, 3);
|
|
|
|
mainChatLayout->setRowStretch(curRow+1, 1);
|
|
|
|
mainChatLayout->setRowStretch(curRow, 0);
|
|
|
|
curRow++;
|
|
|
|
|
|
|
|
connect(Widget::getInstance()->getCore(), &Core::fileTransferInfo, fileTrans, &FileTransfertWidget::onFileTransferInfo);
|
2014-06-26 07:35:30 +08:00
|
|
|
connect(Widget::getInstance()->getCore(), &Core::fileTransferCancelled, fileTrans, &FileTransfertWidget::onFileTransferCancelled);
|
|
|
|
connect(Widget::getInstance()->getCore(), &Core::fileTransferFinished, fileTrans, &FileTransfertWidget::onFileTransferFinished);
|
2014-08-31 22:48:15 +08:00
|
|
|
|
2014-09-01 00:29:55 +08:00
|
|
|
Widget* w = Widget::getInstance();
|
|
|
|
if (!w->isFriendWidgetCurActiveWidget(f)|| w->getIsWindowMinimized() || !w->isActiveWindow())
|
2014-08-31 22:48:15 +08:00
|
|
|
{
|
2014-09-01 00:29:55 +08:00
|
|
|
w->newMessageAlert();
|
|
|
|
f->hasNewEvents=true;
|
|
|
|
f->widget->updateStatusLight();
|
2014-08-31 22:48:15 +08:00
|
|
|
}
|
2014-06-26 06:30:24 +08:00
|
|
|
}
|
2014-06-27 06:42:45 +08:00
|
|
|
|
2014-06-30 10:39:43 +08:00
|
|
|
void ChatForm::onAvInvite(int FriendId, int CallId, bool video)
|
2014-06-27 06:42:45 +08:00
|
|
|
{
|
2014-06-27 08:08:33 +08:00
|
|
|
if (FriendId != f->friendId)
|
|
|
|
return;
|
2014-08-30 01:28:22 +08:00
|
|
|
|
2014-06-27 08:08:33 +08:00
|
|
|
callId = CallId;
|
|
|
|
callButton->disconnect();
|
2014-06-30 10:39:43 +08:00
|
|
|
videoButton->disconnect();
|
|
|
|
if (video)
|
|
|
|
{
|
|
|
|
callButton->setObjectName("grey");
|
|
|
|
callButton->style()->polish(callButton);
|
|
|
|
videoButton->setObjectName("yellow");
|
|
|
|
videoButton->style()->polish(videoButton);
|
|
|
|
connect(videoButton, SIGNAL(clicked()), this, SLOT(onAnswerCallTriggered()));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
callButton->setObjectName("yellow");
|
|
|
|
callButton->style()->polish(callButton);
|
|
|
|
videoButton->setObjectName("grey");
|
|
|
|
videoButton->style()->polish(videoButton);
|
|
|
|
connect(callButton, SIGNAL(clicked()), this, SLOT(onAnswerCallTriggered()));
|
|
|
|
}
|
2014-07-01 03:14:51 +08:00
|
|
|
|
|
|
|
Widget* w = Widget::getInstance();
|
2014-09-01 00:29:55 +08:00
|
|
|
if (!w->isFriendWidgetCurActiveWidget(f)|| w->getIsWindowMinimized() || !w->isActiveWindow())
|
2014-07-01 03:14:51 +08:00
|
|
|
{
|
|
|
|
w->newMessageAlert();
|
2014-08-31 22:48:15 +08:00
|
|
|
f->hasNewEvents=true;
|
2014-08-31 22:19:16 +08:00
|
|
|
f->widget->updateStatusLight();
|
2014-07-01 03:14:51 +08:00
|
|
|
}
|
2014-06-27 08:08:33 +08:00
|
|
|
}
|
|
|
|
|
2014-06-30 10:39:43 +08:00
|
|
|
void ChatForm::onAvStart(int FriendId, int CallId, bool video)
|
2014-06-27 08:08:33 +08:00
|
|
|
{
|
|
|
|
if (FriendId != f->friendId)
|
|
|
|
return;
|
2014-08-30 01:28:22 +08:00
|
|
|
|
|
|
|
audioInputFlag = true;
|
2014-06-27 08:08:33 +08:00
|
|
|
callId = CallId;
|
|
|
|
callButton->disconnect();
|
2014-06-30 10:39:43 +08:00
|
|
|
videoButton->disconnect();
|
|
|
|
if (video)
|
|
|
|
{
|
|
|
|
callButton->setObjectName("grey");
|
|
|
|
callButton->style()->polish(callButton);
|
|
|
|
videoButton->setObjectName("red");
|
|
|
|
videoButton->style()->polish(videoButton);
|
|
|
|
connect(videoButton, SIGNAL(clicked()), this, SLOT(onHangupCallTriggered()));
|
|
|
|
netcam->show();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
callButton->setObjectName("red");
|
|
|
|
callButton->style()->polish(callButton);
|
|
|
|
videoButton->setObjectName("grey");
|
|
|
|
videoButton->style()->polish(videoButton);
|
|
|
|
connect(callButton, SIGNAL(clicked()), this, SLOT(onHangupCallTriggered()));
|
|
|
|
}
|
2014-06-27 08:08:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ChatForm::onAvCancel(int FriendId, int)
|
|
|
|
{
|
|
|
|
if (FriendId != f->friendId)
|
|
|
|
return;
|
2014-08-30 01:28:22 +08:00
|
|
|
|
|
|
|
audioInputFlag = false;
|
|
|
|
micButton->setObjectName("green");
|
|
|
|
micButton->style()->polish(micButton);
|
2014-06-27 08:08:33 +08:00
|
|
|
callButton->disconnect();
|
2014-06-30 10:39:43 +08:00
|
|
|
videoButton->disconnect();
|
|
|
|
callButton->setObjectName("green");
|
|
|
|
callButton->style()->polish(callButton);
|
|
|
|
videoButton->setObjectName("green");
|
|
|
|
videoButton->style()->polish(videoButton);
|
2014-06-27 08:08:33 +08:00
|
|
|
connect(callButton, SIGNAL(clicked()), this, SLOT(onCallTriggered()));
|
2014-06-30 10:39:43 +08:00
|
|
|
connect(videoButton, SIGNAL(clicked()), this, SLOT(onVideoCallTriggered()));
|
|
|
|
netcam->hide();
|
2014-06-27 08:08:33 +08:00
|
|
|
}
|
2014-06-27 06:42:45 +08:00
|
|
|
|
2014-06-27 08:08:33 +08:00
|
|
|
void ChatForm::onAvEnd(int FriendId, int)
|
|
|
|
{
|
|
|
|
if (FriendId != f->friendId)
|
|
|
|
return;
|
2014-08-30 01:28:22 +08:00
|
|
|
|
|
|
|
audioInputFlag = false;
|
|
|
|
micButton->setObjectName("green");
|
|
|
|
micButton->style()->polish(micButton);
|
2014-06-30 10:39:43 +08:00
|
|
|
callButton->disconnect();
|
|
|
|
videoButton->disconnect();
|
2014-06-28 13:14:38 +08:00
|
|
|
callButton->setObjectName("green");
|
|
|
|
callButton->style()->polish(callButton);
|
2014-06-30 10:39:43 +08:00
|
|
|
videoButton->setObjectName("green");
|
|
|
|
videoButton->style()->polish(videoButton);
|
2014-06-27 08:08:33 +08:00
|
|
|
connect(callButton, SIGNAL(clicked()), this, SLOT(onCallTriggered()));
|
2014-06-30 10:39:43 +08:00
|
|
|
connect(videoButton, SIGNAL(clicked()), this, SLOT(onVideoCallTriggered()));
|
|
|
|
netcam->hide();
|
2014-06-27 08:08:33 +08:00
|
|
|
}
|
|
|
|
|
2014-06-30 10:39:43 +08:00
|
|
|
void ChatForm::onAvRinging(int FriendId, int CallId, bool video)
|
2014-06-27 09:06:56 +08:00
|
|
|
{
|
|
|
|
if (FriendId != f->friendId)
|
|
|
|
return;
|
2014-08-30 01:28:22 +08:00
|
|
|
|
2014-06-27 09:06:56 +08:00
|
|
|
callId = CallId;
|
|
|
|
callButton->disconnect();
|
2014-06-30 10:39:43 +08:00
|
|
|
videoButton->disconnect();
|
|
|
|
if (video)
|
|
|
|
{
|
|
|
|
callButton->setObjectName("grey");
|
|
|
|
callButton->style()->polish(callButton);
|
|
|
|
videoButton->setObjectName("yellow");
|
|
|
|
videoButton->style()->polish(videoButton);
|
|
|
|
connect(videoButton, SIGNAL(clicked()), this, SLOT(onCancelCallTriggered()));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
callButton->setObjectName("yellow");
|
|
|
|
callButton->style()->polish(callButton);
|
|
|
|
videoButton->setObjectName("grey");
|
|
|
|
videoButton->style()->polish(videoButton);
|
|
|
|
connect(callButton, SIGNAL(clicked()), this, SLOT(onCancelCallTriggered()));
|
|
|
|
}
|
2014-06-27 09:06:56 +08:00
|
|
|
}
|
|
|
|
|
2014-06-30 10:39:43 +08:00
|
|
|
void ChatForm::onAvStarting(int FriendId, int, bool video)
|
2014-06-27 09:06:56 +08:00
|
|
|
{
|
|
|
|
if (FriendId != f->friendId)
|
|
|
|
return;
|
2014-08-30 01:28:22 +08:00
|
|
|
|
2014-06-27 09:06:56 +08:00
|
|
|
callButton->disconnect();
|
2014-06-30 10:39:43 +08:00
|
|
|
videoButton->disconnect();
|
|
|
|
if (video)
|
|
|
|
{
|
|
|
|
callButton->setObjectName("grey");
|
|
|
|
callButton->style()->polish(callButton);
|
|
|
|
videoButton->setObjectName("red");
|
|
|
|
videoButton->style()->polish(videoButton);
|
|
|
|
connect(videoButton, SIGNAL(clicked()), this, SLOT(onHangupCallTriggered()));
|
|
|
|
netcam->show();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
callButton->setObjectName("red");
|
|
|
|
callButton->style()->polish(callButton);
|
|
|
|
videoButton->setObjectName("grey");
|
|
|
|
videoButton->style()->polish(videoButton);
|
|
|
|
connect(callButton, SIGNAL(clicked()), this, SLOT(onHangupCallTriggered()));
|
|
|
|
}
|
2014-06-27 09:06:56 +08:00
|
|
|
}
|
|
|
|
|
2014-06-27 08:08:33 +08:00
|
|
|
void ChatForm::onAvEnding(int FriendId, int)
|
|
|
|
{
|
|
|
|
if (FriendId != f->friendId)
|
|
|
|
return;
|
2014-08-30 01:28:22 +08:00
|
|
|
|
|
|
|
audioInputFlag = false;
|
|
|
|
micButton->setObjectName("green");
|
|
|
|
micButton->style()->polish(micButton);
|
2014-06-30 10:39:43 +08:00
|
|
|
callButton->disconnect();
|
|
|
|
videoButton->disconnect();
|
2014-06-28 13:14:38 +08:00
|
|
|
callButton->setObjectName("green");
|
|
|
|
callButton->style()->polish(callButton);
|
2014-06-27 08:08:33 +08:00
|
|
|
callButton->disconnect();
|
2014-06-30 10:39:43 +08:00
|
|
|
videoButton->setObjectName("green");
|
|
|
|
videoButton->style()->polish(videoButton);
|
|
|
|
videoButton->disconnect();
|
2014-06-27 08:08:33 +08:00
|
|
|
connect(callButton, SIGNAL(clicked()), this, SLOT(onCallTriggered()));
|
2014-06-30 10:39:43 +08:00
|
|
|
connect(videoButton, SIGNAL(clicked()), this, SLOT(onVideoCallTriggered()));
|
|
|
|
netcam->hide();
|
2014-06-27 08:08:33 +08:00
|
|
|
}
|
|
|
|
|
2014-06-27 09:06:56 +08:00
|
|
|
void ChatForm::onAvRequestTimeout(int FriendId, int)
|
|
|
|
{
|
|
|
|
if (FriendId != f->friendId)
|
|
|
|
return;
|
2014-08-30 01:28:22 +08:00
|
|
|
|
|
|
|
audioInputFlag = false;
|
|
|
|
micButton->setObjectName("green");
|
|
|
|
micButton->style()->polish(micButton);
|
2014-06-30 10:39:43 +08:00
|
|
|
callButton->disconnect();
|
|
|
|
videoButton->disconnect();
|
2014-06-28 13:14:38 +08:00
|
|
|
callButton->setObjectName("green");
|
|
|
|
callButton->style()->polish(callButton);
|
2014-06-27 09:06:56 +08:00
|
|
|
callButton->disconnect();
|
2014-06-30 10:39:43 +08:00
|
|
|
videoButton->setObjectName("green");
|
|
|
|
videoButton->style()->polish(videoButton);
|
|
|
|
videoButton->disconnect();
|
2014-06-27 09:06:56 +08:00
|
|
|
connect(callButton, SIGNAL(clicked()), this, SLOT(onCallTriggered()));
|
2014-06-30 10:39:43 +08:00
|
|
|
connect(videoButton, SIGNAL(clicked()), this, SLOT(onVideoCallTriggered()));
|
|
|
|
netcam->hide();
|
2014-06-27 09:06:56 +08:00
|
|
|
}
|
|
|
|
|
2014-06-28 03:59:25 +08:00
|
|
|
void ChatForm::onAvPeerTimeout(int FriendId, int)
|
|
|
|
{
|
|
|
|
if (FriendId != f->friendId)
|
|
|
|
return;
|
2014-08-30 01:28:22 +08:00
|
|
|
|
|
|
|
audioInputFlag = false;
|
|
|
|
micButton->setObjectName("green");
|
|
|
|
micButton->style()->polish(micButton);
|
2014-06-30 10:39:43 +08:00
|
|
|
callButton->disconnect();
|
|
|
|
videoButton->disconnect();
|
2014-06-28 13:14:38 +08:00
|
|
|
callButton->setObjectName("green");
|
|
|
|
callButton->style()->polish(callButton);
|
2014-06-28 03:59:25 +08:00
|
|
|
callButton->disconnect();
|
2014-06-30 10:39:43 +08:00
|
|
|
videoButton->setObjectName("green");
|
|
|
|
videoButton->style()->polish(videoButton);
|
|
|
|
videoButton->disconnect();
|
2014-06-28 03:59:25 +08:00
|
|
|
connect(callButton, SIGNAL(clicked()), this, SLOT(onCallTriggered()));
|
2014-06-30 10:39:43 +08:00
|
|
|
connect(videoButton, SIGNAL(clicked()), this, SLOT(onVideoCallTriggered()));
|
|
|
|
netcam->hide();
|
2014-06-28 03:59:25 +08:00
|
|
|
}
|
|
|
|
|
2014-08-30 01:20:34 +08:00
|
|
|
void ChatForm::onAvMediaChange(int, int, bool video)
|
|
|
|
{
|
|
|
|
if (video)
|
|
|
|
{
|
|
|
|
netcam->show();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
netcam->hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-27 08:08:33 +08:00
|
|
|
void ChatForm::onAnswerCallTriggered()
|
|
|
|
{
|
2014-08-30 00:16:16 +08:00
|
|
|
audioInputFlag = true;
|
2014-06-27 08:08:33 +08:00
|
|
|
emit answerCall(callId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChatForm::onHangupCallTriggered()
|
|
|
|
{
|
2014-08-30 00:16:16 +08:00
|
|
|
audioInputFlag = false;
|
2014-06-27 08:08:33 +08:00
|
|
|
emit hangupCall(callId);
|
2014-08-20 01:15:56 +08:00
|
|
|
micButton->setObjectName("green");
|
|
|
|
micButton->style()->polish(micButton);
|
2014-06-27 06:42:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ChatForm::onCallTriggered()
|
|
|
|
{
|
2014-08-30 00:16:16 +08:00
|
|
|
audioInputFlag = true;
|
2014-08-19 23:20:20 +08:00
|
|
|
callButton->disconnect();
|
|
|
|
videoButton->disconnect();
|
|
|
|
emit startCall(f->friendId);
|
2014-06-27 09:06:56 +08:00
|
|
|
}
|
2014-06-27 06:42:45 +08:00
|
|
|
|
2014-06-30 10:39:43 +08:00
|
|
|
void ChatForm::onVideoCallTriggered()
|
|
|
|
{
|
2014-08-30 00:16:16 +08:00
|
|
|
audioInputFlag = true;
|
2014-06-30 10:39:43 +08:00
|
|
|
callButton->disconnect();
|
|
|
|
videoButton->disconnect();
|
|
|
|
emit startVideoCall(f->friendId, true);
|
|
|
|
}
|
|
|
|
|
2014-06-27 09:06:56 +08:00
|
|
|
void ChatForm::onCancelCallTriggered()
|
|
|
|
{
|
2014-08-30 00:16:16 +08:00
|
|
|
audioInputFlag = false;
|
2014-08-30 01:28:22 +08:00
|
|
|
micButton->setObjectName("green");
|
|
|
|
micButton->style()->polish(micButton);
|
2014-06-30 10:39:43 +08:00
|
|
|
callButton->disconnect();
|
|
|
|
videoButton->disconnect();
|
2014-06-28 13:14:38 +08:00
|
|
|
callButton->setObjectName("green");
|
|
|
|
callButton->style()->polish(callButton);
|
2014-06-27 09:06:56 +08:00
|
|
|
callButton->disconnect();
|
2014-06-30 10:39:43 +08:00
|
|
|
videoButton->setObjectName("green");
|
|
|
|
videoButton->style()->polish(videoButton);
|
|
|
|
videoButton->disconnect();
|
2014-06-27 09:06:56 +08:00
|
|
|
connect(callButton, SIGNAL(clicked()), this, SLOT(onCallTriggered()));
|
2014-06-30 10:39:43 +08:00
|
|
|
connect(videoButton, SIGNAL(clicked()), this, SLOT(onVideoCallTriggered()));
|
|
|
|
netcam->hide();
|
2014-06-27 09:06:56 +08:00
|
|
|
emit cancelCall(callId, f->friendId);
|
2014-06-27 06:42:45 +08:00
|
|
|
}
|
2014-06-28 07:48:54 +08:00
|
|
|
|
2014-08-19 23:20:20 +08:00
|
|
|
void ChatForm::onMicMuteToggle()
|
|
|
|
{
|
2014-08-30 00:16:16 +08:00
|
|
|
if (audioInputFlag == true)
|
2014-08-19 23:20:20 +08:00
|
|
|
{
|
2014-08-30 00:16:16 +08:00
|
|
|
emit micMuteToggle(callId);
|
|
|
|
if (micButton->objectName() == "red")
|
2014-08-19 23:20:20 +08:00
|
|
|
{
|
2014-08-30 00:16:16 +08:00
|
|
|
micButton->setObjectName("green");
|
|
|
|
micButton->style()->polish(micButton);
|
2014-08-19 23:20:20 +08:00
|
|
|
}
|
2014-08-30 00:16:16 +08:00
|
|
|
else
|
2014-08-19 23:20:20 +08:00
|
|
|
{
|
2014-08-30 00:16:16 +08:00
|
|
|
micButton->setObjectName("red");
|
|
|
|
micButton->style()->polish(micButton);
|
2014-08-19 23:20:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|