Commit 011e16b2 authored by luyikei's avatar luyikei

MediaLibraryView: Set a clip to play ClipPreview when pressed

parent a1a1aa3d
......@@ -531,6 +531,11 @@ MainWindow::setupClipPreview()
{
renderer->setClip( Core::instance()->library()->clip( uuid ).data() );
} );
connect( m_mediaLibrary, &MediaLibraryView::baseClipSelected, renderer, [renderer]( const QString& uuid )
{
renderer->setClip( Core::instance()->library()->clip( uuid ).data() );
} );
KeyboardShortcutHelper* clipShortcut = new KeyboardShortcutHelper( "keyboard/mediapreview", this );
connect( clipShortcut, SIGNAL( activated() ), m_clipPreview, SLOT( on_pushButtonPlay_clicked() ) );
......
......@@ -76,11 +76,6 @@ MediaLibraryView::startDrag( qint64 mediaId )
QMimeData* mimeData = new QMimeData;
QSharedPointer<Media> media = Core::instance()->library()->media( mediaId );
if ( media == nullptr ) {
media.reset( new Media( Core::instance()->library()->model( Library::MediaType::Video )->findMedia( mediaId ) ) );
Core::instance()->library()->addMedia( media );
}
mimeData->setData( QStringLiteral( "vlmc/uuid" ), media->baseClip()->uuid().toByteArray() );
drag->setMimeData( mimeData );
......@@ -89,3 +84,17 @@ MediaLibraryView::startDrag( qint64 mediaId )
thumbnailPath ).scaled( 100, 100, Qt::KeepAspectRatio ) );
drag->exec();
}
void
MediaLibraryView::onMediaSelected( qint64 mediaId )
{
QSharedPointer<Media> media = Core::instance()->library()->media( mediaId );
if ( media == nullptr ) {
media.reset( new Media( Core::instance()->library()->model( Library::MediaType::Video )->findMedia( mediaId ) ) );
Core::instance()->library()->addMedia( media );
}
emit baseClipSelected( media->baseClip()->uuid().toString() );
startDrag( mediaId );
}
......@@ -38,9 +38,13 @@ class MediaLibraryView : public QObject
public slots:
void startDrag( qint64 mediaId );
void onMediaSelected( qint64 mediaId );
private:
QWidget* m_container;
signals:
void baseClipSelected( const QString& uuid );
};
#endif // MEDIALIBRARYVIEW_H
......@@ -58,7 +58,7 @@ Rectangle {
anchors.fill: parent
onPressed: {
gridView.currentIndex = index;
view.startDrag( mediaId );
view.onMediaSelected( mediaId );
}
}
}
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