blob: 17e83d6b4a1203b1602f176a840a758ff10b7355 [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>*
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
Edric Milaret5f316da2015-09-28 11:57:42 -040019#pragma once
Edric Milaret029b95a2015-06-09 09:51:44 -040020
21#include <QWidget>
22#include <QTimer>
23#include <QMouseEvent>
24#include <QPropertyAnimation>
25
Andreas Traczyk7548e732018-12-12 10:47:21 -050026#include "callmodel.h"
27#include "video/devicemodel.h"
28#include "video/sourcemodel.h"
29#include "media/video.h"
30
Edric Milaret029b95a2015-06-09 09:51:44 -040031#include "videooverlay.h"
32
33namespace Ui {
34class VideoView;
35}
36
37class VideoView : public QWidget
38{
39 Q_OBJECT
40
41public:
Edric Milaret80e0b212015-10-16 10:07:43 -040042 explicit VideoView(QWidget* parent = 0);
Edric Milaret029b95a2015-06-09 09:51:44 -040043 ~VideoView();
Andreas Traczykb8b13ba2018-08-21 16:30:16 -040044 void pushRenderer(const std::string& callUid);
Edric Milaret029b95a2015-06-09 09:51:44 -040045
46protected:
47 void resizeEvent(QResizeEvent* event);
48 void enterEvent(QEvent* event);
49 void leaveEvent(QEvent* event);
Edric Milaret80e0b212015-10-16 10:07:43 -040050 void mouseDoubleClickEvent(QMouseEvent* e);
51 void dragEnterEvent(QDragEnterEvent* event);
52 void dropEvent(QDropEvent* event);
Nicolas Jagerc7b8e4b2016-02-29 09:20:40 -050053 void mousePressEvent(QMouseEvent* event);
54 void mouseReleaseEvent(QMouseEvent* event);
55 void mouseMoveEvent(QMouseEvent* event);
Edric Milaret029b95a2015-06-09 09:51:44 -040056
57private slots:
Edric Milaret80e0b212015-10-16 10:07:43 -040058 void callStateChanged(Call* call, Call::State previousState);
Edric Milareted0b2802015-10-01 15:10:02 -040059 void updateCall();
Edric Milaret80e0b212015-10-16 10:07:43 -040060 void showContextMenu(const QPoint& pos);
61 void slotVideoStarted(Video::Renderer* renderer);
Andreas Traczykca320d82018-08-09 18:02:07 -040062 void fadeOverlayOut();
63 void showOverlay();
Edric Milaret029b95a2015-06-09 09:51:44 -040064
65private:
Edric Milaret80e0b212015-10-16 10:07:43 -040066 Ui::VideoView* ui;
Edric Milaret029b95a2015-06-09 09:51:44 -040067 VideoOverlay* overlay_;
Edric Milaret029b95a2015-06-09 09:51:44 -040068 QPropertyAnimation* fadeAnim_;
Andreas Traczykca320d82018-08-09 18:02:07 -040069 QTimer fadeTimer_;
Edric Milaret80e0b212015-10-16 10:07:43 -040070 QWidget* oldParent_;
Edric Milaret029b95a2015-06-09 09:51:44 -040071 QSize oldSize_;
Edric Milareted0b2802015-10-01 15:10:02 -040072 QMetaObject::Connection timerConnection_;
Edric Milaret80e0b212015-10-16 10:07:43 -040073 QMetaObject::Connection videoStartedConnection_;
Nicolas Jagerc7b8e4b2016-02-29 09:20:40 -050074 QPoint origin_;
75 QPoint originMouseDisplacement_;
76 bool draggingPreview_ = false;
77 bool resizingPreview_ = false;
78
Andreas Traczyk8d5e5492018-08-09 15:41:52 -040079 constexpr static int fadeOverlayTime_ = 1000; //msec
Nicolas Jagerc7b8e4b2016-02-29 09:20:40 -050080 constexpr static int resizeGrip_ = 40;
81 constexpr static int minimalSize_ = 100;
82
Andreas Traczykca320d82018-08-09 18:02:07 -040083 // Time before the overlay starts fading out after the mouse stops
84 // moving within the videoview.
85 constexpr static int startfadeOverlayTime_ = 2000; //msec
86
Andreas Traczyk8d5e5492018-08-09 15:41:52 -040087 // TODO: fix when changing Qt version
Andreas Traczykb8b13ba2018-08-21 16:30:16 -040088 // Full(1.0) opacity bug affecting many Qt versions (macOS + win10)
Andreas Traczyk8d5e5492018-08-09 15:41:52 -040089 // causing the render to take a buggy code path which can be avoided
90 // by using opacity values other than precisely 1.0.
91 // https://bugreports.qt.io/browse/QTBUG-65981
92 // https://bugreports.qt.io/browse/QTBUG-66803
93 constexpr static qreal maxOverlayOpacity_ = 0.9999999999980000442;
94
Edric Milaret029b95a2015-06-09 09:51:44 -040095private:
96 void toggleFullScreen();
Edric Milaret3aca8e32015-06-12 10:01:40 -040097signals:
98 void setChatVisibility(bool visible);
Olivier SOLDANO2bcdfd72017-05-02 14:37:19 -040099 void videoSettingsClicked();
Edric Milaret029b95a2015-06-09 09:51:44 -0400100};
101