blob: a358dee490c4b3735c9318aea0fb48fbae791d14 [file] [log] [blame]
Edric Milaret029b95a2015-06-09 09:51:44 -04001/***************************************************************************
Anthony LĂ©onard2fde81d2017-04-17 10:06:55 -04002 * Copyright (C) 2015-2017 by Savoir-faire Linux *
Edric Milaret029b95a2015-06-09 09:51:44 -04003 * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
Andreas Traczykb8b13ba2018-08-21 16:30:16 -04004 * Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> *
Edric Milaret029b95a2015-06-09 09:51:44 -04005 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 **************************************************************************/
19
20#include "videooverlay.h"
21#include "ui_videooverlay.h"
22
Olivier SOLDANO223bcc82017-07-19 16:05:05 -040023// LRC
Edric Milaret029b95a2015-06-09 09:51:44 -040024#include "callmodel.h"
Edric Milaret31484f12016-02-02 14:26:27 -050025#include "contactmethod.h"
26#include "person.h"
Olivier SOLDANO09ef23a2017-08-02 17:03:18 -040027#include "account.h"
Edric Milaret029b95a2015-06-09 09:51:44 -040028
Andreas Traczykb8b13ba2018-08-21 16:30:16 -040029#include "lrcinstance.h"
30#include "utils.h"
Olivier SOLDANO223bcc82017-07-19 16:05:05 -040031
Edric Milaret80e0b212015-10-16 10:07:43 -040032VideoOverlay::VideoOverlay(QWidget* parent) :
Edric Milaret029b95a2015-06-09 09:51:44 -040033 QWidget(parent),
Andreas Traczyk7548e732018-12-12 10:47:21 -050034 ui(new Ui::VideoOverlay)
Edric Milaret029b95a2015-06-09 09:51:44 -040035{
36 ui->setupUi(this);
37
Andreas Traczykb8b13ba2018-08-21 16:30:16 -040038 ui->bottomButtons->setMouseTracking(true);
39
Edric Milaret3aca8e32015-06-12 10:01:40 -040040 ui->chatButton->setCheckable(true);
41
Edric Milaret029b95a2015-06-09 09:51:44 -040042 setAttribute(Qt::WA_NoSystemBackground);
Edric Milaret5927d042015-06-15 12:45:29 -040043
Nicolas Jager97a21b42015-12-03 16:55:45 -050044 ui->noMicButton->setCheckable(true);
Edric Milaret5927d042015-06-15 12:45:29 -040045
Andreas Traczykb8b13ba2018-08-21 16:30:16 -040046 ui->onHoldLabel->setVisible(false);
Edric Milaret029b95a2015-06-09 09:51:44 -040047}
48
49VideoOverlay::~VideoOverlay()
50{
51 delete ui;
52}
53
54void
55VideoOverlay::setName(const QString& name)
56{
57 ui->nameLabel->setText(name);
58}
59
60void
61VideoOverlay::setTime(const QString& time)
62{
63 ui->timerLabel->setText(time);
64}
65
Olivier SOLDANO223bcc82017-07-19 16:05:05 -040066void VideoOverlay::toggleContextButtons(bool visible)
67{
68 if (! visible) {
69 ui->videoCfgBtn->hide();
Olivier SOLDANO223bcc82017-07-19 16:05:05 -040070 } else {
71 ui->videoCfgBtn->show();
Olivier SOLDANO223bcc82017-07-19 16:05:05 -040072 }
73}
74
Edric Milaret029b95a2015-06-09 09:51:44 -040075void
Andreas Traczykb8b13ba2018-08-21 16:30:16 -040076VideoOverlay::setVideoMuteVisibility(bool visible)
77{
78 ui->noVideoButton->setVisible(visible);
79}
80
81bool
82VideoOverlay::shouldShowOverlay()
83{
84 return ui->bottomButtons->underMouse() || ui->topInfoBar->underMouse();
85}
86
87void
Edric Milaret029b95a2015-06-09 09:51:44 -040088VideoOverlay::on_hangupButton_clicked()
89{
Andreas Traczykb8b13ba2018-08-21 16:30:16 -040090 auto selectedConvUid = LRCInstance::getSelectedConvUid();
91 auto conversation = Utils::getConversationFromUid(selectedConvUid,
92 *LRCInstance::getCurrentConversationModel());
93 auto& callId = conversation->callId;
94 auto callModel = LRCInstance::getCurrentCallModel();
95 if (callModel->hasCall(callId)) {
96 callModel->hangUp(callId);
97 }
Edric Milaret3aca8e32015-06-12 10:01:40 -040098 ui->chatButton->setChecked(false);
Edric Milaret029b95a2015-06-09 09:51:44 -040099}
100
101void
102VideoOverlay::on_chatButton_toggled(bool checked)
103{
Edric Milaret3aca8e32015-06-12 10:01:40 -0400104 emit setChatVisibility(checked);
Edric Milaret029b95a2015-06-09 09:51:44 -0400105}
106
Edric Milaret5cbf2b62015-07-09 11:36:53 -0400107void
Edric Milaret80e0b212015-10-16 10:07:43 -0400108VideoOverlay::on_holdButton_clicked()
109{
Andreas Traczykb8b13ba2018-08-21 16:30:16 -0400110 auto selectedConvUid = LRCInstance::getSelectedConvUid();
111 auto conversation = Utils::getConversationFromUid(selectedConvUid,
112 *LRCInstance::getCurrentConversationModel());
113 auto& callId = conversation->callId;
114 auto callModel = LRCInstance::getCurrentCallModel();
115 if (callModel->hasCall(callId)) {
116 auto onHold = callModel->getCall(callId).status == lrc::api::call::Status::PAUSED;
117 ui->holdButton->setChecked(!onHold);
118 ui->onHoldLabel->setVisible(!onHold);
119 callModel->togglePause(callId);
120 }
Edric Milaret80e0b212015-10-16 10:07:43 -0400121}
122
Nicolas Jager97a21b42015-12-03 16:55:45 -0500123void
124VideoOverlay::on_noMicButton_clicked()
125{
Andreas Traczykb8b13ba2018-08-21 16:30:16 -0400126 auto selectedConvUid = LRCInstance::getSelectedConvUid();
127 auto conversation = Utils::getConversationFromUid(selectedConvUid,
128 *LRCInstance::getCurrentConversationModel());
129 auto& callId = conversation->callId;
130 auto callModel = LRCInstance::getCurrentCallModel();
131 if (callModel->hasCall(callId)) {
132 ui->noMicButton->setChecked(callModel->getCall(callId).audioMuted);
133 callModel->toggleMedia(callId, lrc::api::NewCallModel::Media::AUDIO);
134 }
Nicolas Jager97a21b42015-12-03 16:55:45 -0500135}
136
137void
138VideoOverlay::on_noVideoButton_clicked()
139{
Andreas Traczykb8b13ba2018-08-21 16:30:16 -0400140 auto selectedConvUid = LRCInstance::getSelectedConvUid();
141 auto conversation = Utils::getConversationFromUid(selectedConvUid,
142 *LRCInstance::getCurrentConversationModel());
143 auto& callId = conversation->callId;
144 auto callModel = LRCInstance::getCurrentCallModel();
145 if (callModel->hasCall(callId)) {
146 ui->noVideoButton->setChecked(callModel->getCall(callId).videoMuted);
147 callModel->toggleMedia(callId, lrc::api::NewCallModel::Media::VIDEO);
148 }
Nicolas Jager97a21b42015-12-03 16:55:45 -0500149}
150
Edric Milaret31484f12016-02-02 14:26:27 -0500151void
Edric Milareta5fe70f2016-02-05 15:03:31 -0500152VideoOverlay::on_recButton_clicked()
153{
Andreas Traczykb8b13ba2018-08-21 16:30:16 -0400154 auto selectedConvUid = LRCInstance::getSelectedConvUid();
155 auto conversation = Utils::getConversationFromUid(selectedConvUid,
156 *LRCInstance::getCurrentConversationModel());
157 auto& callId = conversation->callId;
158 auto callModel = LRCInstance::getCurrentCallModel();
159 if (callModel->hasCall(callId)) {
160 callModel->toggleAudioRecord(callId);
161 }
Edric Milareta5fe70f2016-02-05 15:03:31 -0500162}
Olivier SOLDANO2bcdfd72017-05-02 14:37:19 -0400163
Olivier SOLDANO2bcdfd72017-05-02 14:37:19 -0400164void VideoOverlay::on_videoCfgBtn_clicked()
165{
166 emit videoCfgBtnClicked();
167}