mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge branch 'pr1045'
This commit is contained in:
commit
a62b1dc7ac
1
res.qrc
1
res.qrc
|
@ -229,5 +229,6 @@
|
|||
<file>ui/window/window.css</file>
|
||||
<file>ui/acceptCall/acceptCall.png</file>
|
||||
<file>ui/rejectCall/rejectCall.png</file>
|
||||
<file>ui/volButton/volButtonDisabled.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -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();
|
||||
|
@ -279,9 +280,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
|
||||
|
@ -293,11 +292,11 @@ void ChatForm::onAvInvite(int FriendId, int CallId, bool video)
|
|||
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());
|
||||
|
||||
|
@ -326,21 +325,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();
|
||||
}
|
||||
|
@ -357,20 +356,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();
|
||||
|
||||
|
@ -387,21 +373,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();
|
||||
|
@ -423,7 +396,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
|
||||
{
|
||||
|
@ -431,7 +405,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());
|
||||
|
@ -478,22 +453,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();
|
||||
|
||||
|
@ -510,23 +470,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();
|
||||
}
|
||||
|
||||
|
@ -539,23 +484,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();
|
||||
}
|
||||
|
@ -570,22 +500,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());
|
||||
|
||||
|
@ -631,10 +546,8 @@ void ChatForm::onHangupCallTriggered()
|
|||
audioInputFlag = false;
|
||||
audioOutputFlag = false;
|
||||
emit hangupCall(callId);
|
||||
micButton->setObjectName("green");
|
||||
micButton->style()->polish(micButton);
|
||||
volButton->setObjectName("green");
|
||||
volButton->style()->polish(volButton);
|
||||
|
||||
enableCallButtons();
|
||||
}
|
||||
|
||||
void ChatForm::onRejectCallTriggered()
|
||||
|
@ -650,10 +563,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()
|
||||
|
@ -688,37 +600,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();
|
||||
delete disableCallButtonsTimer;
|
||||
disableCallButtonsTimer = nullptr;
|
||||
}
|
||||
|
||||
void ChatForm::onMicMuteToggle()
|
||||
|
@ -900,11 +852,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();
|
||||
}
|
||||
|
@ -912,20 +864,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;
|
||||
|
||||
delete callDurationTimer;
|
||||
callDurationTimer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void ChatForm::updateTime()
|
||||
void ChatForm::onUpdateTime()
|
||||
{
|
||||
callDuration->setText(secondsToDHMS(timeElapsed.elapsed()/1000));
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user