Skip to content
GitLab
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
11bc0f08
Commit
11bc0f08
authored
Mar 18, 2020
by
Jean-Baptiste Mardelle
Browse files
Restore cursore position on undo insert/overwrite zone.
Fixes
#430
parent
ce065b3c
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/mainwindow.cpp
View file @
11bc0f08
...
...
@@ -2626,14 +2626,7 @@ void MainWindow::slotInsertClipOverwrite()
// No clip in monitor
return
;
}
int
pos
=
getMainTimeline
()
->
controller
()
->
insertZone
(
binId
,
m_clipMonitor
->
getZoneInfo
(),
true
);
if
(
pos
>
0
)
{
Kdenlive
::
MonitorId
activeMonitor
=
pCore
->
monitorManager
()
->
activeMonitor
()
->
id
();
pCore
->
monitorManager
()
->
activateMonitor
(
Kdenlive
::
ProjectMonitor
);
m_projectMonitor
->
refreshMonitorIfActive
(
true
);
getCurrentTimeline
()
->
controller
()
->
setPosition
(
pos
);
pCore
->
monitorManager
()
->
activateMonitor
(
activeMonitor
);
}
getMainTimeline
()
->
controller
()
->
insertZone
(
binId
,
m_clipMonitor
->
getZoneInfo
(),
true
);
}
void
MainWindow
::
slotInsertClipInsert
()
...
...
@@ -2644,14 +2637,7 @@ void MainWindow::slotInsertClipInsert()
pCore
->
displayMessage
(
i18n
(
"No clip selected in project bin"
),
InformationMessage
);
return
;
}
int
pos
=
getMainTimeline
()
->
controller
()
->
insertZone
(
binId
,
m_clipMonitor
->
getZoneInfo
(),
false
);
if
(
pos
>
0
)
{
Kdenlive
::
MonitorId
activeMonitor
=
pCore
->
monitorManager
()
->
activeMonitor
()
->
id
();
pCore
->
monitorManager
()
->
activateMonitor
(
Kdenlive
::
ProjectMonitor
);
m_projectMonitor
->
refreshMonitorIfActive
(
true
);
getCurrentTimeline
()
->
controller
()
->
setPosition
(
pos
);
pCore
->
monitorManager
()
->
activateMonitor
(
activeMonitor
);
}
getMainTimeline
()
->
controller
()
->
insertZone
(
binId
,
m_clipMonitor
->
getZoneInfo
(),
false
);
}
void
MainWindow
::
slotExtractZone
()
...
...
src/timeline2/model/timelinefunctions.cpp
View file @
11bc0f08
...
...
@@ -335,9 +335,22 @@ bool TimelineFunctions::extractZone(const std::shared_ptr<TimelineItemModel> &ti
bool
TimelineFunctions
::
insertZone
(
const
std
::
shared_ptr
<
TimelineItemModel
>
&
timeline
,
QList
<
int
>
trackIds
,
const
QString
&
binId
,
int
insertFrame
,
QPoint
zone
,
bool
overwrite
,
bool
useTargets
)
{
// Start undoable command
std
::
function
<
bool
(
void
)
>
undo
=
[]()
{
return
true
;
};
std
::
function
<
bool
(
void
)
>
redo
=
[]()
{
return
true
;
};
bool
res
=
TimelineFunctions
::
insertZone
(
timeline
,
trackIds
,
binId
,
insertFrame
,
zone
,
overwrite
,
useTargets
,
undo
,
redo
);
if
(
res
)
{
pCore
->
pushUndo
(
undo
,
redo
,
overwrite
?
i18n
(
"Overwrite zone"
)
:
i18n
(
"Insert zone"
));
}
else
{
pCore
->
displayMessage
(
i18n
(
"Could not insert zone"
),
InformationMessage
);
undo
();
}
return
res
;
}
bool
TimelineFunctions
::
insertZone
(
const
std
::
shared_ptr
<
TimelineItemModel
>
&
timeline
,
QList
<
int
>
trackIds
,
const
QString
&
binId
,
int
insertFrame
,
QPoint
zone
,
bool
overwrite
,
bool
useTargets
,
Fun
&
undo
,
Fun
&
redo
)
{
// Start undoable command
bool
result
=
true
;
QVector
<
int
>
affectedTracks
;
auto
it
=
timeline
->
m_allTracks
.
cbegin
();
...
...
@@ -400,15 +413,8 @@ bool TimelineFunctions::insertZone(const std::shared_ptr<TimelineItemModel> &tim
clipInserted
=
true
;
}
}
if
(
result
)
{
pCore
->
pushUndo
(
undo
,
redo
,
overwrite
?
i18n
(
"Overwrite zone"
)
:
i18n
(
"Insert zone"
));
}
}
if
(
!
result
)
{
qDebug
()
<<
"// REQUESTING SPACE FAILED"
;
undo
();
}
return
clipInserted
;
return
result
;
}
bool
TimelineFunctions
::
liftZone
(
const
std
::
shared_ptr
<
TimelineItemModel
>
&
timeline
,
int
trackId
,
QPoint
zone
,
Fun
&
undo
,
Fun
&
redo
)
...
...
src/timeline2/model/timelinefunctions.hpp
View file @
11bc0f08
...
...
@@ -91,8 +91,8 @@ struct TimelineFunctions
@returns true on success, false otherwise
*/
static
bool
requestInsertSpace
(
const
std
::
shared_ptr
<
TimelineItemModel
>
&
timeline
,
QPoint
zone
,
Fun
&
undo
,
Fun
&
redo
,
QVector
<
int
>
allowedTracks
=
QVector
<
int
>
());
static
bool
insertZone
(
const
std
::
shared_ptr
<
TimelineItemModel
>
&
timeline
,
QList
<
int
>
trackIds
,
const
QString
&
binId
,
int
insertFrame
,
QPoint
zone
,
bool
overwrite
,
bool
useTargets
=
true
);
static
bool
insertZone
(
const
std
::
shared_ptr
<
TimelineItemModel
>
&
timeline
,
QList
<
int
>
trackIds
,
const
QString
&
binId
,
int
insertFrame
,
QPoint
zone
,
bool
overwrite
,
bool
useTargets
=
true
);
static
bool
insertZone
(
const
std
::
shared_ptr
<
TimelineItemModel
>
&
timeline
,
QList
<
int
>
trackIds
,
const
QString
&
binId
,
int
insertFrame
,
QPoint
zone
,
bool
overwrite
,
bool
useTargets
,
Fun
&
undo
,
Fun
&
redo
);
static
bool
requestItemCopy
(
const
std
::
shared_ptr
<
TimelineItemModel
>
&
timeline
,
int
clipId
,
int
trackId
,
int
position
);
static
void
showClipKeyframes
(
const
std
::
shared_ptr
<
TimelineItemModel
>
&
timeline
,
int
clipId
,
bool
value
);
...
...
src/timeline2/view/timelinecontroller.cpp
View file @
11bc0f08
...
...
@@ -1886,8 +1886,38 @@ bool TimelineController::insertClipZone(const QString &binId, int tid, int posit
if
(
aTrack
>
-
1
)
{
target_tracks
<<
aTrack
;
}
return
TimelineFunctions
::
insertZone
(
m_model
,
target_tracks
,
binId
,
position
,
QPoint
(
in
,
out
+
1
),
m_model
->
m_editMode
==
TimelineMode
::
OverwriteEdit
,
false
);
std
::
function
<
bool
(
void
)
>
undo
=
[]()
{
return
true
;
};
std
::
function
<
bool
(
void
)
>
redo
=
[]()
{
return
true
;
};
bool
overwrite
=
m_model
->
m_editMode
==
TimelineMode
::
OverwriteEdit
;
QPoint
zone
(
in
,
out
+
1
);
bool
res
=
TimelineFunctions
::
insertZone
(
m_model
,
target_tracks
,
binId
,
position
,
zone
,
overwrite
,
false
,
undo
,
redo
);
if
(
res
)
{
int
newPos
=
position
+
(
zone
.
y
()
-
zone
.
x
());
int
currentPos
=
pCore
->
getTimelinePosition
();
Fun
redoPos
=
[
this
,
newPos
]()
{
Kdenlive
::
MonitorId
activeMonitor
=
pCore
->
monitorManager
()
->
activeMonitor
()
->
id
();
pCore
->
monitorManager
()
->
activateMonitor
(
Kdenlive
::
ProjectMonitor
);
pCore
->
monitorManager
()
->
refreshProjectMonitor
();
setPosition
(
newPos
);
pCore
->
monitorManager
()
->
activateMonitor
(
activeMonitor
);
return
true
;
};
Fun
undoPos
=
[
this
,
currentPos
]()
{
Kdenlive
::
MonitorId
activeMonitor
=
pCore
->
monitorManager
()
->
activeMonitor
()
->
id
();
pCore
->
monitorManager
()
->
activateMonitor
(
Kdenlive
::
ProjectMonitor
);
pCore
->
monitorManager
()
->
refreshProjectMonitor
();
setPosition
(
currentPos
);
pCore
->
monitorManager
()
->
activateMonitor
(
activeMonitor
);
return
true
;
};
redoPos
();
UPDATE_UNDO_REDO_NOLOCK
(
redoPos
,
undoPos
,
undo
,
redo
);
pCore
->
pushUndo
(
undo
,
redo
,
overwrite
?
i18n
(
"Overwrite zone"
)
:
i18n
(
"Insert zone"
));
}
else
{
pCore
->
displayMessage
(
i18n
(
"Could not insert zone"
),
InformationMessage
);
undo
();
}
return
res
;
}
int
TimelineController
::
insertZone
(
const
QString
&
binId
,
QPoint
zone
,
bool
overwrite
)
...
...
@@ -1933,8 +1963,36 @@ int TimelineController::insertZone(const QString &binId, QPoint zone, bool overw
pCore
->
displayMessage
(
i18n
(
"Please select a target track by clicking on a track's target zone"
),
InformationMessage
);
return
-
1
;
}
return
TimelineFunctions
::
insertZone
(
m_model
,
target_tracks
,
binId
,
insertPoint
,
sourceZone
,
overwrite
)
?
insertPoint
+
(
sourceZone
.
y
()
-
sourceZone
.
x
())
:
-
1
;
std
::
function
<
bool
(
void
)
>
undo
=
[]()
{
return
true
;
};
std
::
function
<
bool
(
void
)
>
redo
=
[]()
{
return
true
;
};
bool
res
=
TimelineFunctions
::
insertZone
(
m_model
,
target_tracks
,
binId
,
insertPoint
,
sourceZone
,
overwrite
,
true
,
undo
,
redo
);
if
(
res
)
{
int
newPos
=
insertPoint
+
(
sourceZone
.
y
()
-
sourceZone
.
x
());
int
currentPos
=
pCore
->
getTimelinePosition
();
Fun
redoPos
=
[
this
,
newPos
]()
{
Kdenlive
::
MonitorId
activeMonitor
=
pCore
->
monitorManager
()
->
activeMonitor
()
->
id
();
pCore
->
monitorManager
()
->
activateMonitor
(
Kdenlive
::
ProjectMonitor
);
pCore
->
monitorManager
()
->
refreshProjectMonitor
();
setPosition
(
newPos
);
pCore
->
monitorManager
()
->
activateMonitor
(
activeMonitor
);
return
true
;
};
Fun
undoPos
=
[
this
,
currentPos
]()
{
Kdenlive
::
MonitorId
activeMonitor
=
pCore
->
monitorManager
()
->
activeMonitor
()
->
id
();
pCore
->
monitorManager
()
->
activateMonitor
(
Kdenlive
::
ProjectMonitor
);
pCore
->
monitorManager
()
->
refreshProjectMonitor
();
setPosition
(
currentPos
);
pCore
->
monitorManager
()
->
activateMonitor
(
activeMonitor
);
return
true
;
};
redoPos
();
UPDATE_UNDO_REDO_NOLOCK
(
redoPos
,
undoPos
,
undo
,
redo
);
pCore
->
pushUndo
(
undo
,
redo
,
overwrite
?
i18n
(
"Overwrite zone"
)
:
i18n
(
"Insert zone"
));
}
else
{
pCore
->
displayMessage
(
i18n
(
"Could not insert zone"
),
InformationMessage
);
undo
();
}
return
res
;
}
void
TimelineController
::
updateClip
(
int
clipId
,
const
QVector
<
int
>
&
roles
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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