~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to kde/src/widgets/videowidget3.cpp

  • Committer: Package Import Robot
  • Author(s): Francois Marier, Francois Marier, Mark Purcell
  • Date: 2014-10-18 15:08:50 UTC
  • mfrom: (1.1.12)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20141018150850-2exfk34ckb15pcwi
Tags: 1.4.1-0.1
[ Francois Marier ]
* Non-maintainer upload
* New upstream release (closes: #759576, #741130)
  - debian/rules +PJPROJECT_VERSION := 2.2.1
  - add upstream patch to fix broken TLS support
  - add patch to fix pjproject regression

[ Mark Purcell ]
* Build-Depends:
  - sflphone-daemon + libavformat-dev, libavcodec-dev, libswscale-dev,
  libavdevice-dev, libavutil-dev
  - sflphone-gnome + libclutter-gtk-1.0-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
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>
24
30
 
25
31
//System
26
32
#include <math.h>
27
33
#include <GL/glu.h>
28
34
 
29
35
//SFLPhone
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"
35
43
 
36
44
 
37
45
#ifndef GL_MULTISAMPLE
39
47
#endif
40
48
 
41
49
 
42
 
VideoWidget3::VideoWidget3(QWidget *parent) : QGraphicsView(parent)
 
50
VideoWidget3::VideoWidget3(QWidget *parent) : QGraphicsView(parent),m_pBackDevice(nullptr)
43
51
{
 
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);
60
69
 
61
 
   VideoToolbar* tb = new VideoToolbar(nullptr);
62
 
   tb->setForcedParent(this);
63
 
   tb->show();
64
 
   m_pScene->setToolbar(tb);
 
70
   if (VideoModel::instance()->isPreviewing()) {
 
71
      slotShowPreview(true);
 
72
   }
 
73
 
 
74
//    m_pScene->setToolbar(tb);
65
75
   m_pScene->setSceneRect(0,0,width(),height());
66
 
   tb->resizeToolbar();
 
76
   setAcceptDrops(true);
67
77
}
68
78
 
69
79
VideoWidget3::~VideoWidget3()
71
81
   
72
82
}
73
83
 
 
84
void VideoWidget3::dragLeaveEvent( QDragLeaveEvent* e )
 
85
{
 
86
   Q_UNUSED(e)
 
87
}
 
88
 
 
89
void VideoWidget3::dragEnterEvent( QDragEnterEvent* e )
 
90
{
 
91
   e->accept();
 
92
}
 
93
 
 
94
void VideoWidget3::dragMoveEvent( QDragMoveEvent* e )
 
95
{
 
96
   e->accept();
 
97
}
 
98
 
 
99
void VideoWidget3::dropEvent( QDropEvent* e )
 
100
{
 
101
   if (e->mimeData()->hasFormat("text/uri-list")) {
 
102
      ExtendedVideoDeviceModel::instance()->setFile(QUrl(e->mimeData()->data("text/uri-list")));
 
103
   }
 
104
   e->accept();
 
105
}
 
106
 
74
107
void VideoWidget3::addRenderer(VideoRenderer* renderer)
75
108
{
76
109
   m_pWdg->makeCurrent();
 
110
   if (m_hFrames[renderer]) {
 
111
      m_pScene->addFrame(m_hFrames[renderer]);
 
112
      return;
 
113
   }
77
114
   if (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;
82
121
   }
83
122
}
84
123
 
 
124
void VideoWidget3::removeRenderer(VideoRenderer* renderer)
 
125
{
 
126
   Q_UNUSED(renderer)
 
127
   m_pScene->removeFrame(m_hFrames[renderer]);
 
128
}
 
129
 
85
130
void VideoWidget3::resizeEvent(QResizeEvent* event)
86
131
{
87
132
   m_pScene->setSceneRect(0,0,event->size().width(),event->size().height());
88
133
}
 
134
 
 
135
 
 
136
 
 
137
void VideoWidget3::slotRotateLeft()
 
138
{
 
139
   m_pScene->slotRotateLeft();
 
140
}
 
141
 
 
142
void VideoWidget3::slotRotateRight()
 
143
{
 
144
   m_pScene->slotRotateRight();
 
145
}
 
146
 
 
147
void VideoWidget3::slotShowPreview(bool show)
 
148
{
 
149
   ConfigurationSkeleton::setDisplayVideoPreview(show);
 
150
   if (VideoModel::instance()->isPreviewing() && show) {
 
151
      addRenderer(VideoModel::instance()->previewRenderer());
 
152
      VideoGLFrame* frm = m_hFrames[VideoModel::instance()->previewRenderer()];
 
153
      if (frm) {
 
154
         frm->setScale(0.3);
 
155
         frm->setTranslationX(1.8);
 
156
         frm->setTranslationY(1.8);
 
157
//          frm->setRotY(60);
 
158
      }
 
159
   }
 
160
   else {
 
161
      removeRenderer(VideoModel::instance()->previewRenderer());
 
162
   }
 
163
}
 
164
 
 
165
void VideoWidget3::slotMuteOutgoindVideo(bool mute)
 
166
{
 
167
   if (mute) {
 
168
      m_pBackDevice = VideoDeviceModel::instance()->activeDevice();
 
169
      ExtendedVideoDeviceModel::instance()->switchTo(ExtendedVideoDeviceModel::ExtendedDeviceList::NONE);
 
170
   }
 
171
   else if (m_pBackDevice) {
 
172
      ExtendedVideoDeviceModel::instance()->switchTo(m_pBackDevice);
 
173
   }
 
174
}
 
175
 
 
176
void VideoWidget3::slotKeepAspectRatio(bool keep)
 
177
{
 
178
   m_pScene->slotKeepAspectRatio(keep);
 
179
}
 
180
 
 
181
 
 
182
void VideoWidget3::slotPreviewEnabled(bool show)
 
183
{
 
184
   if (show && ActionCollection::instance()->videoPreviewAction()->isChecked()) {
 
185
      slotShowPreview(true);
 
186
   }
 
187
}