Commit a493d5bf authored by Andreas Traczyk's avatar Andreas Traczyk

ui: fix time on call overlay

Change-Id: I132f7c7aba3111d7bc1bd186bd67a6c174e0ac27
parent 1cf20c77
......@@ -20,6 +20,8 @@
#include "videooverlay.h"
#include "ui_videooverlay.h"
#include <QTime>
// LRC
#include "callmodel.h"
#include "contactmethod.h"
......@@ -45,27 +47,6 @@ VideoOverlay::VideoOverlay(QWidget* parent) :
ui->noMicButton->setCheckable(true);
ui->onHoldLabel->setVisible(false);
auto accountList = LRCInstance::accountModel().getAccountList();
if (!accountList.size()) {
Utils::oneShotConnect(&LRCInstance::accountModel(),
&lrc::api::NewAccountModel::accountAdded,
[this](const std::string& accountId) {
Q_UNUSED(accountId);
connect(LRCInstance::getCurrentCallModel(), &lrc::api::NewCallModel::callStarted,
[this](const std::string& tempCallId) {
callId = tempCallId;
});
});
} else {
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()
......@@ -73,6 +54,15 @@ VideoOverlay::~VideoOverlay()
delete ui;
}
void
VideoOverlay::callStarted(const std::string& callId)
{
ui->timerLabel->setText("00:00");
callId_ = callId;
connect(oneSecondTimer_, &QTimer::timeout, this, &VideoOverlay::setTime);
oneSecondTimer_->start(1000);
}
void
VideoOverlay::setName(const QString& name)
{
......@@ -82,32 +72,16 @@ VideoOverlay::setName(const QString& name)
void
VideoOverlay::setTime()
{
if (callId.empty()) { return; }
if (callId_.empty()) {
return;
}
try {
auto callInfo = LRCInstance::getCurrentCallModel()->getCall(callId);
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);
QTime t(0, 0, numSeconds);
ui->timerLabel->setText(t.toString(numSeconds > 3600 ? "hh:mm:ss" : "mm:ss"));
}
} catch (...) { }
}
......
......@@ -36,6 +36,7 @@ public:
public:
void setName(const QString& name);
void callStarted(const std::string & callId);
inline bool isDialogVisible(){ return dialogVisible_; };
void toggleContextButtons(bool visible);
void setVideoMuteVisibility(bool visible);
......@@ -43,11 +44,9 @@ public:
void simulateShowChatview(bool checked);
bool getShowChatView();
public slots:
void setTime();
//UI SLOTS
private slots:
void setTime();
void on_hangupButton_clicked();
void on_chatButton_toggled(bool checked);
void on_holdButton_clicked();
......@@ -60,10 +59,9 @@ private:
Ui::VideoOverlay* ui;
bool dialogVisible_ = false;
QTimer* oneSecondTimer_;
std::string callId;
std::string callId_;
signals:
void setChatVisibility(bool visible);
void videoCfgBtnClicked();
};
......@@ -324,21 +324,23 @@ VideoView::showContextMenu(const QPoint& pos)
}
void
VideoView::pushRenderer(const std::string& callUid) {
VideoView::pushRenderer(const std::string& callId) {
auto callModel = LRCInstance::getCurrentCallModel();
QObject::disconnect(videoStartedConnection_);
if (!callModel->hasCall(callUid)) {
if (!callModel->hasCall(callId)) {
return;
}
auto call = callModel->getCall(callUid);
auto call = callModel->getCall(callId);
this->overlay_->callStarted(callId);
this->overlay_->setVideoMuteVisibility(!LRCInstance::getCurrentCallModel()->getCall(callId).isAudioOnly);
videoStartedConnection_ = QObject::connect(callModel, &lrc::api::NewCallModel::remotePreviewStarted,
[this](const std::string& callId, Video::Renderer* renderer) {
Q_UNUSED(callId);
slotVideoStarted(renderer);
this->overlay_->setVideoMuteVisibility(!LRCInstance::getCurrentCallModel()->getCall(callId).isAudioOnly);
});
ui->videoWidget->setPreviewDisplay(call.type != lrc::api::call::Type::CONFERENCE);
}
......
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