Commit a3c0c710 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

Media: Add a method to create a subclip

And use it from the PreviewWidget
parent c794e399
......@@ -28,6 +28,7 @@
#include <memory>
#include "Media/Clip.h"
#include "Media/Media.h"
#include "Renderer/ClipRenderer.h"
#include "Backend/MLT/MLTOutput.h"
#include "PreviewWidget.h"
......@@ -240,6 +241,7 @@ PreviewWidget::createNewClipFromMarkers()
Clip* clip = clipRenderer->getClip();
if ( clip == nullptr )
return ;
auto media = clip->media();
qint64 beg = m_ui->rulerWidget->getMarker( PreviewRuler::Start );
qint64 end = m_ui->rulerWidget->getMarker( PreviewRuler::Stop );
......@@ -250,7 +252,7 @@ PreviewWidget::createNewClipFromMarkers()
return ;
beg = beg < 0 ? 0 : beg;
Clip* part = new Clip( clip, beg, end );
Clip* part = media->cut( beg, end );
//Adding the newly created clip to the media
if ( clip->addSubclip( part ) == false )
......
......@@ -116,6 +116,12 @@ Media::id() const
return m_mlMedia->id();
}
Clip*
Media::cut(qint64 begin, qint64 end)
{
return new Clip( m_baseClip, begin, end );
}
QVariant
Media::toVariant() const
{
......
......@@ -91,6 +91,13 @@ public:
Clip* baseClip() { return m_baseClip; }
const Clip* baseClip() const { return m_baseClip; }
/**
* @brief cut Creates a clip to represent a cut of a media
* @param begin The first frame of the cut
* @param end The last frame of the cut
* @return A new Clip, representing the media from [begin] to [end]
*/
Clip* cut( qint64 begin, qint64 end );
QVariant toVariant() const;
......
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