[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [sflphone-kde/contact_refactor] src: [ #44118 ] Fix rotate left/right buttons
From:       Emmanuel Lepage Vallee <emmanuel.lepage () savoirfairelinux ! com>
Date:       2014-03-31 21:20:01
Message-ID: E1WUjcf-0000Fd-Cy () scm ! kde ! org
[Download RAW message or body]

Git commit f2f8c84aa1d8a17a63d62e06f51f9862ae2cb871 by Emmanuel Lepage Vallee.
Committed on 31/03/2014 at 20:12.
Pushed by lepagevalleeemmanuel into branch 'contact_refactor'.

[ #44118 ] Fix rotate left/right buttons

M  +11   -0    src/lib/call.cpp
M  +2    -0    src/lib/call.h
M  +16   -2    src/lib/videorenderer.cpp
M  +10   -5    src/lib/videorenderer.h
M  +6    -0    src/widgets/videodock.cpp
M  +2    -0    src/widgets/videoglframe.cpp
M  +34   -13   src/widgets/videoscene.cpp
M  +3    -0    src/widgets/videoscene.h
M  +18   -0    src/widgets/videowidget3.cpp
M  +3    -0    src/widgets/videowidget3.h

http://commits.kde.org/sflphone-kde/f2f8c84aa1d8a17a63d62e06f51f9862ae2cb871

diff --git a/src/lib/call.cpp b/src/lib/call.cpp
index 0be3e5f..eb86407 100644
--- a/src/lib/call.cpp
+++ b/src/lib/call.cpp
@@ -608,6 +608,17 @@ AbstractHistoryBackend* Call::backend() const
 }
 
 
+///Does this call currently has video
+bool Call::hasVideo() const
+{
+   #ifdef ENABLE_VIDEO
+   return VideoModel::instance()->getRenderer(this) != nullptr;
+   #else
+   return false;
+   #endif
+}
+
+
 ///Get the current state
 Call::State Call::state() const
 {
diff --git a/src/lib/call.h b/src/lib/call.h
index 18106da..ec90b46 100644
--- a/src/lib/call.h
+++ b/src/lib/call.h
@@ -279,6 +279,7 @@ public:
    Q_PROPERTY( QString            toHumanStateName READ toHumanStateName             \
)  Q_PROPERTY( bool               missed           READ isMissed                      \
)  Q_PROPERTY( Direction          direction        READ direction                     \
) +   Q_PROPERTY( bool               hasVideo         READ hasVideo                   \
)  Q_PROPERTY( Call::LegacyHistoryState historyState     READ historyState            \
)  
    //Read/write properties
@@ -329,6 +330,7 @@ public:
    bool                     isMissed         () const;
    Call::Direction          direction        () const;
    AbstractHistoryBackend*  backend          () const;
+   bool                     hasVideo         () const;
 
    //Automated function
    Call::State stateChanged(const QString & newState);
diff --git a/src/lib/videorenderer.cpp b/src/lib/videorenderer.cpp
index 89cd560..e92f3b3 100644
--- a/src/lib/videorenderer.cpp
+++ b/src/lib/videorenderer.cpp
@@ -29,8 +29,7 @@
 #include <sys/mman.h>
 #include <semaphore.h>
 #include <errno.h>
-// #include <linux/time.h>
-#include <time.h>
+
 
 #ifndef CLOCK_REALTIME
 #define CLOCK_REALTIME 0
@@ -265,6 +264,15 @@ void VideoRenderer::timedEvents()
    bool ok = renderToBitmap();
 
    if (ok == true) {
+
+      //Compute the FPS shown to the client
+      if (m_CurrentTime.second() != QTime::currentTime().second()) {
+         m_Fps = m_fpsC;
+         m_fpsC=0;
+         m_CurrentTime = QTime::currentTime();
+      }
+      m_fpsC++;
+
       emit frameUpdated();
    }
    else {
@@ -349,6 +357,12 @@ QMutex* VideoRenderer::mutex()
    return m_pMutex;
 }
 
+///Get the current frame rate of this renderer
+int VideoRenderer::fps() const
+{
+   return m_Fps;
+}
+
 
 /*****************************************************************************
  *                                                                           *
diff --git a/src/lib/videorenderer.h b/src/lib/videorenderer.h
index d07607a..cff3189 100644
--- a/src/lib/videorenderer.h
+++ b/src/lib/videorenderer.h
@@ -20,6 +20,7 @@
 
 //Base
 #include <QtCore/QObject>
+#include <QtCore/QTime>
 #include "typedefs.h"
 #include <time.h>
 
@@ -49,11 +50,12 @@ class LIB_EXPORT VideoRenderer : public QObject {
       bool startShm ();
 
       //Getters
-      const char* rawData         ();
-      bool        isRendering     ();
-      QByteArray  currentFrame    ();
-      Resolution  activeResolution();
-      QMutex*     mutex           ();
+      const char* rawData         ()      ;
+      bool        isRendering     ()      ;
+      QByteArray  currentFrame    ()      ;
+      Resolution  activeResolution()      ;
+      QMutex*     mutex           ()      ;
+      int         fps             () const;
 
       //Setters
       void setResolution(QSize   size);
@@ -76,6 +78,9 @@ class LIB_EXPORT VideoRenderer : public QObject {
       QMutex*    m_pMutex     ;
       QMutex*    m_pSSMutex   ;
       QString    m_Id         ;
+      int        m_fpsC       ;
+      int        m_Fps        ;
+      QTime      m_CurrentTime;
 
       //Constants
       static const int TIMEOUT_SEC = 1; // 1 second
diff --git a/src/widgets/videodock.cpp b/src/widgets/videodock.cpp
index e8abbfb..64765e2 100644
--- a/src/widgets/videodock.cpp
+++ b/src/widgets/videodock.cpp
@@ -27,6 +27,8 @@
 #include "videowidget3.h"
 #include "videoscene.h"
 #include "videotoolbar.h"
+#include "actioncollection.h"
+#include "extendedaction.h"
 
 class VideoWidgetItem : public QWidgetItem {
 public:
@@ -60,6 +62,10 @@ VideoDock::VideoDock(QWidget* parent) : QDockWidget(parent)
 
    VideoToolbar* tb = new VideoToolbar(this);
    l->addWidget(tb,2,0);
+
+   connect(ActionCollection::instance()->videoRotateLeftAction() \
,SIGNAL(triggered(bool)),m_pVideoWidet,SLOT(slotRotateLeft())); +   \
connect(ActionCollection::instance()->videoRotateRightAction(),SIGNAL(triggered(bool)),m_pVideoWidet,SLOT(slotRotateRight()));
 +   connect(ActionCollection::instance()->videoPreviewAction()    \
,SIGNAL(triggered(bool)),m_pVideoWidet,SLOT(slotShowPreview()));  }
 
 ///Set current renderer
diff --git a/src/widgets/videoglframe.cpp b/src/widgets/videoglframe.cpp
index 3f32a25..6585f7d 100644
--- a/src/widgets/videoglframe.cpp
+++ b/src/widgets/videoglframe.cpp
@@ -155,6 +155,7 @@ void ThreadedPainter2::draw(QPainter* p)
       glEnable(GL_MULTISAMPLE);
       glEnable(GL_CULL_FACE);
       glScalef(-1.0f*scale, -1.0f*scale, 1.0f*scale);
+
       glRotatef(rot_x, 1.0f, 0.0f, 0.0f);
       glRotatef(rot_y, 0.0f, 1.0f, 0.0f);
       glRotatef(rot_z, 0.0f, 0.0f, 1.0f);
@@ -276,6 +277,7 @@ void VideoGLFrame::setRotZ(float rot)
 
 void VideoGLFrame::setRotY(float rot)
 {
+   qDebug() << "HERE" << this << rot << m_pPainter;
    m_pPainter->rot_y = rot;
 }
 
diff --git a/src/widgets/videoscene.cpp b/src/widgets/videoscene.cpp
index b84bf58..5d06bd9 100644
--- a/src/widgets/videoscene.cpp
+++ b/src/widgets/videoscene.cpp
@@ -85,12 +85,13 @@ void VideoScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
       update();
    }
    foreach(VideoGLFrame* frm, m_lFrames) {
-      const QPointF diff = event->pos() - frm->anchor();
+//       const QPointF diff = event->pos() - frm->anchor();
       if (event->buttons() & Qt::LeftButton) {
-         frm->setRotX(frm->rotX()+diff.y()/5.0f);
-         frm->setRotY(frm->rotY()+diff.x()/5.0f);
-      } else if (event->buttons() & Qt::RightButton) {
-         frm->setRotZ(frm->rotZ()+diff.x()/5.0f);
+         
+         frm->setRotZ(frm->rotZ()+1);
+//          frm->setRotY(frm->rotY()+1/5.0f);
+//       } else if (event->buttons() & Qt::RightButton) {
+//          frm->setRotZ(frm->rotZ()+diff.x()/5.0f);
       }
 
       frm->setAnchor(event->pos());
@@ -126,15 +127,15 @@ void VideoScene::wheelEvent(QGraphicsSceneWheelEvent *event)
    if (event->isAccepted())
       return;
 
-   event->accept();
-   foreach(VideoGLFrame* frm, m_lFrames) {
-      if (frm) {
+//    event->accept();
+//    foreach(VideoGLFrame* frm, m_lFrames) {
+//       if (frm) {
 //          frm->renderer()->mutex()->lock();
-         frm->setScale(frm->scale() +(event->delta() > 0 ?1:-1)*frm->scale()*0.1f);
+//          frm->setScale(frm->scale() +(event->delta() > 0 \
?1:-1)*frm->scale()*0.1f);  //          frm->renderer()->mutex()->unlock();
-      }
-   }
-   update();
+//       }
+//    }
+//    update();
 }
 
 void VideoScene::frameChanged()
@@ -151,6 +152,26 @@ void VideoScene::frameChanged()
 void VideoScene::addFrame(VideoGLFrame* frame)
 {
    m_lFrames << frame;
-   qDebug() << "HERE";
 //    m_pToolbar->resizeToolbar();
 }
+
+
+void VideoScene::slotRotateLeft()
+{
+   foreach(VideoGLFrame* frm, m_lFrames) {
+      frm->setRotZ(frm->rotZ()-90);
+   }
+}
+
+void VideoScene::slotRotateRight()
+{
+   foreach(VideoGLFrame* frm, m_lFrames) {
+      frm->setRotZ(frm->rotZ()+90);
+   }
+}
+
+void VideoScene::slotShowPreview()
+{
+   
+}
+
diff --git a/src/widgets/videoscene.h b/src/widgets/videoscene.h
index 9eb1dd8..dfb771f 100644
--- a/src/widgets/videoscene.h
+++ b/src/widgets/videoscene.h
@@ -55,6 +55,9 @@ private:
 public Q_SLOTS:
    void setBackgroundColor();
    void frameChanged      ();
+   void slotRotateLeft();
+   void slotRotateRight();
+   void slotShowPreview();
 };
 
 #endif
diff --git a/src/widgets/videowidget3.cpp b/src/widgets/videowidget3.cpp
index dda94b0..1aa8421 100644
--- a/src/widgets/videowidget3.cpp
+++ b/src/widgets/videowidget3.cpp
@@ -89,3 +89,21 @@ void VideoWidget3::resizeEvent(QResizeEvent* event)
 {
    m_pScene->setSceneRect(0,0,event->size().width(),event->size().height());
 }
+
+
+
+void VideoWidget3::slotRotateLeft()
+{
+   m_pScene->slotRotateLeft();
+}
+
+void VideoWidget3::slotRotateRight()
+{
+   m_pScene->slotRotateRight();
+}
+
+void VideoWidget3::slotShowPreview()
+{
+   m_pScene->slotShowPreview();
+}
+
diff --git a/src/widgets/videowidget3.h b/src/widgets/videowidget3.h
index 353fcda..b0f559b 100644
--- a/src/widgets/videowidget3.h
+++ b/src/widgets/videowidget3.h
@@ -47,6 +47,9 @@ private:
 public Q_SLOTS:
    void addRenderer(VideoRenderer* renderer);
    void removeRenderer(VideoRenderer* renderer);
+   void slotRotateLeft();
+   void slotRotateRight();
+   void slotShowPreview();
 
 Q_SIGNALS:
    void changed();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic