Fix paste clips/compositions sometimes not working or pasting on wrong track/position

Fixes #642
parent 4f5af497
......@@ -1376,7 +1376,7 @@ bool TimelineFunctions::pasteClips(const std::shared_ptr<TimelineItemModel> &tim
// Find top-most video track that requires an audio mirror
int topAudioOffset = videoTracks.indexOf(topAudioMirror) - videoTracks.indexOf(masterSourceTrack);
// Check if we have enough video tracks with mirror at paste track position
if (projectTracks.first.size() <= projectTracks.second.indexOf(trackId) + topAudioOffset) {
if (requestedAudioTracks > 0 && projectTracks.first.size() <= (projectTracks.second.indexOf(trackId) + topAudioOffset)) {
int updatedPos = projectTracks.first.size() - topAudioOffset - 1;
if (updatedPos < 0 || updatedPos >= projectTracks.second.size()) {
pCore->displayMessage(i18n("Not enough tracks to paste clipboard"), InformationMessage, 500);
......@@ -1407,9 +1407,6 @@ bool TimelineFunctions::pasteClips(const std::shared_ptr<TimelineItemModel> &tim
masterIx = projectTracks.first.indexOf(trackId);
audioMaster = true;
}
qDebug() << "/// PROJECT VIDEO TKS: " << projectTracks.second << ", MASTER: " << trackId;
qDebug() << "/// PASTE VIDEO TKS: " << videoTracks << " / MASTER: " << masterSourceTrack;
qDebug() << "/// MASTER PASTE: " << masterIx;
for (int tk : videoTracks) {
int newPos = masterIx + tk - masterSourceTrack;
if (newPos < 0 || newPos >= projectTracks.second.size()) {
......@@ -1418,6 +1415,7 @@ bool TimelineFunctions::pasteClips(const std::shared_ptr<TimelineItemModel> &tim
return false;
}
tracksMap.insert(tk, projectTracks.second.at(newPos));
//qDebug() << "/// MAPPING SOURCE TRACK: "<<tk<<" TO PROJECT TK: "<<projectTracks.second.at(newPos)<<" = "<<timeline->getTrackMltIndex(projectTracks.second.at(newPos));
}
bool audioOffsetCalculated = false;
int audioOffset = 0;
......
......@@ -73,6 +73,7 @@ Rectangle {
property bool hideClipViews: false
property var groupTrimData
property int scrollStart: scrollView.contentX - (clipRoot.modelStart * timeline.scaleFactor)
property int mouseXPos: mouseArea.mouseX
width : clipDuration * timeScale
opacity: dragProxyArea.drag.active && dragProxy.draggedItem == clipId ? 0.8 : 1.0
......
......@@ -63,6 +63,7 @@ Item {
property color borderColor: 'black'
property bool hideCompoViews
property int scrollStart: scrollView.contentX - modelStart * timeline.scaleFactor
property int mouseXPos: mouseArea.mouseX
signal moved(var clip)
signal dragged(var clip, var mouse)
......
......@@ -150,6 +150,9 @@ Rectangle {
}
function getMousePos() {
if (dragProxy.draggedItem > -1 && dragProxy.masterObject) {
return (dragProxy.masterObject.x + dragProxy.masterObject.mouseXPos) / timeline.scaleFactor
}
if (tracksArea.containsMouse) {
return (scrollView.contentX + tracksArea.mouseX) / timeline.scaleFactor
} else {
......@@ -170,6 +173,9 @@ Rectangle {
}
function getMouseTrack() {
if (dragProxy.draggedItem > -1 && dragProxy.masterObject) {
return dragProxy.masterObject.trackId
}
return Logic.getTrackIdFromPos(tracksArea.mouseY - ruler.height + scrollView.contentY)
}
......
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