diff --git a/callwidget.cpp b/callwidget.cpp index 9c4b56f3760acae0f79739d6f182c1aa4120959f..4f28dd488fd0514f6e70ca07feefcb5fc74b26af 100644 --- a/callwidget.cpp +++ b/callwidget.cpp @@ -645,8 +645,19 @@ void CallWidget::slotShowCallView(const std::string& accountId, Q_UNUSED(convInfo); qDebug() << "slotShowCallView"; setCallPanelVisibility(true); + + auto callModel = LRCInstance::getCurrentCallModel(); + + if (callModel->hasCall(convInfo.callId)) { + auto call = callModel->getCall(convInfo.callId); + ui->videoWidget->resetVideoOverlay(call.audioMuted && (call.status != lrc::api::call::Status::PAUSED), + call.videoMuted && (call.status != lrc::api::call::Status::PAUSED) && (!call.isAudioOnly), + callModel->isRecording(convInfo.callId), + call.status == lrc::api::call::Status::PAUSED); + } else { + ui->videoWidget->resetVideoOverlay(false, false, false, false); + } ui->callStackWidget->setCurrentWidget(ui->videoPage); - ui->videoWidget->showChatviewIfToggled(); hideMiniSpinner(); ui->videoWidget->pushRenderer(convInfo.callId); } diff --git a/utils.h b/utils.h index ed4863752b050aef52eba7d905fa870cffed2304..64c68cd419836387cf0f868842a945bdde16cde5 100644 --- a/utils.h +++ b/utils.h @@ -155,6 +155,23 @@ oneShotConnect( const typename QtPrivate::FunctionPointer<Func1>::Object* sender }); } +template<class T> +class Blocker { + T *blocked; + bool previous; +public: + Blocker(T *blocked) + : blocked(blocked), + previous(blocked->blockSignals(true)) {} + ~Blocker() { blocked->blockSignals(previous); } + T *operator->() { return blocked; } +}; + +template<class T> +inline Blocker<T> whileBlocking(T *blocked) { + return Blocker<T>(blocked); +} + template<typename T> void setElidedText(T* object, const QString &text, Qt::TextElideMode mode = Qt::ElideMiddle, int padding = 32) { diff --git a/videooverlay.cpp b/videooverlay.cpp index c04965f934685093011935f5b4e916a869be7598..17d2d26bcba38f19f87cb579f817c0ed69a94f2f 100644 --- a/videooverlay.cpp +++ b/videooverlay.cpp @@ -175,3 +175,14 @@ VideoOverlay::on_recButton_clicked() callModel->toggleAudioRecord(callId_); } } + +void +VideoOverlay::resetOverlay(bool isAudioMuted, bool isVideoMuted, bool isRecording, bool isHolding) +{ + // Block the signals of buttons + Utils::whileBlocking(ui->noMicButton)->setChecked(isAudioMuted); + Utils::whileBlocking(ui->noVideoButton)->setChecked(isVideoMuted); + Utils::whileBlocking(ui->recButton)->setChecked(isRecording); + Utils::whileBlocking(ui->holdButton)->setChecked(isHolding); + Utils::whileBlocking(ui->onHoldLabel)->setVisible(isHolding); +} diff --git a/videooverlay.h b/videooverlay.h index 28cef61a37fd0a4b014ff706e99b9c53c6886b3c..640c1eb6b6abfe22f9277e4cd02b566578bf5b6a 100644 --- a/videooverlay.h +++ b/videooverlay.h @@ -45,6 +45,7 @@ public: bool shouldShowOverlay(); void simulateShowChatview(bool checked); bool getShowChatView(); + void resetOverlay(bool isAudioMuted, bool isVideoMuted, bool isRecording, bool isHolding); //UI SLOTS private slots: diff --git a/videoview.cpp b/videoview.cpp index ad2aa533242d0ebab1f80ce2366c2a72bb30e511..61e54e36572ca1e5f2b6b63faa4d285436758bd1 100644 --- a/videoview.cpp +++ b/videoview.cpp @@ -171,12 +171,6 @@ VideoView::slotCallStatusChanged(const std::string& callId) QObject::disconnect(timerConnection_); } -void -VideoView::showChatviewIfToggled() -{ - emit setChatVisibility(overlay_->getShowChatView()); -} - void VideoView::simulateShowChatview(bool checked) { @@ -432,3 +426,9 @@ VideoView::mouseMoveEvent(QMouseEvent* event) and geometry().contains(event->pos())) previewRect.setBottomRight(event->pos()); } +void +VideoView::resetVideoOverlay(bool isAudioMuted, bool isVideoMuted, bool isRecording, bool isHolding) +{ + emit overlay_->setChatVisibility(false); + overlay_->resetOverlay(isAudioMuted, isVideoMuted, isRecording, isHolding); +} diff --git a/videoview.h b/videoview.h index 44e07a189739a4ce42f669cc0ea84c9c6778f3e3..f07bef2ceb945422719f3408d0a3cb42a9ba5bb0 100644 --- a/videoview.h +++ b/videoview.h @@ -37,8 +37,8 @@ public: explicit VideoView(QWidget* parent = 0); ~VideoView(); void pushRenderer(const std::string& callUid); - void showChatviewIfToggled(); void simulateShowChatview(bool checked); + void resetVideoOverlay(bool isAudioMuted, bool isVideoMuted, bool isRecording, bool isHolding); protected: void resizeEvent(QResizeEvent* event);