Commit ca027aba authored by Isa's avatar Isa Committed by Andreas Traczyk

fix: show duration of call during call

Change-Id: I6b4d8522bdf9554871314a22d49ff51002840931
parent 43865373
......@@ -31,7 +31,8 @@
VideoOverlay::VideoOverlay(QWidget* parent) :
QWidget(parent),
ui(new Ui::VideoOverlay)
ui(new Ui::VideoOverlay),
oneSecondTimer_(new QTimer(this))
{
ui->setupUi(this);
......@@ -44,6 +45,12 @@ VideoOverlay::VideoOverlay(QWidget* parent) :
ui->noMicButton->setCheckable(true);
ui->onHoldLabel->setVisible(false);
connect(LRCInstance::getCurrentCallModel(), &lrc::api::NewCallModel::callStarted,
[this](const std::string& tempCallId) { callId = tempCallId; });
connect(oneSecondTimer_, &QTimer::timeout, this, &VideoOverlay::setTime);
oneSecondTimer_->start(1000);
}
VideoOverlay::~VideoOverlay()
......@@ -58,9 +65,35 @@ VideoOverlay::setName(const QString& name)
}
void
VideoOverlay::setTime(const QString& time)
VideoOverlay::setTime()
{
ui->timerLabel->setText(time);
if (callId.empty()) { return; }
auto callInfo = LRCInstance::getCurrentCallModel()->getCall(callId);
if(callInfo.status == lrc::api::call::Status::IN_PROGRESS) {
int numSeconds = std::chrono::duration_cast<std::chrono::seconds>(
std::chrono::steady_clock::now() - callInfo.startTime).count();
QString labelSec;
QString labelMin;
int numMinutes = numSeconds / 60;
int remainder = numSeconds - numMinutes * 60;
if (remainder < 10) {
labelSec = ":0" + QString::number(remainder);
} else {
labelSec = ":" + QString::number(remainder);
}
if (numMinutes < 10) {
labelMin = "0" + QString::number(numMinutes);
} else {
labelMin = QString::number(numMinutes);
}
ui->timerLabel->setText(labelMin + labelSec);
}
}
void VideoOverlay::toggleContextButtons(bool visible)
......
......@@ -20,6 +20,7 @@
#include <QWidget>
#include <QMenu>
#include <QTimer>
namespace Ui {
class VideoOverlay;
......@@ -35,7 +36,6 @@ public:
public:
void setName(const QString& name);
void setTime(const QString& time);
inline bool isDialogVisible(){ return dialogVisible_; };
void toggleContextButtons(bool visible);
void setVideoMuteVisibility(bool visible);
......@@ -43,6 +43,9 @@ public:
void simulateShowChatview(bool checked);
bool getShowChatView();
public slots:
void setTime();
//UI SLOTS
private slots:
void on_hangupButton_clicked();
......@@ -56,6 +59,8 @@ private slots:
private:
Ui::VideoOverlay* ui;
bool dialogVisible_ = false;
QTimer* oneSecondTimer_;
std::string callId;
signals:
void setChatVisibility(bool visible);
......
......@@ -70,6 +70,7 @@ VideoView::VideoView(QWidget* parent) :
emit this->setChatVisibility(visible);
});
connect(overlay_, &VideoOverlay::videoCfgBtnClicked, [=](){emit videoSettingsClicked();});
}
VideoView::~VideoView()
......@@ -187,7 +188,6 @@ VideoView::updateCall()
{
if (auto call = CallModel::instance().selectedCall()) {
overlay_->setName(call->formattedName());
overlay_->setTime(call->length());
}
}
......
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