Commit cf14e223 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Seek to item last frame on paste

parent 32449d0d
......@@ -19,6 +19,7 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "effects/effectstack/model/effectstackmodel.hpp"
#include "groupsmodel.hpp"
#include "mainwindow.h"
#include "monitor/monitor.h"
#include "project/projectmanager.h"
#include "timelineitemmodel.hpp"
#include "trackmodel.hpp"
......@@ -1523,14 +1524,19 @@ QString TimelineFunctions::copyClips(const std::shared_ptr<TimelineItemModel> &t
int masterTrack = subtitleOnlyCopy ? -1 : timeline->getTrackPosition(masterTid);
QDomDocument copiedItems;
int offset = -1;
int lastFrame = -1;
QDomElement container = copiedItems.createElement(QStringLiteral("kdenlive-scene"));
container.setAttribute(QStringLiteral("fps"), QString::number(pCore->getCurrentFps()));
copiedItems.appendChild(container);
QStringList binIds;
for (int id : allIds) {
if (offset == -1 || timeline->getItemPosition(id) < offset) {
int startPos = timeline->getItemPosition(id);
if (offset == -1 || startPos < offset) {
offset = timeline->getItemPosition(id);
}
if (startPos + timeline->getItemPlaytime(id) > lastFrame) {
lastFrame = startPos + timeline->getItemPlaytime(id);
}
if (timeline->isClip(id)) {
QDomElement clipXml = timeline->m_allClips[id]->toXml(copiedItems);
container.appendChild(clipXml);
......@@ -1559,6 +1565,7 @@ QString TimelineFunctions::copyClips(const std::shared_ptr<TimelineItemModel> &t
container2.appendChild(clip->toXml(tmp));
}
container.setAttribute(QStringLiteral("offset"), offset);
container.setAttribute(QStringLiteral("duration"), lastFrame - offset);
if (audioCopy) {
container.setAttribute(QStringLiteral("masterAudioTrack"), masterTrack);
int masterMirror = timeline->getMirrorVideoTrackId(masterTid);
......@@ -1826,7 +1833,7 @@ bool TimelineFunctions::pasteClips(const std::shared_ptr<TimelineItemModel> &tim
}
};
bool clipsImported = false;
int pasteDuration = copiedItems.documentElement().attribute(QStringLiteral("duration")).toInt();
if (docId == pCore->currentDoc()->getDocumentProperty(QStringLiteral("documentid"))) {
// Check that the bin clips exists in case we try to paste in a copy of original project
QDomNodeList binClips = copiedItems.documentElement().elementsByTagName(QStringLiteral("producer"));
......@@ -1851,6 +1858,7 @@ bool TimelineFunctions::pasteClips(const std::shared_ptr<TimelineItemModel> &tim
pCore->projectItemModel()->requestAddBinClip(updatedId, currentProd, folderId, undo, redo, callBack);
}
}
pCore->getMonitor(Kdenlive::ProjectMonitor)->requestSeek(position + pasteDuration);
}
if (!docId.isEmpty() && docId != pCore->currentDoc()->getDocumentProperty(QStringLiteral("documentid"))) {
......@@ -1879,6 +1887,7 @@ bool TimelineFunctions::pasteClips(const std::shared_ptr<TimelineItemModel> &tim
pCore->projectItemModel()->requestAddFolder(folderId, i18n("Pasted clips"), rootId, undo, redo);
}
QDomNodeList binClips = copiedItems.documentElement().elementsByTagName(QStringLiteral("producer"));
pCore->getMonitor(Kdenlive::ProjectMonitor)->requestSeek(position + (pasteDuration * ratio));
for (int i = 0; i < binClips.count(); ++i) {
QDomElement currentProd = binClips.item(i).toElement();
if (ratio != 1.) {
......
Supports Markdown
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