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 )
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,6 @@
#include "About.h"
#include "Transcode.h"
#include "FileBrowser.h"
#include "PreviewWidget.h"
#include "WorkflowRenderer.h"
#include "ClipRenderer.h"
......@@ -113,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()
......@@ -143,20 +145,20 @@ void MainWindow::m_initializeDockWidgets( void )
QDockWidget::AllDockWidgetFeatures,
Qt::TopDockWidgetArea);
setupLibrary();
dockManager->addDockedWidget( new PreviewWidget( new ClipRenderer, this ),
m_clipPreview = new PreviewWidget( new ClipRenderer, this );
dockManager->addDockedWidget( m_clipPreview,
tr( "Clip Preview" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures,
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" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures,
Qt::TopDockWidgetArea );
Qt::LeftDockWidgetArea );
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 ) );
......@@ -56,12 +58,18 @@ void MediaListWidget::mousePressEvent( QMouseEvent* event )
{
if ( event->button() == Qt::LeftButton)
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 );
}
void MediaListWidget::mouseMoveEvent( QMouseEvent* event )
{
if ( this->currentItem() == NULL )
if ( currentItem() == NULL )
return;
if ( !( event->buttons() & Qt::LeftButton ) )
return;
......@@ -70,7 +78,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
......@@ -60,7 +60,6 @@ PreviewWidget::PreviewWidget( GenericRenderer* genericRenderer, QWidget *parent
PreviewWidget::~PreviewWidget()
{
delete m_ui;
delete m_renderer;
}
void PreviewWidget::changeEvent( QEvent *e )
......@@ -208,3 +207,7 @@ void PreviewWidget::on_pushButtonPreviousFrame_clicked()
m_renderer->previousFrame();
}
const GenericRenderer* PreviewWidget::getGenericRenderer() const
{
return m_renderer;
}
......@@ -40,6 +40,7 @@ class PreviewWidget : public QWidget
public:
explicit PreviewWidget( GenericRenderer* renderer, QWidget* parent = NULL );
virtual ~PreviewWidget();
const GenericRenderer* getGenericRenderer() const;
private:
Ui::PreviewWidget* m_ui;
......@@ -51,6 +52,7 @@ protected:
virtual void changeEvent( QEvent *e );
// virtual void dragEnterEvent( QDragEnterEvent* event );
// virtual void dropEvent( QDropEvent* event );
private slots:
void on_pushButtonPlay_clicked();
void on_pushButtonStop_clicked();
......
......@@ -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 ( 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 );
......@@ -75,7 +83,7 @@ void ClipRenderer::stop()
void ClipRenderer::togglePlayPause( bool forcePause )
{
if ( m_clipLoaded == false)
return ;
startPreview();
if ( m_paused == false && m_isRendering == true )
{
......
......@@ -40,16 +40,20 @@ public:
explicit ClipRenderer();
virtual ~ClipRenderer();
virtual void startPreview( Media* media );
virtual void setMedia( const Media* media );
virtual void setPosition( float newPos );
virtual void togglePlayPause( bool forcePause );
virtual void stop();
virtual void nextFrame();
virtual void previousFrame();
private:
void startPreview();
private:
bool m_clipLoaded;
LibVLCpp::Media* m_vlcMedia;
const Media* m_selectedMedia;
public slots:
void __positionChanged();
......
......@@ -50,7 +50,6 @@ public:
{
m_mediaPlayer->setDrawable( renderWidget->winId() );
}
virtual void startPreview( Media* media ) = 0;
virtual void setPosition( float newPos ) = 0;
virtual void togglePlayPause( bool forcePause = false ) = 0;
virtual void nextFrame() = 0;
......@@ -85,6 +84,8 @@ public slots:
virtual void __videoPaused() = 0;
virtual void __videoPlaying() = 0;
virtual void __endReached() = 0;
virtual void setMedia( const Media* media ) = 0;
signals:
void stopped();
......
......@@ -96,7 +96,7 @@ void WorkflowRenderer::stopPreview()
stop();
}
void WorkflowRenderer::startPreview( Media* )
void WorkflowRenderer::startPreview()
{
char buff[128];
......@@ -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 ( m_isRendering == false && forcePause == false )
startPreview( NULL );
startPreview();
else if ( m_isRendering == true )
{
if ( m_paused == true && forcePause == false )
......
......@@ -39,7 +39,8 @@ class WorkflowRenderer : public GenericRenderer
WorkflowRenderer( MainWorkflow* mainWorkflow );
~WorkflowRenderer();
virtual void startPreview( Media* );
virtual void setMedia( const Media* ){}
void stopPreview();
/**
......@@ -57,6 +58,9 @@ class WorkflowRenderer : public GenericRenderer
static void* lock( void* datas );
static void unlock( void* datas );
private:
virtual void startPreview();
private:
MainWorkflow* m_mainWorkflow;
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