Commit 2ad2f026 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Preview widget now uses the Clip uuid.

The library is now a singleton, and can be asked for any loaded media by its
uuid.
parent 390c0fc3
......@@ -25,6 +25,8 @@
#include "LibraryWidget.h"
QList<ListViewMediaItem*>* LibraryWidget::m_medias = NULL;
//TODO: please remove me :'(
LibraryWidget* LibraryWidget::m_instance = NULL;
LibraryWidget::LibraryWidget( QWidget *parent ) : QWidget( parent )
{
......
......@@ -41,20 +41,29 @@
#include "Clip.h"
#include "Singleton.hpp"
class LibraryWidget : public QWidget, public Singleton<LibraryWidget>
class LibraryWidget : public QWidget//, public Singleton<LibraryWidget>
{
Q_OBJECT
public:
explicit LibraryWidget( QWidget *parent = 0 );
virtual ~LibraryWidget();
ListViewMediaItem* addMedia( QFileInfo* fileInfo, ListViewMediaItem::fType fileType );
bool removeMedia( ListViewMediaItem* item );
int getIndex( ListViewMediaItem* media );
Clip* getClip( const QUuid& uuid );
//Temporary !!!
static LibraryWidget* getInstance( QWidget* parent = NULL )
{
if ( m_instance == NULL )
m_instance = new LibraryWidget( parent );
return m_instance;
}
protected:
explicit LibraryWidget( QWidget *parent = 0 );
virtual ~LibraryWidget();
virtual void changeEvent( QEvent *e );
private:
ListViewMediaItem* insertNewMedia( QString filename, ListViewMediaItem::fType fileType );
void insertNewMediasFromFileDialog( QString title, QString filter, ListViewMediaItem::fType fileType );
......@@ -63,14 +72,16 @@ private:
static QList<ListViewMediaItem*>* m_medias;
QHash<QUuid, Clip*> m_mediaHash;
//TODO: remove the singleton from this class...
static LibraryWidget* m_instance;
//friend class Singleton<LibraryWidget>;
private slots:
void on_pushButtonAddMedia_clicked();
void on_pushButtonRemoveMedia_clicked();
signals:
void listViewMediaAdded(ListViewMediaItem* item);
friend class Singleton<LibraryWidget>;
};
#endif /* !LIBRARYWIDGET_H */
......@@ -35,7 +35,7 @@ ListViewMediaItem::ListViewMediaItem( QFileInfo* fInfo, ListViewMediaItem::fType
m_renderWidget = new QWidget();
//TODO: create the actual clip.
m_clip = new Clip( "file://" + fInfo->absoluteFilePath() );
}
ListViewMediaItem::~ListViewMediaItem()
......
......@@ -70,7 +70,7 @@ void MainWindow::m_initializeDockWidgets( void )
DockWidgetManager *dockManager = DockWidgetManager::instance();
LibraryWidget* libraryWidget = new LibraryWidget( this );
LibraryWidget* libraryWidget = LibraryWidget::getInstance( this );
dockManager->addDockedWidget( libraryWidget,
tr( "Media Library" ),
Qt::AllDockWidgetAreas,
......
......@@ -59,6 +59,7 @@ private slots:
signals:
void translateDockWidgetTitle();
};
#endif // MAINWINDOW_H
......@@ -65,7 +65,7 @@ void MediaListWidget::mouseMoveEvent( QMouseEvent* event )
return;
QMimeData* mimeData = new QMimeData;
mimeData->setText( ( ( ListViewMediaItem* )( currentItem() ) )->fileInfo()->absoluteFilePath() );
mimeData->setText( static_cast<ListViewMediaItem*>( currentItem() )->getClip()->getUuid() );
QDrag* drag = new QDrag( this );
drag->setMimeData( mimeData );
//TODO: get the snapshot.
......
......@@ -20,9 +20,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <QtDebug>
#include "PreviewWidget.h"
#include "ui_PreviewWidget.h"
#include "MediaListWidget.h"
#include "LibraryWidget.h"
PreviewWidget::PreviewWidget( QWidget *parent ) :
QDialog( parent ),
......@@ -35,7 +38,7 @@ PreviewWidget::PreviewWidget( QWidget *parent ) :
m_ui->seekSlider->setSingleStep( 2 );
m_ui->seekSlider->setFocusPolicy( Qt::NoFocus );
// setAcceptDrops(true);
setAcceptDrops(true);
m_currentInstance = LibVLCpp::Instance::getInstance();
......@@ -69,30 +72,32 @@ void PreviewWidget::dragEnterEvent( QDragEnterEvent* event )
void PreviewWidget::dropEvent( QDropEvent* event )
{
QListWidget* listWidget = reinterpret_cast<QListWidget*>( event->source() );
ListViewMediaItem* item = dynamic_cast<ListViewMediaItem*>( listWidget->currentItem() );
if ( item == NULL )
return ;
Clip* clip = LibraryWidget::getInstance()->getClip( event->mimeData()->text() );
m_mediaPlayer->setMedia( clip->getVLCMedia() );
clip->setupMedia();
m_mediaPlayer->setDrawable( m_ui->clipRenderWidget->winId() );
//FIXME Connecting endReached to pause to change icon of playpause button
// this might not work as it works now later!
// connect( m_currentMedia->mediaPlayer(),
// SIGNAL( endReached() ),
// this,
// SLOT ( videoPaused() ) );
// connect( m_currentMedia->mediaPlayer(),
// SIGNAL( stopped() ),
// this,
// SLOT ( videoPaused() ) );
// connect( m_currentMedia->mediaPlayer(),
// SIGNAL( playing() ),
// this,
// SLOT ( videoPlaying() ) );
// m_currentMedia->play();
// connect( m_currentMedia->mediaPlayer(),
// SIGNAL( positionChanged() ),
// this,
// SLOT( positionChanged() ) );
connect( m_mediaPlayer,
SIGNAL( endReached() ),
this,
SLOT ( videoPaused() ) );
connect( m_mediaPlayer,
SIGNAL( stopped() ),
this,
SLOT ( videoPaused() ) );
connect( m_mediaPlayer,
SIGNAL( playing() ),
this,
SLOT ( videoPlaying() ) );
connect( m_mediaPlayer,
SIGNAL( positionChanged() ),
this,
SLOT( positionChanged() ) );
m_mediaPlayer->play();
}
void PreviewWidget::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