diff --git a/src/core/coreav.cpp b/src/core/coreav.cpp index cbb02efec..6da937044 100644 --- a/src/core/coreav.cpp +++ b/src/core/coreav.cpp @@ -83,6 +83,7 @@ void CoreAV::answerCall(uint32_t friendNum) else { qWarning() << "Failed to answer call with error"<(_self); assert(self->calls.contains(friendNum)); diff --git a/src/core/coreav.h b/src/core/coreav.h index 8e6469d9e..b02e4e84e 100644 --- a/src/core/coreav.h +++ b/src/core/coreav.h @@ -94,13 +94,7 @@ signals: void avCancel(uint32_t friendId); void avEnd(uint32_t friendId); void avRinging(uint32_t friendId, bool video); - void avStarting(uint32_t friendId, bool video); - void avEnding(uint32_t friendId); - void avRequestTimeout(uint32_t friendId); - void avPeerTimeout(uint32_t friendId); - void avMediaChange(uint32_t friendId, bool videoEnabled); void avCallFailed(uint32_t friendId); - void avRejected(uint32_t friendId); void videoFrameReceived(vpx_image* frame); diff --git a/src/widget/form/chatform.cpp b/src/widget/form/chatform.cpp index 7b1d3cad9..6963a7240 100644 --- a/src/widget/form/chatform.cpp +++ b/src/widget/form/chatform.cpp @@ -313,10 +313,9 @@ void ChatForm::onAvStart(uint32_t FriendId, bool video) if (video) { - callButton->setObjectName("grey"); - callButton->setToolTip(""); videoButton->setObjectName("red"); videoButton->setToolTip(tr("End video call")); + videoButton->style()->polish(videoButton); connect(videoButton, SIGNAL(clicked()), this, SLOT(onHangupCallTriggered())); @@ -326,14 +325,11 @@ void ChatForm::onAvStart(uint32_t FriendId, bool video) { callButton->setObjectName("red"); callButton->setToolTip(tr("End audio call")); - videoButton->setObjectName("grey"); - videoButton->setToolTip(""); + callButton->style()->polish(callButton); connect(callButton, SIGNAL(clicked()), this, SLOT(onHangupCallTriggered())); hideNetcam(); } - callButton->style()->polish(callButton); - videoButton->style()->polish(videoButton); micButton->setObjectName("green"); micButton->style()->polish(micButton); @@ -370,95 +366,6 @@ void ChatForm::onAvCancel(uint32_t FriendId) QDateTime::currentDateTime()); } -void ChatForm::onAvRinging(uint32_t FriendId, bool video) -{ - if (FriendId != f->getFriendID()) - return; - - qDebug() << "onAvRinging"; - - callButton->disconnect(); - videoButton->disconnect(); - if (video) - { - callButton->setObjectName("grey"); - callButton->style()->polish(callButton); - callButton->setToolTip(""); - videoButton->setObjectName("yellow"); - videoButton->style()->polish(videoButton); - videoButton->setToolTip(tr("Cancel video call")); - connect(videoButton, SIGNAL(clicked()), - this, SLOT(onCancelCallTriggered())); - } - else - { - callButton->setObjectName("yellow"); - callButton->style()->polish(callButton); - callButton->setToolTip(tr("Cancel audio call")); - videoButton->setObjectName("grey"); - videoButton->style()->polish(videoButton); - videoButton->setToolTip(""); - connect(callButton, SIGNAL(clicked()), - this, SLOT(onCancelCallTriggered())); - } - - addSystemInfoMessage(tr("Calling to %1").arg(f->getDisplayedName()), - ChatMessage::INFO, - QDateTime::currentDateTime()); - - Widget::getInstance()->updateFriendActivity(f); -} - -void ChatForm::onAvStarting(uint32_t FriendId, bool video) -{ - if (FriendId != f->getFriendID()) - return; - - qDebug() << "onAvStarting"; - - disableCallButtons(); - if (video) - { - callButton->setObjectName("grey"); - callButton->style()->polish(callButton); - callButton->setToolTip(""); - videoButton->setObjectName("red"); - videoButton->style()->polish(videoButton); - videoButton->setToolTip(tr("End video call")); - connect(videoButton, SIGNAL(clicked()), this, SLOT(onHangupCallTriggered())); - - showNetcam(); - } - else - { - callButton->setObjectName("red"); - callButton->style()->polish(callButton); - callButton->setToolTip(tr("End audio call")); - videoButton->setObjectName("grey"); - videoButton->style()->polish(videoButton); - videoButton->setToolTip(""); - connect(callButton, SIGNAL(clicked()), this, SLOT(onHangupCallTriggered())); - } - - startCounter(); -} - -void ChatForm::onAvEnding(uint32_t FriendId) -{ - if (FriendId != f->getFriendID()) - return; - - qDebug() << "onAvEnding"; - - delete callConfirm; - callConfirm = nullptr; - - enableCallButtons(); - stopCounter(); - CameraSource::getInstance().unsubscribe(); - hideNetcam(); -} - void ChatForm::onAvEnd(uint32_t FriendId) { if (FriendId != f->getFriendID()) @@ -474,68 +381,36 @@ void ChatForm::onAvEnd(uint32_t FriendId) hideNetcam(); } -void ChatForm::onAvRequestTimeout(uint32_t FriendId) +void ChatForm::onAvRinging(uint32_t FriendId, bool video) { if (FriendId != f->getFriendID()) return; - qDebug() << "onAvRequestTimeout"; - - delete callConfirm; - callConfirm = nullptr; - - enableCallButtons(); - stopCounter(); - hideNetcam(); -} - -void ChatForm::onAvPeerTimeout(uint32_t FriendId) -{ - if (FriendId != f->getFriendID()) - return; - - qDebug() << "onAvPeerTimeout"; - - delete callConfirm; - callConfirm = nullptr; - - enableCallButtons(); - stopCounter(); - - hideNetcam(); -} - -void ChatForm::onAvRejected(uint32_t FriendId) -{ - if (FriendId != f->getFriendID()) - return; - - qDebug() << "onAvRejected"; - - delete callConfirm; - callConfirm = nullptr; - - enableCallButtons(); - stopCounter(); - - insertChatMessage(ChatMessage::createChatInfoMessage(tr("Call rejected"), - ChatMessage::INFO, - QDateTime::currentDateTime())); - - hideNetcam(); -} - -void ChatForm::onAvMediaChange(uint32_t FriendId, bool video) -{ - if (FriendId != f->getFriendID()) - return; - - qDebug() << "onAvMediaChange"; + qDebug() << "onAvRinging"; + disableCallButtons(); if (video) - showNetcam(); + { + videoButton->setObjectName("yellow"); + videoButton->style()->polish(videoButton); + videoButton->setToolTip(tr("Cancel video call")); + connect(videoButton, SIGNAL(clicked()), + this, SLOT(onCancelCallTriggered())); + } else - hideNetcam(); + { + callButton->setObjectName("yellow"); + callButton->style()->polish(callButton); + callButton->setToolTip(tr("Cancel audio call")); + connect(callButton, SIGNAL(clicked()), + this, SLOT(onCancelCallTriggered())); + } + + addSystemInfoMessage(tr("Calling %1").arg(f->getDisplayedName()), + ChatMessage::INFO, + QDateTime::currentDateTime()); + + Widget::getInstance()->updateFriendActivity(f); } void ChatForm::onAnswerCallTriggered() @@ -548,6 +423,8 @@ void ChatForm::onAnswerCallTriggered() callConfirm = nullptr; } + disableCallButtons(); + audioInputFlag = true; audioOutputFlag = true; emit answerCall(f->getFriendID()); @@ -593,8 +470,7 @@ void ChatForm::onCallTriggered() audioInputFlag = true; audioOutputFlag = true; - callButton->disconnect(); - videoButton->disconnect(); + disableCallButtons(); emit startCall(f->getFriendID(), false); } @@ -604,8 +480,7 @@ void ChatForm::onVideoCallTriggered() audioInputFlag = true; audioOutputFlag = true; - callButton->disconnect(); - videoButton->disconnect(); + disableCallButtons(); emit startCall(f->getFriendID(), true); } diff --git a/src/widget/form/chatform.h b/src/widget/form/chatform.h index 6a0bd43e8..286f8b387 100644 --- a/src/widget/form/chatform.h +++ b/src/widget/form/chatform.h @@ -69,13 +69,7 @@ public slots: void onAvCancel(uint32_t FriendId); void onAvEnd(uint32_t FriendId); void onAvRinging(uint32_t FriendId, bool video); - void onAvStarting(uint32_t FriendId, bool video); - void onAvEnding(uint32_t FriendId); - void onAvRequestTimeout(uint32_t FriendId); - void onAvPeerTimeout(uint32_t FriendId); - void onAvMediaChange(uint32_t FriendId, bool video); void onAvCallFailed(uint32_t FriendId); - void onAvRejected(uint32_t FriendId); void onMicMuteToggle(); void onVolMuteToggle(); void onAvatarChange(uint32_t FriendId, const QPixmap& pic); diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index 0a6470707..73339e0d0 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -906,13 +906,7 @@ void Widget::addFriend(int friendId, const QString &userId) connect(coreav, &CoreAV::avCancel, newfriend->getChatForm(), &ChatForm::onAvCancel); connect(coreav, &CoreAV::avEnd, newfriend->getChatForm(), &ChatForm::onAvEnd); connect(coreav, &CoreAV::avRinging, newfriend->getChatForm(), &ChatForm::onAvRinging); - connect(coreav, &CoreAV::avStarting, newfriend->getChatForm(), &ChatForm::onAvStarting); - connect(coreav, &CoreAV::avEnding, newfriend->getChatForm(), &ChatForm::onAvEnding); - connect(coreav, &CoreAV::avRequestTimeout, newfriend->getChatForm(), &ChatForm::onAvRequestTimeout); - connect(coreav, &CoreAV::avPeerTimeout, newfriend->getChatForm(), &ChatForm::onAvPeerTimeout); - connect(coreav, &CoreAV::avMediaChange, newfriend->getChatForm(), &ChatForm::onAvMediaChange); connect(coreav, &CoreAV::avCallFailed, newfriend->getChatForm(), &ChatForm::onAvCallFailed); - connect(coreav, &CoreAV::avRejected, newfriend->getChatForm(), &ChatForm::onAvRejected); connect(core, &Core::friendAvatarChanged, newfriend->getChatForm(), &ChatForm::onAvatarChange); connect(core, &Core::friendAvatarChanged, newfriend->getFriendWidget(), &FriendWidget::onAvatarChange); connect(core, &Core::friendAvatarRemoved, newfriend->getChatForm(), &ChatForm::onAvatarRemoved);