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 |
Sébastien Blin | 93bd206 | 2018-12-17 15:57:16 -0500 | [diff] [blame^] | 88 | VideoOverlay::simulateShowChatview(bool checked) |
| 89 | { |
| 90 | ui->chatButton->setChecked(checked); |
| 91 | } |
| 92 | |
| 93 | bool |
| 94 | VideoOverlay::getShowChatView() |
| 95 | { |
| 96 | return ui->chatButton->isChecked(); |
| 97 | } |
| 98 | |
| 99 | void |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 100 | VideoOverlay::on_hangupButton_clicked() |
| 101 | { |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame] | 102 | auto selectedConvUid = LRCInstance::getSelectedConvUid(); |
| 103 | auto conversation = Utils::getConversationFromUid(selectedConvUid, |
| 104 | *LRCInstance::getCurrentConversationModel()); |
| 105 | auto& callId = conversation->callId; |
| 106 | auto callModel = LRCInstance::getCurrentCallModel(); |
| 107 | if (callModel->hasCall(callId)) { |
| 108 | callModel->hangUp(callId); |
| 109 | } |
Edric Milaret | 3aca8e3 | 2015-06-12 10:01:40 -0400 | [diff] [blame] | 110 | ui->chatButton->setChecked(false); |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | void |
| 114 | VideoOverlay::on_chatButton_toggled(bool checked) |
| 115 | { |
Edric Milaret | 3aca8e3 | 2015-06-12 10:01:40 -0400 | [diff] [blame] | 116 | emit setChatVisibility(checked); |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 117 | } |
| 118 | |
Edric Milaret | 5cbf2b6 | 2015-07-09 11:36:53 -0400 | [diff] [blame] | 119 | void |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 120 | VideoOverlay::on_holdButton_clicked() |
| 121 | { |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame] | 122 | auto selectedConvUid = LRCInstance::getSelectedConvUid(); |
| 123 | auto conversation = Utils::getConversationFromUid(selectedConvUid, |
| 124 | *LRCInstance::getCurrentConversationModel()); |
| 125 | auto& callId = conversation->callId; |
| 126 | auto callModel = LRCInstance::getCurrentCallModel(); |
| 127 | if (callModel->hasCall(callId)) { |
| 128 | auto onHold = callModel->getCall(callId).status == lrc::api::call::Status::PAUSED; |
| 129 | ui->holdButton->setChecked(!onHold); |
| 130 | ui->onHoldLabel->setVisible(!onHold); |
| 131 | callModel->togglePause(callId); |
| 132 | } |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 133 | } |
| 134 | |
Nicolas Jager | 97a21b4 | 2015-12-03 16:55:45 -0500 | [diff] [blame] | 135 | void |
| 136 | VideoOverlay::on_noMicButton_clicked() |
| 137 | { |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame] | 138 | auto selectedConvUid = LRCInstance::getSelectedConvUid(); |
| 139 | auto conversation = Utils::getConversationFromUid(selectedConvUid, |
| 140 | *LRCInstance::getCurrentConversationModel()); |
| 141 | auto& callId = conversation->callId; |
| 142 | auto callModel = LRCInstance::getCurrentCallModel(); |
| 143 | if (callModel->hasCall(callId)) { |
| 144 | ui->noMicButton->setChecked(callModel->getCall(callId).audioMuted); |
| 145 | callModel->toggleMedia(callId, lrc::api::NewCallModel::Media::AUDIO); |
| 146 | } |
Nicolas Jager | 97a21b4 | 2015-12-03 16:55:45 -0500 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | void |
| 150 | VideoOverlay::on_noVideoButton_clicked() |
| 151 | { |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame] | 152 | auto selectedConvUid = LRCInstance::getSelectedConvUid(); |
| 153 | auto conversation = Utils::getConversationFromUid(selectedConvUid, |
| 154 | *LRCInstance::getCurrentConversationModel()); |
| 155 | auto& callId = conversation->callId; |
| 156 | auto callModel = LRCInstance::getCurrentCallModel(); |
| 157 | if (callModel->hasCall(callId)) { |
| 158 | ui->noVideoButton->setChecked(callModel->getCall(callId).videoMuted); |
| 159 | callModel->toggleMedia(callId, lrc::api::NewCallModel::Media::VIDEO); |
| 160 | } |
Nicolas Jager | 97a21b4 | 2015-12-03 16:55:45 -0500 | [diff] [blame] | 161 | } |
| 162 | |
Edric Milaret | 31484f1 | 2016-02-02 14:26:27 -0500 | [diff] [blame] | 163 | void |
Edric Milaret | a5fe70f | 2016-02-05 15:03:31 -0500 | [diff] [blame] | 164 | VideoOverlay::on_recButton_clicked() |
| 165 | { |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame] | 166 | auto selectedConvUid = LRCInstance::getSelectedConvUid(); |
| 167 | auto conversation = Utils::getConversationFromUid(selectedConvUid, |
| 168 | *LRCInstance::getCurrentConversationModel()); |
| 169 | auto& callId = conversation->callId; |
| 170 | auto callModel = LRCInstance::getCurrentCallModel(); |
| 171 | if (callModel->hasCall(callId)) { |
| 172 | callModel->toggleAudioRecord(callId); |
| 173 | } |
Edric Milaret | a5fe70f | 2016-02-05 15:03:31 -0500 | [diff] [blame] | 174 | } |
Olivier SOLDANO | 2bcdfd7 | 2017-05-02 14:37:19 -0400 | [diff] [blame] | 175 | |
Olivier SOLDANO | 2bcdfd7 | 2017-05-02 14:37:19 -0400 | [diff] [blame] | 176 | void VideoOverlay::on_videoCfgBtn_clicked() |
| 177 | { |
| 178 | emit videoCfgBtnClicked(); |
| 179 | } |