Commit 934e3c8a authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Plugged play button with the render workflow

You can now play/pause the render preview
parent d3a6beaf
......@@ -49,8 +49,8 @@ PreviewWidget::PreviewWidget( MainWorkflow* mainWorkflow, QWidget *parent ) :
connect( m_ui->seekSlider, SIGNAL( sliderPosChanged(int) ), this, SLOT( seekSliderMoved(int) ) );
connect( m_ui->seekSlider, SIGNAL( sliderReleased() ), this, SLOT( seekSliderReleased() ) );
m_clipPreview = new ClipPreviewWidget( m_ui->clipPreviewRenderWidget );
m_renderPreview = new RenderPreviewWidget( mainWorkflow, m_ui->renderPreviewRenderWidget );
initClipPreview();
initRenderPreview( mainWorkflow );
m_currentMode = m_ui->tabWidget->currentIndex();
m_currentPreviewRenderer = m_renderPreview;
......@@ -64,7 +64,30 @@ PreviewWidget::~PreviewWidget()
delete m_renderPreview;
}
void PreviewWidget::changeEvent( QEvent *e )
void PreviewWidget::initClipPreview()
{
m_clipPreview = new ClipPreviewWidget( m_ui->clipPreviewRenderWidget );
connectPreview( m_clipPreview );
}
void PreviewWidget::initRenderPreview( MainWorkflow* mainWorkflow )
{
m_renderPreview = new RenderPreviewWidget( mainWorkflow, m_ui->renderPreviewRenderWidget );
connectPreview( m_renderPreview );
}
void PreviewWidget::connectPreview( GenericPreviewWidget* target )
{
//WARNING: the slots must NOT be virtual, since this is called from the constructor
// which would be unsafe... if not fatal...
connect( target, SIGNAL( stopped() ), this, SLOT( videoPaused() ) );
connect( target, SIGNAL( paused() ), this, SLOT( videoPaused() ) );
connect( target, SIGNAL( playing() ), this, SLOT( videoPlaying() ) );
connect( target, SIGNAL( positionChanged(float) ), this, SLOT( positionChanged(float) ) );
connect( target, SIGNAL( endReached() ), this, SLOT( endReached() ) );
}
void PreviewWidget::changeEvent( QEvent *e )
{
switch ( e->type() )
{
......@@ -104,12 +127,6 @@ void PreviewWidget::dropEvent( QDropEvent* event )
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() ) );
connect( m_clipPreview, SIGNAL( positionChanged(float) ), this, SLOT( positionChanged(float) ) );
connect( m_clipPreview, SIGNAL( endReached() ), this, SLOT( endReached() ) );
m_clipPreview->startPreview( media );
event->acceptProposedAction();
m_previewStopped = false;
......
......@@ -42,6 +42,11 @@ public:
explicit PreviewWidget( MainWorkflow* mainWorkflow, QWidget* parent = NULL );
virtual ~PreviewWidget();
private:
void initRenderPreview( MainWorkflow* );
void initClipPreview();
void connectPreview( GenericPreviewWidget* target );
private:
Ui::PreviewWidget* m_ui;
GenericPreviewWidget* m_clipPreview;
......@@ -53,8 +58,6 @@ private:
static const int renderPreviewMode = 0;
static const int clipPreviewMode = 1;
private:
int m_sliderPosBackup;
protected:
......
......@@ -47,6 +47,9 @@ RenderPreviewWidget::RenderPreviewWidget( MainWorkflow* mainWorkflow, QWidget* r
sprintf( buffer, ":invmem-data=%lld", (qint64)this );
m_media->addOption( buffer );
m_mediaPlayer->setMedia( m_media );
connect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( __videoPlaying() ) );
connect( m_mediaPlayer, SIGNAL( paused() ), this, SLOT( __videoPaused() ) );
}
......@@ -79,6 +82,7 @@ void RenderPreviewWidget::startPreview( Media* )
qDebug() << "Starting render preview";
m_mainWorkflow->startRender();
m_mediaPlayer->play();
m_isRendering = true;
}
void RenderPreviewWidget::setPosition( float /*newPos*/ )
......@@ -87,7 +91,16 @@ void RenderPreviewWidget::setPosition( float /*newPos*/ )
void RenderPreviewWidget::togglePlayPause( bool /*forcePause*/ )
{
startPreview( NULL );
if ( m_isRendering == false )
startPreview( NULL );
else
{
qDebug() << m_mediaPlayer->isPlaying();
if ( m_mediaPlayer->isPlaying() == false )
m_mediaPlayer->play();
else
m_mediaPlayer->pause();
}
}
/////////////////////////////////////////////////////////////////////
......@@ -106,10 +119,10 @@ void RenderPreviewWidget::__positionChanged()
void RenderPreviewWidget::__videoPaused()
{
qDebug() << "RenderPreviewWidget::__videoPaused: Unimplemented";
emit paused();
}
void RenderPreviewWidget::__videoPlaying()
{
qDebug() << "RenderPreviewWidget::__videoPlaying: Unimplemented";
emit playing();
}
......@@ -50,6 +50,7 @@ class RenderPreviewWidget : public GenericPreviewWidget
private:
MainWorkflow* m_mainWorkflow;
LibVLCpp::Media* m_media;
bool m_isRendering;
public slots:
void __positionChanged();
......
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