Commit 6f6999a8 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle

First draft of direct dropping in timeline

parent 05670931
Pipeline #13846 passed with stage
in 15 minutes and 6 seconds
......@@ -91,6 +91,7 @@ QDomDocument ClipCreator::getXmlFromUrl(const QString &path)
QMimeType type = db.mimeTypeForUrl(QUrl::fromLocalFile(path));
QDomElement prod;
qDebug()<<"=== GOT DROPPPED MIME: "<<type.name();
if (type.name().startsWith(QLatin1String("image/"))) {
int duration = pCore->currentDoc()->getFramePos(KdenliveSettings::image_duration());
prod = createProducer(xml, ClipType::Image, path, QString(), duration, QString());
......
......@@ -508,6 +508,77 @@ Rectangle {
clearDropData()
}
}
DropArea { //Drop area for urls (direct drop from file manager)
/** @brief local helper function to handle the insertion of multiple dragged items */
property int fakeFrame: -1
property int fakeTrack: -1
property var droppedUrls: []
width: root.width - headerWidth
height: root.height - ruler.height
y: ruler.height
x: headerWidth
keys: 'text/uri-list'
onEntered: {
drag.accepted = true
droppedUrls.length = 0
for(var i in drag.urls){
var url = drag.urls[i]
droppedUrls.push(Qt.resolvedUrl(url))
}
}
onExited:{
if (clipBeingDroppedId != -1) {
controller.requestItemDeletion(clipBeingDroppedId, false)
}
clearDropData()
}
onPositionChanged: {
if (clipBeingMovedId == -1) {
var track = Logic.getTrackIndexFromPos(drag.y + scrollView.flickableItem.contentY)
if (track >= 0 && track < tracksRepeater.count) {
timeline.activeTrack = tracksRepeater.itemAt(track).trackInternalId
var frame = Math.round((drag.x + scrollView.flickableItem.contentX) / timeline.scaleFactor)
if (clipBeingDroppedId >= 0) {
//fakeFrame = controller.suggestClipMove(clipBeingDroppedId, timeline.activeTrack, frame, root.consumerPosition, Math.floor(root.snapping))
fakeTrack = timeline.activeTrack
//controller.requestClipMove(clipBeingDroppedId, timeline.activeTrack, frame, true, false, false)
continuousScrolling(drag.x + scrollView.flickableItem.contentX)
} else {
frame = controller.suggestSnapPoint(frame, Math.floor(root.snapping))
if (controller.normalEdit()) {
//clipBeingDroppedId = insertAndMaybeGroup(timeline.activeTrack, frame, drag.getDataAsString('kdenlive/producerslist'), false, true)
} else {
// we want insert/overwrite mode, make a fake insert at end of timeline, then move to position
//clipBeingDroppedId = insertAndMaybeGroup(timeline.activeTrack, timeline.fullDuration, clipBeingDroppedData)
//fakeFrame = controller.suggestClipMove(clipBeingDroppedId, timeline.activeTrack, frame, root.consumerPosition, Math.floor(root.snapping))
fakeTrack = timeline.activeTrack
}
continuousScrolling(drag.x + scrollView.flickableItem.contentX)
}
}
}
}
onDropped: {
var frame = Math.round((drag.x + scrollView.flickableItem.contentX) / timeline.scaleFactor)
var track = timeline.activeTrack
//var binIds = clipBeingDroppedData.split(";")
//if (binIds.length == 1) {
if (controller.normalEdit()) {
timeline.urlDropped(droppedUrls, frame, track)
} else {
//timeline.insertClipZone(clipBeingDroppedData, track, frame)
}
/*} else {
if (controller.normalEdit()) {
timeline.insertClips(track, frame, binIds, true, true)
} else {
// TODO
console.log('multiple clips insert/overwrite not supported yet')
}
}*/
clearDropData()
}
}
OLD.Menu {
id: menu
property int clickedX
......
......@@ -2678,6 +2678,14 @@ void TimelineController::switchRecording(int trackId)
}
}
void TimelineController::urlDropped(QStringList droppedFile, int frame, int tid)
{
m_recordTrack = tid;
m_recordStart = {frame, -1};
qDebug()<<"=== GOT DROPPED FILED: "<<droppedFile<<"\n======";
finishRecording(QUrl(droppedFile.first()).toLocalFile());
}
void TimelineController::finishRecording(const QString &recordedFile)
{
if (recordedFile.isEmpty()) {
......
......@@ -346,6 +346,7 @@ public:
Q_INVOKABLE void splitVideo(int clipId);
Q_INVOKABLE void setAudioRef(int clipId = -1);
Q_INVOKABLE void alignAudio(int clipId = -1);
Q_INVOKABLE void urlDropped(QStringList droppedFile, int frame, int tid);
Q_INVOKABLE bool endFakeMove(int clipId, int position, bool updateView, bool logUndo, bool invalidateTimeline);
Q_INVOKABLE int getItemMovingTrack(int itemId) const;
......
  • wishlist: https://bugs.kde.org/show_bug.cgi?id=415731

    @mardelle Cool. First attempt looks good. 2 things:

    • Open new project 1080p25 -> add a 1080p50 clip to the timeline -> Kdenlive ask to switch project according clip -> OK -> the project and timeline switch -> the clip in the timeline is now just half the length.
    • In general I can Drag/Drop the same clip into the bin as many times as I like. Should not be possible or Kdenlive should ask if the clip should be added again.
      WeDrag/drop a clip into the timeline (the clip appear in the bin) -> delete the clip in the timeline -> drag/drop the same clip from the folder into the timeline again -> now the clip is twice in the project bin.
    Edited by Eugen Mohr
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