Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Multimedia
Kdenlive
Commits
603b0d68
Commit
603b0d68
authored
Mar 24, 2022
by
Jean-Baptiste Mardelle
Browse files
Fix timeline focus issues on drag and drop
parent
7f3bbc4e
Pipeline
#154449
passed with stage
in 6 minutes and 29 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/timeline2/view/qml/Clip.qml
View file @
603b0d68
...
...
@@ -99,6 +99,11 @@ Rectangle {
}
}
function
itemHeight
()
{
return
clipRoot
.
height
}
function
boundValue
(
min
,
val
,
max
)
{
return
Math
.
max
(
min
,
Math
.
min
(
val
,
max
))
}
...
...
@@ -597,7 +602,7 @@ Rectangle {
height
:
parent
.
height
width
:
root
.
baseUnit
/
2
visible
:
root
.
activeTool
===
ProjectTool
.
SelectTool
||
(
root
.
activeTool
===
ProjectTool
.
RippleTool
&&
clipRoot
.
mixDuration
<=
0
&&
!
controller
.
hasClipEndMix
(
clipRoot
.
clipId
))
enabled
:
!
isLocked
&&
(
pressed
||
clipRoot
.
width
>
3
*
width
)
enabled
:
!
isLocked
&&
(
pressed
||
clipRoot
.
width
>
3
*
width
)
&&
clipRoot
.
clipId
==
dragProxy
.
draggedItem
hoverEnabled
:
true
drag.target
:
trimInMouseArea
drag.axis
:
Drag
.
XAxis
...
...
@@ -733,7 +738,7 @@ Rectangle {
width
:
root
.
baseUnit
/
2
hoverEnabled
:
true
visible
:
root
.
activeTool
===
ProjectTool
.
SelectTool
||
(
root
.
activeTool
===
ProjectTool
.
RippleTool
&&
clipRoot
.
mixDuration
<=
0
)
enabled
:
!
isLocked
&&
(
pressed
||
clipRoot
.
width
>
3
*
width
)
enabled
:
!
isLocked
&&
(
pressed
||
clipRoot
.
width
>
3
*
width
)
&&
clipRoot
.
clipId
==
dragProxy
.
draggedItem
property
bool
shiftTrim
:
false
property
bool
controlTrim
:
false
property
bool
sizeChanged
:
false
...
...
src/timeline2/view/qml/Composition.qml
View file @
603b0d68
...
...
@@ -49,6 +49,10 @@ Item {
property
bool
hideCompoViews
:
scrollStart
>
(
clipDuration
*
timeline
.
scaleFactor
)
||
scrollStart
+
scrollView
.
width
<
0
||
width
<
root
.
minClipWidthForViews
property
int
scrollStart
:
scrollView
.
contentX
-
modelStart
*
timeline
.
scaleFactor
property
int
mouseXPos
:
mouseArea
.
mouseX
// We set coordinates to ensure the item can be found using childAt in timeline.qml getItemAtPosq
property
int
trackOffset
:
5
y
:
trackOffset
height
:
5
signal
moved
(
var
clip
)
signal
dragged
(
var
clip
,
var
mouse
)
...
...
@@ -83,6 +87,10 @@ Item {
}
}
function
itemHeight
()
{
return
displayRect
.
height
}
function
grabItem
()
{
compositionRoot
.
forceActiveFocus
()
mouseArea
.
focus
=
true
...
...
@@ -133,7 +141,7 @@ Item {
anchors.top
:
compositionRoot
.
top
anchors.right
:
compositionRoot
.
right
anchors.left
:
compositionRoot
.
left
anchors.topMargin
:
displayHeight
anchors.topMargin
:
displayHeight
-
compositionRoot
.
trackOffset
height
:
parentTrack
.
height
-
displayHeight
color
:
Qt
.
darker
(
'
mediumpurple
'
)
border.color
:
grouped
?
root
.
groupColor
:
mouseArea
.
containsMouse
?
activePalette
.
highlight
:
borderColor
...
...
src/timeline2/view/qml/timeline.qml
View file @
603b0d68
...
...
@@ -325,19 +325,37 @@ Rectangle {
var
currentMouseTrack
=
Logic
.
getTrackIdFromPos
(
mousePos
.
y
-
ruler
.
height
-
subtitleTrack
.
height
+
scrollView
.
contentY
)
// Try to find correct item
//console.log('checking item on TK: ', currentMouseTrack, ' AT: XPOS', (mousePos.x - trackHeaders.width), ', SCROLL:', scrollView.contentX, ', RES: ', ((mousePos.x - trackHeaders.width + scrollView.contentX) / root.timeScale), ' SCROLL POS: ', (mousePos.y - ruler.height - subtitleTrack.height + scrollView.contentY))
var
tentativeClip
=
getItemAtPos
(
currentMouseTrack
,
mousePos
.
x
-
trackHeaders
.
width
+
scrollView
.
contentX
,
dragProxy
.
isComposition
)
var
sourceTrack
=
Logic
.
getTrackById
(
currentMouseTrack
)
var
mouseYPos
=
(
mousePos
.
y
-
ruler
.
height
-
subtitleTrack
.
height
+
scrollView
.
contentY
)
-
sourceTrack
.
y
var
allowComposition
=
mouseYPos
>
sourceTrack
.
height
/
2
var
tentativeClip
=
undefined
if
(
allowComposition
)
{
tentativeClip
=
getItemAtPos
(
currentMouseTrack
,
mousePos
.
x
-
trackHeaders
.
width
+
scrollView
.
contentX
,
true
)
if
(
tentativeClip
)
{
// Ensure mouse is really over the composition
if
(
mouseYPos
<
tentativeClip
.
displayHeight
)
{
tentativeClip
=
undefined
}
}
}
if
(
!
tentativeClip
)
{
tentativeClip
=
getItemAtPos
(
currentMouseTrack
,
mousePos
.
x
-
trackHeaders
.
width
+
scrollView
.
contentX
,
false
)
}
if
(
tentativeClip
&&
tentativeClip
.
clipId
)
{
dragProxy
.
draggedItem
=
tentativeClip
.
clipId
var
tk
=
controller
.
getItemTrackId
(
tentativeClip
.
clipId
)
dragProxy
.
x
=
tentativeClip
.
x
dragProxy
.
y
=
tentativeClip
.
y
+
Logic
.
getTrackYFromId
(
tk
)
dragProxy
.
y
=
sourceTrack
.
y
+
(
tentativeClip
.
isComposition
?
tentativeClip
.
displayHeight
:
tentativeClip
.
y
)
//+ Logic.getTrackYFromId(tk)
dragProxy
.
width
=
tentativeClip
.
width
dragProxy
.
height
=
tentativeClip
.
h
eight
dragProxy
.
height
=
tentativeClip
.
itemH
eight
()
dragProxy
.
masterObject
=
tentativeClip
dragProxy
.
sourceTrack
=
tk
dragProxy
.
sourceFrame
=
tentativeClip
.
modelStart
dragProxy
.
isComposition
=
tentativeClip
.
isComposition
console
.
log
(
'
missing item
'
,
tentativeClip
.
clipId
,
'
, COORDS:
'
,
tentativeClip
.
x
,
'
x
'
,
tentativeClip
.
y
,
'
, TK id:
'
,
tk
,
'
, TKY:
'
,
Logic
.
getTrackYFromId
(
tk
),
'
STARTFRM:
'
,
dragProxy
.
sourceFrame
)
dragProxy
.
verticalOffset
=
tentativeClip
.
isComposition
?
tentativeClip
.
displayHeight
:
0
//console.log('missing item', tentativeClip.clipId, ', COORDS: ', dragProxy.x, 'x', dragProxy.y,'-',dragProxy.width,'x',dragProxy.height, ', TK id: ', tk, ', TKY: ', Logic.getTrackYFromId(tk),' STARTFRM: ', dragProxy.sourceFrame)
}
else
{
console
.
log
(
'
item not found
'
)
if
(
dragProxy
.
draggedItem
>
-
1
)
{
...
...
@@ -356,7 +374,7 @@ Rectangle {
return
audioCount
;
}
function
getItemAtPos
(
tk
,
posx
,
isC
omposition
)
{
function
getItemAtPos
(
tk
,
posx
,
c
omposition
Wanted
)
{
var
track
=
Logic
.
getTrackById
(
tk
)
if
(
track
==
undefined
||
track
.
children
==
undefined
)
{
return
undefined
...
...
@@ -367,8 +385,8 @@ Rectangle {
if
(
container
.
children
[
i
].
children
.
length
===
0
||
container
.
children
[
i
].
children
[
0
].
children
.
length
===
0
)
{
continue
}
tentativeClip
=
container
.
children
[
i
].
children
[
0
].
childAt
(
posx
,
1
)
if
(
tentativeClip
&&
tentativeClip
.
clipId
&&
(
tentativeClip
.
isComposition
===
isC
omposition
))
{
tentativeClip
=
container
.
children
[
i
].
children
[
0
].
childAt
(
posx
,
compositionWanted
?
5
:
0
)
if
(
tentativeClip
&&
tentativeClip
.
clipId
&&
(
tentativeClip
.
isComposition
===
c
omposition
Wanted
))
{
break
}
}
...
...
@@ -608,6 +626,7 @@ Rectangle {
}
}
clearDropData
()
regainFocus
(
Qt
.
point
(
drag
.
x
+
trackHeaders
.
width
,
drag
.
y
+
ruler
.
height
))
}
}
DropArea
{
...
...
@@ -772,6 +791,7 @@ Rectangle {
}
onDropped
:
{
processDrop
()
regainFocus
(
Qt
.
point
(
drag
.
x
+
trackHeaders
.
width
,
drag
.
y
+
ruler
.
height
))
}
}
DropArea
{
//Drop area for urls (direct drop from file manager)
...
...
@@ -1722,12 +1742,13 @@ Rectangle {
clickAccepted
=
true
dragProxy
.
draggedItem
=
tentativeClip
.
clipId
dragProxy
.
x
=
tentativeClip
.
x
//dragProxy.y = tentativeClip.y
dragProxy
.
y
=
currentMouseTrack
.
y
+
tentativeClip
.
isComposition
?
tentativeClip
.
displayHeight
:
tentativeClip
.
y
dragProxy
.
height
=
tentativeClip
.
itemHeight
()
dragProxy
.
width
=
tentativeClip
.
width
dragProxy
.
height
=
tentativeClip
.
height
dragProxy
.
masterObject
=
tentativeClip
dragProxy
.
sourceTrack
=
tk
dragProxy
.
isComposition
=
tentativeClip
.
isComposition
dragProxy
.
verticalOffset
=
tentativeClip
.
isComposition
?
tentativeClip
.
displayHeight
:
0
}
else
{
console
.
log
(
'
item not found
'
)
clickAccepted
=
false
...
...
src/timeline2/view/timelinewidget.cpp
View file @
603b0d68
...
...
@@ -497,7 +497,6 @@ bool TimelineWidget::eventFilter(QObject *object, QEvent *event)
void
TimelineWidget
::
regainFocus
()
{
qDebug
()
<<
"=== REG FOCUS: "
<<
underMouse
();
if
(
underMouse
()
&&
rootObject
())
{
QPoint
mousePos
=
mapFromGlobal
(
QCursor
::
pos
());
QMetaObject
::
invokeMethod
(
rootObject
(),
"regainFocus"
,
Qt
::
DirectConnection
,
Q_ARG
(
QVariant
,
mousePos
));
...
...
src/timeline2/view/timelinewidget.h
View file @
603b0d68
...
...
@@ -63,6 +63,7 @@ public slots:
void
endDrag
();
/** @brief Show menu to switch track target audio stream */
void
showTargetMenu
(
int
tid
=
-
1
);
/** @brief Focus qml item under mouse in timeline, for example after app looses focus or a menu showed up*/
void
regainFocus
();
private
slots
:
...
...
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