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

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2015-01-07 14:51:16 UTC
  • mfrom: (4.3.5 sid)
  • Revision ID: package-import@ubuntu.com-20150107145116-yxnafinf4lrdvrmx
Tags: 1.4.1-0.1ubuntu1
* Merge with Debian, remaining changes:
 - Drop soprano, nepomuk build-dep
* Drop ubuntu patches, now upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
#include "videoscene.h"
19
19
#include <QtGui/QLabel>
 
20
#include <QtCore/QMutex>
 
21
#include <QtGui/QGraphicsSceneMouseEvent>
20
22
#include <GL/glu.h>
21
23
#include <QGraphicsSceneMouseEvent>
22
24
 
23
25
#include "videoglframe.h"
24
26
#include "videotoolbar.h"
 
27
#include <lib/video/videorenderer.h>
 
28
#include <lib/video/videomodel.h>
 
29
#include "klib/kcfg_settings.h"
25
30
 
26
31
#ifndef GL_MULTISAMPLE
27
32
#define GL_MULTISAMPLE  0x809D
28
33
#endif
29
34
 
30
35
VideoScene::VideoScene()
31
 
   : m_backgroundColor(25, 25, 25),m_pToolbar(nullptr)
 
36
   : m_backgroundColor(25, 25, 25),m_pPreviewFrame(nullptr)//,m_pToolbar(nullptr)
32
37
{
33
 
 
34
 
//    QPointF pos(10, 10);
35
 
//    foreach (QGraphicsItem *item, items()) {
36
 
//       item->setFlag(QGraphicsItem::ItemIsMovable);
37
 
//       item->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
38
 
// 
39
 
//       const QRectF rect = item->boundingRect();
40
 
//       item->setPos(pos.x() - rect.x(), pos.y() - rect.y());
41
 
//       pos += QPointF(0, 10 + rect.height());
42
 
//    }
43
 
 
44
 
//    QRadialGradient gradient(40, 40, 40, 40, 40);
45
 
//    gradient.setColorAt(0.2, Qt::yellow);
46
 
//    gradient.setColorAt(1, Qt::transparent);
47
 
 
48
 
//    m_lightItem = new QGraphicsRectItem(0, 0, 80, 80);
49
 
//    m_lightItem->setPen(Qt::NoPen);
50
 
//    m_lightItem->setBrush(gradient);
51
 
//    m_lightItem->setFlag(QGraphicsItem::ItemIsMovable);
52
 
//    m_lightItem->setPos(800, 200);
53
 
//    addItem(m_lightItem);
54
38
}
55
39
 
56
40
void VideoScene::drawBackground(QPainter *painter, const QRectF& rect)
62
46
   foreach(VideoGLFrame* frm, m_lFrames) {
63
47
      frm->paintEvent(painter);
64
48
   }
65
 
}
66
 
 
67
 
void VideoScene::setBackgroundColor()
68
 
{
69
 
//    const QColor color = QColorDialog::getColor(m_backgroundColor);
70
 
//    if (color.isValid()) {
71
 
//       m_backgroundColor = color;
72
 
//       update();
73
 
//    }
74
 
}
75
 
 
76
 
void VideoScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
77
 
{
78
 
   QGraphicsScene::mouseMoveEvent(event);
79
 
   if (event->isAccepted())
80
 
      return;
81
 
   if (event->buttons() & Qt::LeftButton) {
82
 
      event->accept();
83
 
      update();
84
 
   }
85
 
   foreach(VideoGLFrame* frm, m_lFrames) {
86
 
      const QPointF diff = event->pos() - frm->anchor();
87
 
      if (event->buttons() & Qt::LeftButton) {
88
 
         frm->setRotX(frm->rotX()+diff.y()/5.0f);
89
 
         frm->setRotY(frm->rotY()+diff.x()/5.0f);
90
 
      } else if (event->buttons() & Qt::RightButton) {
91
 
         frm->setRotZ(frm->rotZ()+diff.x()/5.0f);
92
 
      }
93
 
 
94
 
      frm->setAnchor(event->pos());
95
 
   }
96
 
}
97
 
 
98
 
void VideoScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
99
 
{
100
 
   QGraphicsScene::mousePressEvent(event);
101
 
   if (event->isAccepted())
102
 
      return;
103
 
 
104
 
   event->accept();
105
 
 
106
 
   foreach(VideoGLFrame* frm, m_lFrames) {
107
 
      frm->setAnchor(event->pos());
108
 
   }
109
 
}
110
 
 
111
 
void VideoScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
112
 
{
113
 
   QGraphicsScene::mouseReleaseEvent(event);
114
 
   if (event->isAccepted())
115
 
      return;
116
 
 
117
 
   event->accept();
118
 
   update();
 
49
   if (m_pPreviewFrame) {
 
50
      m_pPreviewFrame->paintEvent(painter);
 
51
   }
119
52
}
120
53
 
121
54
void VideoScene::wheelEvent(QGraphicsSceneWheelEvent *event)
126
59
 
127
60
   event->accept();
128
61
   foreach(VideoGLFrame* frm, m_lFrames) {
129
 
      frm->setScale(frm->scale() +(event->delta() > 0 ?1:-1)*frm->scale()*0.1f);
 
62
      if (frm) {
 
63
         if (VideoModel::instance()->previewRenderer() != frm->renderer())
 
64
            frm->setScale(frm->scale() +(event->delta() > 0 ?1:-1)*frm->scale()*0.1f);
 
65
      }
130
66
   }
131
67
   update();
132
68
}
136
72
   update();
137
73
}
138
74
 
139
 
void VideoScene::setToolbar(VideoToolbar* tb)
140
 
{
141
 
   m_pToolbar = tb;
142
 
   addWidget(m_pToolbar);
143
 
}
144
 
 
145
75
void VideoScene::addFrame(VideoGLFrame* frame)
146
76
{
147
 
   m_lFrames << frame;
148
 
   m_pToolbar->resizeToolbar();
149
 
}
 
77
   if (frame->renderer() == VideoModel::instance()->previewRenderer())
 
78
      m_pPreviewFrame = frame;
 
79
   else
 
80
      m_lFrames << frame;
 
81
//    m_pToolbar->resizeToolbar();
 
82
   invalidate();
 
83
}
 
84
 
 
85
void VideoScene::removeFrame( VideoGLFrame* frame )
 
86
{
 
87
   if (!frame) return;
 
88
   if (frame == m_pPreviewFrame)
 
89
      m_pPreviewFrame = nullptr;
 
90
   else
 
91
      m_lFrames.removeAll(frame);
 
92
   invalidate();
 
93
}
 
94
 
 
95
void VideoScene::slotRotateLeft()
 
96
{
 
97
   foreach(VideoGLFrame* frm, m_lFrames) {
 
98
      if (VideoModel::instance()->previewRenderer() != frm->renderer())
 
99
         frm->setRotZ(frm->rotZ()+90);
 
100
   }
 
101
}
 
102
 
 
103
void VideoScene::slotRotateRight()
 
104
{
 
105
   foreach(VideoGLFrame* frm, m_lFrames) {
 
106
      if (VideoModel::instance()->previewRenderer() != frm->renderer())
 
107
         frm->setRotZ(frm->rotZ()-90);
 
108
   }
 
109
}
 
110
 
 
111
void VideoScene::slotKeepAspectRatio(bool keep)
 
112
{
 
113
   ConfigurationSkeleton::setKeepVideoAspectRatio(keep);
 
114
   foreach(VideoGLFrame* frm, m_lFrames) {
 
115
      if (VideoModel::instance()->previewRenderer() != frm->renderer())
 
116
         frm->setKeepAspectRatio(keep);
 
117
   }
 
118
}
 
119