Skip to content
Snippets Groups Projects
Commit a493d5bf authored by Andreas Traczyk's avatar Andreas Traczyk
Browse files

ui: fix time on call overlay

Change-Id: I132f7c7aba3111d7bc1bd186bd67a6c174e0ac27
parent 1cf20c77
No related branches found
No related tags found
No related merge requests found
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include "videooverlay.h" #include "videooverlay.h"
#include "ui_videooverlay.h" #include "ui_videooverlay.h"
#include <QTime>
// LRC // LRC
#include "callmodel.h" #include "callmodel.h"
#include "contactmethod.h" #include "contactmethod.h"
...@@ -45,27 +47,6 @@ VideoOverlay::VideoOverlay(QWidget* parent) : ...@@ -45,27 +47,6 @@ VideoOverlay::VideoOverlay(QWidget* parent) :
ui->noMicButton->setCheckable(true); ui->noMicButton->setCheckable(true);
ui->onHoldLabel->setVisible(false); 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() VideoOverlay::~VideoOverlay()
...@@ -73,6 +54,15 @@ VideoOverlay::~VideoOverlay() ...@@ -73,6 +54,15 @@ VideoOverlay::~VideoOverlay()
delete ui; 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 void
VideoOverlay::setName(const QString& name) VideoOverlay::setName(const QString& name)
{ {
...@@ -82,32 +72,16 @@ VideoOverlay::setName(const QString& name) ...@@ -82,32 +72,16 @@ VideoOverlay::setName(const QString& name)
void void
VideoOverlay::setTime() VideoOverlay::setTime()
{ {
if (callId.empty()) { return; } if (callId_.empty()) {
return;
}
try { try {
auto callInfo = LRCInstance::getCurrentCallModel()->getCall(callId); auto callInfo = LRCInstance::getCurrentCallModel()->getCall(callId_);
if (callInfo.status == lrc::api::call::Status::IN_PROGRESS) { if (callInfo.status == lrc::api::call::Status::IN_PROGRESS) {
int numSeconds = std::chrono::duration_cast<std::chrono::seconds>( int numSeconds = std::chrono::duration_cast<std::chrono::seconds>(
std::chrono::steady_clock::now() - callInfo.startTime).count(); std::chrono::steady_clock::now() - callInfo.startTime).count();
QTime t(0, 0, numSeconds);
QString labelSec; ui->timerLabel->setText(t.toString(numSeconds > 3600 ? "hh:mm:ss" : "mm:ss"));
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);
} }
} catch (...) { } } catch (...) { }
} }
......
...@@ -36,6 +36,7 @@ public: ...@@ -36,6 +36,7 @@ public:
public: public:
void setName(const QString& name); void setName(const QString& name);
void callStarted(const std::string & callId);
inline bool isDialogVisible(){ return dialogVisible_; }; inline bool isDialogVisible(){ return dialogVisible_; };
void toggleContextButtons(bool visible); void toggleContextButtons(bool visible);
void setVideoMuteVisibility(bool visible); void setVideoMuteVisibility(bool visible);
...@@ -43,11 +44,9 @@ public: ...@@ -43,11 +44,9 @@ public:
void simulateShowChatview(bool checked); void simulateShowChatview(bool checked);
bool getShowChatView(); bool getShowChatView();
public slots:
void setTime();
//UI SLOTS //UI SLOTS
private slots: private slots:
void setTime();
void on_hangupButton_clicked(); void on_hangupButton_clicked();
void on_chatButton_toggled(bool checked); void on_chatButton_toggled(bool checked);
void on_holdButton_clicked(); void on_holdButton_clicked();
...@@ -60,10 +59,9 @@ private: ...@@ -60,10 +59,9 @@ private:
Ui::VideoOverlay* ui; Ui::VideoOverlay* ui;
bool dialogVisible_ = false; bool dialogVisible_ = false;
QTimer* oneSecondTimer_; QTimer* oneSecondTimer_;
std::string callId; std::string callId_;
signals: signals:
void setChatVisibility(bool visible); void setChatVisibility(bool visible);
void videoCfgBtnClicked(); void videoCfgBtnClicked();
}; };
...@@ -324,21 +324,23 @@ VideoView::showContextMenu(const QPoint& pos) ...@@ -324,21 +324,23 @@ VideoView::showContextMenu(const QPoint& pos)
} }
void void
VideoView::pushRenderer(const std::string& callUid) { VideoView::pushRenderer(const std::string& callId) {
auto callModel = LRCInstance::getCurrentCallModel(); auto callModel = LRCInstance::getCurrentCallModel();
QObject::disconnect(videoStartedConnection_); QObject::disconnect(videoStartedConnection_);
if (!callModel->hasCall(callUid)) { if (!callModel->hasCall(callId)) {
return; 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, videoStartedConnection_ = QObject::connect(callModel, &lrc::api::NewCallModel::remotePreviewStarted,
[this](const std::string& callId, Video::Renderer* renderer) { [this](const std::string& callId, Video::Renderer* renderer) {
Q_UNUSED(callId); Q_UNUSED(callId);
slotVideoStarted(renderer); slotVideoStarted(renderer);
this->overlay_->setVideoMuteVisibility(!LRCInstance::getCurrentCallModel()->getCall(callId).isAudioOnly);
}); });
ui->videoWidget->setPreviewDisplay(call.type != lrc::api::call::Type::CONFERENCE); ui->videoWidget->setPreviewDisplay(call.type != lrc::api::call::Type::CONFERENCE);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment