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
b7f1705c
Commit
b7f1705c
authored
Mar 01, 2021
by
Jean-Baptiste Mardelle
Browse files
Fix various selection issues.
related to
#859
parent
62e74b17
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/mainwindow.cpp
View file @
b7f1705c
...
...
@@ -810,6 +810,11 @@ void MainWindow::init()
#endif
getMainTimeline
()
->
setTimelineMenu
(
timelineClipMenu
,
compositionMenu
,
timelineMenu
,
guideMenu
,
timelineRulerMenu
,
actionCollection
()
->
action
(
QStringLiteral
(
"edit_guide"
)),
timelineHeadersMenu
,
thumbsMenu
,
timelineSubtitleMenu
);
scmanager
->
slotCheckActiveScopes
();
connect
(
qApp
,
&
QGuiApplication
::
applicationStateChanged
,
[
&
](
Qt
::
ApplicationState
state
)
{
if
(
state
==
Qt
::
ApplicationActive
)
{
getMainTimeline
()
->
regainFocus
();
}
});
// m_messageLabel->setMessage(QStringLiteral("This is a beta version. Always backup your data"), MltError);
}
...
...
src/timeline2/view/qml/Timeline.js
View file @
b7f1705c
...
...
@@ -49,7 +49,7 @@ function getTrackIdFromPos(pos) {
}
function
getTrackYFromId
(
id
)
{
var
result
=
-
scrollView
.
contentY
var
result
=
0
for
(
var
i
=
0
;
i
<
trackHeaderRepeater
.
count
;
i
++
)
{
if
(
trackHeaderRepeater
.
itemAt
(
i
).
trackId
==
id
)
{
break
;
...
...
src/timeline2/view/qml/timeline.qml
View file @
b7f1705c
...
...
@@ -75,7 +75,8 @@ Rectangle {
}
function
getActiveTrackStreamPos
()
{
return
Logic
.
getTrackYFromId
(
timeline
.
activeTrack
)
+
rulercontainer
.
height
// Return the relative y click position, to display the context menu
return
Logic
.
getTrackYFromId
(
timeline
.
activeTrack
)
+
rulercontainer
.
height
-
scrollView
.
contentY
}
function
updatePalette
()
{
...
...
@@ -161,7 +162,7 @@ Rectangle {
function
verticalScroll
(
wheel
)
{
var
newScroll
=
Math
.
min
(
scrollView
.
contentY
-
wheel
.
angleDelta
.
y
,
trackHeaders
.
height
-
tracksArea
.
height
+
horScroll
.
height
+
ruler
.
height
trackHeaders
.
height
+
subtitleTrackHeader
.
height
-
tracksArea
.
height
+
horScroll
.
height
+
ruler
.
height
)
scrollView
.
contentY
=
Math
.
max
(
newScroll
,
0
)
}
...
...
@@ -195,13 +196,6 @@ Rectangle {
}
}
}
function
getTrackYFromId
(
a_track
)
{
return
Logic
.
getTrackYFromId
(
a_track
)
}
function
getTrackYFromMltIndex
(
a_track
)
{
return
Logic
.
getTrackYFromMltIndex
(
a_track
)
}
function
getMousePos
()
{
if
(
dragProxy
.
draggedItem
>
-
1
&&
dragProxy
.
masterObject
)
{
...
...
@@ -282,18 +276,37 @@ Rectangle {
dragProxy
.
isComposition
=
isComposition
dragProxy
.
verticalOffset
=
isComposition
?
itemObject
.
displayHeight
:
0
}
function
endDrag
()
{
console
.
log
(
'
ENDING DRAG!!!!!!!!!!!!!!!!!!!!!!
\n
'
)
dragProxy
.
draggedItem
=
-
1
//
dragProxy.x = 0
//
dragProxy.y = 0
dragProxy
.
x
=
0
dragProxy
.
y
=
0
dragProxy
.
width
=
0
dragProxy
.
height
=
0
dragProxy
.
verticalOffset
=
0
}
function
regainFocus
()
{
dragProxyArea
.
doRegainFocus
()
function
regainFocus
(
mousePos
)
{
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:
'
,
mousePos
,
'
SCROLL POS:
'
,
(
mousePos
.
y
-
ruler
.
height
-
subtitleTrack
.
height
+
scrollView
.
contentY
))
var
tentativeClip
=
getItemAtPos
(
currentMouseTrack
,
mousePos
.
x
-
trackHeaders
.
width
,
dragProxy
.
isComposition
)
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
.
width
=
tentativeClip
.
width
dragProxy
.
height
=
tentativeClip
.
height
dragProxy
.
masterObject
=
tentativeClip
dragProxy
.
sourceTrack
=
tk
console
.
log
(
'
missing item
'
,
tentativeClip
.
clipId
,
'
, COORDS:
'
,
tentativeClip
.
x
,
'
x
'
,
tentativeClip
.
y
,
'
, TK id:
'
,
tk
,
'
, TKY:
'
,
Logic
.
getTrackYFromId
(
tk
))
dragProxy
.
sourceFrame
=
tentativeClip
.
modelStart
dragProxy
.
isComposition
=
tentativeClip
.
isComposition
}
else
{
console
.
log
(
'
item not found
'
)
}
}
function
getAudioTracksCount
(){
...
...
@@ -800,7 +813,7 @@ Rectangle {
MouseArea
{
width
:
trackHeaders
.
width
height
:
trackHeaders
.
height
height
:
trackHeaders
.
height
+
subtitleTrackHeader
.
height
acceptedButtons
:
Qt
.
NoButton
onWheel
:
{
var
newScroll
=
Math
.
min
(
scrollView
.
contentY
-
wheel
.
angleDelta
.
y
,
height
-
tracksArea
.
height
+
scrollView
.
ScrollBar
.
horizontal
.
height
+
ruler
.
height
)
...
...
@@ -1178,7 +1191,7 @@ Rectangle {
if
(
pressed
&&
((
mouse
.
buttons
===
Qt
.
MidButton
)
||
(
mouse
.
buttons
===
Qt
.
LeftButton
&&
root
.
activeTool
==
0
&&
(
mouse
.
modifiers
&
Qt
.
ControlModifier
)
&&
!
shiftPress
)))
{
// Pan view
var
newScroll
=
Math
.
min
(
scrollView
.
contentX
-
(
mouseX
-
clickX
),
timeline
.
fullDuration
*
root
.
timeScale
-
(
scrollView
.
width
-
scrollView
.
ScrollBar
.
vertical
.
width
))
var
vScroll
=
Math
.
min
(
scrollView
.
contentY
-
(
mouseY
-
clickY
),
trackHeaders
.
height
-
scrollView
.
height
+
scrollView
.
ScrollBar
.
horizontal
.
height
)
var
vScroll
=
Math
.
min
(
scrollView
.
contentY
-
(
mouseY
-
clickY
),
trackHeaders
.
height
+
subtitleTrackHeader
.
height
-
scrollView
.
height
+
scrollView
.
ScrollBar
.
horizontal
.
height
)
scrollView
.
contentX
=
Math
.
max
(
newScroll
,
0
)
scrollView
.
contentY
=
Math
.
max
(
vScroll
,
0
)
clickX
=
mouseX
...
...
@@ -1251,7 +1264,9 @@ Rectangle {
var
bottomRubber
=
y
+
rubberSelect
.
height
if
(
bottomRubber
>
subtitleTrack
.
height
)
{
y
=
Math
.
max
(
0
,
y
-
subtitleTrack
.
height
)
selectionHeight
=
bottomRubber
-
subtitleTrack
.
height
if
(
selectSubs
)
{
selectionHeight
=
bottomRubber
-
subtitleTrack
.
height
}
}
else
{
y
-=
subtitleTrack
.
height
selectOnlySubs
=
true
...
...
@@ -1260,7 +1275,8 @@ Rectangle {
var
topTrack
=
Logic
.
getTrackIndexFromPos
(
Math
.
max
(
0
,
y
))
var
bottomTrack
=
Logic
.
getTrackIndexFromPos
(
Math
.
max
(
0
,
y
)
+
selectionHeight
)
// Check if bottom of rubber selection covers the last track compositions
var
selectBottomCompositions
=
((
y
+
selectionHeight
)
-
Logic
.
getTrackYFromId
(
tracksRepeater
.
itemAt
(
bottomTrack
).
trackInternalId
)
-
scrollView
.
contentY
)
>
(
Logic
.
getTrackHeightByPos
(
bottomTrack
)
*
0.6
)
console
.
log
(
'
Got rubber bottom:
'
,
y
,
'
- height:
'
,
selectionHeight
,
'
, TK y:
'
,
Logic
.
getTrackYFromId
(
tracksRepeater
.
itemAt
(
bottomTrack
).
trackInternalId
),
'
, SCROLLVIEWY:
'
,
scrollView
.
contentY
)
var
selectBottomCompositions
=
((
y
+
selectionHeight
)
-
Logic
.
getTrackYFromId
(
tracksRepeater
.
itemAt
(
bottomTrack
).
trackInternalId
))
>
(
Logic
.
getTrackHeightByPos
(
bottomTrack
)
*
0.6
)
if
(
bottomTrack
>=
topTrack
)
{
var
t
=
[]
if
(
!
selectOnlySubs
)
{
...
...
@@ -1427,7 +1443,7 @@ Rectangle {
Item
{
id
:
tracksContainerArea
width
:
Math
.
max
(
scrollView
.
width
-
vertScroll
.
width
,
timeline
.
fullDuration
*
timeScale
)
height
:
trackHeaders
.
height
height
:
trackHeaders
.
height
+
subtitleTrackHeader
.
height
y
:
subtitleTrack
.
height
//Math.max(trackHeaders.height, scrollView.contentHeight - scrollView.__horizontalScrollBar.height)
//color: root.color
...
...
@@ -1444,7 +1460,7 @@ Rectangle {
property
bool
isComposition
property
int
verticalOffset
property
var
masterObject
//opacity: 0.8
//
opacity: 0.8
MouseArea
{
id
:
dragProxyArea
anchors.fill
:
parent
...
...
@@ -1540,31 +1556,6 @@ Rectangle {
moveItem
()
}
}
function
doRegainFocus
()
{
// This is currently broken, fix pending
return
var
itemPos
=
mapToItem
(
tracksContainerArea
,
mouseX
,
mouseY
)
var
currentMouseTrack
=
Logic
.
getTrackIdFromPos
(
parent
.
y
+
mouseY
)
// Try to find correct item
console
.
log
(
'
checking item on TK:
'
,
currentMouseTrack
,
'
AT:
'
,
itemPos
.
x
,
'
mouse:
'
,
mouseX
,
'
, PARENT:
'
,
parent
.
x
)
var
tentativeClip
=
getItemAtPos
(
currentMouseTrack
,
itemPos
.
x
,
dragProxy
.
isComposition
)
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
.
width
=
tentativeClip
.
width
dragProxy
.
height
=
tentativeClip
.
height
dragProxy
.
masterObject
=
tentativeClip
dragProxy
.
sourceTrack
=
tk
console
.
log
(
'
missing item
'
,
tentativeClip
.
clipId
,
'
, COORDS:
'
,
tentativeClip
.
x
,
'
x
'
,
tentativeClip
.
y
,
'
, TK id:
'
,
tk
)
dragProxy
.
sourceFrame
=
tentativeClip
.
modelStart
dragProxy
.
isComposition
=
tentativeClip
.
isComposition
}
else
{
console
.
log
(
'
item not found
'
)
}
}
function
moveItem
()
{
if
(
dragProxy
.
draggedItem
>
-
1
)
{
...
...
src/timeline2/view/timelinewidget.cpp
View file @
b7f1705c
...
...
@@ -484,9 +484,6 @@ bool TimelineWidget::eventFilter(QObject *object, QEvent *event)
emit
pCore
->
window
()
->
focusTimeline
(
false
,
false
);
break
;
case
QEvent
::
FocusIn
:
if
(
rootObject
())
{
QMetaObject
::
invokeMethod
(
rootObject
(),
"regainFocus"
);
}
emit
pCore
->
window
()
->
focusTimeline
(
true
,
false
);
break
;
default:
...
...
@@ -496,6 +493,14 @@ bool TimelineWidget::eventFilter(QObject *object, QEvent *event)
return
QQuickWidget
::
eventFilter
(
object
,
event
);
}
void
TimelineWidget
::
regainFocus
()
{
if
(
underMouse
()
&&
rootObject
())
{
QPoint
mousePos
=
mapFromGlobal
(
QCursor
::
pos
());
QMetaObject
::
invokeMethod
(
rootObject
(),
"regainFocus"
,
Q_ARG
(
QVariant
,
mousePos
));
}
}
void
TimelineWidget
::
connectSubtitleModel
(
bool
firstConnect
)
{
qDebug
()
<<
"root context get sub model new function"
;
...
...
src/timeline2/view/timelinewidget.h
View file @
b7f1705c
...
...
@@ -57,6 +57,7 @@ public:
void
setTimelineMenu
(
QMenu
*
clipMenu
,
QMenu
*
compositionMenu
,
QMenu
*
timelineMenu
,
QMenu
*
timelineRulerMenu
,
QMenu
*
guideMenu
,
QAction
*
editGuideAction
,
QMenu
*
headerMenu
,
QMenu
*
thumbsMenu
,
QMenu
*
subtitleClipMenu
);
bool
loading
;
void
connectSubtitleModel
(
bool
firstConnect
);
void
regainFocus
();
protected:
void
mousePressEvent
(
QMouseEvent
*
event
)
override
;
...
...
Write
Preview
Supports
Markdown
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