From 6762840cf62ab0d89732a426d01077be97f6ddb8 Mon Sep 17 00:00:00 2001 From: Andreas Traczyk Date: Fri, 8 Nov 2019 18:29:17 -0500 Subject: [PATCH] media messages: hide record buttons when in call Change-Id: I113246c5536e8ec4926127c4448427c3c4086468 --- callwidget.cpp | 12 +++++------- messagewebview.cpp | 18 +++++++++++++----- messagewebview.h | 1 + 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/callwidget.cpp b/callwidget.cpp index b542f6b..78d3196 100644 --- a/callwidget.cpp +++ b/callwidget.cpp @@ -713,13 +713,6 @@ CallWidget::slotShowIncomingCallView(const std::string& accountId, auto isCallSelected = LRCInstance::getCurrentConvUid() == convInfo.uid; ui->callingStatusLabel->setText(QString::fromStdString(lrc::api::call::to_string(call.status))); - connect(callModel, &lrc::api::NewCallModel::callStatusChanged, ui->incomingCallPage, - [this, accountId](const std::string& callId) { - auto callModel = LRCInstance::accountModel().getAccountInfo(accountId).callModel.get(); - auto call = callModel->getCall(callId); - ui->callingStatusLabel->setText(QString::fromStdString(lrc::api::call::to_string(call.status))); - }); - auto itemInCurrentFilter = false; if (call.isOutgoing) { if (isCallSelected) { @@ -1327,6 +1320,10 @@ CallWidget::connectAccount(const std::string& accountId) auto& accInfo = LRCInstance::accountModel().getAccountInfo(accountId); auto& callModel = accInfo.callModel; auto call = callModel->getCall(callId); + + // change status label text + ui->callingStatusLabel->setText(QString::fromStdString(lrc::api::call::to_string(call.status))); + switch (call.status) { case lrc::api::call::Status::INVALID: case lrc::api::call::Status::INACTIVE: @@ -1404,6 +1401,7 @@ CallWidget::setCallPanelVisibility(bool visible) ui->btnAudioCall->setVisible(!visible); ui->btnVideoCall->setVisible(!visible); ui->callStackWidget->setVisible(visible); + ui->messageView->setRecordButtonsVisibility(!visible); } void diff --git a/messagewebview.cpp b/messagewebview.cpp index 2118801..1d1b5dc 100644 --- a/messagewebview.cpp +++ b/messagewebview.cpp @@ -20,7 +20,12 @@ **************************************************************************/ #include "messagewebview.h" + #include "recordwidget.h" +#include "lrcinstance.h" +#include "messagewebpage.h" +#include "utils.h" +#include "webchathelpers.h" #include #include @@ -43,11 +48,6 @@ #include #include -#include "lrcinstance.h" -#include "messagewebpage.h" -#include "utils.h" -#include "webchathelpers.h" - MessageWebView::MessageWebView(QWidget *parent) : QWebEngineView(parent) { @@ -273,6 +273,14 @@ MessageWebView::openVideoRecorder(int spikePosX, int spikePosY) recordWidget_->openRecorder(false); } +void +MessageWebView::setRecordButtonsVisibility(bool visible) +{ + QString s = QString::fromLatin1("displayRecordControls(%1);") + .arg(visible ? "true" : "false"); + page()->runJavaScript(s, QWebEngineScript::MainWorld); +} + void MessageWebView::buildView() { auto html = Utils::QByteArrayFromFile(":/chatview.html"); diff --git a/messagewebview.h b/messagewebview.h index 84710e8..74859ca 100644 --- a/messagewebview.h +++ b/messagewebview.h @@ -93,6 +93,7 @@ public: void runJsText(); void openAudioRecorder(int spikePosX,int spikePosY); void openVideoRecorder(int spikePosX,int spikePosY); + void setRecordButtonsVisibility(bool visible); protected: -- 2.22.0