From ac75f7b5944dc6dfc0b7334b22f53a159d8e7bc7 Mon Sep 17 00:00:00 2001 From: tWido Date: Sat, 1 Jul 2017 15:17:43 +0200 Subject: [PATCH] feat(video): Error message on call fail notifies user if call ended unexpectedly --- src/core/coreav.cpp | 2 +- src/core/coreav.h | 2 +- src/widget/form/chatform.cpp | 11 +++++++---- src/widget/form/chatform.h | 4 ++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/core/coreav.cpp b/src/core/coreav.cpp index ed814f3b9..7ff001728 100644 --- a/src/core/coreav.cpp +++ b/src/core/coreav.cpp @@ -728,7 +728,7 @@ void CoreAV::stateCallback(ToxAV* toxav, uint32_t friendNum, uint32_t state, voi if (state & TOXAV_FRIEND_CALL_STATE_ERROR) { qWarning() << "Call with friend" << friendNum << "died of unnatural causes!"; calls.remove(friendNum); - emit self->avEnd(friendNum); + emit self->avEnd(friendNum, true); } else if (state & TOXAV_FRIEND_CALL_STATE_FINISHED) { qDebug() << "Call with friend" << friendNum << "finished quietly"; calls.remove(friendNum); diff --git a/src/core/coreav.h b/src/core/coreav.h index b714a251c..843e3c400 100644 --- a/src/core/coreav.h +++ b/src/core/coreav.h @@ -92,7 +92,7 @@ public slots: signals: void avInvite(uint32_t friendId, bool video); void avStart(uint32_t friendId, bool video); - void avEnd(uint32_t friendId); + void avEnd(uint32_t friendId, bool error = false); private slots: static void callCallback(ToxAV* toxAV, uint32_t friendNum, bool audio, bool video, void* self); diff --git a/src/widget/form/chatform.cpp b/src/widget/form/chatform.cpp index 0f245bbc1..54f0bb446 100644 --- a/src/widget/form/chatform.cpp +++ b/src/widget/form/chatform.cpp @@ -378,7 +378,7 @@ void ChatForm::onAvStart(uint32_t friendId, bool video) startCounter(); } -void ChatForm::onAvEnd(uint32_t friendId) +void ChatForm::onAvEnd(uint32_t friendId, bool error) { if (friendId != f->getFriendId()) { return; @@ -392,7 +392,7 @@ void ChatForm::onAvEnd(uint32_t friendId) } updateCallButtons(); - stopCounter(); + stopCounter(error); hideNetcam(); } @@ -891,14 +891,17 @@ void ChatForm::startCounter() callDuration->show(); } -void ChatForm::stopCounter() +void ChatForm::stopCounter(bool error) { if (!callDurationTimer) { return; } QString dhms = secondsToDHMS(timeElapsed.elapsed() / 1000); QString name = f->getDisplayedName(); - addSystemInfoMessage(tr("Call with %1 ended. %2").arg(name, dhms), ChatMessage::INFO, + QString mess = error ? "Call with %1 ended unexpectedly. %2" : "Call with %1 ended. %2"; + // TODO: add notification once notifications are implemented + + addSystemInfoMessage(tr(mess.toStdString().c_str()).arg(name, dhms), ChatMessage::INFO, QDateTime::currentDateTime()); callDurationTimer->stop(); callDuration->setText(""); diff --git a/src/widget/form/chatform.h b/src/widget/form/chatform.h index 18e2826a2..489096abf 100644 --- a/src/widget/form/chatform.h +++ b/src/widget/form/chatform.h @@ -68,7 +68,7 @@ public slots: void onFileRecvRequest(ToxFile file); void onAvInvite(uint32_t friendId, bool video); void onAvStart(uint32_t friendId, bool video); - void onAvEnd(uint32_t friendId); + void onAvEnd(uint32_t friendId, bool error); void onAvatarChange(uint32_t friendId, const QPixmap& pic); void onAvatarRemoved(uint32_t friendId); @@ -108,7 +108,7 @@ private: void retranslateUi(); void showOutgoingCall(bool video); void startCounter(); - void stopCounter(); + void stopCounter(bool error = false); void updateCallButtons(); void SendMessageStr(QString msg);