...
 
Commits (1)
......@@ -124,6 +124,7 @@ nodist_vlmc_SOURCES = \
src/Library/Library.moc.cpp \
src/Library/MediaLibraryModel.moc.cpp \
src/Gui/library/MediaLibraryView.moc.cpp \
src/Gui/library/ClipLibraryView.moc.cpp \
$(NULL)
vlmc_RC = \
......@@ -184,6 +185,7 @@ vlmc_SOURCES += \
src/Gui/export/ShareOnInternet.cpp \
src/Gui/import/TagWidget.cpp \
src/Gui/library/MediaLibraryView.cpp \
src/Gui/library/ClipLibraryView.cpp \
src/Gui/media/ClipMetadataDisplayer.cpp \
src/Gui/preview/LCDTimecode.cpp \
src/Gui/preview/PreviewRuler.cpp \
......@@ -248,6 +250,7 @@ vlmc_SOURCES += \
src/Gui/About.h \
src/Gui/LanguageHelper.h \
src/Gui/library/MediaLibraryView.h \
src/Gui/library/ClipLibraryView.h \
src/Gui/library/ViewController.h \
src/Gui/media/ClipMetadataDisplayer.h \
src/Gui/preview/RenderWidget.h \
......@@ -383,7 +386,9 @@ vlmc_QML = \
src/Gui/timeline/ClipContextMenu.qml \
src/Gui/timeline/Cursor.qml \
src/Gui/library/ui/MediaLibraryView.qml \
src/Gui/library/ui/ClipLibraryView.qml \
src/Gui/library/ui/MediaItem.qml \
src/Gui/library/ui/ClipItem.qml \
src/Gui/effectsengine/Effect.qml \
src/Gui/effectsengine/EffectsListView.qml \
$(NULL)
......
......@@ -138,12 +138,6 @@ MainWindow::MainWindow( Backend::IBackend* backend, QWidget *parent )
m_ui.statusbar->showMessage( "Analyzing media" );
}, Qt::QueuedConnection );
//Connecting Library stuff:
const ClipRenderer* clipRenderer = qobject_cast<const ClipRenderer*>( m_clipPreview->getAbstractRenderer() );
Q_ASSERT( clipRenderer != nullptr );
connect( m_mediaLibrary, SIGNAL( clipSelected( Clip* ) ),
clipRenderer, SLOT( setClip( Clip* ) ) );
#ifdef WITH_CRASHHANDLER
if ( restoreSession() == true )
return ;
......@@ -511,12 +505,15 @@ MainWindow::setupEffectsList()
m_effectsList = new EffectsListView;
m_dockedEffectsList = dockWidget( m_effectsList->container(), Qt::TopDockWidgetArea );
}
#include <Gui/library/ClipLibraryView.h>
void
MainWindow::setupLibrary()
{
m_mediaLibrary = new MediaLibraryView( this );
m_clipLibrary = new ClipLibraryView( this );
m_dockedLibrary = dockWidget( m_mediaLibrary->container(), Qt::TopDockWidgetArea );
auto dockedClipLibrary = dockWidget( m_clipLibrary->container(), Qt::TopDockWidgetArea );
tabifyDockWidget( m_dockedLibrary, dockedClipLibrary );
}
void
......@@ -528,6 +525,10 @@ MainWindow::setupClipPreview()
m_clipPreview->setRenderer( renderer );
connect( Core::instance()->library(), SIGNAL( clipRemoved( const QUuid& ) ),
renderer, SLOT( clipUnloaded( const QUuid& ) ) );
connect( m_clipLibrary, &ClipLibraryView::clipSelected, 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() ) );
......
......@@ -37,6 +37,7 @@ class QProgressBar;
#include "ui/MainWindow.h"
class EffectsListView;
class ClipLibraryView;
class MediaLibraryView;
class PreviewWidget;
class Project;
......@@ -128,7 +129,8 @@ private:
SettingsDialog* m_DefaultProjectPreferences;
SettingsDialog* m_projectPreferences;
ProjectWizard* m_wizard;
MediaLibraryView *m_mediaLibrary;
MediaLibraryView* m_mediaLibrary;
ClipLibraryView* m_clipLibrary;
EffectsListView* m_effectsList;
QUndoView* m_undoView;
QDockWidget* m_dockedUndoView;
......
#include "ClipLibraryView.h"
#include "Library/Library.h"
#include "Main/Core.h"
#include "Media/Clip.h"
#include "Media/Media.h"
#include "Tools/VlmcDebug.h"
#include <QUuid>
#include <QDrag>
#include <QMimeData>
#include <QtQuick/QQuickView>
#include <QtQml/QQmlContext>
ClipLibraryView::ClipLibraryView( QWidget* parent )
: QObject( parent )
{
setObjectName( QStringLiteral( "Clip Library" ) );
auto view = new QQuickView;
m_container = QWidget::createWindowContainer( view, parent );
m_container->setMinimumSize( 100, 1 );
m_container->setObjectName( objectName() );
view->rootContext()->setContextProperty( QStringLiteral( "view" ), this );
view->setSource( QUrl( QStringLiteral( "qrc:/QML/ClipLibraryView.qml" ) ) );
view->setResizeMode( QQuickView::SizeRootObjectToView );
connect( Core::instance()->library(), &Library::clipAdded, this, &ClipLibraryView::clipAdded );
connect( Core::instance()->library(), &Library::clipRemoved, this, &ClipLibraryView::clipRemoved );
}
QWidget*
ClipLibraryView::container()
{
return m_container;
}
QJsonObject
ClipLibraryView::clip( const QString& uuid )
{
auto clip = Core::instance()->library()->clip( uuid );
return QJsonObject{
{ "uuid", uuid },
{ "title", clip->media()->title() },
{ "thumbnailPath", clip->media()->snapshot() },
{ "duration", clip->length() },
};
}
void
ClipLibraryView::onClipSelected( const QString& uuid )
{
emit clipSelected( uuid );
}
void
ClipLibraryView::startDrag( const QString& uuid )
{
auto clip = Core::instance()->library()->clip( uuid );
if ( !clip )
{
vlmcCritical() << "Couldn't find a clip " << uuid;
return;
}
QDrag* drag = new QDrag( this );
QMimeData* mimeData = new QMimeData;
mimeData->setData( QStringLiteral( "vlmc/uuid" ), clip->uuid().toByteArray() );
drag->setMimeData( mimeData );
auto thumbnailPath = clip->media()->snapshot();
drag->setPixmap( QPixmap( thumbnailPath.isEmpty() ? QStringLiteral( ":/images/vlmc" ) :
thumbnailPath ).scaled( 100, 100, Qt::KeepAspectRatio ) );
drag->exec();
}
#ifndef CLIPLIBRARYVIEW_H
#define CLIPLIBRARYVIEW_H
#include <QWidget>
#include <QJsonObject>
class ClipLibraryView : public QObject
{
Q_OBJECT
Q_DISABLE_COPY( ClipLibraryView )
public:
explicit ClipLibraryView( QWidget* parent = 0 );
QWidget* container();
Q_INVOKABLE
QJsonObject clip( const QString& uuid );
public slots:
void onClipSelected( const QString& uuid );
void startDrag( const QString& uuid );
private:
QWidget* m_container;
signals:
void clipAdded( const QString& uuid );
void clipRemoved( const QString& uuid );
void clipSelected( const QString& uuid );
};
#endif // CLIPLIBRARYVIEW_H
import QtQuick 2.0
import QtQuick.Controls 1.4
Rectangle {
id: clipItem
color: ListView.isCurrentItem ? "black" : "#333333"
property string uuid
property string thumbnailPath
property string title
property int duration
function toDuration( seconds ) {
if ( seconds <= 0 )
return "00:00:00";
var hours = Math.floor(seconds / 3600);
seconds = seconds % 3600;
var minutes = Math.floor( seconds / 60 );
seconds = Math.floor( seconds % 60 );
if (hours < 10) {hours = "0" + hours;}
if (minutes < 10) {minutes = "0" + minutes;}
if (seconds < 10) {seconds = "0" + seconds;}
return hours + ':' + minutes + ':' + seconds;
}
Row {
Image {
id: thumbnail
height: clipItem.height
anchors.left: parent.parent.left
source: thumbnailPath.length > 0 ? "file://" + thumbnailPath : "qrc:///images/vlmc"
fillMode: Image.PreserveAspectFit
}
Column {
anchors.left: thumbnail
Text {
id: titleText
width: clipItem.width - thumbnail.width - 10
font.pointSize: 8
maximumLineCount: 2
color: "#EEEEEE"
text: title
elide: Text.ElideRight
wrapMode: Text.Wrap
}
Text {
id: durationText
width: clipItem.width - thumbnail.width - 10
font.pointSize: 8
maximumLineCount: 1
color: "#EEEEEE"
text: "Duration: " + toDuration( duration )
elide: Text.ElideRight
wrapMode: Text.Wrap
}
}
}
MouseArea {
anchors.fill: parent
onClicked: {
clipListView.currentIndex = index;
view.onClipSelected( uuid );
}
onPressed: {
view.startDrag( uuid );
}
}
}
import QtQuick 2.0
import QtQuick.Controls 1.4
Rectangle {
anchors.fill: parent
color: "#999999"
ListModel {
id: clips
}
ScrollView {
id: sView
height: parent.height
width: parent.width
ListView {
id: clipListView
width: sView.viewport.width
model: clips
focus: true
delegate: ClipItem {
uuid: model.uuid
duration: model.duration
thumbnailPath: model.thumbnailPath
title: model.title
height: 50
width: parent.width
}
}
}
Connections {
target: view
onClipAdded: {
clips.append( view.clip( uuid ) );
}
onClipRemoved: {
for ( var i = 0; i < clips.count; ++i ) {
if ( clips[i].uuid === uuid ) {
clips.remove( i );
break;
}
}
}
}
}
......@@ -105,14 +105,17 @@ Library::addMedia( QSharedPointer<Media> media )
return;
m_media[media->id()] = media;
m_clips[media->baseClip()->uuid()] = media->baseClip();
emit clipAdded( media->baseClip()->uuid().toString() );
vlmcDebug() << "Clip " << media->baseClip()->uuid().toString() << " is added to Library";
connect( media.data(), &Media::subclipAdded, [this]( QSharedPointer<Clip> c ) {
m_clips[c->uuid()] = c;
emit clipAdded( c->uuid().toString() );
vlmcDebug() << "Clip " << c->uuid().toString() << " is added to Library";
setCleanState( false );
});
connect( media.data(), &Media::subclipRemoved, [this]( const QUuid& uuid ) {
m_clips.remove( uuid );
emit clipRemoved( uuid.toString() );
vlmcDebug() << "Clip " << uuid.toString() << " is removed in Library";
// This seems wrong, for instance if we undo a clip splitting
setCleanState( false );
......@@ -157,6 +160,12 @@ Library::clip( const QUuid& uuid )
}
const QHash<QUuid, QSharedPointer<Clip>>
Library::clips() const
{
return m_clips;
}
void
Library::clear()
{
......
......@@ -78,6 +78,13 @@ public:
* This can be any clip, the given UUID doesn't have to refer to a root clip
*/
QSharedPointer<Clip> clip( const QUuid& uuid );
/**
* @brief clips returns all the clips loaded in the library, without any
* subclip hierarchy
*/
const QHash<QUuid, QSharedPointer<Clip>> clips() const;
void clear();
private:
......@@ -130,6 +137,9 @@ signals:
void discoveryProgress( QString );
void discoveryCompleted( QString );
void clipAdded( const QString& uuid );
void clipRemoved( const QString& uuid );
};
#endif // LIBRARY_H