Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 1 | /*************************************************************************** |
Anthony LĂ©onard | 2fde81d | 2017-04-17 10:06:55 -0400 | [diff] [blame] | 2 | * Copyright (C) 2015-2017 by Savoir-faire Linux * |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 3 | * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>* |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame] | 4 | * Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> * |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 5 | * * |
| 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 SOLDANO | 223bcc8 | 2017-07-19 16:05:05 -0400 | [diff] [blame] | 23 | // LRC |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 24 | #include "callmodel.h" |
Edric Milaret | 31484f1 | 2016-02-02 14:26:27 -0500 | [diff] [blame] | 25 | #include "contactmethod.h" |
| 26 | #include "person.h" |
Olivier SOLDANO | 09ef23a | 2017-08-02 17:03:18 -0400 | [diff] [blame] | 27 | #include "account.h" |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 28 | |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame] | 29 | #include "lrcinstance.h" |
| 30 | #include "utils.h" |
Olivier SOLDANO | 223bcc8 | 2017-07-19 16:05:05 -0400 | [diff] [blame] | 31 | |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 32 | VideoOverlay::VideoOverlay(QWidget* parent) : |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 33 | QWidget(parent), |
Andreas Traczyk | 7548e73 | 2018-12-12 10:47:21 -0500 | [diff] [blame] | 34 | ui(new Ui::VideoOverlay) |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 35 | { |
| 36 | ui->setupUi(this); |
| 37 | |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame] | 38 | ui->bottomButtons->setMouseTracking(true); |
| 39 | |
Edric Milaret | 3aca8e3 | 2015-06-12 10:01:40 -0400 | [diff] [blame] | 40 | ui->chatButton->setCheckable(true); |
| 41 | |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 42 | setAttribute(Qt::WA_NoSystemBackground); |
Edric Milaret | 5927d04 | 2015-06-15 12:45:29 -0400 | [diff] [blame] | 43 | |
Nicolas Jager | 97a21b4 | 2015-12-03 16:55:45 -0500 | [diff] [blame] | 44 | ui->noMicButton->setCheckable(true); |
Edric Milaret | 5927d04 | 2015-06-15 12:45:29 -0400 | [diff] [blame] | 45 | |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame] | 46 | ui->onHoldLabel->setVisible(false); |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | VideoOverlay::~VideoOverlay() |
| 50 | { |
| 51 | delete ui; |
| 52 | } |
| 53 | |
| 54 | void |
| 55 | VideoOverlay::setName(const QString& name) |
| 56 | { |
| 57 | ui->nameLabel->setText(name); |
| 58 | } |
| 59 | |
| 60 | void |
| 61 | VideoOverlay::setTime(const QString& time) |
| 62 | { |
| 63 | ui->timerLabel->setText(time); |
| 64 | } |
| 65 | |
Olivier SOLDANO | 223bcc8 | 2017-07-19 16:05:05 -0400 | [diff] [blame] | 66 | void VideoOverlay::toggleContextButtons(bool visible) |
| 67 | { |
| 68 | if (! visible) { |
| 69 | ui->videoCfgBtn->hide(); |
Olivier SOLDANO | 223bcc8 | 2017-07-19 16:05:05 -0400 | [diff] [blame] | 70 | } else { |
| 71 | ui->videoCfgBtn->show(); |
Olivier SOLDANO | 223bcc8 | 2017-07-19 16:05:05 -0400 | [diff] [blame] | 72 | } |
| 73 | } |
| 74 | |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 75 | void |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame] | 76 | VideoOverlay::setVideoMuteVisibility(bool visible) |
| 77 | { |
| 78 | ui->noVideoButton->setVisible(visible); |
| 79 | } |
| 80 | |
| 81 | bool |
| 82 | VideoOverlay::shouldShowOverlay() |
| 83 | { |
| 84 | return ui->bottomButtons->underMouse() || ui->topInfoBar->underMouse(); |
| 85 | } |
| 86 | |
| 87 | void |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 88 | VideoOverlay::on_hangupButton_clicked() |
| 89 | { |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame] | 90 | 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 Milaret | 3aca8e3 | 2015-06-12 10:01:40 -0400 | [diff] [blame] | 98 | ui->chatButton->setChecked(false); |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | void |
| 102 | VideoOverlay::on_chatButton_toggled(bool checked) |
| 103 | { |
Edric Milaret | 3aca8e3 | 2015-06-12 10:01:40 -0400 | [diff] [blame] | 104 | emit setChatVisibility(checked); |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 105 | } |
| 106 | |
Edric Milaret | 5cbf2b6 | 2015-07-09 11:36:53 -0400 | [diff] [blame] | 107 | void |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 108 | VideoOverlay::on_holdButton_clicked() |
| 109 | { |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame] | 110 | 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 Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 121 | } |
| 122 | |
Nicolas Jager | 97a21b4 | 2015-12-03 16:55:45 -0500 | [diff] [blame] | 123 | void |
| 124 | VideoOverlay::on_noMicButton_clicked() |
| 125 | { |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame] | 126 | 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 Jager | 97a21b4 | 2015-12-03 16:55:45 -0500 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | void |
| 138 | VideoOverlay::on_noVideoButton_clicked() |
| 139 | { |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame] | 140 | 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 Jager | 97a21b4 | 2015-12-03 16:55:45 -0500 | [diff] [blame] | 149 | } |
| 150 | |
Edric Milaret | 31484f1 | 2016-02-02 14:26:27 -0500 | [diff] [blame] | 151 | void |
Edric Milaret | a5fe70f | 2016-02-05 15:03:31 -0500 | [diff] [blame] | 152 | VideoOverlay::on_recButton_clicked() |
| 153 | { |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame] | 154 | 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 Milaret | a5fe70f | 2016-02-05 15:03:31 -0500 | [diff] [blame] | 162 | } |
Olivier SOLDANO | 2bcdfd7 | 2017-05-02 14:37:19 -0400 | [diff] [blame] | 163 | |
Olivier SOLDANO | 2bcdfd7 | 2017-05-02 14:37:19 -0400 | [diff] [blame] | 164 | void VideoOverlay::on_videoCfgBtn_clicked() |
| 165 | { |
| 166 | emit videoCfgBtnClicked(); |
| 167 | } |