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 | |
| 26 | #include "videooverlay.h" |
| 27 | |
| 28 | namespace Ui { |
| 29 | class VideoView; |
| 30 | } |
| 31 | |
| 32 | class VideoView : public QWidget |
| 33 | { |
| 34 | Q_OBJECT |
| 35 | |
| 36 | public: |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 37 | explicit VideoView(QWidget* parent = 0); |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 38 | ~VideoView(); |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 39 | void pushRenderer(Call* call); |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 40 | |
| 41 | protected: |
| 42 | void resizeEvent(QResizeEvent* event); |
| 43 | void enterEvent(QEvent* event); |
| 44 | void leaveEvent(QEvent* event); |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 45 | void mouseDoubleClickEvent(QMouseEvent* e); |
| 46 | void dragEnterEvent(QDragEnterEvent* event); |
| 47 | void dropEvent(QDropEvent* event); |
Nicolas Jager | c7b8e4b | 2016-02-29 09:20:40 -0500 | [diff] [blame] | 48 | void mousePressEvent(QMouseEvent* event); |
| 49 | void mouseReleaseEvent(QMouseEvent* event); |
| 50 | void mouseMoveEvent(QMouseEvent* event); |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 51 | |
| 52 | private slots: |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 53 | void callStateChanged(Call* call, Call::State previousState); |
Edric Milaret | ed0b280 | 2015-10-01 15:10:02 -0400 | [diff] [blame] | 54 | void updateCall(); |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 55 | void showContextMenu(const QPoint& pos); |
| 56 | void slotVideoStarted(Video::Renderer* renderer); |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 57 | |
| 58 | private: |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 59 | Ui::VideoView* ui; |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 60 | VideoOverlay* overlay_; |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 61 | QPropertyAnimation* fadeAnim_; |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 62 | QWidget* oldParent_; |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 63 | QSize oldSize_; |
Edric Milaret | ed0b280 | 2015-10-01 15:10:02 -0400 | [diff] [blame] | 64 | QMetaObject::Connection timerConnection_; |
Edric Milaret | 80e0b21 | 2015-10-16 10:07:43 -0400 | [diff] [blame] | 65 | QMetaObject::Connection videoStartedConnection_; |
Nicolas Jager | c7b8e4b | 2016-02-29 09:20:40 -0500 | [diff] [blame] | 66 | QPoint origin_; |
| 67 | QPoint originMouseDisplacement_; |
| 68 | bool draggingPreview_ = false; |
| 69 | bool resizingPreview_ = false; |
| 70 | |
| 71 | constexpr static int fadeOverlayTime_ = 2000; //msec |
| 72 | constexpr static int resizeGrip_ = 40; |
| 73 | constexpr static int minimalSize_ = 100; |
| 74 | |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 75 | private: |
| 76 | void toggleFullScreen(); |
Edric Milaret | 3aca8e3 | 2015-06-12 10:01:40 -0400 | [diff] [blame] | 77 | signals: |
| 78 | void setChatVisibility(bool visible); |
Edric Milaret | 029b95a | 2015-06-09 09:51:44 -0400 | [diff] [blame] | 79 | }; |
| 80 | |