Commit 1199e755 authored by luyikei's avatar luyikei

First qml-compatible Workflow

parent d11d4df8
......@@ -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()
......
......@@ -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
......
......@@ -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;
......
......@@ -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()
);
......
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