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>* |
| 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 Milaret | 5f316da | 2015-09-28 11:57:42 -0400 | [diff] [blame] | 19 | #pragma once |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 20 | |
| 21 | #include <QWidget> |
| 22 | #include <QTimer> |
| 23 | #include <QMouseEvent> |
| 24 | #include <QPropertyAnimation> |
| 25 | |
Andreas Traczyk | 7548e73 | 2018-12-12 10:47:21 -0500 | [diff] [blame] | 26 | #include "callmodel.h" |
| 27 | #include "video/devicemodel.h" |
| 28 | #include "video/sourcemodel.h" |
| 29 | #include "media/video.h" |
| 30 | |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 31 | #include "videooverlay.h" |
| 32 | |
| 33 | namespace Ui { |
| 34 | class VideoView; |
| 35 | } |
| 36 | |
| 37 | class VideoView : public QWidget |
| 38 | { |
| 39 | Q_OBJECT |
| 40 | |
| 41 | public: |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 42 | explicit VideoView(QWidget* parent = 0); |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 43 | ~VideoView(); |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame] | 44 | void pushRenderer(const std::string& callUid); |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 45 | |
| 46 | protected: |
| 47 | void resizeEvent(QResizeEvent* event); |
| 48 | void enterEvent(QEvent* event); |
| 49 | void leaveEvent(QEvent* event); |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 50 | void mouseDoubleClickEvent(QMouseEvent* e); |
| 51 | void dragEnterEvent(QDragEnterEvent* event); |
| 52 | void dropEvent(QDropEvent* event); |
Nicolas Jager | c7b8e4b | 2016-02-29 09:20:40 -0500 | [diff] [blame] | 53 | void mousePressEvent(QMouseEvent* event); |
| 54 | void mouseReleaseEvent(QMouseEvent* event); |
| 55 | void mouseMoveEvent(QMouseEvent* event); |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 56 | |
| 57 | private slots: |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 58 | void callStateChanged(Call* call, Call::State previousState); |
Edric Milaret | ed0b280 | 2015-10-01 15:10:02 -0400 | [diff] [blame] | 59 | void updateCall(); |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 60 | void showContextMenu(const QPoint& pos); |
| 61 | void slotVideoStarted(Video::Renderer* renderer); |
Andreas Traczyk | ca320d8 | 2018-08-09 18:02:07 -0400 | [diff] [blame] | 62 | void fadeOverlayOut(); |
| 63 | void showOverlay(); |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 64 | |
| 65 | private: |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 66 | Ui::VideoView* ui; |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 67 | VideoOverlay* overlay_; |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 68 | QPropertyAnimation* fadeAnim_; |
Andreas Traczyk | ca320d8 | 2018-08-09 18:02:07 -0400 | [diff] [blame] | 69 | QTimer fadeTimer_; |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 70 | QWidget* oldParent_; |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 71 | QSize oldSize_; |
Edric Milaret | ed0b280 | 2015-10-01 15:10:02 -0400 | [diff] [blame] | 72 | QMetaObject::Connection timerConnection_; |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 73 | QMetaObject::Connection videoStartedConnection_; |
Nicolas Jager | c7b8e4b | 2016-02-29 09:20:40 -0500 | [diff] [blame] | 74 | QPoint origin_; |
| 75 | QPoint originMouseDisplacement_; |
| 76 | bool draggingPreview_ = false; |
| 77 | bool resizingPreview_ = false; |
| 78 | |
Andreas Traczyk | 8d5e549 | 2018-08-09 15:41:52 -0400 | [diff] [blame] | 79 | constexpr static int fadeOverlayTime_ = 1000; //msec |
Nicolas Jager | c7b8e4b | 2016-02-29 09:20:40 -0500 | [diff] [blame] | 80 | constexpr static int resizeGrip_ = 40; |
| 81 | constexpr static int minimalSize_ = 100; |
| 82 | |
Andreas Traczyk | ca320d8 | 2018-08-09 18:02:07 -0400 | [diff] [blame] | 83 | // 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 Traczyk | 8d5e549 | 2018-08-09 15:41:52 -0400 | [diff] [blame] | 87 | // TODO: fix when changing Qt version |
Andreas Traczyk | b8b13ba | 2018-08-21 16:30:16 -0400 | [diff] [blame] | 88 | // Full(1.0) opacity bug affecting many Qt versions (macOS + win10) |
Andreas Traczyk | 8d5e549 | 2018-08-09 15:41:52 -0400 | [diff] [blame] | 89 | // 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 Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 95 | private: |
| 96 | void toggleFullScreen(); |
Edric Milaret | 3aca8e3 | 2015-06-12 10:01:40 -0400 | [diff] [blame] | 97 | signals: |
| 98 | void setChatVisibility(bool visible); |
Olivier SOLDANO | 2bcdfd7 | 2017-05-02 14:37:19 -0400 | [diff] [blame] | 99 | void videoSettingsClicked(); |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 100 | }; |
| 101 | |