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

Timeline clip drop: add id to each drag operation to avoid incorrectly...

Timeline clip drop: add id to each drag operation to avoid incorrectly interpreting a new drag operation as the continuation of a previous one.
Should fix #1235
Related to #1239
parent abfea9bb
......@@ -360,6 +360,7 @@ QMimeData *ProjectItemModel::mimeData(const QModelIndexList &indices) const
QByteArray data;
data.append(list.join(QLatin1Char(';')).toUtf8());
mimeData->setData(QStringLiteral("kdenlive/producerslist"), data);
mimeData->setData(QStringLiteral("kdenlive/dragid"), QUuid::createUuid().toByteArray());
mimeData->setText(QString::number(duration));
}
return mimeData;
......
......@@ -965,6 +965,7 @@ void Monitor::slotStartDrag()
prodData.append(list.join(QLatin1Char('/')).toUtf8());
}
mimeData->setData(QStringLiteral("kdenlive/producerslist"), prodData);
mimeData->setData(QStringLiteral("kdenlive/dragid"), QUuid::createUuid().toByteArray());
drag->setMimeData(mimeData);
drag->exec(Qt::MoveAction);
emit pCore->bin()->processDragEnd();
......
......@@ -27,6 +27,8 @@
#include "monitormanager.h"
#include "profiles/profilemodel.hpp"
#include <QUuid>
#include <mlt++/MltConsumer.h>
#include <mlt++/MltFilter.h>
#include <mlt++/MltProducer.h>
......@@ -410,3 +412,8 @@ void MonitorProxy::setSpeed(double speed)
emit speedChanged();
}
}
QByteArray MonitorProxy::getUuid() const
{
return QUuid::createUuid().toByteArray();
}
......@@ -85,6 +85,7 @@ public:
Q_INVOKABLE void seek(int delta, uint modifiers);
Q_INVOKABLE QColor thumbColor1() const;
Q_INVOKABLE QColor thumbColor2() const;
Q_INVOKABLE QByteArray getUuid() const;
bool audioThumbFormat() const;
bool audioThumbNormalize() const;
void positionFromConsumer(int pos, bool playing);
......
......@@ -520,6 +520,7 @@ Item {
Rectangle {
// Audio or video only drag zone
id: dragZone
property string uuid
x: 2
y: inPoint.visible || outPoint.visible || marker.visible ? parent.height - inPoint.height - height - 2 - overlayMargin : parent.height - height - 2 - overlayMargin
width: childrenRect.width
......@@ -544,7 +545,8 @@ Item {
Drag.active: dragVideoArea.drag.active
Drag.dragType: Drag.Automatic
Drag.mimeData: {
"kdenlive/producerslist" : "V" + controller.clipId + "/" + controller.zoneIn + "/" + (controller.zoneOut - 1)
"kdenlive/producerslist" : "V" + controller.clipId + "/" + controller.zoneIn + "/" + (controller.zoneOut - 1),
"kdenlive/dragid" : dragZone.uuid
}
MouseArea {
id: dragVideoArea
......@@ -553,6 +555,9 @@ Item {
propagateComposedEvents: true
cursorShape: Qt.PointingHand
drag.target: parent
onPressed: {
dragZone.uuid = controller.getUuid()
}
onExited: {
parent.x = 0
parent.y = 0
......@@ -565,7 +570,8 @@ Item {
Drag.active: dragAudioArea.drag.active
Drag.dragType: Drag.Automatic
Drag.mimeData: {
"kdenlive/producerslist" : "A" + controller.clipId + "/" + controller.zoneIn + "/" + (controller.zoneOut - 1)
"kdenlive/producerslist" : "A" + controller.clipId + "/" + controller.zoneIn + "/" + (controller.zoneOut - 1),
"kdenlive/dragid" : dragZone.uuid
}
MouseArea {
id: dragAudioArea
......@@ -574,6 +580,9 @@ Item {
propagateComposedEvents: true
cursorShape: Qt.PointingHand
drag.target: parent
onPressed: {
dragZone.uuid = controller.getUuid()
}
onExited: {
parent.x = videoDragButton.x + videoDragButton.width
parent.y = 0
......
......@@ -266,6 +266,7 @@ Rectangle {
clipBeingDroppedId = -1
droppedPosition = -1
droppedTrack = -1
clipDropArea.lastDragUuid = ""
scrollTimer.running = false
scrollTimer.stop()
}
......@@ -517,7 +518,7 @@ Rectangle {
var track = Logic.getTrackIdFromPos(drag.y + scrollView.contentY - subtitleTrack.height)
if (track !== -1) {
var frame = Math.round((drag.x + scrollView.contentX) / timeline.scaleFactor)
if (clipBeingDroppedId >= 0){
if (clipBeingDroppedId >= 0) {
if (controller.isAudioTrack(track)) {
// Don't allow moving composition to an audio track
track = controller.getCompositionTrackId(clipBeingDroppedId)
......@@ -554,6 +555,7 @@ Rectangle {
DropArea {
//Drop area for bin/clips
id: clipDropArea
property string lastDragUuid
/** @brief local helper function to handle the insertion of multiple dragged items */
function insertAndMaybeGroup(track, frame, droppedData) {
var binIds = droppedData.split(";")
......@@ -620,6 +622,10 @@ Rectangle {
clearDropData()
}
onEntered: {
if (clipBeingDroppedId > -1 && lastDragUuid != drag.getDataAsString('kdenlive/dragid')) {
// We are re-entering drop zone with another drag operation, ensure the previous drop operation is complete
processDrop()
}
if (clipBeingMovedId == -1 && clipBeingDroppedId == -1) {
//var track = Logic.getTrackIdFromPos(drag.y)
var yOffset = 0
......@@ -633,6 +639,7 @@ Rectangle {
timeline.activeTrack = tracksRepeater.itemAt(track).trackInternalId
//drag.acceptProposedAction()
clipBeingDroppedData = drag.getDataAsString('kdenlive/producerslist')
lastDragUuid = drag.getDataAsString('kdenlive/dragid')
if (controller.normalEdit()) {
clipBeingDroppedId = insertAndMaybeGroup(timeline.activeTrack, frame, clipBeingDroppedData)
} else {
......
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