From 60a3e631730cbe00e8d8bc8afbbee748787ad258 Mon Sep 17 00:00:00 2001 From: Ming Rui Zhang <mingrui.zhang@savoirfairelinux.com> Date: Wed, 7 Aug 2019 17:03:59 -0400 Subject: [PATCH] callwidget: reset videooverlay when conversation changed from one to another - keep the button state as the setting od the user - set chatview close by default Change-Id: Idd6d1c4f1173d7dbe23eda9008f7d2b1b70ef7db --- callwidget.cpp | 13 ++++++++++++- utils.h | 17 +++++++++++++++++ videooverlay.cpp | 11 +++++++++++ videooverlay.h | 1 + videoview.cpp | 12 ++++++------ videoview.h | 2 +- 6 files changed, 48 insertions(+), 8 deletions(-) diff --git a/callwidget.cpp b/callwidget.cpp index 9c4b56f..4f28dd4 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 ed48637..64c68cd 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 c04965f..17d2d26 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 28cef61..640c1eb 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 ad2aa53..61e54e3 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 44e07a1..f07bef2 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); -- GitLab