blob: 08f2a0f54d76bdeb612efc9f791e6cbd10ceea4c [file] [log] [blame]
Edric Milaret029b95a2015-06-09 09:51:44 -04001/***************************************************************************
Nicolas Jagerc7b8e4b2016-02-29 09:20:40 -05002 * Copyright (C) 2015-2016 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);
Edric Milaret029b95a2015-06-09 09:51:44 -040040
41protected:
42 void resizeEvent(QResizeEvent* event);
43 void enterEvent(QEvent* event);
44 void leaveEvent(QEvent* event);
Edric Milaret80e0b212015-10-16 10:07:43 -040045 void mouseDoubleClickEvent(QMouseEvent* e);
46 void dragEnterEvent(QDragEnterEvent* event);
47 void dropEvent(QDropEvent* event);
Nicolas Jagerc7b8e4b2016-02-29 09:20:40 -050048 void mousePressEvent(QMouseEvent* event);
49 void mouseReleaseEvent(QMouseEvent* event);
50 void mouseMoveEvent(QMouseEvent* event);
Edric Milaret029b95a2015-06-09 09:51:44 -040051
52private slots:
Edric Milaret80e0b212015-10-16 10:07:43 -040053 void callStateChanged(Call* call, Call::State previousState);
Edric Milareted0b2802015-10-01 15:10:02 -040054 void updateCall();
Edric Milaret80e0b212015-10-16 10:07:43 -040055 void showContextMenu(const QPoint& pos);
56 void slotVideoStarted(Video::Renderer* renderer);
Edric Milaret029b95a2015-06-09 09:51:44 -040057
58private:
Edric Milaret80e0b212015-10-16 10:07:43 -040059 Ui::VideoView* ui;
Edric Milaret029b95a2015-06-09 09:51:44 -040060 VideoOverlay* overlay_;
Edric Milaret029b95a2015-06-09 09:51:44 -040061 QPropertyAnimation* fadeAnim_;
Edric Milaret80e0b212015-10-16 10:07:43 -040062 QWidget* oldParent_;
Edric Milaret029b95a2015-06-09 09:51:44 -040063 QSize oldSize_;
Edric Milareted0b2802015-10-01 15:10:02 -040064 QMetaObject::Connection timerConnection_;
Edric Milaret80e0b212015-10-16 10:07:43 -040065 QMetaObject::Connection videoStartedConnection_;
Nicolas Jagerc7b8e4b2016-02-29 09:20:40 -050066 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 Milaret029b95a2015-06-09 09:51:44 -040075private:
76 void toggleFullScreen();
Edric Milaret3aca8e32015-06-12 10:01:40 -040077signals:
78 void setChatVisibility(bool visible);
Edric Milaret029b95a2015-06-09 09:51:44 -040079};
80