[vlmc-devel] Link clips by Commands::Clip::Link

Hugo Beauzée-Luyssen hugo at beauzee.fr
Fri Jul 29 15:27:24 CEST 2016


On 07/23/2016 12:06 PM, Yikai Lu wrote:
> vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Sat Jul 23 18:42:08 2016 +0900| [f861c6d56e22dcf2b0607dd96954f12c916ffc28] | committer: Yikai Lu
>
> Link clips by Commands::Clip::Link
>
>> https://code.videolan.org/videolan/vlmc/commit/f861c6d56e22dcf2b0607dd96954f12c916ffc28
> ---
>
>  src/Commands/Commands.cpp     | 36 ++++++++++++++++++++++++++++++++++++
>  src/Commands/Commands.h       | 15 +++++++++++++++
>  src/Gui/timeline/Track.qml    |  1 +
>  src/Media/Clip.cpp            | 34 +++++++++++++++++++++++++++++++++-
>  src/Media/Clip.h              |  9 +++++++++
>  src/Workflow/MainWorkflow.cpp | 15 +++++++++++++++
>  src/Workflow/MainWorkflow.h   |  4 ++++
>  7 files changed, 113 insertions(+), 1 deletion(-)
>
> diff --git a/src/Commands/Commands.cpp b/src/Commands/Commands.cpp
> index 5ca1302..1e78c5c 100644
> --- a/src/Commands/Commands.cpp
> +++ b/src/Commands/Commands.cpp
> @@ -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()
> +{
> +
> +}

Empty destructors instead of ommited/defaulted constructors makes me a 
sad panda :(

> +
> +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 )
> diff --git a/src/Commands/Commands.h b/src/Commands/Commands.h
> index 2387945..97bf65e 100644
> --- a/src/Commands/Commands.h
> +++ b/src/Commands/Commands.h
> @@ -177,6 +177,21 @@ namespace Commands
>                  qint64                      m_newClipBegin;
>                  qint64                      m_oldEnd;
>          };
> +
> +        class   Link : public Generic
> +        {
> +            Q_OBJECT

No need for Q_OBJECT here unless I'm missing something

> +
> +            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
>      {
> diff --git a/src/Gui/timeline/Track.qml b/src/Gui/timeline/Track.qml
> index 2ef9010..7489b27 100644
> --- a/src/Gui/timeline/Track.qml
> +++ b/src/Gui/timeline/Track.qml
> @@ -184,6 +184,7 @@ Item {
>                          if ( audioClipUuid && videoClipUuid ) {
>                              findClipItem( audioClipUuid ).linkedClip = videoClipUuid;
>                              findClipItem( videoClipUuid ).linkedClip = audioClipUuid;
> +                            workflow.linkClips( audioClipUuid, videoClipUuid );
>                          }
>                          currentUuid = "";
>                          aClipInfo = null;
> diff --git a/src/Media/Clip.cpp b/src/Media/Clip.cpp
> index 2c3f70e..91b27bc 100644
> --- a/src/Media/Clip.cpp
> +++ b/src/Media/Clip.cpp
> @@ -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 );
>
> diff --git a/src/Media/Clip.h b/src/Media/Clip.h
> index 1bb4664..dab3506 100644
> --- a/src/Media/Clip.h
> +++ b/src/Media/Clip.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:
> diff --git a/src/Workflow/MainWorkflow.cpp b/src/Workflow/MainWorkflow.cpp
> index 2b716a9..3b6b0a1 100644
> --- a/src/Workflow/MainWorkflow.cpp
> +++ b/src/Workflow/MainWorkflow.cpp
> @@ -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,
> diff --git a/src/Workflow/MainWorkflow.h b/src/Workflow/MainWorkflow.h
> index c328c2f..c21580c 100644
> --- a/src/Workflow/MainWorkflow.h
> +++ b/src/Workflow/MainWorkflow.h
> @@ -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
>
> _______________________________________________
> Vlmc-devel mailing list
> Vlmc-devel at videolan.org
> https://mailman.videolan.org/listinfo/vlmc-devel
>



More information about the Vlmc-devel mailing list