Commit dbc5328d authored by Piotrek Brzeziński's avatar Piotrek Brzeziński Committed by Alexandru Băluț
Browse files

timeline: Select newly pasted clips

Automatically selects clip(s) after they're pasted on the timeline.
Fixes #2529.
parent 5377ad53
......@@ -2000,16 +2000,17 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
with self.app.action_log.started("paste",
finalizing_action=CommitTimelineFinalizingAction(self._project.pipeline),
toplevel=True):
copied_group_shallow_copy = self.__copied_group.paste(position)
if not copied_group_shallow_copy:
pasted_group = self.__copied_group.paste(position)
if not pasted_group:
self.info("The paste is not possible at position: %s", position)
return
self.timeline.selection.select(pasted_group.children)
try:
self.__copied_group = copied_group_shallow_copy.copy(True)
# We need to recreate the copied group as pasting destroys it.
self.__copied_group = pasted_group.copy(True)
self.__copied_group.props.serialize = False
finally:
copied_group_shallow_copy.ungroup(recursive=False)
pasted_group.ungroup(recursive=False)
def __add_layer_cb(self, unused_action, unused_parameter):
with self.app.action_log.started("add layer",
......
......@@ -559,6 +559,34 @@ class TestCopyPaste(common.TestCase):
timeline_container.paste_action.emit("activate", None)
self.assertEqual(len(layer.get_clips()), 1)
def test_paste_selection(self):
timeline_container = self.copy_clips(1)
timeline = timeline_container.timeline
layer = timeline.ges_timeline.get_layers()[0]
project = timeline.ges_timeline.get_asset()
# Paste a single clip.
clips = layer.get_clips()
self.assertEqual(len(clips), 1)
position = 10
project.pipeline.get_position = mock.Mock(return_value=position)
timeline_container.paste_action.emit("activate", None)
clips = layer.get_clips()
self.assertListEqual([bool(clip.selected) for clip in clips], [False, True])
# The copy_clips() above simulates CTRL button press, so this will add 1st clip to the selection.
self.toggle_clip_selection(clips[0], True)
timeline_container.copy_action.emit("activate", None)
# Paste two clips.
position = 20
project.pipeline.get_position = mock.Mock(return_value=position)
timeline_container.paste_action.emit("activate", None)
clips = layer.get_clips()
self.assertListEqual([bool(clip.selected) for clip in clips], [False, False, True, True])
class TestEditing(common.TestCase):
......
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