blob: 41f02f0547b6480127907378ee838d06baf8a0c2 [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
26#include "videooverlay.h"
27
28namespace Ui {
29class VideoView;
30}
31
32class VideoView : public QWidget
33{
34 Q_OBJECT
35
36public:
Edric Milaret80e0b212015-10-16 10:07:43 -040037 explicit VideoView(QWidget* parent = 0);
Edric Milaret029b95a2015-06-09 09:51:44 -040038 ~VideoView();
Edric Milaret80e0b212015-10-16 10:07:43 -040039 void pushRenderer(Call* call);
Andreas Traczykb8b13ba2018-08-21 16:30:16 -040040 void pushRenderer(const std::string& callUid);
Edric Milaret029b95a2015-06-09 09:51:44 -040041
42protected:
43 void resizeEvent(QResizeEvent* event);
44 void enterEvent(QEvent* event);
45 void leaveEvent(QEvent* event);
Edric Milaret80e0b212015-10-16 10:07:43 -040046 void mouseDoubleClickEvent(QMouseEvent* e);
47 void dragEnterEvent(QDragEnterEvent* event);
48 void dropEvent(QDropEvent* event);
Nicolas Jagerc7b8e4b2016-02-29 09:20:40 -050049 void mousePressEvent(QMouseEvent* event);
50 void mouseReleaseEvent(QMouseEvent* event);
51 void mouseMoveEvent(QMouseEvent* event);
Edric Milaret029b95a2015-06-09 09:51:44 -040052
53private slots:
Edric Milaret80e0b212015-10-16 10:07:43 -040054 void callStateChanged(Call* call, Call::State previousState);
Edric Milareted0b2802015-10-01 15:10:02 -040055 void updateCall();
Edric Milaret80e0b212015-10-16 10:07:43 -040056 void showContextMenu(const QPoint& pos);
57 void slotVideoStarted(Video::Renderer* renderer);
Andreas Traczykca320d82018-08-09 18:02:07 -040058 void fadeOverlayOut();
59 void showOverlay();
Edric Milaret029b95a2015-06-09 09:51:44 -040060
61private:
Edric Milaret80e0b212015-10-16 10:07:43 -040062 Ui::VideoView* ui;
Edric Milaret029b95a2015-06-09 09:51:44 -040063 VideoOverlay* overlay_;
Edric Milaret029b95a2015-06-09 09:51:44 -040064 QPropertyAnimation* fadeAnim_;
Andreas Traczykca320d82018-08-09 18:02:07 -040065 QTimer fadeTimer_;
Edric Milaret80e0b212015-10-16 10:07:43 -040066 QWidget* oldParent_;
Edric Milaret029b95a2015-06-09 09:51:44 -040067 QSize oldSize_;
Edric Milareted0b2802015-10-01 15:10:02 -040068 QMetaObject::Connection timerConnection_;
Edric Milaret80e0b212015-10-16 10:07:43 -040069 QMetaObject::Connection videoStartedConnection_;
Nicolas Jagerc7b8e4b2016-02-29 09:20:40 -050070 QPoint origin_;
71 QPoint originMouseDisplacement_;
72 bool draggingPreview_ = false;
73 bool resizingPreview_ = false;
74
Andreas Traczyk8d5e5492018-08-09 15:41:52 -040075 constexpr static int fadeOverlayTime_ = 1000; //msec
Nicolas Jagerc7b8e4b2016-02-29 09:20:40 -050076 constexpr static int resizeGrip_ = 40;
77 constexpr static int minimalSize_ = 100;
78
Andreas Traczykca320d82018-08-09 18:02:07 -040079 // Time before the overlay starts fading out after the mouse stops
80 // moving within the videoview.
81 constexpr static int startfadeOverlayTime_ = 2000; //msec
82
Andreas Traczyk8d5e5492018-08-09 15:41:52 -040083 // TODO: fix when changing Qt version
Andreas Traczykb8b13ba2018-08-21 16:30:16 -040084 // Full(1.0) opacity bug affecting many Qt versions (macOS + win10)
Andreas Traczyk8d5e5492018-08-09 15:41:52 -040085 // causing the render to take a buggy code path which can be avoided
86 // by using opacity values other than precisely 1.0.
87 // https://bugreports.qt.io/browse/QTBUG-65981
88 // https://bugreports.qt.io/browse/QTBUG-66803
89 constexpr static qreal maxOverlayOpacity_ = 0.9999999999980000442;
90
Edric Milaret029b95a2015-06-09 09:51:44 -040091private:
92 void toggleFullScreen();
Edric Milaret3aca8e32015-06-12 10:01:40 -040093signals:
94 void setChatVisibility(bool visible);
Olivier SOLDANO2bcdfd72017-05-02 14:37:19 -040095 void videoSettingsClicked();
Edric Milaret029b95a2015-06-09 09:51:44 -040096};
97