blob: c3bcc79a0d9f1f8f449a0f3c71e113b847810864 [file] [log] [blame]
Edric Milaret029b95a2015-06-09 09:51:44 -04001/***************************************************************************
2 * Copyright (C) 2015 by Savoir-Faire Linux *
3 * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17 **************************************************************************/
18
19#include "videooverlay.h"
20#include "ui_videooverlay.h"
21
22#include "callmodel.h"
23
24VideoOverlay::VideoOverlay(QWidget *parent) :
25 QWidget(parent),
26 ui(new Ui::VideoOverlay)
27{
28 ui->setupUi(this);
29
Edric Milaret3aca8e32015-06-12 10:01:40 -040030 ui->chatButton->setCheckable(true);
31
Edric Milaret029b95a2015-06-09 09:51:44 -040032 actionModel_ = CallModel::instance()->userActionModel();
33 setAttribute(Qt::WA_NoSystemBackground);
Edric Milaret5927d042015-06-15 12:45:29 -040034
35 menu_ = new QMenu(this);
36 auto muteAudio = new QAction("Mute Audio", this);
37 muteAudio->setCheckable(true);
38 connect(muteAudio, &QAction::triggered, [=](bool) {
39 actionModel_->execute(UserActionModel::Action::MUTE_AUDIO);
40 });
41 menu_->addAction(muteAudio);
42
43 auto muteVideo = new QAction("Mute Video", this);
44 muteVideo->setCheckable(true);
45 connect(muteVideo, &QAction::triggered, [=](bool) {
46 actionModel_->execute(UserActionModel::Action::MUTE_VIDEO);
47 });
48 menu_->addAction(muteVideo);
49
50 connect(actionModel_,&UserActionModel::dataChanged, [=](const QModelIndex& tl, const QModelIndex& br) {
51 const int first(tl.row()),last(br.row());
52 for(int i = first; i <= last;i++) {
53 const QModelIndex& idx = actionModel_->index(i,0);
54 switch (idx.data(UserActionModel::Role::ACTION).value<UserActionModel::Action>()) {
55 case UserActionModel::Action::MUTE_AUDIO:
56 muteAudio->setChecked(idx.data(Qt::CheckStateRole).value<bool>());
57 muteAudio->setEnabled(idx.flags() & Qt::ItemIsEnabled);
58 break;
59 case UserActionModel::Action::MUTE_VIDEO:
60 muteVideo->setChecked(idx.data(Qt::CheckStateRole).value<bool>());
61 muteVideo->setEnabled(idx.flags() & Qt::ItemIsEnabled);
62 break;
63 default:
64 break;
65 }
66 }
67 });
68
69 ui->moreButton->setMenu(menu_);
Edric Milaret029b95a2015-06-09 09:51:44 -040070}
71
72VideoOverlay::~VideoOverlay()
73{
74 delete ui;
Edric Milaret5927d042015-06-15 12:45:29 -040075 delete menu_;
Edric Milaret029b95a2015-06-09 09:51:44 -040076}
77
78void
79VideoOverlay::setName(const QString& name)
80{
81 ui->nameLabel->setText(name);
82}
83
84void
85VideoOverlay::setTime(const QString& time)
86{
87 ui->timerLabel->setText(time);
88}
89
90void
91VideoOverlay::on_holdButton_toggled(bool checked)
92{
93 Q_UNUSED(checked)
94 actionModel_->execute(UserActionModel::Action::HOLD);
95}
96
97void
98VideoOverlay::on_hangupButton_clicked()
99{
100 actionModel_->execute(UserActionModel::Action::HANGUP);
Edric Milaret3aca8e32015-06-12 10:01:40 -0400101 ui->chatButton->setChecked(false);
Edric Milaret029b95a2015-06-09 09:51:44 -0400102}
103
104void
105VideoOverlay::on_chatButton_toggled(bool checked)
106{
Edric Milaret3aca8e32015-06-12 10:01:40 -0400107 emit setChatVisibility(checked);
Edric Milaret029b95a2015-06-09 09:51:44 -0400108}
109