From kde-commits Mon Mar 31 21:20:01 2014 From: Emmanuel Lepage Vallee Date: Mon, 31 Mar 2014 21:20:01 +0000 To: kde-commits Subject: [sflphone-kde/contact_refactor] src: [ #44118 ] Fix preview Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=139630081216479 Git commit f51772db4f1d811e7feaf0a67c58bc2239c29708 by Emmanuel Lepage Vall= ee. Committed on 31/03/2014 at 21:11. Pushed by lepagevalleeemmanuel into branch 'contact_refactor'. [ #44118 ] Fix preview M +1 -0 src/actioncollection.cpp M +1 -1 src/widgets/videodock.cpp M +22 -3 src/widgets/videoglframe.cpp M +3 -0 src/widgets/videoglframe.h M +61 -55 src/widgets/videoscene.cpp M +4 -3 src/widgets/videoscene.h M +23 -5 src/widgets/videowidget3.cpp M +5 -1 src/widgets/videowidget3.h http://commits.kde.org/sflphone-kde/f51772db4f1d811e7feaf0a67c58bc2239c29708 diff --git a/src/actioncollection.cpp b/src/actioncollection.cpp index 11772df..8870d4b 100644 --- a/src/actioncollection.cpp +++ b/src/actioncollection.cpp @@ -117,6 +117,7 @@ ActionCollection::ActionCollection(QObject* parent) : Q= Object(parent),m_pWizard( action_video_flip_vertical ->setIcon(KIcon("object-flip-vertical" )); action_video_mute ->setIcon(KIcon("camera-web" )); action_video_preview ->setIcon(KIcon("view-preview" )); + action_video_preview ->setCheckable(true); #endif } = diff --git a/src/widgets/videodock.cpp b/src/widgets/videodock.cpp index 64765e2..862f2dd 100644 --- a/src/widgets/videodock.cpp +++ b/src/widgets/videodock.cpp @@ -65,7 +65,7 @@ VideoDock::VideoDock(QWidget* parent) : QDockWidget(paren= t) = connect(ActionCollection::instance()->videoRotateLeftAction() ,SIGNAL(t= riggered(bool)),m_pVideoWidet,SLOT(slotRotateLeft())); connect(ActionCollection::instance()->videoRotateRightAction(),SIGNAL(t= riggered(bool)),m_pVideoWidet,SLOT(slotRotateRight())); - connect(ActionCollection::instance()->videoPreviewAction() ,SIGNAL(t= riggered(bool)),m_pVideoWidet,SLOT(slotShowPreview())); + connect(ActionCollection::instance()->videoPreviewAction() ,SIGNAL(t= riggered(bool)),m_pVideoWidet,SLOT(slotShowPreview(bool))); } = ///Set current renderer diff --git a/src/widgets/videoglframe.cpp b/src/widgets/videoglframe.cpp index 6585f7d..b67059d 100644 --- a/src/widgets/videoglframe.cpp +++ b/src/widgets/videoglframe.cpp @@ -50,6 +50,7 @@ public: QPointF anchor; float scale; float rot_x, rot_y, rot_z; + float tra_x, tra_y, tra_z; GLuint tile_list; bool isRendering; = @@ -79,7 +80,7 @@ Q_SIGNALS: = ThreadedPainter2::ThreadedPainter2(VideoGLFrame* frm,QGLWidget* wdg) : QOb= ject(), m_pRenderer(nullptr), m_pW(wdg), rot_x(0.0f),rot_y(0.0f),rot_z(0.0f),scale(0.8f),isRendering(= false),m_pFrm(frm), - m_Data(nullptr),tile_list(0) + m_Data(nullptr),tile_list(0),tra_x(0.0f), tra_y(0.0f), tra_z(0.0f) { } = @@ -138,7 +139,7 @@ void ThreadedPainter2::draw(QPainter* p) gluBuild2DMipmaps(GL_TEXTURE_2D, 4, m_ActiveSize.width(), m_Activ= eSize.height(), GL_BGRA, GL_UNSIGNED_BYTE, m_Data); = // draw into the GL widget - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); +// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(-1, 1, -1, 1, 10, 100); @@ -160,9 +161,12 @@ void ThreadedPainter2::draw(QPainter* p) glRotatef(rot_y, 0.0f, 1.0f, 0.0f); glRotatef(rot_z, 0.0f, 0.0f, 1.0f); = + + // draw background glPushMatrix(); glScalef(1.7f, 1.7f, 1.7f); + glTranslatef(tra_x, tra_y, tra_z); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glCallList(tile_list); glPopMatrix(); @@ -277,7 +281,6 @@ void VideoGLFrame::setRotZ(float rot) = void VideoGLFrame::setRotY(float rot) { - qDebug() << "HERE" << this << rot << m_pPainter; m_pPainter->rot_y =3D rot; } = @@ -286,6 +289,22 @@ void VideoGLFrame::setRotX(float rot) m_pPainter->rot_x =3D rot; } = +void VideoGLFrame::setTranslationZ(float tra) +{ + m_pPainter->tra_z =3D tra; +} + +void VideoGLFrame::setTranslationY(float tra) +{ + m_pPainter->tra_y =3D tra; +} + +void VideoGLFrame::setTranslationX(float tra) +{ + m_pPainter->tra_x =3D tra; +} + + void VideoGLFrame::setScale(float scale) { QMutexLocker locker(&m_pPainter->mutex); diff --git a/src/widgets/videoglframe.h b/src/widgets/videoglframe.h index 272c1cb..b7be80e 100644 --- a/src/widgets/videoglframe.h +++ b/src/widgets/videoglframe.h @@ -48,6 +48,9 @@ public: void setRotZ(float rot); void setRotY(float rot); void setRotX(float rot); + void setTranslationZ(float tra); + void setTranslationY(float tra); + void setTranslationX(float tra); void setScale(float scale); void setAnchor(const QPointF& point); = diff --git a/src/widgets/videoscene.cpp b/src/widgets/videoscene.cpp index 5d06bd9..47d13c9 100644 --- a/src/widgets/videoscene.cpp +++ b/src/widgets/videoscene.cpp @@ -24,6 +24,7 @@ #include "videoglframe.h" #include "videotoolbar.h" #include +#include = #ifndef GL_MULTISAMPLE #define GL_MULTISAMPLE 0x809D @@ -62,7 +63,7 @@ void VideoScene::drawBackground(QPainter *painter, const = QRectF& rect) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); = foreach(VideoGLFrame* frm, m_lFrames) { - frm->paintEvent(painter); + frm->paintEvent(painter); } } = @@ -75,69 +76,68 @@ void VideoScene::setBackgroundColor() // } } = -void VideoScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - QGraphicsScene::mouseMoveEvent(event); - if (event->isAccepted()) - return; - if (event->buttons() & Qt::LeftButton) { - event->accept(); - update(); - } - foreach(VideoGLFrame* frm, m_lFrames) { -// const QPointF diff =3D event->pos() - frm->anchor(); - if (event->buttons() & Qt::LeftButton) { - = - 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); - } +// void VideoScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) +// { +// QGraphicsScene::mouseMoveEvent(event); +// if (event->isAccepted()) +// return; +// if (event->buttons() & Qt::LeftButton) { +// event->accept(); +// update(); +// } +// foreach(VideoGLFrame* frm, m_lFrames) { +// // const QPointF diff =3D event->pos() - frm->anchor(); +// if (event->buttons() & Qt::LeftButton) { +// = +// 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()); +// } +// } = - frm->setAnchor(event->pos()); - } -} +// void VideoScene::mousePressEvent(QGraphicsSceneMouseEvent *event) +// { +// QGraphicsScene::mousePressEvent(event); +// if (event->isAccepted()) +// return; +// = +// event->accept(); +// = +// foreach(VideoGLFrame* frm, m_lFrames) { +// frm->setAnchor(event->pos()); +// } +// } = -void VideoScene::mousePressEvent(QGraphicsSceneMouseEvent *event) +// void VideoScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +// { +// QGraphicsScene::mouseReleaseEvent(event); +// if (event->isAccepted()) +// return; +// = +// event->accept(); +// update(); +// } + +void VideoScene::wheelEvent(QGraphicsSceneWheelEvent *event) { - QGraphicsScene::mousePressEvent(event); + QGraphicsScene::wheelEvent(event); if (event->isAccepted()) return; = event->accept(); - foreach(VideoGLFrame* frm, m_lFrames) { - frm->setAnchor(event->pos()); + if (frm) { + if (VideoModel::instance()->previewRenderer() !=3D frm->renderer(= )) + frm->setScale(frm->scale() +(event->delta() > 0 ?1:-1)*frm->sc= ale()*0.1f); + } } -} - -void VideoScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - QGraphicsScene::mouseReleaseEvent(event); - if (event->isAccepted()) - return; - - event->accept(); update(); } = -void VideoScene::wheelEvent(QGraphicsSceneWheelEvent *event) -{ - QGraphicsScene::wheelEvent(event); - if (event->isAccepted()) - return; - -// event->accept(); -// foreach(VideoGLFrame* frm, m_lFrames) { -// if (frm) { -// frm->renderer()->mutex()->lock(); -// frm->setScale(frm->scale() +(event->delta() > 0 ?1:-1)*frm->sc= ale()*0.1f); -// frm->renderer()->mutex()->unlock(); -// } -// } -// update(); -} - void VideoScene::frameChanged() { update(); @@ -155,23 +155,29 @@ void VideoScene::addFrame(VideoGLFrame* frame) // m_pToolbar->resizeToolbar(); } = +void VideoScene::removeFrame( VideoGLFrame* frame ) +{ + m_lFrames.removeAll(frame); +} = void VideoScene::slotRotateLeft() { foreach(VideoGLFrame* frm, m_lFrames) { - frm->setRotZ(frm->rotZ()-90); + if (VideoModel::instance()->previewRenderer() !=3D frm->renderer()) + frm->setRotZ(frm->rotZ()-90); } } = void VideoScene::slotRotateRight() { foreach(VideoGLFrame* frm, m_lFrames) { - frm->setRotZ(frm->rotZ()+90); + if (VideoModel::instance()->previewRenderer() !=3D frm->renderer()) + frm->setRotZ(frm->rotZ()+90); } } = void VideoScene::slotShowPreview() { - = + = } = diff --git a/src/widgets/videoscene.h b/src/widgets/videoscene.h index dfb771f..12b2dcb 100644 --- a/src/widgets/videoscene.h +++ b/src/widgets/videoscene.h @@ -36,12 +36,13 @@ public: //Setters // void setToolbar( VideoToolbar* tb ); void addFrame ( VideoGLFrame* frame ); + void removeFrame( VideoGLFrame* frame ); = protected: //Events - virtual void mousePressEvent ( QGraphicsSceneMouseEvent* event ); - virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent* event ); - virtual void mouseMoveEvent ( QGraphicsSceneMouseEvent* event ); +// virtual void mousePressEvent ( QGraphicsSceneMouseEvent* event = ); +// virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent* event = ); +// virtual void mouseMoveEvent ( QGraphicsSceneMouseEvent* event = ); virtual void wheelEvent ( QGraphicsSceneWheelEvent* wheelEvent ); = private: diff --git a/src/widgets/videowidget3.cpp b/src/widgets/videowidget3.cpp index 1aa8421..ac17011 100644 --- a/src/widgets/videowidget3.cpp +++ b/src/widgets/videowidget3.cpp @@ -28,10 +28,8 @@ #include = //SFLPhone -#include #include #include "videoscene.h" -#include "videoglframe.h" #include "videotoolbar.h" = = @@ -71,18 +69,24 @@ VideoWidget3::~VideoWidget3() void VideoWidget3::addRenderer(VideoRenderer* renderer) { m_pWdg->makeCurrent(); + if (m_hFrames[renderer]) { + m_pScene->addFrame(m_hFrames[renderer]); + return; + } if (renderer) { + qDebug() << "NEW"; VideoGLFrame* frm =3D new VideoGLFrame(m_pWdg); frm->setRenderer(renderer); connect(frm,SIGNAL(changed()),m_pScene,SLOT(frameChanged())); m_pScene->addFrame(frm); + m_hFrames[renderer] =3D frm; } } = void VideoWidget3::removeRenderer(VideoRenderer* renderer) { Q_UNUSED(renderer) - //TODO + m_pScene->removeFrame(m_hFrames[renderer]); } = void VideoWidget3::resizeEvent(QResizeEvent* event) @@ -102,8 +106,22 @@ void VideoWidget3::slotRotateRight() m_pScene->slotRotateRight(); } = -void VideoWidget3::slotShowPreview() +void VideoWidget3::slotShowPreview(bool show) { - m_pScene->slotShowPreview(); + if (VideoModel::instance()->isPreviewing() && show) { + qDebug() << "show"; + addRenderer(VideoModel::instance()->previewRenderer()); + VideoGLFrame* frm =3D m_hFrames[VideoModel::instance()->previewRende= rer()]; + if (frm) { + frm->setScale(0.3); + frm->setTranslationX(1.8); + frm->setTranslationY(1.8); +// frm->setRotY(60); + } + } + else { + qDebug() << "hide"; + removeRenderer(VideoModel::instance()->previewRenderer()); + } } = diff --git a/src/widgets/videowidget3.h b/src/widgets/videowidget3.h index b0f559b..70d7a65 100644 --- a/src/widgets/videowidget3.h +++ b/src/widgets/videowidget3.h @@ -19,6 +19,8 @@ #define VIDEOWIDGET3_H = #include +#include "videoglframe.h" +#include = //Qt class QGLWidget; @@ -26,6 +28,7 @@ class QGLWidget; //SFLPhone class VideoRenderer; class VideoScene; +class VideoGLFrame; = class VideoWidget3 : public QGraphicsView { @@ -43,13 +46,14 @@ protected: private: VideoScene* m_pScene ; QGLWidget* m_pWdg ; + QHash m_hFrames; = public Q_SLOTS: void addRenderer(VideoRenderer* renderer); void removeRenderer(VideoRenderer* renderer); void slotRotateLeft(); void slotRotateRight(); - void slotShowPreview(); + void slotShowPreview(bool show); = Q_SIGNALS: void changed();