21
21
#include <QtCore/QDebug>
22
22
#include <QtOpenGL/QGLWidget>
23
23
#include <QtOpenGL/QGLFormat>
24
#include <QtGui/QResizeEvent>
25
#include <QtGui/QDragEnterEvent>
26
#include <QtGui/QDragLeaveEvent>
27
#include <QtGui/QDragMoveEvent>
28
#include <QtGui/QDropEvent>
29
#include <QtCore/QMimeData>
27
33
#include <GL/glu.h>
30
#include <lib/videorenderer.h>
31
#include <lib/videomodel.h>
36
#include <lib/video/videomodel.h>
32
37
#include "videoscene.h"
33
#include "videoglframe.h"
34
38
#include "videotoolbar.h"
39
#include "actioncollection.h"
40
#include "extendedaction.h"
41
#include <lib/video/videodevicemodel.h>
42
#include "klib/kcfg_settings.h"
37
45
#ifndef GL_MULTISAMPLE
42
VideoWidget3::VideoWidget3(QWidget *parent) : QGraphicsView(parent)
50
VideoWidget3::VideoWidget3(QWidget *parent) : QGraphicsView(parent),m_pBackDevice(nullptr)
52
connect(VideoModel::instance(),SIGNAL(previewStateChanged(bool)),this,SLOT(slotPreviewEnabled(bool)));
44
53
QSizePolicy sp = sizePolicy();
45
54
sp.setVerticalPolicy ( QSizePolicy::Preferred );
46
55
sp.setHorizontalPolicy( QSizePolicy::Preferred );
58
67
m_pScene = new VideoScene();
59
68
setScene(m_pScene);
61
VideoToolbar* tb = new VideoToolbar(nullptr);
62
tb->setForcedParent(this);
64
m_pScene->setToolbar(tb);
70
if (VideoModel::instance()->isPreviewing()) {
71
slotShowPreview(true);
74
// m_pScene->setToolbar(tb);
65
75
m_pScene->setSceneRect(0,0,width(),height());
69
79
VideoWidget3::~VideoWidget3()
84
void VideoWidget3::dragLeaveEvent( QDragLeaveEvent* e )
89
void VideoWidget3::dragEnterEvent( QDragEnterEvent* e )
94
void VideoWidget3::dragMoveEvent( QDragMoveEvent* e )
99
void VideoWidget3::dropEvent( QDropEvent* e )
101
if (e->mimeData()->hasFormat("text/uri-list")) {
102
ExtendedVideoDeviceModel::instance()->setFile(QUrl(e->mimeData()->data("text/uri-list")));
74
107
void VideoWidget3::addRenderer(VideoRenderer* renderer)
76
109
m_pWdg->makeCurrent();
110
if (m_hFrames[renderer]) {
111
m_pScene->addFrame(m_hFrames[renderer]);
78
115
VideoGLFrame* frm = new VideoGLFrame(m_pWdg);
116
frm->setKeepAspectRatio(ConfigurationSkeleton::keepVideoAspectRatio());
79
117
frm->setRenderer(renderer);
80
118
connect(frm,SIGNAL(changed()),m_pScene,SLOT(frameChanged()));
81
119
m_pScene->addFrame(frm);
120
m_hFrames[renderer] = frm;
124
void VideoWidget3::removeRenderer(VideoRenderer* renderer)
127
m_pScene->removeFrame(m_hFrames[renderer]);
85
130
void VideoWidget3::resizeEvent(QResizeEvent* event)
87
132
m_pScene->setSceneRect(0,0,event->size().width(),event->size().height());
137
void VideoWidget3::slotRotateLeft()
139
m_pScene->slotRotateLeft();
142
void VideoWidget3::slotRotateRight()
144
m_pScene->slotRotateRight();
147
void VideoWidget3::slotShowPreview(bool show)
149
ConfigurationSkeleton::setDisplayVideoPreview(show);
150
if (VideoModel::instance()->isPreviewing() && show) {
151
addRenderer(VideoModel::instance()->previewRenderer());
152
VideoGLFrame* frm = m_hFrames[VideoModel::instance()->previewRenderer()];
155
frm->setTranslationX(1.8);
156
frm->setTranslationY(1.8);
161
removeRenderer(VideoModel::instance()->previewRenderer());
165
void VideoWidget3::slotMuteOutgoindVideo(bool mute)
168
m_pBackDevice = VideoDeviceModel::instance()->activeDevice();
169
ExtendedVideoDeviceModel::instance()->switchTo(ExtendedVideoDeviceModel::ExtendedDeviceList::NONE);
171
else if (m_pBackDevice) {
172
ExtendedVideoDeviceModel::instance()->switchTo(m_pBackDevice);
176
void VideoWidget3::slotKeepAspectRatio(bool keep)
178
m_pScene->slotKeepAspectRatio(keep);
182
void VideoWidget3::slotPreviewEnabled(bool show)
184
if (show && ActionCollection::instance()->videoPreviewAction()->isChecked()) {
185
slotShowPreview(true);