~ubuntu-branches/ubuntu/trusty/sflphone/trusty

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (4.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20140128182336-jrsv0k9u6cawc068
Tags: 1.3.0-1
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2008 Nokia Corporation                                  *
 
3
 *                                                                         *
 
4
 *   This program is free software; you can redistribute it and/or modify  *
 
5
 *   it under the terms of the GNU General Public License as published by  *
 
6
 *   the Free Software Foundation; either version 3 of the License, or     *
 
7
 *   (at your option) any later version.                                   *
 
8
 *                                                                         *
 
9
 *   This program is distributed in the hope that it will be useful,       *
 
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
12
 *   GNU General Public License for more details.                          *
 
13
 *                                                                         *
 
14
 *   You should have received a copy of the GNU General Public License     *
 
15
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
 
16
 **************************************************************************/
 
17
 
 
18
#include "videoscene.h"
 
19
#include <QtGui/QLabel>
 
20
#include <GL/glu.h>
 
21
 
 
22
#include "videoglframe.h"
 
23
#include "videotoolbar.h"
 
24
 
 
25
#ifndef GL_MULTISAMPLE
 
26
#define GL_MULTISAMPLE  0x809D
 
27
#endif
 
28
 
 
29
VideoScene::VideoScene()
 
30
   : m_backgroundColor(25, 25, 25),m_pToolbar(nullptr)
 
31
{
 
32
 
 
33
//    QPointF pos(10, 10);
 
34
//    foreach (QGraphicsItem *item, items()) {
 
35
//       item->setFlag(QGraphicsItem::ItemIsMovable);
 
36
//       item->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
 
37
// 
 
38
//       const QRectF rect = item->boundingRect();
 
39
//       item->setPos(pos.x() - rect.x(), pos.y() - rect.y());
 
40
//       pos += QPointF(0, 10 + rect.height());
 
41
//    }
 
42
 
 
43
//    QRadialGradient gradient(40, 40, 40, 40, 40);
 
44
//    gradient.setColorAt(0.2, Qt::yellow);
 
45
//    gradient.setColorAt(1, Qt::transparent);
 
46
 
 
47
//    m_lightItem = new QGraphicsRectItem(0, 0, 80, 80);
 
48
//    m_lightItem->setPen(Qt::NoPen);
 
49
//    m_lightItem->setBrush(gradient);
 
50
//    m_lightItem->setFlag(QGraphicsItem::ItemIsMovable);
 
51
//    m_lightItem->setPos(800, 200);
 
52
//    addItem(m_lightItem);
 
53
}
 
54
 
 
55
void VideoScene::drawBackground(QPainter *painter, const QRectF& rect)
 
56
{
 
57
   Q_UNUSED(rect)
 
58
   glClearColor(m_backgroundColor.redF(), m_backgroundColor.greenF(), m_backgroundColor.blueF(), 1.0f);
 
59
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
60
 
 
61
   foreach(VideoGLFrame* frm, m_lFrames) {
 
62
      frm->paintEvent(painter);
 
63
   }
 
64
}
 
65
 
 
66
void VideoScene::setBackgroundColor()
 
67
{
 
68
//    const QColor color = QColorDialog::getColor(m_backgroundColor);
 
69
//    if (color.isValid()) {
 
70
//       m_backgroundColor = color;
 
71
//       update();
 
72
//    }
 
73
}
 
74
 
 
75
void VideoScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
 
76
{
 
77
   QGraphicsScene::mouseMoveEvent(event);
 
78
   if (event->isAccepted())
 
79
      return;
 
80
   if (event->buttons() & Qt::LeftButton) {
 
81
      event->accept();
 
82
      update();
 
83
   }
 
84
   foreach(VideoGLFrame* frm, m_lFrames) {
 
85
      const QPointF diff = event->pos() - frm->anchor();
 
86
      if (event->buttons() & Qt::LeftButton) {
 
87
         frm->setRotX(frm->rotX()+diff.y()/5.0f);
 
88
         frm->setRotY(frm->rotY()+diff.x()/5.0f);
 
89
      } else if (event->buttons() & Qt::RightButton) {
 
90
         frm->setRotZ(frm->rotZ()+diff.x()/5.0f);
 
91
      }
 
92
 
 
93
      frm->setAnchor(event->pos());
 
94
   }
 
95
}
 
96
 
 
97
void VideoScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
 
98
{
 
99
   QGraphicsScene::mousePressEvent(event);
 
100
   if (event->isAccepted())
 
101
      return;
 
102
 
 
103
   event->accept();
 
104
 
 
105
   foreach(VideoGLFrame* frm, m_lFrames) {
 
106
      frm->setAnchor(event->pos());
 
107
   }
 
108
}
 
109
 
 
110
void VideoScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
 
111
{
 
112
   QGraphicsScene::mouseReleaseEvent(event);
 
113
   if (event->isAccepted())
 
114
      return;
 
115
 
 
116
   event->accept();
 
117
   update();
 
118
}
 
119
 
 
120
void VideoScene::wheelEvent(QGraphicsSceneWheelEvent *event)
 
121
{
 
122
   QGraphicsScene::wheelEvent(event);
 
123
   if (event->isAccepted())
 
124
      return;
 
125
 
 
126
   event->accept();
 
127
   foreach(VideoGLFrame* frm, m_lFrames) {
 
128
      frm->setScale(frm->scale() +(event->delta() > 0 ?1:-1)*frm->scale()*0.1f);
 
129
   }
 
130
   update();
 
131
}
 
132
 
 
133
void VideoScene::frameChanged()
 
134
{
 
135
   update();
 
136
}
 
137
 
 
138
void VideoScene::setToolbar(VideoToolbar* tb)
 
139
{
 
140
   m_pToolbar = tb;
 
141
   addWidget(m_pToolbar);
 
142
}
 
143
 
 
144
void VideoScene::addFrame(VideoGLFrame* frame)
 
145
{
 
146
   m_lFrames << frame;
 
147
   m_pToolbar->resizeToolbar();
 
148
}