Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
kdenlive
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Heiko Becker
kdenlive
Commits
593e207c
Commit
593e207c
authored
Apr 09, 2019
by
Jean-Baptiste Mardelle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix insert/overwrite modes, as well as drag and drop insert/overwrite. Fixes #119
parent
5080a445
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
93 additions
and
9 deletions
+93
-9
src/timeline2/model/timelinefunctions.cpp
src/timeline2/model/timelinefunctions.cpp
+3
-1
src/timeline2/model/trackmodel.cpp
src/timeline2/model/trackmodel.cpp
+0
-1
src/timeline2/view/qml/timeline.qml
src/timeline2/view/qml/timeline.qml
+40
-7
src/timeline2/view/timelinecontroller.cpp
src/timeline2/view/timelinecontroller.cpp
+49
-0
src/timeline2/view/timelinecontroller.h
src/timeline2/view/timelinecontroller.h
+1
-0
No files found.
src/timeline2/model/timelinefunctions.cpp
View file @
593e207c
...
...
@@ -295,7 +295,7 @@ bool TimelineFunctions::insertZone(const std::shared_ptr<TimelineItemModel> &tim
std
::
function
<
bool
(
void
)
>
undo
=
[]()
{
return
true
;
};
std
::
function
<
bool
(
void
)
>
redo
=
[]()
{
return
true
;
};
bool
result
=
true
;
int
trackId
=
trackIds
.
takeF
irst
();
int
trackId
=
trackIds
.
f
irst
();
if
(
overwrite
)
{
// Cut all tracks
auto
it
=
timeline
->
m_allTracks
.
cbegin
();
...
...
@@ -307,6 +307,7 @@ bool TimelineFunctions::insertZone(const std::shared_ptr<TimelineItemModel> &tim
}
result
=
result
&&
TimelineFunctions
::
liftZone
(
timeline
,
target_track
,
QPoint
(
insertFrame
,
insertFrame
+
(
zone
.
y
()
-
zone
.
x
())),
undo
,
redo
);
if
(
!
result
)
{
qDebug
()
<<
"// LIFTING ZONE FAILED
\n
"
;
break
;
}
++
it
;
...
...
@@ -338,6 +339,7 @@ bool TimelineFunctions::insertZone(const std::shared_ptr<TimelineItemModel> &tim
}
}
if
(
!
result
)
{
qDebug
()
<<
"// REQUESTING SPACE FAILED"
;
undo
();
}
return
result
;
...
...
src/timeline2/model/trackmodel.cpp
View file @
593e207c
...
...
@@ -207,7 +207,6 @@ Fun TrackModel::requestClipInsertion_lambda(int clipId, int position, bool updat
};
}
}
return
[]()
{
return
false
;
};
}
...
...
src/timeline2/view/qml/timeline.qml
View file @
593e207c
...
...
@@ -325,6 +325,8 @@ Rectangle {
return
id
}
property
int
fakeFrame
:
-
1
property
int
fakeTrack
:
-
1
width
:
root
.
width
-
headerWidth
height
:
root
.
height
-
ruler
.
height
y
:
ruler
.
height
...
...
@@ -341,7 +343,14 @@ Rectangle {
//drag.acceptProposedAction()
clipBeingDroppedData
=
drag
.
getDataAsString
(
'
kdenlive/producerslist
'
)
console
.
log
(
'
dropped data:
'
,
clipBeingDroppedData
)
clipBeingDroppedId
=
insertAndMaybeGroup
(
timeline
.
activeTrack
,
frame
,
clipBeingDroppedData
)
if
(
controller
.
normalEdit
())
{
clipBeingDroppedId
=
insertAndMaybeGroup
(
timeline
.
activeTrack
,
frame
,
clipBeingDroppedData
)
}
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
,
timeline
.
position
,
Math
.
floor
(
root
.
snapping
))
fakeTrack
=
timeline
.
activeTrack
}
continuousScrolling
(
drag
.
x
+
scrollView
.
flickableItem
.
contentX
)
}
else
{
drag
.
accepted
=
false
...
...
@@ -360,12 +369,21 @@ Rectangle {
if
(
track
>=
0
&&
track
<
tracksRepeater
.
count
)
{
timeline
.
activeTrack
=
tracksRepeater
.
itemAt
(
track
).
trackInternalId
var
frame
=
Math
.
round
((
drag
.
x
+
scrollView
.
flickableItem
.
contentX
)
/
timeline
.
scaleFactor
)
frame
=
controller
.
suggestSnapPoint
(
frame
,
Math
.
floor
(
root
.
snapping
))
if
(
clipBeingDroppedId
>=
0
){
controller
.
requestClipMove
(
clipBeingDroppedId
,
timeline
.
activeTrack
,
frame
,
true
,
false
,
false
)
fakeFrame
=
controller
.
suggestClipMove
(
clipBeingDroppedId
,
timeline
.
activeTrack
,
frame
,
timeline
.
position
,
Math
.
floor
(
root
.
snapping
))
fakeTrack
=
timeline
.
activeTrack
//controller.requestClipMove(clipBeingDroppedId, timeline.activeTrack, frame, true, false, false)
continuousScrolling
(
drag
.
x
+
scrollView
.
flickableItem
.
contentX
)
}
else
{
clipBeingDroppedId
=
insertAndMaybeGroup
(
timeline
.
activeTrack
,
frame
,
drag
.
getDataAsString
(
'
kdenlive/producerslist
'
),
false
,
true
)
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
,
timeline
.
position
,
Math
.
floor
(
root
.
snapping
))
fakeTrack
=
timeline
.
activeTrack
}
continuousScrolling
(
drag
.
x
+
scrollView
.
flickableItem
.
contentX
)
}
}
...
...
@@ -375,6 +393,10 @@ Rectangle {
if
(
clipBeingDroppedId
!=
-
1
)
{
var
frame
=
controller
.
getClipPosition
(
clipBeingDroppedId
)
var
track
=
controller
.
getClipTrackId
(
clipBeingDroppedId
)
if
(
!
controller
.
normalEdit
())
{
frame
=
fakeFrame
track
=
fakeTrack
}
/* We simulate insertion at the final position so that stored undo has correct value
* NOTE: even if dropping multiple clips, requesting the deletion of the first one is
* enough as internally it will request the group deletion
...
...
@@ -383,10 +405,21 @@ Rectangle {
var
binIds
=
clipBeingDroppedData
.
split
(
"
;
"
)
if
(
binIds
.
length
==
1
)
{
timeline
.
insertClip
(
track
,
frame
,
clipBeingDroppedData
,
true
,
true
,
false
)
if
(
controller
.
normalEdit
())
{
timeline
.
insertClip
(
track
,
frame
,
clipBeingDroppedData
,
true
,
true
,
false
)
}
else
{
timeline
.
insertClipZone
(
clipBeingDroppedData
,
track
,
frame
)
}
}
else
{
timeline
.
insertClips
(
track
,
frame
,
binIds
,
true
,
true
)
if
(
controller
.
normalEdit
())
{
timeline
.
insertClips
(
track
,
frame
,
binIds
,
true
,
true
)
}
else
{
// TODO
console
.
log
(
'
multiple clips insert/overwrite not supported yet
'
)
}
}
fakeTrack
=
-
1
fakeFrame
=
-
1
}
clearDropData
()
}
...
...
@@ -1129,7 +1162,7 @@ Rectangle {
controller
.
requestClipMove
(
dragProxy
.
draggedItem
,
tId
,
dragFrame
,
true
,
true
,
true
)
}
else
{
// Fake move, only process final move
timeline
.
endFakeMove
(
dragProxy
.
draggedItem
,
dragFrame
,
true
,
true
,
true
)
timeline
.
endFakeMove
(
dragProxy
.
draggedItem
,
dragFrame
,
true
,
true
,
true
)
}
}
dragProxy
.
x
=
controller
.
getItemPosition
(
dragProxy
.
draggedItem
)
*
timeline
.
scaleFactor
...
...
src/timeline2/view/timelinecontroller.cpp
View file @
593e207c
...
...
@@ -1466,6 +1466,55 @@ void TimelineController::extract(int clipId)
TimelineFunctions
::
extractZone
(
m_model
,
QVector
<
int
>
()
<<
track
,
zone
,
false
);
}
bool
TimelineController
::
insertClipZone
(
const
QString
&
binId
,
int
tid
,
int
position
)
{
QStringList
binIdData
=
binId
.
split
(
QLatin1Char
(
'/'
));
int
in
=
0
;
int
out
=
-
1
;
if
(
binIdData
.
size
()
>=
3
)
{
in
=
binIdData
.
at
(
1
).
toInt
();
out
=
binIdData
.
at
(
2
).
toInt
();
}
QString
bid
=
binIdData
.
first
();
// dropType indicates if we want a normal drop (disabled), audio only or video only drop
PlaylistState
::
ClipState
dropType
=
PlaylistState
::
Disabled
;
if
(
bid
.
startsWith
(
QLatin1Char
(
'A'
)))
{
dropType
=
PlaylistState
::
AudioOnly
;
bid
=
bid
.
remove
(
0
,
1
);
}
else
if
(
bid
.
startsWith
(
QLatin1Char
(
'V'
)))
{
dropType
=
PlaylistState
::
VideoOnly
;
bid
=
bid
.
remove
(
0
,
1
);
}
int
aTrack
=
-
1
;
int
vTrack
=
-
1
;
std
::
shared_ptr
<
ProjectClip
>
clip
=
pCore
->
bin
()
->
getBinClip
(
bid
);
if
(
out
<=
in
)
{
out
=
clip
->
frameDuration
()
-
1
;
}
if
(
dropType
==
PlaylistState
::
VideoOnly
)
{
vTrack
=
tid
;
}
else
if
(
dropType
==
PlaylistState
::
AudioOnly
)
{
aTrack
=
tid
;
}
else
{
if
(
m_model
->
getTrackById_const
(
tid
)
->
isAudioTrack
())
{
aTrack
=
tid
;
vTrack
=
clip
->
hasAudioAndVideo
()
?
m_model
->
getMirrorVideoTrackId
(
aTrack
)
:
-
1
;
}
else
{
vTrack
=
tid
;
aTrack
=
clip
->
hasAudioAndVideo
()
?
m_model
->
getMirrorAudioTrackId
(
vTrack
)
:
-
1
;
}
}
QList
<
int
>
target_tracks
;
if
(
vTrack
>
-
1
)
{
target_tracks
<<
vTrack
;
}
if
(
aTrack
>
-
1
)
{
target_tracks
<<
aTrack
;
}
return
TimelineFunctions
::
insertZone
(
m_model
,
target_tracks
,
binId
,
position
,
QPoint
(
in
,
out
),
m_model
->
m_editMode
==
TimelineMode
::
OverwriteEdit
);
}
int
TimelineController
::
insertZone
(
const
QString
&
binId
,
QPoint
zone
,
bool
overwrite
)
{
std
::
shared_ptr
<
ProjectClip
>
clip
=
pCore
->
bin
()
->
getBinClip
(
binId
);
...
...
src/timeline2/view/timelinecontroller.h
View file @
593e207c
...
...
@@ -421,6 +421,7 @@ public:
/** @brief Insert clip monitor into timeline
* @returns the zone end position or -1 on fail
*/
Q_INVOKABLE
bool
insertClipZone
(
const
QString
&
binId
,
int
tid
,
int
pos
);
int
insertZone
(
const
QString
&
binId
,
QPoint
zone
,
bool
overwrite
);
void
updateClip
(
int
clipId
,
const
QVector
<
int
>
&
roles
);
void
showClipKeyframes
(
int
clipId
,
bool
value
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment