Commit 753a0c3e authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen
Browse files

Added Pixmap for video dragging.

parent b6584e64
......@@ -36,7 +36,7 @@ public:
};
OutputMedia( LibVLCpp::Instance* instance );
virtual ~OutputMedia();
//FIXME: destructor ?
static uchar* lock( OutputMedia::DataCtx* dataCtx );
static void unlock( OutputMedia::DataCtx* dataCtx );
......
......@@ -63,11 +63,16 @@ void ListViewMediaItem::setSnapshot()
void ListViewMediaItem::takeSnapshot()
{
// TODO: Debug of the multiple snapshot
// TODO: Check for memory leak in the snapshot
// qDebug() << "take Snapshot";
QPixmap* snapshot = m_currentMedia->takeSnapshot( 32, 32 );
setIcon( QIcon( *snapshot ) );
m_currentMediaSnapshot = m_currentMedia->takeSnapshot( 32, 32 );
setIcon( QIcon( *m_currentMediaSnapshot ) );
m_currentMedia->stop();
disconnect( m_currentMedia->mediaPlayer(), SIGNAL( playing() ), this, SLOT( setSnapshot() ) );
disconnect( m_currentMedia->mediaPlayer(), SIGNAL( timeChanged() ), this, SLOT( takeSnapshot() ) );
}
const QPixmap* ListViewMediaItem::getSnapshot() const
{
return m_currentMediaSnapshot;
}
......@@ -76,6 +76,12 @@ public:
*/
ListViewMediaItem::fType fileType() { return m_fileType; }
/**
* \brief Get the current media snapshot
* \return the current media snapshot as a QPixmap*, or NULL if there is no current media.
*/
const QPixmap* getSnapshot() const;
private:
/**
* \brief fileInfo member
......@@ -93,10 +99,16 @@ private:
InputMedia* m_currentMedia;
/**
* \Instance of the temporary QWidget use for the snapshot
* \brief Instance of the temporary QWidget use for the snapshot
*/
QWidget* m_renderWidget;
/**
* \brief The current media snapshot
*/
//FIXME: this should probably be in the media itself
QPixmap* m_currentMediaSnapshot;
private slots:
void setSnapshot();
void takeSnapshot();
......
......@@ -68,6 +68,12 @@ void MediaListWidget::mouseMoveEvent( QMouseEvent* event )
mimeData->setText( ( ( ListViewMediaItem* )( currentItem() ) )->fileInfo()->absoluteFilePath() );
QDrag* drag = new QDrag( this );
drag->setMimeData( mimeData );
const QPixmap* dragPixmap = static_cast<ListViewMediaItem*>( currentItem() )->getSnapshot();
if ( dragPixmap != NULL )
{
//TODO: creating a new pixmap maybe a little too much for this...
drag->setPixmap( dragPixmap->scaled( 100, 100, Qt::KeepAspectRatio ) );
}
drag->exec( Qt::CopyAction | Qt::MoveAction, Qt::CopyAction );
}
......
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