1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00
This commit is contained in:
agilob 2015-01-25 22:19:25 +00:00
parent 0eba4fefca
commit 17561a8c3b
No known key found for this signature in database
GPG Key ID: 34568050DBCCB997
3 changed files with 110 additions and 145 deletions

View File

@ -68,7 +68,8 @@ ChatForm::ChatForm(Friend* chatFriend)
mainLayout->insertWidget(1, isTypingLabel);
netcam = new NetCamView();
timer = nullptr;
callDurationTimer = nullptr;
disableCallButtonsTimer = nullptr;
headTextLayout->addWidget(statusMessageLabel);
headTextLayout->addStretch();
@ -277,9 +278,7 @@ void ChatForm::onAvInvite(int FriendId, int CallId, bool video)
connect(callConfirm, &CallConfirmWidget::rejected, this, &ChatForm::onRejectCallTriggered);
callButton->setObjectName("grey");
callButton->style()->polish(callButton);
videoButton->setObjectName("yellow");
videoButton->style()->polish(videoButton);
connect(videoButton, &QPushButton::clicked, this, &ChatForm::onAnswerCallTriggered);
}
else
@ -290,12 +289,12 @@ void ChatForm::onAvInvite(int FriendId, int CallId, bool video)
connect(callConfirm, &CallConfirmWidget::accepted, this, &ChatForm::onAnswerCallTriggered);
connect(callConfirm, &CallConfirmWidget::rejected, this, &ChatForm::onRejectCallTriggered);
callButton->setObjectName("yellow");
callButton->style()->polish(callButton);
videoButton->setObjectName("grey");
videoButton->style()->polish(videoButton);
connect(callButton, &QPushButton::clicked, this, &ChatForm::onAnswerCallTriggered);
}
callButton->style()->polish(callButton);
videoButton->style()->polish(videoButton);
addSystemInfoMessage(tr("%1 is calling").arg(f->getDisplayedName()), "white", QDateTime::currentDateTime());
@ -324,21 +323,21 @@ void ChatForm::onAvStart(int FriendId, int CallId, bool video)
if (video)
{
callButton->setObjectName("grey");
callButton->style()->polish(callButton);
videoButton->setObjectName("red");
videoButton->style()->polish(videoButton);
connect(videoButton, SIGNAL(clicked()), this, SLOT(onHangupCallTriggered()));
connect(videoButton, SIGNAL(clicked()),
this, SLOT(onHangupCallTriggered()));
netcam->show(Core::getInstance()->getVideoSourceFromCall(CallId), f->getDisplayedName());
}
else
{
callButton->setObjectName("red");
callButton->style()->polish(callButton);
videoButton->setObjectName("grey");
videoButton->style()->polish(videoButton);
connect(callButton, SIGNAL(clicked()), this, SLOT(onHangupCallTriggered()));
connect(callButton, SIGNAL(clicked()),
this, SLOT(onHangupCallTriggered()));
}
callButton->style()->polish(callButton);
videoButton->style()->polish(videoButton);
startCounter();
}
@ -355,20 +354,7 @@ void ChatForm::onAvCancel(int FriendId, int)
stopCounter();
audioInputFlag = false;
audioOutputFlag = false;
micButton->setObjectName("green");
micButton->style()->polish(micButton);
volButton->setObjectName("green");
volButton->style()->polish(volButton);
callButton->disconnect();
videoButton->disconnect();
callButton->setObjectName("green");
callButton->style()->polish(callButton);
videoButton->setObjectName("green");
videoButton->style()->polish(videoButton);
connect(callButton, SIGNAL(clicked()), this, SLOT(onCallTriggered()));
connect(videoButton, SIGNAL(clicked()), this, SLOT(onVideoCallTriggered()));
enableCallButtons();
netcam->hide();
@ -385,21 +371,8 @@ void ChatForm::onAvEnd(int FriendId, int)
delete callConfirm;
callConfirm = nullptr;
audioInputFlag = false;
audioOutputFlag = false;
micButton->setObjectName("green");
micButton->style()->polish(micButton);
volButton->setObjectName("green");
volButton->style()->polish(volButton);
callButton->disconnect();
videoButton->disconnect();
callButton->setObjectName("green");
callButton->style()->polish(callButton);
videoButton->setObjectName("green");
videoButton->style()->polish(videoButton);
connect(callButton, SIGNAL(clicked()), this, SLOT(onCallTriggered()));
connect(videoButton, SIGNAL(clicked()), this, SLOT(onVideoCallTriggered()));
enableCallButtons();
netcam->hide();
stopCounter();
@ -421,7 +394,8 @@ void ChatForm::onAvRinging(int FriendId, int CallId, bool video)
callButton->style()->polish(callButton);
videoButton->setObjectName("yellow");
videoButton->style()->polish(videoButton);
connect(videoButton, SIGNAL(clicked()), this, SLOT(onCancelCallTriggered()));
connect(videoButton, SIGNAL(clicked()),
this, SLOT(onCancelCallTriggered()));
}
else
{
@ -429,7 +403,8 @@ void ChatForm::onAvRinging(int FriendId, int CallId, bool video)
callButton->style()->polish(callButton);
videoButton->setObjectName("grey");
videoButton->style()->polish(videoButton);
connect(callButton, SIGNAL(clicked()), this, SLOT(onCancelCallTriggered()));
connect(callButton, SIGNAL(clicked()),
this, SLOT(onCancelCallTriggered()));
}
addSystemInfoMessage(tr("Calling to %1").arg(f->getDisplayedName()), "white", QDateTime::currentDateTime());
@ -476,22 +451,7 @@ void ChatForm::onAvEnding(int FriendId, int)
delete callConfirm;
callConfirm = nullptr;
audioInputFlag = false;
audioOutputFlag = false;
micButton->setObjectName("green");
micButton->style()->polish(micButton);
volButton->setObjectName("green");
volButton->style()->polish(volButton);
callButton->disconnect();
videoButton->disconnect();
callButton->setObjectName("green");
callButton->style()->polish(callButton);
callButton->disconnect();
videoButton->setObjectName("green");
videoButton->style()->polish(videoButton);
videoButton->disconnect();
connect(callButton, SIGNAL(clicked()), this, SLOT(onCallTriggered()));
connect(videoButton, SIGNAL(clicked()), this, SLOT(onVideoCallTriggered()));
enableCallButtons();
netcam->hide();
@ -508,23 +468,8 @@ void ChatForm::onAvRequestTimeout(int FriendId, int)
delete callConfirm;
callConfirm = nullptr;
audioInputFlag = false;
audioOutputFlag = false;
micButton->setObjectName("green");
micButton->style()->polish(micButton);
volButton->setObjectName("green");
volButton->style()->polish(volButton);
callButton->disconnect();
videoButton->disconnect();
callButton->setObjectName("green");
callButton->style()->polish(callButton);
callButton->disconnect();
videoButton->setObjectName("green");
videoButton->style()->polish(videoButton);
videoButton->disconnect();
connect(callButton, SIGNAL(clicked()), this, SLOT(onCallTriggered()));
connect(videoButton, SIGNAL(clicked()), this, SLOT(onVideoCallTriggered()));
enableCallButtons();
netcam->hide();
}
@ -537,23 +482,8 @@ void ChatForm::onAvPeerTimeout(int FriendId, int)
delete callConfirm;
callConfirm = nullptr;
audioInputFlag = false;
audioOutputFlag = false;
micButton->setObjectName("green");
micButton->style()->polish(micButton);
volButton->setObjectName("green");
volButton->style()->polish(volButton);
callButton->disconnect();
videoButton->disconnect();
callButton->setObjectName("green");
callButton->style()->polish(callButton);
callButton->disconnect();
videoButton->setObjectName("green");
videoButton->style()->polish(videoButton);
videoButton->disconnect();
connect(callButton, SIGNAL(clicked()), this, SLOT(onCallTriggered()));
connect(videoButton, SIGNAL(clicked()), this, SLOT(onVideoCallTriggered()));
enableCallButtons();
netcam->hide();
}
@ -568,22 +498,7 @@ void ChatForm::onAvRejected(int FriendId, int)
delete callConfirm;
callConfirm = nullptr;
audioInputFlag = false;
audioOutputFlag = false;
micButton->setObjectName("green");
micButton->style()->polish(micButton);
volButton->setObjectName("green");
volButton->style()->polish(volButton);
callButton->disconnect();
videoButton->disconnect();
callButton->setObjectName("green");
callButton->style()->polish(callButton);
callButton->disconnect();
videoButton->setObjectName("green");
videoButton->style()->polish(videoButton);
videoButton->disconnect();
connect(callButton, SIGNAL(clicked()), this, SLOT(onCallTriggered()));
connect(videoButton, SIGNAL(clicked()), this, SLOT(onVideoCallTriggered()));
enableCallButtons();
addSystemInfoMessage(tr("Call rejected"), "white", QDateTime::currentDateTime());
@ -629,10 +544,6 @@ void ChatForm::onHangupCallTriggered()
audioInputFlag = false;
audioOutputFlag = false;
emit hangupCall(callId);
micButton->setObjectName("green");
micButton->style()->polish(micButton);
volButton->setObjectName("green");
volButton->style()->polish(volButton);
}
void ChatForm::onRejectCallTriggered()
@ -648,10 +559,9 @@ void ChatForm::onRejectCallTriggered()
audioInputFlag = false;
audioOutputFlag = false;
emit rejectCall(callId);
micButton->setObjectName("green");
micButton->style()->polish(micButton);
volButton->setObjectName("green");
volButton->style()->polish(volButton);
enableCallButtons();
}
void ChatForm::onCallTriggered()
@ -686,37 +596,77 @@ void ChatForm::onAvCallFailed(int FriendId)
delete callConfirm;
callConfirm = nullptr;
audioInputFlag = false;
audioOutputFlag = false;
callButton->disconnect();
videoButton->disconnect();
connect(callButton, SIGNAL(clicked()), this, SLOT(onCallTriggered()));
connect(videoButton, SIGNAL(clicked()), this, SLOT(onVideoCallTriggered()));
enableCallButtons();
}
void ChatForm::onCancelCallTriggered()
{
qDebug() << "onCancelCallTriggered";
enableCallButtons();
netcam->hide();
emit cancelCall(callId, f->getFriendID());
}
void ChatForm::enableCallButtons()
{
qDebug() << "enableCallButtons";
audioInputFlag = false;
audioOutputFlag = false;
micButton->setObjectName("grey");
micButton->style()->polish(micButton);
micButton->disconnect();
volButton->setObjectName("grey");
volButton->style()->polish(volButton);
volButton->disconnect();
callButton->setObjectName("grey");
callButton->style()->polish(callButton);
callButton->disconnect();
videoButton->setObjectName("grey");
videoButton->style()->polish(videoButton);
videoButton->disconnect();
if(disableCallButtonsTimer == nullptr)
{
disableCallButtonsTimer = new QTimer();
connect(disableCallButtonsTimer, SIGNAL(timeout()),
this, SLOT(onEnableCallButtons()));
disableCallButtonsTimer->start(1500); // 1.5sec
qDebug() << "timer started!!";
}
}
void ChatForm::onEnableCallButtons()
{
qDebug() << "onEnableCallButtons";
audioInputFlag = false;
audioOutputFlag = false;
micButton->setObjectName("green");
micButton->style()->polish(micButton);
volButton->setObjectName("green");
volButton->style()->polish(volButton);
callButton->disconnect();
videoButton->disconnect();
callButton->setObjectName("green");
callButton->style()->polish(callButton);
callButton->disconnect();
videoButton->setObjectName("green");
videoButton->style()->polish(videoButton);
videoButton->disconnect();
connect(callButton, SIGNAL(clicked()), this, SLOT(onCallTriggered()));
connect(videoButton, SIGNAL(clicked()), this, SLOT(onVideoCallTriggered()));
netcam->hide();
emit cancelCall(callId, f->getFriendID());
connect(callButton, SIGNAL(clicked()),
this, SLOT(onCallTriggered()));
connect(videoButton, SIGNAL(clicked()),
this, SLOT(onVideoCallTriggered()));
connect(micButton, SIGNAL(clicked()),
this, SLOT(onMicMuteToggle()));
connect(volButton, SIGNAL(clicked()),
this, SLOT(onVolMuteToggle()));
disableCallButtonsTimer->stop();
disableCallButtonsTimer = nullptr;
delete disableCallButtonsTimer;
}
void ChatForm::onMicMuteToggle()
@ -898,11 +848,11 @@ void ChatForm::onLoadHistory()
void ChatForm::startCounter()
{
if (!timer)
if (!callDurationTimer)
{
timer = new QTimer();
connect(timer, SIGNAL(timeout()), this, SLOT(updateTime()));
timer->start(1000);
callDurationTimer = new QTimer();
connect(callDurationTimer, SIGNAL(timeout()), this, SLOT(onUpdateTime()));
callDurationTimer->start(1000);
timeElapsed.start();
callDuration->show();
}
@ -910,20 +860,21 @@ void ChatForm::startCounter()
void ChatForm::stopCounter()
{
if (timer)
{
if (callDurationTimer)
{
addSystemInfoMessage(tr("Call with %1 ended. %2").arg(f->getDisplayedName(),
secondsToDHMS(timeElapsed.elapsed()/1000)),
"white", QDateTime::currentDateTime());
timer->stop();
callDurationTimer->stop();
callDuration->setText("");
callDuration->hide();
timer = nullptr;
delete timer;
callDurationTimer = nullptr;
delete callDurationTimer;
}
}
void ChatForm::updateTime()
void ChatForm::onUpdateTime()
{
callDuration->setText(secondsToDHMS(timeElapsed.elapsed()/1000));
}

View File

@ -19,10 +19,11 @@
#include "genericchatform.h"
#include "src/corestructs.h"
#include <QSet>
#include <QLabel>
#include <QTimer>
#include <QElapsedTimer>
#include <QSet>
struct Friend;
class FileTransferInstance;
@ -93,7 +94,8 @@ private slots:
void onFileTansBtnClicked(QString widgetName, QString buttonName);
void onFileSendFailed(int FriendId, const QString &fname);
void onLoadHistory();
void updateTime();
void onUpdateTime();
void onEnableCallButtons();
protected:
// drag & drop
@ -108,10 +110,11 @@ private:
NetCamView* netcam;
int callId;
QLabel *callDuration;
QTimer *timer;
QTimer *callDurationTimer;
QTimer typingTimer;
QTimer *disableCallButtonsTimer;
QElapsedTimer timeElapsed;
QLabel *isTypingLabel;
QTimer typingTimer;
QHash<uint, FileTransferInstance*> ftransWidgets;
void startCounter();
@ -120,6 +123,7 @@ private:
QHash<int, int> receipts;
QMap<int, MessageActionPtr> undeliveredMsgs;
CallConfirmWidget *callConfirm;
void enableCallButtons();
};
#endif // CHATFORM_H

View File

@ -23,6 +23,16 @@ QPushButton#red
height: 18px;
}
QPushButton#grey
{
background-color: transparent;
background-image: url(":/ui/volButton/volButtonDisabled.png");
background-repeat: none;
border: none;
width: 22px;
height: 18px;
}
QPushButton:focus {
outline: none;
}