Commit eed6f065 authored by Ming Rui Zhang's avatar Ming Rui Zhang Committed by Andreas Traczyk

videoview: add key presss and key release events to catch DTMF input for sip calls

Change-Id: I8fe7996fa90652cf24504154531eba04736fc517
parent 6edfff10
......@@ -663,6 +663,7 @@ void CallWidget::slotShowCallView(const std::string& accountId,
ui->callStackWidget->setCurrentWidget(ui->videoPage);
hideMiniSpinner();
ui->videoWidget->pushRenderer(convInfo.callId, LRCInstance::accountModel().getAccountInfo(accountId).profileInfo.type == lrc::api::profile::Type::SIP);
ui->videoWidget->setFocus();
}
void CallWidget::slotShowIncomingCallView(const std::string& accountId,
......
......@@ -345,6 +345,7 @@ VideoView::showContextMenu(const QPoint& pos)
void
VideoView::pushRenderer(const std::string& callId, bool isSIP) {
currentCallId_ = callId;
auto callModel = LRCInstance::getCurrentCallModel();
QObject::disconnect(ui->videoWidget);
......@@ -464,3 +465,26 @@ VideoView::connectRendering(bool started)
ui->videoWidget->connectRendering();
}
}
void
VideoView::keyPressEvent(QKeyEvent *event)
{
// used to manage DTMF
// For "#" and "*", qt will automatically read the shift + 3 or 8
keyPressed_ = event->key();
QWidget::keyPressEvent(event);
}
void
VideoView::keyReleaseEvent(QKeyEvent *event)
{
if (keyPressed_ == static_cast<int>(Qt::Key_NumberSign)) {
LRCInstance::getCurrentCallModel()->playDTMF(currentCallId_, "#");
} else if (keyPressed_ == static_cast<int>(Qt::Key_Asterisk)) {
LRCInstance::getCurrentCallModel()->playDTMF(currentCallId_, "*");
} else if (keyPressed_ >= 48 && keyPressed_ <= 57){
//enum Qt::Key_0 = 48, QT::Key_9 = 57
LRCInstance::getCurrentCallModel()->playDTMF(currentCallId_, std::to_string(keyPressed_ - 48));
}
QWidget::keyReleaseEvent(event);
}
......@@ -21,6 +21,7 @@
#include <QWidget>
#include <QTimer>
#include <QMouseEvent>
#include <QKeyEvent>
#include <QPropertyAnimation>
#include "videooverlay.h"
......@@ -56,6 +57,8 @@ protected:
void mousePressEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
void mouseMoveEvent(QMouseEvent* event);
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event);
private slots:
void slotCallStatusChanged(const std::string& callId);
......@@ -77,6 +80,8 @@ private:
bool draggingPreview_ = false;
bool resizingPreview_ = false;
bool sharingEntireScreen_ = false;
std::string currentCallId_;
int keyPressed_;
constexpr static int fadeOverlayTime_ = 1000; //msec
constexpr static int resizeGrip_ = 40;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment