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

When focusing the app, ensure we have the correct timeline item under mouse referenced.

Related to #859
parent b221dba5
......@@ -263,13 +263,18 @@ Rectangle {
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 getAudioTracksCount(){
var audioCount = 0;
......@@ -1433,6 +1438,28 @@ Rectangle {
moveItem()
}
}
function doRegainFocus() {
var itemPos = mapToItem(tracksContainerArea, mouseX, mouseY)
var currentMouseTrack = Logic.getTrackIdFromPos(parent.y + mouseY)
// Try to find correct item
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) {
......
......@@ -483,6 +483,9 @@ 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:
......
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