blob: 2782d9068abd667af3212c2c946cf28650936710 [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);
Sébastien Blin93bd2062018-12-17 15:57:16 -050045 void showChatviewIfToggled();
Andreas Traczyk4b4bfde2018-12-19 09:53:22 -050046 void simulateShowChatview(bool checked);
Edric Milaret029b95a2015-06-09 09:51:44 -040047
48protected:
49 void resizeEvent(QResizeEvent* event);
50 void enterEvent(QEvent* event);
51 void leaveEvent(QEvent* event);
Edric Milaret80e0b212015-10-16 10:07:43 -040052 void mouseDoubleClickEvent(QMouseEvent* e);
53 void dragEnterEvent(QDragEnterEvent* event);
54 void dropEvent(QDropEvent* event);
Nicolas Jagerc7b8e4b2016-02-29 09:20:40 -050055 void mousePressEvent(QMouseEvent* event);
56 void mouseReleaseEvent(QMouseEvent* event);
57 void mouseMoveEvent(QMouseEvent* event);
Edric Milaret029b95a2015-06-09 09:51:44 -040058
59private slots:
Andreas Traczyk7cc79c02019-01-18 12:48:16 -050060 void slotCallStatusChanged(const std::string& callId);
Edric Milaret80e0b212015-10-16 10:07:43 -040061 void showContextMenu(const QPoint& pos);
62 void slotVideoStarted(Video::Renderer* renderer);
Andreas Traczykca320d82018-08-09 18:02:07 -040063 void fadeOverlayOut();
64 void showOverlay();
Edric Milaret029b95a2015-06-09 09:51:44 -040065
66private:
Edric Milaret80e0b212015-10-16 10:07:43 -040067 Ui::VideoView* ui;
Edric Milaret029b95a2015-06-09 09:51:44 -040068 VideoOverlay* overlay_;
Edric Milaret029b95a2015-06-09 09:51:44 -040069 QPropertyAnimation* fadeAnim_;
Andreas Traczykca320d82018-08-09 18:02:07 -040070 QTimer fadeTimer_;
Edric Milaret80e0b212015-10-16 10:07:43 -040071 QWidget* oldParent_;
Edric Milaret029b95a2015-06-09 09:51:44 -040072 QSize oldSize_;
Edric Milareted0b2802015-10-01 15:10:02 -040073 QMetaObject::Connection timerConnection_;
Edric Milaret80e0b212015-10-16 10:07:43 -040074 QMetaObject::Connection videoStartedConnection_;
Andreas Traczyk7cc79c02019-01-18 12:48:16 -050075 QMetaObject::Connection callStatusChangedConnection_;
Nicolas Jagerc7b8e4b2016-02-29 09:20:40 -050076 QPoint origin_;
77 QPoint originMouseDisplacement_;
78 bool draggingPreview_ = false;
79 bool resizingPreview_ = false;
80
Andreas Traczyk8d5e5492018-08-09 15:41:52 -040081 constexpr static int fadeOverlayTime_ = 1000; //msec
Nicolas Jagerc7b8e4b2016-02-29 09:20:40 -050082 constexpr static int resizeGrip_ = 40;
83 constexpr static int minimalSize_ = 100;
84
Andreas Traczykca320d82018-08-09 18:02:07 -040085 // Time before the overlay starts fading out after the mouse stops
86 // moving within the videoview.
87 constexpr static int startfadeOverlayTime_ = 2000; //msec
88
Andreas Traczyk8d5e5492018-08-09 15:41:52 -040089 // TODO: fix when changing Qt version
Andreas Traczykb8b13ba2018-08-21 16:30:16 -040090 // Full(1.0) opacity bug affecting many Qt versions (macOS + win10)
Andreas Traczyk8d5e5492018-08-09 15:41:52 -040091 // causing the render to take a buggy code path which can be avoided
92 // by using opacity values other than precisely 1.0.
93 // https://bugreports.qt.io/browse/QTBUG-65981
94 // https://bugreports.qt.io/browse/QTBUG-66803
95 constexpr static qreal maxOverlayOpacity_ = 0.9999999999980000442;
96
Edric Milaret029b95a2015-06-09 09:51:44 -040097private:
98 void toggleFullScreen();
Edric Milaret3aca8e32015-06-12 10:01:40 -040099signals:
100 void setChatVisibility(bool visible);
Olivier SOLDANO2bcdfd72017-05-02 14:37:19 -0400101 void videoSettingsClicked();
Sébastien Blin93bd2062018-12-17 15:57:16 -0500102 void toggleFullScreenClicked();
103 void closing(const std::string& callid);
Edric Milaret029b95a2015-06-09 09:51:44 -0400104};