videoview.h 3.76 KB
Newer Older
1
/***************************************************************************
2
 * Copyright (C) 2015-2017 by Savoir-faire Linux                           *
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
 *                                                                         *
 * This program is free software; you can redistribute it and/or modify    *
 * it under the terms of the GNU General Public License as published by    *
 * the Free Software Foundation; either version 3 of the License, or       *
 * (at your option) any later version.                                     *
 *                                                                         *
 * This program is distributed in the hope that it will be useful,         *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of          *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
 * GNU General Public License for more details.                            *
 *                                                                         *
 * You should have received a copy of the GNU General Public License       *
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.   *
 **************************************************************************/

Edric Milaret's avatar
Edric Milaret committed
19
#pragma once
20 21 22 23 24 25

#include <QWidget>
#include <QTimer>
#include <QMouseEvent>
#include <QPropertyAnimation>

26 27 28 29 30
#include "callmodel.h"
#include "video/devicemodel.h"
#include "video/sourcemodel.h"
#include "media/video.h"

31 32 33 34 35 36 37 38 39 40 41
#include "videooverlay.h"

namespace Ui {
class VideoView;
}

class VideoView : public QWidget
{
    Q_OBJECT

public:
42
    explicit VideoView(QWidget* parent = 0);
43
    ~VideoView();
44
    void pushRenderer(const std::string& callUid);
45
    void showChatviewIfToggled();
46
    void simulateShowChatview(bool checked);
47 48 49 50 51

protected:
    void resizeEvent(QResizeEvent* event);
    void enterEvent(QEvent* event);
    void leaveEvent(QEvent* event);
52 53 54
    void mouseDoubleClickEvent(QMouseEvent* e);
    void dragEnterEvent(QDragEnterEvent* event);
    void dropEvent(QDropEvent* event);
55 56 57
    void mousePressEvent(QMouseEvent* event);
    void mouseReleaseEvent(QMouseEvent* event);
    void mouseMoveEvent(QMouseEvent* event);
58 59

private slots:
60
    void slotCallStatusChanged(const std::string& callId);
61 62
    void showContextMenu(const QPoint& pos);
    void slotVideoStarted(Video::Renderer* renderer);
63 64
    void fadeOverlayOut();
    void showOverlay();
65 66

private:
67
    Ui::VideoView* ui;
68 69
    VideoOverlay* overlay_;
    QPropertyAnimation* fadeAnim_;
70
    QTimer fadeTimer_;
71
    QWidget* oldParent_;
72
    QSize oldSize_;
73
    QMetaObject::Connection timerConnection_;
74
    QMetaObject::Connection videoStartedConnection_;
75
    QMetaObject::Connection callStatusChangedConnection_;
76 77 78 79 80
    QPoint origin_;
    QPoint originMouseDisplacement_;
    bool draggingPreview_ = false;
    bool resizingPreview_ = false;

81
    constexpr static int fadeOverlayTime_ = 1000; //msec
82 83 84
    constexpr static int resizeGrip_ = 40;
    constexpr static int minimalSize_ = 100;

85 86 87 88
    // Time before the overlay starts fading out after the mouse stops
    // moving within the videoview.
    constexpr static int startfadeOverlayTime_ = 2000; //msec

89
    // TODO: fix when changing Qt version
90
    // Full(1.0) opacity bug affecting many Qt versions (macOS + win10)
91 92 93 94 95 96
    // causing the render to take a buggy code path which can be avoided
    // by using opacity values other than precisely 1.0.
    // https://bugreports.qt.io/browse/QTBUG-65981
    // https://bugreports.qt.io/browse/QTBUG-66803
    constexpr static qreal maxOverlayOpacity_ = 0.9999999999980000442;

97 98
private:
    void toggleFullScreen();
99 100
signals:
    void setChatVisibility(bool visible);
101
    void videoSettingsClicked();
102 103
    void toggleFullScreenClicked();
    void closing(const std::string& callid);
104
};