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

The Clip Preview widget now displays the currently selected media.

At least one crash remains, and this hasn't been tester much yet...
parent c99f5251
...@@ -215,3 +215,13 @@ void LibraryWidget::dropEvent( QDropEvent* event ) ...@@ -215,3 +215,13 @@ void LibraryWidget::dropEvent( QDropEvent* event )
lib->newMediaLoadingAsked( url.path() ); 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: ...@@ -51,6 +51,8 @@ public:
ListViewMediaItem* addMedia( const Media* clip ); ListViewMediaItem* addMedia( const Media* clip );
void removeMedia( const QUuid& uuid ); void removeMedia( const QUuid& uuid );
int getIndex( ListViewMediaItem* media ); int getIndex( ListViewMediaItem* media );
const MediaListWidget* getVideoListWidget() const;
const MediaListWidget* getAudioListWidget() const;
protected: protected:
virtual void changeEvent( QEvent *e ); virtual void changeEvent( QEvent *e );
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include "About.h" #include "About.h"
#include "Transcode.h" #include "Transcode.h"
#include "FileBrowser.h" #include "FileBrowser.h"
#include "PreviewWidget.h"
#include "WorkflowRenderer.h" #include "WorkflowRenderer.h"
#include "ClipRenderer.h" #include "ClipRenderer.h"
...@@ -113,6 +112,9 @@ void MainWindow::setupLibrary() ...@@ -113,6 +112,9 @@ void MainWindow::setupLibrary()
SIGNAL( mediaRemoved( const QUuid& ) ), SIGNAL( mediaRemoved( const QUuid& ) ),
libraryWidget, libraryWidget,
SLOT( mediaRemoved( const QUuid& ) ) ); SLOT( mediaRemoved( const QUuid& ) ) );
connect ( libraryWidget->getVideoListWidget(), SIGNAL( selectedMediaChanged(const Media*) ),
m_clipPreview->getGenericRenderer(), SLOT( setMedia(const Media*) ) );
} }
void MainWindow::createStatusBar() void MainWindow::createStatusBar()
...@@ -143,20 +145,20 @@ void MainWindow::m_initializeDockWidgets( void ) ...@@ -143,20 +145,20 @@ void MainWindow::m_initializeDockWidgets( void )
QDockWidget::AllDockWidgetFeatures, QDockWidget::AllDockWidgetFeatures,
Qt::TopDockWidgetArea); Qt::TopDockWidgetArea);
m_clipPreview = new PreviewWidget( new ClipRenderer, this );
setupLibrary(); dockManager->addDockedWidget( m_clipPreview,
dockManager->addDockedWidget( new PreviewWidget( new ClipRenderer, this ),
tr( "Clip Preview" ), tr( "Clip Preview" ),
Qt::AllDockWidgetAreas, Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures, QDockWidget::AllDockWidgetFeatures,
Qt::TopDockWidgetArea ); Qt::TopDockWidgetArea );
dockManager->addDockedWidget( new PreviewWidget( new WorkflowRenderer( m_timeline->getMainWorkflow() ), this ), m_projectPreview = new PreviewWidget( new WorkflowRenderer( m_timeline->getMainWorkflow() ), this );
dockManager->addDockedWidget( m_projectPreview,
tr( "Project Preview" ), tr( "Project Preview" ),
Qt::AllDockWidgetAreas, Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures, QDockWidget::AllDockWidgetFeatures,
Qt::TopDockWidgetArea ); Qt::LeftDockWidgetArea );
setupLibrary();
m_metaDataManager = MetaDataManager::getInstance(); m_metaDataManager = MetaDataManager::getInstance();
} }
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include "MetaDataManager.h" #include "MetaDataManager.h"
#include "Timeline.h" #include "Timeline.h"
#include "WorkflowFileRenderer.h" #include "WorkflowFileRenderer.h"
#include "PreviewWidget.h"
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
...@@ -61,6 +61,8 @@ private: ...@@ -61,6 +61,8 @@ private:
MetaDataManager* m_metaDataManager; MetaDataManager* m_metaDataManager;
QSlider* m_zoomSlider; QSlider* m_zoomSlider;
Timeline* m_timeline; Timeline* m_timeline;
PreviewWidget* m_clipPreview;
PreviewWidget* m_projectPreview;
WorkflowFileRenderer* m_renderer; WorkflowFileRenderer* m_renderer;
private slots: private slots:
......
...@@ -27,7 +27,9 @@ ...@@ -27,7 +27,9 @@
#include "MediaListWidget.h" #include "MediaListWidget.h"
MediaListWidget::MediaListWidget( QWidget* parent ) : QListWidget( parent ) MediaListWidget::MediaListWidget( QWidget* parent ) :
QListWidget( parent ),
m_lastClicked( NULL )
{ {
m_svgRenderer = new QSvgRenderer( this ); m_svgRenderer = new QSvgRenderer( this );
setIconSize( QSize( 128, 128 ) ); setIconSize( QSize( 128, 128 ) );
...@@ -56,12 +58,18 @@ void MediaListWidget::mousePressEvent( QMouseEvent* event ) ...@@ -56,12 +58,18 @@ void MediaListWidget::mousePressEvent( QMouseEvent* event )
{ {
if ( event->button() == Qt::LeftButton) if ( event->button() == Qt::LeftButton)
this->m_dragStartPos = event->pos(); this->m_dragStartPos = event->pos();
ListViewMediaItem* item = static_cast<ListViewMediaItem*>( currentItem() );
if ( item->getMedia() != m_lastClicked )
{
m_lastClicked = item->getMedia();
emit selectedMediaChanged( m_lastClicked );
}
QListWidget::mousePressEvent( event ); QListWidget::mousePressEvent( event );
} }
void MediaListWidget::mouseMoveEvent( QMouseEvent* event ) void MediaListWidget::mouseMoveEvent( QMouseEvent* event )
{ {
if ( this->currentItem() == NULL ) if ( currentItem() == NULL )
return; return;
if ( !( event->buttons() & Qt::LeftButton ) ) if ( !( event->buttons() & Qt::LeftButton ) )
return; return;
...@@ -70,7 +78,6 @@ void MediaListWidget::mouseMoveEvent( QMouseEvent* event ) ...@@ -70,7 +78,6 @@ void MediaListWidget::mouseMoveEvent( QMouseEvent* event )
return; return;
ListViewMediaItem* item = static_cast<ListViewMediaItem*>( currentItem() ); ListViewMediaItem* item = static_cast<ListViewMediaItem*>( currentItem() );
QMimeData* mimeData = new QMimeData; QMimeData* mimeData = new QMimeData;
mimeData->setData( "vlmc/uuid", item->getMedia()->getUuid().toString().toAscii() ); mimeData->setData( "vlmc/uuid", item->getMedia()->getUuid().toString().toAscii() );
QDrag* drag = new QDrag( this ); QDrag* drag = new QDrag( this );
......
...@@ -48,6 +48,10 @@ private: ...@@ -48,6 +48,10 @@ private:
Media::FileType m_Type; Media::FileType m_Type;
QPoint m_dragStartPos; QPoint m_dragStartPos;
QSvgRenderer* m_svgRenderer; QSvgRenderer* m_svgRenderer;
const Media* m_lastClicked;
signals:
void selectedMediaChanged( const Media* newMedia );
}; };
#endif // MEDIALISTWIDGET_H #endif // MEDIALISTWIDGET_H
...@@ -60,7 +60,6 @@ PreviewWidget::PreviewWidget( GenericRenderer* genericRenderer, QWidget *parent ...@@ -60,7 +60,6 @@ PreviewWidget::PreviewWidget( GenericRenderer* genericRenderer, QWidget *parent
PreviewWidget::~PreviewWidget() PreviewWidget::~PreviewWidget()
{ {
delete m_ui; delete m_ui;
delete m_renderer;
} }
void PreviewWidget::changeEvent( QEvent *e ) void PreviewWidget::changeEvent( QEvent *e )
...@@ -208,3 +207,7 @@ void PreviewWidget::on_pushButtonPreviousFrame_clicked() ...@@ -208,3 +207,7 @@ void PreviewWidget::on_pushButtonPreviousFrame_clicked()
m_renderer->previousFrame(); m_renderer->previousFrame();
} }
const GenericRenderer* PreviewWidget::getGenericRenderer() const
{
return m_renderer;
}
...@@ -40,6 +40,7 @@ class PreviewWidget : public QWidget ...@@ -40,6 +40,7 @@ class PreviewWidget : public QWidget
public: public:
explicit PreviewWidget( GenericRenderer* renderer, QWidget* parent = NULL ); explicit PreviewWidget( GenericRenderer* renderer, QWidget* parent = NULL );
virtual ~PreviewWidget(); virtual ~PreviewWidget();
const GenericRenderer* getGenericRenderer() const;
private: private:
Ui::PreviewWidget* m_ui; Ui::PreviewWidget* m_ui;
...@@ -51,6 +52,7 @@ protected: ...@@ -51,6 +52,7 @@ protected:
virtual void changeEvent( QEvent *e ); virtual void changeEvent( QEvent *e );
// virtual void dragEnterEvent( QDragEnterEvent* event ); // virtual void dragEnterEvent( QDragEnterEvent* event );
// virtual void dropEvent( QDropEvent* event ); // virtual void dropEvent( QDropEvent* event );
private slots: private slots:
void on_pushButtonPlay_clicked(); void on_pushButtonPlay_clicked();
void on_pushButtonStop_clicked(); void on_pushButtonStop_clicked();
......
...@@ -40,12 +40,20 @@ ClipRenderer::~ClipRenderer() ...@@ -40,12 +40,20 @@ ClipRenderer::~ClipRenderer()
{ {
} }
void ClipRenderer::startPreview( Media* media ) void ClipRenderer::setMedia( const Media* media )
{ {
qDebug() << "selected new media";
m_selectedMedia = media;
}
void ClipRenderer::startPreview()
{
if ( m_selectedMedia == NULL )
return ;
//If an old media is found, we delete it, and disconnect //If an old media is found, we delete it, and disconnect
if ( m_vlcMedia != NULL ) if ( m_vlcMedia != NULL )
delete m_vlcMedia; 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 ); m_mediaPlayer->setMedia( m_vlcMedia );
...@@ -75,7 +83,7 @@ void ClipRenderer::stop() ...@@ -75,7 +83,7 @@ void ClipRenderer::stop()
void ClipRenderer::togglePlayPause( bool forcePause ) void ClipRenderer::togglePlayPause( bool forcePause )
{ {
if ( m_clipLoaded == false) if ( m_clipLoaded == false)
return ; startPreview();
if ( m_paused == false && m_isRendering == true ) if ( m_paused == false && m_isRendering == true )
{ {
......
...@@ -40,16 +40,20 @@ public: ...@@ -40,16 +40,20 @@ public:
explicit ClipRenderer(); explicit ClipRenderer();
virtual ~ClipRenderer(); virtual ~ClipRenderer();
virtual void startPreview( Media* media ); virtual void setMedia( const Media* media );
virtual void setPosition( float newPos ); virtual void setPosition( float newPos );
virtual void togglePlayPause( bool forcePause ); virtual void togglePlayPause( bool forcePause );
virtual void stop(); virtual void stop();
virtual void nextFrame(); virtual void nextFrame();
virtual void previousFrame(); virtual void previousFrame();
private:
void startPreview();
private: private:
bool m_clipLoaded; bool m_clipLoaded;
LibVLCpp::Media* m_vlcMedia; LibVLCpp::Media* m_vlcMedia;
const Media* m_selectedMedia;
public slots: public slots:
void __positionChanged(); void __positionChanged();
......
...@@ -50,7 +50,6 @@ public: ...@@ -50,7 +50,6 @@ public:
{ {
m_mediaPlayer->setDrawable( renderWidget->winId() ); m_mediaPlayer->setDrawable( renderWidget->winId() );
} }
virtual void startPreview( Media* media ) = 0;
virtual void setPosition( float newPos ) = 0; virtual void setPosition( float newPos ) = 0;
virtual void togglePlayPause( bool forcePause = false ) = 0; virtual void togglePlayPause( bool forcePause = false ) = 0;
virtual void nextFrame() = 0; virtual void nextFrame() = 0;
...@@ -85,6 +84,8 @@ public slots: ...@@ -85,6 +84,8 @@ public slots:
virtual void __videoPaused() = 0; virtual void __videoPaused() = 0;
virtual void __videoPlaying() = 0; virtual void __videoPlaying() = 0;
virtual void __endReached() = 0; virtual void __endReached() = 0;
virtual void setMedia( const Media* media ) = 0;
signals: signals:
void stopped(); void stopped();
......
...@@ -96,7 +96,7 @@ void WorkflowRenderer::stopPreview() ...@@ -96,7 +96,7 @@ void WorkflowRenderer::stopPreview()
stop(); stop();
} }
void WorkflowRenderer::startPreview( Media* ) void WorkflowRenderer::startPreview()
{ {
char buff[128]; char buff[128];
...@@ -142,7 +142,7 @@ void WorkflowRenderer::togglePlayPause( bool forcePause ) ...@@ -142,7 +142,7 @@ void WorkflowRenderer::togglePlayPause( bool forcePause )
{ {
//If force pause is true, we just ensure that this render is paused... no need to start it. //If force pause is true, we just ensure that this render is paused... no need to start it.
if ( m_isRendering == false && forcePause == false ) if ( m_isRendering == false && forcePause == false )
startPreview( NULL ); startPreview();
else if ( m_isRendering == true ) else if ( m_isRendering == true )
{ {
if ( m_paused == true && forcePause == false ) if ( m_paused == true && forcePause == false )
......
...@@ -39,7 +39,8 @@ class WorkflowRenderer : public GenericRenderer ...@@ -39,7 +39,8 @@ class WorkflowRenderer : public GenericRenderer
WorkflowRenderer( MainWorkflow* mainWorkflow ); WorkflowRenderer( MainWorkflow* mainWorkflow );
~WorkflowRenderer(); ~WorkflowRenderer();
virtual void startPreview( Media* ); virtual void setMedia( const Media* ){}
void stopPreview(); void stopPreview();
/** /**
...@@ -57,6 +58,9 @@ class WorkflowRenderer : public GenericRenderer ...@@ -57,6 +58,9 @@ class WorkflowRenderer : public GenericRenderer
static void* lock( void* datas ); static void* lock( void* datas );
static void unlock( void* datas ); static void unlock( void* datas );
private:
virtual void startPreview();
private: private:
MainWorkflow* m_mainWorkflow; MainWorkflow* m_mainWorkflow;
LibVLCpp::Media* m_media; LibVLCpp::Media* m_media;
......
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