Commit 819cd688 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen
Browse files

Merge branch 'chouquette_split_preview_widget'

Conflicts:
	src/renderer/WorkflowRenderer.cpp
parents 3d3e51ad b32b90a5
......@@ -215,3 +215,13 @@ void LibraryWidget::dropEvent( QDropEvent* event )
lib->newMediaLoadingAsked( url.path() );
}
}
const MediaListWidget* LibraryWidget::getVideoListWidget() const
{
return m_ui.listWidgetVideo;
}
const MediaListWidget* LibraryWidget::getAudioListWidget() const
{
return m_ui.listWidgetAudio;
}
......@@ -51,6 +51,8 @@ public:
ListViewMediaItem* addMedia( const Media* clip );
void removeMedia( const QUuid& uuid );
int getIndex( ListViewMediaItem* media );
const MediaListWidget* getVideoListWidget() const;
const MediaListWidget* getAudioListWidget() const;
protected:
virtual void changeEvent( QEvent *e );
......
......@@ -35,7 +35,8 @@
#include "About.h"
#include "Transcode.h"
#include "FileBrowser.h"
#include "PreviewWidget.h"
#include "WorkflowRenderer.h"
#include "ClipRenderer.h"
MainWindow::MainWindow( QWidget *parent ) :
QMainWindow( parent ), m_renderer( NULL )
......@@ -111,6 +112,9 @@ void MainWindow::setupLibrary()
SIGNAL( mediaRemoved( const QUuid& ) ),
libraryWidget,
SLOT( mediaRemoved( const QUuid& ) ) );
connect ( libraryWidget->getVideoListWidget(), SIGNAL( selectedMediaChanged(const Media*) ),
m_clipPreview->getGenericRenderer(), SLOT( setMedia(const Media*) ) );
}
void MainWindow::createStatusBar()
......@@ -141,15 +145,20 @@ void MainWindow::m_initializeDockWidgets( void )
QDockWidget::AllDockWidgetFeatures,
Qt::TopDockWidgetArea);
setupLibrary();
dockManager->addDockedWidget( new PreviewWidget( m_timeline->getMainWorkflow(), this ),
tr( "Preview" ),
m_clipPreview = new PreviewWidget( new ClipRenderer, this );
dockManager->addDockedWidget( m_clipPreview,
tr( "Clip Preview" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures,
Qt::TopDockWidgetArea );
m_projectPreview = new PreviewWidget( new WorkflowRenderer( m_timeline->getMainWorkflow() ), this );
dockManager->addDockedWidget( m_projectPreview,
tr( "Project Preview" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures,
Qt::TopDockWidgetArea );
setupLibrary();
m_metaDataManager = MetaDataManager::getInstance();
}
......
......@@ -33,7 +33,7 @@
#include "MetaDataManager.h"
#include "Timeline.h"
#include "WorkflowFileRenderer.h"
#include "PreviewWidget.h"
class MainWindow : public QMainWindow
{
......@@ -61,6 +61,8 @@ private:
MetaDataManager* m_metaDataManager;
QSlider* m_zoomSlider;
Timeline* m_timeline;
PreviewWidget* m_clipPreview;
PreviewWidget* m_projectPreview;
WorkflowFileRenderer* m_renderer;
private slots:
......
......@@ -27,7 +27,9 @@
#include "MediaListWidget.h"
MediaListWidget::MediaListWidget( QWidget* parent ) : QListWidget( parent )
MediaListWidget::MediaListWidget( QWidget* parent ) :
QListWidget( parent ),
m_lastClicked( NULL )
{
m_svgRenderer = new QSvgRenderer( this );
setIconSize( QSize( 128, 128 ) );
......@@ -57,11 +59,20 @@ void MediaListWidget::mousePressEvent( QMouseEvent* event )
if ( event->button() == Qt::LeftButton)
this->m_dragStartPos = event->pos();
QListWidget::mousePressEvent( event );
ListViewMediaItem* item = static_cast<ListViewMediaItem*>( currentItem() );
if ( item == NULL )
return ;
if ( item->getMedia() != m_lastClicked )
{
m_lastClicked = item->getMedia();
emit selectedMediaChanged( m_lastClicked );
}
}
void MediaListWidget::mouseMoveEvent( QMouseEvent* event )
{
if ( this->currentItem() == NULL )
if ( currentItem() == NULL )
return;
if ( !( event->buttons() & Qt::LeftButton ) )
return;
......@@ -70,7 +81,6 @@ void MediaListWidget::mouseMoveEvent( QMouseEvent* event )
return;
ListViewMediaItem* item = static_cast<ListViewMediaItem*>( currentItem() );
QMimeData* mimeData = new QMimeData;
mimeData->setData( "vlmc/uuid", item->getMedia()->getUuid().toString().toAscii() );
QDrag* drag = new QDrag( this );
......
......@@ -48,6 +48,10 @@ private:
Media::FileType m_Type;
QPoint m_dragStartPos;
QSvgRenderer* m_svgRenderer;
const Media* m_lastClicked;
signals:
void selectedMediaChanged( const Media* newMedia );
};
#endif // MEDIALISTWIDGET_H
......@@ -30,12 +30,11 @@
#include "MediaListWidget.h"
#include "Library.h"
PreviewWidget::PreviewWidget( MainWorkflow* mainWorkflow, QWidget *parent ) :
PreviewWidget::PreviewWidget( GenericRenderer* genericRenderer, QWidget *parent ) :
QWidget( parent ),
m_ui( new Ui::PreviewWidget ),
m_currentPreviewRenderer( NULL ),
m_previewStopped( true ),
m_sliderPosBackup( 0 )
m_renderer( genericRenderer ),
m_previewStopped( true )
{
m_ui->setupUi( this );
......@@ -50,42 +49,17 @@ 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() ) );
initClipPreview();
initRenderPreview( mainWorkflow );
m_currentMode = m_ui->tabWidget->currentIndex();
m_currentPreviewRenderer = m_renderPreview;
connect( m_ui->tabWidget, SIGNAL( currentChanged(int) ), this, SLOT( changedTab(int) ) );
m_renderer->setRenderWidget( m_ui->renderWidget );
connect( m_renderer, SIGNAL( stopped() ), this, SLOT( videoStopped() ) );
connect( m_renderer, SIGNAL( paused() ), this, SLOT( videoPaused() ) );
connect( m_renderer, SIGNAL( playing() ), this, SLOT( videoPlaying() ) );
connect( m_renderer, SIGNAL( positionChanged(float) ), this, SLOT( positionChanged(float) ) );
connect( m_renderer, SIGNAL( endReached() ), this, SLOT( endReached() ) );
}
PreviewWidget::~PreviewWidget()
{
delete m_ui;
delete m_clipPreview;
delete m_renderPreview;
}
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( videoStopped() ) );
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 )
......@@ -100,45 +74,42 @@ void PreviewWidget::changeEvent( QEvent *e )
}
}
void PreviewWidget::dragEnterEvent( QDragEnterEvent* event )
{
if ( event->mimeData()->hasFormat( "vlmc/uuid" ) ||
event->mimeData()->urls().count() == 1 )
{
event->acceptProposedAction();
}
}
void PreviewWidget::dropEvent( QDropEvent* event )
{
//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 )
{
Library* lib = Library::getInstance();
lib->newMediaLoadingAsked( event->mimeData()->urls()[0].path() );
media = lib->getMedia( event->mimeData()->urls()[0].path() );
}
else
media = Library::getInstance()->getMedia( QUuid( QString( event->mimeData()->data( "vlmc/uuid" ) ) ) );
if ( media == NULL )
{
qDebug() << "Unknown media" << event->mimeData()->data( "vlmc/uuid" );
return ;
}
if ( m_currentMode != PreviewWidget::clipPreviewMode )
m_ui->tabWidget->setCurrentIndex( PreviewWidget::clipPreviewMode );
m_clipPreview->startPreview( media );
event->acceptProposedAction();
m_previewStopped = false;
}
//else: I don't see how we could drag and drop a workflow :o (at the moment)
}
//void PreviewWidget::dragEnterEvent( QDragEnterEvent* event )
//{
// if ( event->mimeData()->hasFormat( "vlmc/uuid" ) ||
// event->mimeData()->urls().count() == 1 )
// {
// event->acceptProposedAction();
// }
//}
//
//void PreviewWidget::dropEvent( QDropEvent* event )
//{
// //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 )
// {
// Library* lib = Library::getInstance();
// lib->newMediaLoadingAsked( event->mimeData()->urls()[0].path() );
// media = lib->getMedia( event->mimeData()->urls()[0].path() );
// }
// else
// media = Library::getInstance()->getMedia( QUuid( QString( event->mimeData()->data( "vlmc/uuid" ) ) ) );
//
// if ( media == NULL )
// {
// qDebug() << "Unknown media" << event->mimeData()->data( "vlmc/uuid" );
// return ;
// }
//
// event->acceptProposedAction();
// m_renderer->startPreview( media );
// m_previewStopped = false;
// }
//}
void PreviewWidget::positionChanged( float newPos )
{
......@@ -149,12 +120,17 @@ void PreviewWidget::positionChanged( float newPos )
void PreviewWidget::seekSliderPressed()
{
disconnect( m_currentPreviewRenderer, SIGNAL( positionChanged( float ) ),
disconnect( m_renderer, SIGNAL( positionChanged( float ) ),
this, SLOT( positionChanged( float ) ) );
}
void PreviewWidget::seekSliderMoved( int )
{
if ( m_renderer->isRendering() == false )
{
m_ui->seekSlider->setValue( 0 );
return ;
}
if ( m_ui->seekSlider->value() == m_ui->seekSlider->maximum() )
{
m_endReached = true;
......@@ -162,7 +138,7 @@ void PreviewWidget::seekSliderMoved( int )
}
m_endReached = false;
//Putting back the slider value into vlc position
m_currentPreviewRenderer->setPosition( (float)m_ui->seekSlider->value() / 1000.0f );
m_renderer->setPosition( (float)m_ui->seekSlider->value() / 1000.0f );
}
void PreviewWidget::seekSliderReleased()
......@@ -173,10 +149,10 @@ 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_currentPreviewRenderer->setPosition( (float)m_ui->seekSlider->maximum() );
m_renderer->setPosition( (float)m_ui->seekSlider->maximum() );
m_previewStopped = false;
}
connect( m_currentPreviewRenderer, SIGNAL( positionChanged( float ) ),
connect( m_renderer, SIGNAL( positionChanged( float ) ),
this, SLOT( positionChanged( float ) ) );
}
......@@ -185,7 +161,7 @@ void PreviewWidget::on_pushButtonStop_clicked()
if ( m_previewStopped == false )
{
m_previewStopped = true;
m_currentPreviewRenderer->stop();
m_renderer->stop();
}
}
......@@ -193,11 +169,7 @@ void PreviewWidget::on_pushButtonPlay_clicked()
{
if ( m_previewStopped == true )
m_previewStopped = false;
// int methodIndex = m_currentPreviewRenderer->metaObject()->indexOfMethod("togglePlayPause(bool)");
// qDebug() << methodIndex;
// QMetaMethod method = m_currentPreviewRenderer->metaObject()->method( methodIndex );
// qDebug() << method.invoke( m_currentPreviewRenderer, Qt::QueuedConnection, Q_ARG(bool, false) );
m_currentPreviewRenderer->togglePlayPause();
m_renderer->togglePlayPause();
}
void PreviewWidget::videoPaused()
......@@ -224,35 +196,19 @@ void PreviewWidget::endReached()
m_ui->seekSlider->setValue( 0 );
}
void PreviewWidget::changedTab( int tabId )
{
m_currentPreviewRenderer->togglePlayPause( true );
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;
int tmp = m_ui->seekSlider->value();
m_ui->seekSlider->setValue( m_sliderPosBackup );
m_sliderPosBackup = tmp;
}
void PreviewWidget::on_pushButtonNextFrame_clicked()
{
if ( m_previewStopped == false )
m_currentPreviewRenderer->nextFrame();
m_renderer->nextFrame();
}
void PreviewWidget::on_pushButtonPreviousFrame_clicked()
{
if ( m_previewStopped == false )
m_currentPreviewRenderer->previousFrame();
m_renderer->previousFrame();
}
const GenericRenderer* PreviewWidget::getGenericRenderer() const
{
return m_renderer;
}
......@@ -26,8 +26,7 @@
#include <QWidget>
#include "Workflow/MainWorkflow.h"
#include "ClipPreviewWidget.h"
#include "RenderPreviewWidget.h"
#include "GenericRenderer.h"
namespace Ui {
class PreviewWidget;
......@@ -39,31 +38,21 @@ class PreviewWidget : public QWidget
Q_DISABLE_COPY( PreviewWidget )
public:
explicit PreviewWidget( MainWorkflow* mainWorkflow, QWidget* parent = NULL );
explicit PreviewWidget( GenericRenderer* renderer, QWidget* parent = NULL );
virtual ~PreviewWidget();
private:
void initRenderPreview( MainWorkflow* );
void initClipPreview();
void connectPreview( GenericPreviewWidget* target );
const GenericRenderer* getGenericRenderer() const;
private:
Ui::PreviewWidget* m_ui;
GenericPreviewWidget* m_clipPreview;
GenericPreviewWidget* m_renderPreview;
GenericPreviewWidget* m_currentPreviewRenderer;
GenericRenderer* m_renderer;
bool m_endReached;
bool m_previewStopped;
int m_currentMode;
static const int renderPreviewMode = 0;
static const int clipPreviewMode = 1;
int m_sliderPosBackup;
protected:
virtual void changeEvent( QEvent *e );
virtual void dragEnterEvent( QDragEnterEvent* event );
virtual void dropEvent( QDropEvent* event );
// virtual void dragEnterEvent( QDragEnterEvent* event );
// virtual void dropEvent( QDropEvent* event );
private slots:
void on_pushButtonPlay_clicked();
void on_pushButtonStop_clicked();
......@@ -77,8 +66,6 @@ private slots:
void videoPlaying();
void videoStopped();
void endReached();
void changedTab( int );
};
#endif // PREVIEWWIDGET_H
......@@ -29,67 +29,6 @@
<string>Preview</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>320</width>
<height>240</height>
</size>
</property>
<property name="tabPosition">
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="ProjectTab">
<attribute name="title">
<string>Project</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QWidget" name="renderPreviewRenderWidget" native="true"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="ClipTab">
<attribute name="title">
<string>Clip</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QWidget" name="clipPreviewRenderWidget" native="true"/>
</item>
</layout>
</widget>
</widget>
</item>
<item row="1" column="0">
<widget class="Slider" name="seekSlider">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>320</width>
<height>23</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
......@@ -199,6 +138,35 @@
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="Slider" name="seekSlider">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>320</width>
<height>23</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QWidget" name="renderWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
......
/*****************************************************************************
* ClipPreviewWidget: Preview widget
* ClipRenderer.cpp: Render from a Clip (mainly for previewing purpose)
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Geoffroy Lacarrière <geoffroylaca@gmail.com>
* 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
......@@ -22,63 +23,82 @@
#include <QtDebug>
#include "ClipPreviewWidget.h"
#include "ClipRenderer.h"
ClipPreviewWidget::ClipPreviewWidget( QWidget* renderWidget ) :
GenericPreviewWidget( renderWidget ),
m_clipLoaded( false ), m_vlcMedia( NULL )
ClipRenderer::ClipRenderer() :
GenericRenderer(),
m_clipLoaded( false ),
m_vlcMedia( NULL ),
m_selectedMedia( NULL ),
m_mediaChanged( false )
{
connect( m_mediaPlayer, SIGNAL( stopped() ), this, SLOT( __videoStopped() ) );
connect( m_mediaPlayer, SIGNAL( paused() ), this, SLOT( __videoPaused() ) );
connect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( __videoPlaying() ) );
connect( m_mediaPlayer, SIGNAL( positionChanged() ), this, SLOT( __positionChanged() ) );
connect( m_mediaPlayer, SIGNAL( endReached() ), this, SLOT( __endReached() ) );
}
ClipPreviewWidget::~ClipPreviewWidget()
ClipRenderer::~ClipRenderer()
{
stop();
}
void ClipPreviewWidget::startPreview( Media* media )
void ClipRenderer::setMedia( const Media* media )
{
m_selectedMedia = media;
if ( m_isRendering == true )
m_mediaChanged = true;
else
m_clipLoaded = false;
}
void ClipRenderer::startPreview()
{
if ( m_selectedMedia == NULL )
return ;
//If an old media is found, we delete it, and disconnect
if ( m_vlcMedia != NULL )
delete m_vlcMedia;
m_vlcMedia = new LibVLCpp::Media( media->getFileInfo()->absoluteFilePath() );
m_vlcMedia = new LibVLCpp::Media( m_selectedMedia->getFileInfo()->absoluteFilePath() );
m_mediaPlayer->setMedia( m_vlcMedia );
connect( m_mediaPlayer, SIGNAL( stopped() ), this, SLOT( __videoStopped() ) );
connect( m_mediaPlayer, SIGNAL( paused() ), this, SLOT( __videoPaused() ) );