[vlmc-devel] First qml-compatible Workflow
Yikai Lu
git at videolan.org
Sun Jul 10 18:03:30 CEST 2016
vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Wed Jul 6 22:33:52 2016 +0900| [1199e755b18c17cba05aded63940a87392d3024d] | committer: Yikai Lu
First qml-compatible Workflow
> https://code.videolan.org/videolan/vlmc/commit/1199e755b18c17cba05aded63940a87392d3024d
---
src/Gui/timeline/Timeline.cpp | 4 ++++
src/Workflow/MainWorkflow.cpp | 25 ++++++++++++++++++++++++-
src/Workflow/MainWorkflow.h | 9 +++++++++
src/Workflow/TrackWorkflow.cpp | 2 +-
4 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/src/Gui/timeline/Timeline.cpp b/src/Gui/timeline/Timeline.cpp
index e7efcab..2fa174e 100644
--- a/src/Gui/timeline/Timeline.cpp
+++ b/src/Gui/timeline/Timeline.cpp
@@ -22,7 +22,10 @@
#include "Timeline.h"
+#include "Main/Core.h"
+#include "Workflow/MainWorkflow.h"
#include <QtQuick/QQuickView>
+#include <QtQml/QQmlContext>
#include <QUrl>
Timeline* Timeline::m_instance = nullptr;
@@ -35,6 +38,7 @@ Timeline::Timeline( QWidget *parent )
m_container->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
m_container->setFocusPolicy( Qt::TabFocus );
m_view->setSource( QUrl( QStringLiteral( "qrc:/QML/main.qml" ) ) );
+ m_view->rootContext()->setContextProperty( "workflow", Core::instance()->workflow() );
}
Timeline::~Timeline()
diff --git a/src/Workflow/MainWorkflow.cpp b/src/Workflow/MainWorkflow.cpp
index 010d798..41ccc6b 100644
--- a/src/Workflow/MainWorkflow.cpp
+++ b/src/Workflow/MainWorkflow.cpp
@@ -67,6 +67,7 @@ MainWorkflow::MainWorkflow( Settings* projectSettings, int trackCount ) :
MainWorkflow::~MainWorkflow()
{
+ m_clips.clear();
for ( auto track : m_tracks )
delete track;
delete m_multitrack;
@@ -160,7 +161,29 @@ MainWorkflow::createClip( const QUuid& uuid )
vlmcCritical() << "Couldn't find an acceptable parent to be added.";
return nullptr;
}
- return std::make_shared<Clip>( clip );
+ auto newClip = std::make_shared<Clip>( clip );
+ m_clips << newClip;
+ return newClip;
+}
+
+QString
+MainWorkflow::createClip( const QString& uuid )
+{
+ auto newClip = createClip( QUuid( uuid ) );
+ return newClip->uuid().toString();
+}
+
+QJsonObject
+MainWorkflow::clipInfo( const QString& uuid )
+{
+ for ( auto clip : m_clips )
+ {
+ if ( clip->uuid().toString() == uuid )
+ {
+ return QJsonObject::fromVariantHash( clip->toVariant().toHash() );
+ }
+ }
+ return QJsonObject();
}
bool
diff --git a/src/Workflow/MainWorkflow.h b/src/Workflow/MainWorkflow.h
index 7ee7c51..d638fe6 100644
--- a/src/Workflow/MainWorkflow.h
+++ b/src/Workflow/MainWorkflow.h
@@ -138,6 +138,14 @@ class MainWorkflow : public QObject
*/
std::shared_ptr<Clip> createClip( const QUuid& uuid );
+
+
+ Q_INVOKABLE
+ QString createClip( const QString& uuid );
+
+ Q_INVOKABLE
+ QJsonObject clipInfo( const QString& uuid );
+
bool startRenderToFile( const QString& outputFileName, quint32 width, quint32 height,
double fps, const QString& ar, quint32 vbitrate, quint32 abitrate,
quint32 nbChannels, quint32 sampleRate );
@@ -161,6 +169,7 @@ class MainWorkflow : public QObject
private:
QList<TrackWorkflow*> m_tracks;
+ QList<std::shared_ptr<Clip>> m_clips;
const quint32 m_trackCount;
Settings* m_settings;
diff --git a/src/Workflow/TrackWorkflow.cpp b/src/Workflow/TrackWorkflow.cpp
index fabd3fd..1492b9f 100644
--- a/src/Workflow/TrackWorkflow.cpp
+++ b/src/Workflow/TrackWorkflow.cpp
@@ -234,7 +234,7 @@ TrackWorkflow::loadFromVariant( const QVariant &variant )
for ( auto& var : variant.toMap()[ "clips" ].toList() )
{
auto m = var.toMap();
- auto c = std::shared_ptr<Clip>( Core::instance()->workflow()->createClip( m["parent"].toString() ) );
+ auto c = std::shared_ptr<Clip>( Core::instance()->workflow()->createClip( QUuid( m["parent"].toString() ) ) );
c->setBoundaries( m["begin"].toULongLong(),
m["end"].toULongLong()
);
More information about the Vlmc-devel
mailing list