Commit c4024fba authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Added GenericPreviewWidget for Preview genericity

This seems to breaks a few things (or at least I observed crash that didn't
occured before, but maybe that's VLC 1.1 :D
parent da819d37
......@@ -25,15 +25,13 @@
#include "ClipPreviewWidget.h"
ClipPreviewWidget::ClipPreviewWidget( QWidget* renderWidget ) :
GenericPreviewWidget( renderWidget ),
m_clipLoaded( false ), m_videoStopped( true )
{
m_mediaPlayer = new LibVLCpp::MediaPlayer();
m_mediaPlayer->setDrawable( renderWidget->winId() );
}
ClipPreviewWidget::~ClipPreviewWidget()
{
delete m_mediaPlayer;
}
void ClipPreviewWidget::startPreview( Media* media )
......
......@@ -28,12 +28,14 @@
#include "VLCMediaPlayer.h"
#include "Media.h"
#include "GenericPreviewWidget.h"
//TODO: This should really share a common interface with RenderPreviewWorkflow
class ClipPreviewWidget : public QObject
class ClipPreviewWidget : public GenericPreviewWidget
{
Q_OBJECT
Q_DISABLE_COPY( ClipPreviewWidget )
public:
explicit ClipPreviewWidget( QWidget* renderWidget );
virtual ~ClipPreviewWidget();
......@@ -43,7 +45,6 @@ public:
void togglePlayPause();
private:
LibVLCpp::MediaPlayer* m_mediaPlayer;
bool m_clipLoaded;
bool m_videoStopped;
......
/*****************************************************************************
* GenericPreviewWidget.h: Describe a common behavior for every preview widget
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef GENERICPREVIEWWIDGET_H
#define GENERICPREVIEWWIDGET_H
#include <QObject>
#include <QWidget>
#include "Media.h"
#include "VLCMediaPlayer.h"
class GenericPreviewWidget : public QObject
{
Q_OBJECT
Q_DISABLE_COPY( GenericPreviewWidget );
public:
explicit GenericPreviewWidget( QWidget* renderWidget )
{
m_mediaPlayer = new LibVLCpp::MediaPlayer();
m_mediaPlayer->setDrawable( renderWidget->winId() );
}
virtual ~GenericPreviewWidget()
{
delete m_mediaPlayer;
}
virtual void startPreview( Media* media ) = 0;
virtual void setPosition( float newPos ) = 0;
virtual void togglePlayPause() = 0;
protected:
LibVLCpp::MediaPlayer* m_mediaPlayer;
public slots:
virtual void __positionChanged() = 0;
virtual void __videoPaused() = 0;
virtual void __videoPlaying() = 0;
virtual void __endReached() = 0;
signals:
void stopped();
void paused();
void playing();
void positionChanged( float );
void endReached();
};
#endif // GENERICPREVIEWWIDGET_H
......@@ -22,6 +22,7 @@
*****************************************************************************/
#include <QUrl>
#include <QtDebug>
#include "ui_PreviewWidget.h"
#include "gui/PreviewWidget.h"
......@@ -30,7 +31,9 @@
PreviewWidget::PreviewWidget( MainWorkflow* mainWorkflow, QWidget *parent ) :
QWidget( parent ),
m_ui( new Ui::PreviewWidget ), m_previewStopped( true )
m_ui( new Ui::PreviewWidget ),
m_currentPreviewRenderer( NULL ),
m_previewStopped( true )
{
m_ui->setupUi( this );
m_ui->groupBoxButton->hide();
......@@ -49,13 +52,15 @@ PreviewWidget::PreviewWidget( MainWorkflow* mainWorkflow, QWidget *parent ) :
m_renderPreview = new RenderPreviewWidget( mainWorkflow, m_ui->renderPreviewRenderWidget );
m_currentMode = m_ui->tabWidget->currentIndex();
qDebug() << "m_currentMode = " << m_currentMode;
m_currentPreviewRenderer = m_renderPreview;
connect( m_ui->tabWidget, SIGNAL( currentChanged(int) ), this, SLOT( changedTab(int) ) );
}
PreviewWidget::~PreviewWidget()
{
delete m_ui;
delete m_clipPreview;
delete m_renderPreview;
}
void PreviewWidget::changeEvent( QEvent *e )
......@@ -72,15 +77,18 @@ void PreviewWidget::changeEvent( QEvent *e )
void PreviewWidget::dragEnterEvent( QDragEnterEvent* event )
{
if ( event->mimeData()->hasFormat( "vlmc/uuid" ) )
event->acceptProposedAction();
else if ( event->mimeData()->urls().count() == 1 )
if ( event->mimeData()->hasFormat( "vlmc/uuid" ) ||
event->mimeData()->urls().count() == 1 )
{
event->acceptProposedAction();
}
}
void PreviewWidget::dropEvent( QDropEvent* event )
{
if ( m_currentMode == PreviewWidget::clipPreviewMode )
//If the dropped event is a clip to preview :
if ( event->mimeData()->hasFormat( "vlmc/uuid" ) ||
event->mimeData()->urls().count() == 1 )
{
Media* media;
if ( event->mimeData()->urls().count() == 1 )
......@@ -89,9 +97,12 @@ void PreviewWidget::dropEvent( QDropEvent* event )
lib->newMediaLoadingAsked( event->mimeData()->urls()[0].path() );
media = lib->getMedia( event->mimeData()->urls()[0].path() );
}
else
else //TODO: Could this rely on an implicit QString CTOR ?
media = Library::getInstance()->getMedia( QUuid( ( const QString& )event->mimeData()->data( "vlmc/uuid" ) ) );
if ( m_currentMode != PreviewWidget::clipPreviewMode )
m_ui->tabWidget->setCurrentIndex( PreviewWidget::clipPreviewMode );
connect( m_clipPreview, SIGNAL( stopped() ), this, SLOT( videoPaused() ) );
connect( m_clipPreview, SIGNAL( paused() ), this, SLOT( videoPaused() ) );
connect( m_clipPreview, SIGNAL( playing() ), this, SLOT( videoPlaying() ) );
......@@ -102,6 +113,12 @@ void PreviewWidget::dropEvent( QDropEvent* event )
event->acceptProposedAction();
m_previewStopped = false;
}
else
{
if ( m_currentMode != PreviewWidget::renderPreviewMode )
m_ui->tabWidget->setCurrentIndex( PreviewWidget::renderPreviewMode );
//launche render preview somehow
}
}
void PreviewWidget::positionChanged( float newPos )
......@@ -112,7 +129,7 @@ void PreviewWidget::positionChanged( float newPos )
void PreviewWidget::seekSliderPressed()
{
disconnect( m_clipPreview, SIGNAL( positionChanged( float ) ),
disconnect( m_currentPreviewRenderer, SIGNAL( positionChanged( float ) ),
this, SLOT( positionChanged( float ) ) );
}
......@@ -124,7 +141,7 @@ void PreviewWidget::seekSliderMoved( int )
return;
}
m_endReached = false;
m_clipPreview->setPosition( (float)m_ui->seekSlider->value() );
m_currentPreviewRenderer->setPosition( (float)m_ui->seekSlider->value() );
}
void PreviewWidget::seekSliderReleased()
......@@ -135,17 +152,18 @@ void PreviewWidget::seekSliderReleased()
//When we will release our slider, if endReached is true, we actually set the position.
//Otherwise, we do nothing.
//This prevents the video to stop if we put the slider to the maximum right by mistake
m_clipPreview->setPosition( (float)m_ui->seekSlider->maximum() );
m_currentPreviewRenderer->setPosition( (float)m_ui->seekSlider->maximum() );
m_previewStopped = false;
}
connect( m_clipPreview, SIGNAL( positionChanged( float ) ), this, SLOT( positionChanged( float ) ) );
connect( m_currentPreviewRenderer, SIGNAL( positionChanged( float ) ),
this, SLOT( positionChanged( float ) ) );
}
void PreviewWidget::on_pushButtonPlay_clicked()
{
if ( m_previewStopped == true )
m_previewStopped = false;
m_clipPreview->togglePlayPause();
m_currentPreviewRenderer->togglePlayPause();
}
void PreviewWidget::videoPaused()
......@@ -168,5 +186,11 @@ void PreviewWidget::endReached()
void PreviewWidget::changedTab( int tabId )
{
qDebug() << "CHanged mode : " << tabId;
if ( tabId == PreviewWidget::clipPreviewMode )
m_currentPreviewRenderer = m_clipPreview;
else if ( tabId == PreviewWidget::renderPreviewMode )
m_currentPreviewRenderer = m_renderPreview;
else
qDebug() << "Unknown and uncoherent tabId for PreviewWidget : " << tabId;
m_currentMode = !m_currentMode;
}
......@@ -44,14 +44,18 @@ public:
private:
Ui::PreviewWidget* m_ui;
ClipPreviewWidget* m_clipPreview;
RenderPreviewWidget* m_renderPreview;
GenericPreviewWidget* m_clipPreview;
GenericPreviewWidget* m_renderPreview;
GenericPreviewWidget* m_currentPreviewRenderer;
bool m_endReached;
bool m_previewStopped;
int m_currentMode;
static const int clipPreviewMode = 0;
static const int renderPreviewMode = 1;
static const int renderPreviewMode = 0;
static const int clipPreviewMode = 1;
private:
protected:
virtual void changeEvent( QEvent *e );
......
......@@ -20,21 +20,31 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <QtDebug>
#include "RenderPreviewWidget.h"
RenderPreviewWidget::RenderPreviewWidget( MainWorkflow* mainWorkflow, QWidget* renderWidget ) :
m_mainWorkflow( mainWorkflow )
GenericPreviewWidget( renderWidget ), m_mainWorkflow( mainWorkflow )
{
m_mediaPlayer = new LibVLCpp::MediaPlayer();
m_mediaPlayer->setDrawable( renderWidget->winId() );
}
RenderPreviewWidget::~RenderPreviewWidget()
{
delete m_mediaPlayer;
}
void RenderPreviewWidget::startPreview( Media* )
{
}
void RenderPreviewWidget::setPosition( float newPos )
{
}
void RenderPreviewWidget::togglePlayPause()
{
}
/////////////////////////////////////////////////////////////////////
/////SLOTS :
......
......@@ -23,15 +23,15 @@
#ifndef RENDERPREVIEWWIDGET_H
#define RENDERPREVIEWWIDGET_H
#include <QObject>
#include <QWidget>
#include <QtDebug>
#include "VLCMediaPlayer.h"
#include "Workflow/MainWorkflow.h"
#include "GenericPreviewWidget.h"
//TODO: This should really share a common interface with ClipPreviewWorkflow
class RenderPreviewWidget : public QObject
class RenderPreviewWidget : public GenericPreviewWidget
{
Q_OBJECT
Q_DISABLE_COPY( RenderPreviewWidget )
......@@ -40,13 +40,12 @@ class RenderPreviewWidget : public QObject
RenderPreviewWidget( MainWorkflow* mainWorkflow, QWidget* renderWidget );
~RenderPreviewWidget();
void startPreview();
void setPosition( float newPos );
void togglePlayPause();
virtual void startPreview( Media* );
virtual void setPosition( float newPos );
virtual void togglePlayPause();
private:
MainWorkflow* m_mainWorkflow;
LibVLCpp::MediaPlayer* m_mediaPlayer;
MainWorkflow* m_mainWorkflow;
public slots:
void __positionChanged();
......
......@@ -79,7 +79,8 @@ HEADERS += src/gui/MainWindow.h \
src/Workflow/TrackWorkflow.h \
src/Workflow/MainWorkflow.h \
src/gui/PreviewWidget.h \
src/gui/RenderPreviewWidget.h
src/gui/RenderPreviewWidget.h \
src/gui/GenericPreviewWidget.h
FORMS += src/gui/ui/MainWindow.ui \
src/gui/ui/PreviewWidget.ui \
src/gui/ui/Preferences.ui \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment