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 | // Client |
Edric Milaret | 31484f1 | 2016-02-02 14:26:27 -0500 | [diff] [blame] | 24 | #include "contactpicker.h" |
| 25 | |
Olivier SOLDANO | 223bcc8 | 2017-07-19 16:05:05 -0400 | [diff] [blame] | 26 | // LRC |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 27 | #include "callmodel.h" |
Edric Milaret | 31484f1 | 2016-02-02 14:26:27 -0500 | [diff] [blame] | 28 | #include "contactmethod.h" |
| 29 | #include "person.h" |
Olivier SOLDANO | 09ef23a | 2017-08-02 17:03:18 -0400 | [diff] [blame] | 30 | #include "account.h" |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 31 | |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame^] | 32 | #include "lrcinstance.h" |
| 33 | #include "utils.h" |
Olivier SOLDANO | 223bcc8 | 2017-07-19 16:05:05 -0400 | [diff] [blame] | 34 | |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 35 | VideoOverlay::VideoOverlay(QWidget* parent) : |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 36 | QWidget(parent), |
Edric Milaret | 5cbf2b6 | 2015-07-09 11:36:53 -0400 | [diff] [blame] | 37 | ui(new Ui::VideoOverlay), |
Edric Milaret | 864a205 | 2016-01-14 15:45:03 -0500 | [diff] [blame] | 38 | transferDialog_(new CallUtilsDialog()), |
| 39 | qualityDialog_(new QualityDialog()) |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 40 | { |
| 41 | ui->setupUi(this); |
| 42 | |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame^] | 43 | ui->bottomButtons->setMouseTracking(true); |
| 44 | |
Edric Milaret | 3aca8e3 | 2015-06-12 10:01:40 -0400 | [diff] [blame] | 45 | ui->chatButton->setCheckable(true); |
| 46 | |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 47 | setAttribute(Qt::WA_NoSystemBackground); |
Edric Milaret | 5927d04 | 2015-06-15 12:45:29 -0400 | [diff] [blame] | 48 | |
Nicolas Jager | 97a21b4 | 2015-12-03 16:55:45 -0500 | [diff] [blame] | 49 | ui->noMicButton->setCheckable(true); |
Edric Milaret | 5927d04 | 2015-06-15 12:45:29 -0400 | [diff] [blame] | 50 | |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame^] | 51 | ui->onHoldLabel->setVisible(false); |
Nicolas Jager | 0a9fc60 | 2016-03-11 18:35:42 -0500 | [diff] [blame] | 52 | |
| 53 | transferDialog_->setAttribute(Qt::WA_TranslucentBackground); |
| 54 | connect(transferDialog_, &CallUtilsDialog::isVisible, [this] (bool visible) { |
| 55 | dialogVisible_ = visible; |
| 56 | }); |
| 57 | |
| 58 | qualityDialog_->setAttribute(Qt::WA_TranslucentBackground); |
| 59 | connect(qualityDialog_, &QualityDialog::isVisible, [this] (bool visible) { |
| 60 | dialogVisible_ = visible; |
| 61 | }); |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | VideoOverlay::~VideoOverlay() |
| 65 | { |
| 66 | delete ui; |
Edric Milaret | 5cbf2b6 | 2015-07-09 11:36:53 -0400 | [diff] [blame] | 67 | delete transferDialog_; |
Edric Milaret | 864a205 | 2016-01-14 15:45:03 -0500 | [diff] [blame] | 68 | delete qualityDialog_; |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | void |
| 72 | VideoOverlay::setName(const QString& name) |
| 73 | { |
| 74 | ui->nameLabel->setText(name); |
| 75 | } |
| 76 | |
| 77 | void |
| 78 | VideoOverlay::setTime(const QString& time) |
| 79 | { |
| 80 | ui->timerLabel->setText(time); |
| 81 | } |
| 82 | |
Olivier SOLDANO | 223bcc8 | 2017-07-19 16:05:05 -0400 | [diff] [blame] | 83 | void VideoOverlay::toggleContextButtons(bool visible) |
| 84 | { |
| 85 | if (! visible) { |
| 86 | ui->videoCfgBtn->hide(); |
Olivier SOLDANO | 223bcc8 | 2017-07-19 16:05:05 -0400 | [diff] [blame] | 87 | } else { |
| 88 | ui->videoCfgBtn->show(); |
Olivier SOLDANO | 223bcc8 | 2017-07-19 16:05:05 -0400 | [diff] [blame] | 89 | } |
| 90 | } |
| 91 | |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 92 | void |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame^] | 93 | VideoOverlay::setVideoMuteVisibility(bool visible) |
| 94 | { |
| 95 | ui->noVideoButton->setVisible(visible); |
| 96 | } |
| 97 | |
| 98 | bool |
| 99 | VideoOverlay::shouldShowOverlay() |
| 100 | { |
| 101 | return ui->bottomButtons->underMouse() || ui->topInfoBar->underMouse(); |
| 102 | } |
| 103 | |
| 104 | void |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 105 | VideoOverlay::on_hangupButton_clicked() |
| 106 | { |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame^] | 107 | auto selectedConvUid = LRCInstance::getSelectedConvUid(); |
| 108 | auto conversation = Utils::getConversationFromUid(selectedConvUid, |
| 109 | *LRCInstance::getCurrentConversationModel()); |
| 110 | auto& callId = conversation->callId; |
| 111 | auto callModel = LRCInstance::getCurrentCallModel(); |
| 112 | if (callModel->hasCall(callId)) { |
| 113 | callModel->hangUp(callId); |
| 114 | } |
Edric Milaret | 3aca8e3 | 2015-06-12 10:01:40 -0400 | [diff] [blame] | 115 | ui->chatButton->setChecked(false); |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | void |
| 119 | VideoOverlay::on_chatButton_toggled(bool checked) |
| 120 | { |
Edric Milaret | 3aca8e3 | 2015-06-12 10:01:40 -0400 | [diff] [blame] | 121 | emit setChatVisibility(checked); |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 122 | } |
| 123 | |
Edric Milaret | 5cbf2b6 | 2015-07-09 11:36:53 -0400 | [diff] [blame] | 124 | void |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 125 | VideoOverlay::on_transferButton_clicked() |
Edric Milaret | 5cbf2b6 | 2015-07-09 11:36:53 -0400 | [diff] [blame] | 126 | { |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 127 | transferDialog_->setConfMode(false); |
Edric Milaret | 5cbf2b6 | 2015-07-09 11:36:53 -0400 | [diff] [blame] | 128 | auto pos = this->mapToGlobal(ui->transferButton->pos()); |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 129 | transferDialog_->move(pos.x() |
| 130 | - transferDialog_->size().width()/2 |
| 131 | + ui->transferButton->size().width()/2, |
| 132 | pos.y() - (transferDialog_->height())); |
| 133 | transferDialog_->show(); |
| 134 | } |
| 135 | |
| 136 | void |
| 137 | VideoOverlay::on_addPersonButton_clicked() |
| 138 | { |
| 139 | transferDialog_->setConfMode(true); |
| 140 | auto pos = this->mapToGlobal(ui->addPersonButton->pos()); |
| 141 | transferDialog_->move(pos.x() |
| 142 | - transferDialog_->size().width()/2 |
| 143 | + ui->addPersonButton->size().width()/2, |
| 144 | pos.y() - (transferDialog_->height())); |
| 145 | transferDialog_->show(); |
| 146 | } |
| 147 | |
| 148 | void |
| 149 | VideoOverlay::on_holdButton_clicked() |
| 150 | { |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame^] | 151 | auto selectedConvUid = LRCInstance::getSelectedConvUid(); |
| 152 | auto conversation = Utils::getConversationFromUid(selectedConvUid, |
| 153 | *LRCInstance::getCurrentConversationModel()); |
| 154 | auto& callId = conversation->callId; |
| 155 | auto callModel = LRCInstance::getCurrentCallModel(); |
| 156 | if (callModel->hasCall(callId)) { |
| 157 | auto onHold = callModel->getCall(callId).status == lrc::api::call::Status::PAUSED; |
| 158 | ui->holdButton->setChecked(!onHold); |
| 159 | ui->onHoldLabel->setVisible(!onHold); |
| 160 | callModel->togglePause(callId); |
| 161 | } |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 162 | } |
| 163 | |
Nicolas Jager | 97a21b4 | 2015-12-03 16:55:45 -0500 | [diff] [blame] | 164 | void |
| 165 | VideoOverlay::on_noMicButton_clicked() |
| 166 | { |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame^] | 167 | auto selectedConvUid = LRCInstance::getSelectedConvUid(); |
| 168 | auto conversation = Utils::getConversationFromUid(selectedConvUid, |
| 169 | *LRCInstance::getCurrentConversationModel()); |
| 170 | auto& callId = conversation->callId; |
| 171 | auto callModel = LRCInstance::getCurrentCallModel(); |
| 172 | if (callModel->hasCall(callId)) { |
| 173 | ui->noMicButton->setChecked(callModel->getCall(callId).audioMuted); |
| 174 | callModel->toggleMedia(callId, lrc::api::NewCallModel::Media::AUDIO); |
| 175 | } |
Nicolas Jager | 97a21b4 | 2015-12-03 16:55:45 -0500 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | void |
| 179 | VideoOverlay::on_noVideoButton_clicked() |
| 180 | { |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame^] | 181 | auto selectedConvUid = LRCInstance::getSelectedConvUid(); |
| 182 | auto conversation = Utils::getConversationFromUid(selectedConvUid, |
| 183 | *LRCInstance::getCurrentConversationModel()); |
| 184 | auto& callId = conversation->callId; |
| 185 | auto callModel = LRCInstance::getCurrentCallModel(); |
| 186 | if (callModel->hasCall(callId)) { |
| 187 | ui->noVideoButton->setChecked(callModel->getCall(callId).videoMuted); |
| 188 | callModel->toggleMedia(callId, lrc::api::NewCallModel::Media::VIDEO); |
| 189 | } |
Nicolas Jager | 97a21b4 | 2015-12-03 16:55:45 -0500 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 193 | void VideoOverlay::on_joinButton_clicked() |
| 194 | { |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame^] | 195 | // TODO:(newlrc) conferences |
| 196 | //CallModel::instance().selectedCall()->joinToParent(); |
Edric Milaret | 5cbf2b6 | 2015-07-09 11:36:53 -0400 | [diff] [blame] | 197 | } |
Edric Milaret | 864a205 | 2016-01-14 15:45:03 -0500 | [diff] [blame] | 198 | |
| 199 | void |
| 200 | VideoOverlay::on_qualityButton_clicked() |
| 201 | { |
| 202 | auto pos = this->mapToGlobal(ui->qualityButton->pos()); |
| 203 | qualityDialog_->move(pos.x() |
| 204 | - qualityDialog_->size().width()/2 |
| 205 | + ui->qualityButton->size().width()/2, |
| 206 | pos.y() - (qualityDialog_->height())); |
| 207 | qualityDialog_->show(); |
| 208 | } |
Edric Milaret | 31484f1 | 2016-02-02 14:26:27 -0500 | [diff] [blame] | 209 | |
| 210 | void |
Edric Milaret | a5fe70f | 2016-02-05 15:03:31 -0500 | [diff] [blame] | 211 | VideoOverlay::on_recButton_clicked() |
| 212 | { |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame^] | 213 | auto selectedConvUid = LRCInstance::getSelectedConvUid(); |
| 214 | auto conversation = Utils::getConversationFromUid(selectedConvUid, |
| 215 | *LRCInstance::getCurrentConversationModel()); |
| 216 | auto& callId = conversation->callId; |
| 217 | auto callModel = LRCInstance::getCurrentCallModel(); |
| 218 | if (callModel->hasCall(callId)) { |
| 219 | callModel->toggleAudioRecord(callId); |
| 220 | } |
Edric Milaret | a5fe70f | 2016-02-05 15:03:31 -0500 | [diff] [blame] | 221 | } |
Olivier SOLDANO | 2bcdfd7 | 2017-05-02 14:37:19 -0400 | [diff] [blame] | 222 | |
Olivier SOLDANO | 2bcdfd7 | 2017-05-02 14:37:19 -0400 | [diff] [blame] | 223 | void VideoOverlay::on_videoCfgBtn_clicked() |
| 224 | { |
| 225 | emit videoCfgBtnClicked(); |
| 226 | } |