Commit f861c6d5 authored by luyikei's avatar luyikei

Link clips by Commands::Clip::Link

parent 83355791
......@@ -271,6 +271,42 @@ Commands::Clip::Split::internalUndo()
m_toSplit->setEnd( m_oldEnd );
}
Commands::Clip::Link::Link( std::shared_ptr<::Clip> const& clipA, std::shared_ptr<::Clip> const& clipB )
: m_clipA( clipA )
, m_clipB( clipB )
{
connect( m_clipA.get(), &::Clip::destroyed, this, &Link::invalidate );
connect( m_clipB.get(), &::Clip::destroyed, this, &Link::invalidate );
retranslate();
}
Commands::Clip::Link::~Link()
{
}
void
Commands::Clip::Link::retranslate()
{
setText( tr( "Linking clip" ) );
}
void
Commands::Clip::Link::internalRedo()
{
m_clipA->setLinkedClipUuid( m_clipB->uuid() );
m_clipB->setLinkedClipUuid( m_clipA->uuid() );
m_clipA->setLinked( true );
m_clipB->setLinked( true );
}
void
Commands::Clip::Link::internalUndo()
{
m_clipA->setLinked( false );
m_clipB->setLinked( false );
}
Commands::Effect::Add::Add( std::shared_ptr<EffectHelper> const& helper, Backend::IInput* target )
: m_helper( helper )
, m_target( target )
......
......@@ -177,6 +177,21 @@ namespace Commands
qint64 m_newClipBegin;
qint64 m_oldEnd;
};
class Link : public Generic
{
Q_OBJECT
public:
Link( std::shared_ptr<::Clip> const& clipA, std::shared_ptr<::Clip> const& clipB );
~Link();
virtual void internalRedo();
virtual void internalUndo();
virtual void retranslate();
private:
std::shared_ptr<::Clip> m_clipA;
std::shared_ptr<::Clip> m_clipB;
};
}
namespace Effect
{
......
......@@ -184,6 +184,7 @@ Item {
if ( audioClipUuid && videoClipUuid ) {
findClipItem( audioClipUuid ).linkedClip = videoClipUuid;
findClipItem( videoClipUuid ).linkedClip = audioClipUuid;
workflow.linkClips( audioClipUuid, videoClipUuid );
}
currentUuid = "";
aClipInfo = null;
......
......@@ -38,7 +38,8 @@ Clip::Clip( Media *media, qint64 begin /*= 0*/, qint64 end /*= Backend::IInput::
Workflow::Helper( uuid ),
m_media( media ),
m_input( std::move( m_media->input()->cut( begin, end ) ) ),
m_parent( media->baseClip() )
m_parent( media->baseClip() ),
m_isLinked( false )
{
m_childs = new MediaContainer( this );
m_rootClip = media->baseClip();
......@@ -186,6 +187,30 @@ Clip::setBoundaries( qint64 begin, qint64 end )
m_input->setBoundaries( begin, end );
}
void
Clip::setLinkedClipUuid( const QUuid& uuid )
{
m_linkedClipUuid = uuid;
}
const QUuid&
Clip::linkedClipUuid() const
{
return m_linkedClipUuid;
}
void
Clip::setLinked( bool isLinked )
{
m_isLinked = isLinked;
}
bool
Clip::isLinked() const
{
return m_isLinked;
}
Clip*
Clip::rootClip()
{
......@@ -267,6 +292,13 @@ Clip::toVariant() const
h.insert( "begin", begin() );
h.insert( "end", end() );
}
if ( isLinked() == true )
{
h.insert( "linkedClip", m_linkedClipUuid );
h.insert( "linked", true );
}
else
h.insert( "linked", false );
h.insert( "filters", EffectHelper::toVariant( m_input.get() ) );
return QVariant( h );
......
......@@ -108,6 +108,12 @@ class Clip : public Workflow::Helper
virtual qint64 length() const override;
virtual void setBoundaries( qint64 begin, qint64 end ) override;
void setLinkedClipUuid( const QUuid& uuid );
const QUuid& linkedClipUuid() const;
void setLinked( bool isLinked );
bool isLinked() const;
const QStringList &metaTags() const;
void setMetaTags( const QStringList &tags );
bool matchMetaTag( const QString &tag ) const;
......@@ -156,6 +162,9 @@ class Clip : public Workflow::Helper
Clip* m_parent;
QUuid m_linkedClipUuid;
bool m_isLinked;
Formats m_formats;
private slots:
......
......@@ -288,6 +288,21 @@ MainWorkflow::removeClip( const QString& uuid )
}
}
void
MainWorkflow::linkClips( const QString& uuidA, const QString& uuidB )
{
for ( auto clipA : m_clips )
if ( clipA->uuid().toString() == uuidA )
for ( auto clipB : m_clips )
if ( clipB->uuid().toString() == uuidB )
{
Commands::trigger( new Commands::Clip::Link( clipA, clipB ) );
emit clipLinked( uuidA, uuidB );
return;
}
}
bool
MainWorkflow::startRenderToFile( const QString &outputFileName, quint32 width, quint32 height,
double fps, const QString &ar, quint32 vbitrate, quint32 abitrate,
......
......@@ -157,6 +157,9 @@ class MainWorkflow : public QObject
Q_INVOKABLE
void removeClip( const QString& uuid );
Q_INVOKABLE
void linkClips( const QString& uuidA, const QString& uuidB );
bool startRenderToFile( const QString& outputFileName, quint32 width, quint32 height,
double fps, const QString& ar, quint32 vbitrate, quint32 abitrate,
quint32 nbChannels, quint32 sampleRate );
......@@ -239,6 +242,7 @@ class MainWorkflow : public QObject
void clipResized( const QString& uuid );
void clipRemoved( const QString& uuid );
void clipMoved( const QString& uuid );
void clipLinked( const QString& uuidA, const QString& uuidB );
};
#endif // MAINWORKFLOW_H
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