Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

feat(timeline): Q and E cut the selected clip at the playhead

minecart551-progb3c3f47db9eb
diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rs
index 525cbd9d..0e34cc91 100644
--- a/src/crates/concat/src/studio.rs
+++ b/src/crates/concat/src/studio.rs
@@ -6863,6 +6863,48 @@ impl Studio {
}
}
+ /// Q / E: the selected clip is cut at the playhead - Q drops its left
+ /// up to there, E its right from there on, as one undo step. Like any
+ /// trim, the lane closes behind the edge only on a magnetic timeline,
+ /// and trim follow carries the playhead to a head cut's new start.
+ pub fn cut_to_playhead(&mut self, left: bool) {
+ let Some(clip_id) = self.sole_selection() else {
+ self.notify(&t("studio.selectClipTimelineFirst"), true);
+ return;
+ };
+ let Some(clip) = self.clip(&clip_id).cloned() else {
+ return;
+ };
+ if self.locked(&clip.track_id) {
+ return;
+ }
+ let at = f64::from(self.playhead);
+ // Nothing is cut unless the playhead sits inside the clip, as
+ // split_at requires of its cuts.
+ if !(clip.start + f64::from(MIN_DURATION) < at
+ && at < clip.start + clip.duration - f64::from(MIN_DURATION))
+ {
+ return;
+ }
+ let (edge, delta) = if left {
+ (TrimEdge::Start, at - clip.start)
+ } else {
+ (TrimEdge::End, at - (clip.start + clip.duration))
+ };
+ let follow = left && self.prefs.trim_follow;
+ self.apply(Command::TrimClip {
+ clip_id: clip_id.clone(),
+ edge,
+ delta,
+ ripple: self.prefs.magnetic,
+ });
+ if follow {
+ if let Some(start) = self.clip(&clip_id).map(|clip| clip.start) {
+ self.seek(start as f32);
+ }
+ }
+ }
+
/// Save Video Frame As: the frame under the playhead, drawn at the
/// output's full size rather than the monitor's, written as a PNG
/// where the person says - offered in the project's frames folder -
@@ -10748,6 +10790,10 @@ impl Studio {
TimelineTool::Split
};
}
+ // Q / E: the selected clip's edge jumps to the playhead, taking
+ // the clip's left or its right with it.
+ "cut-left" => self.cut_to_playhead(true),
+ "cut-right" => self.cut_to_playhead(false),
"select-all" => self.select_all(),
// The phone's way out of the clip tools: nothing selected, the
// way a press on an empty lane leaves it.
diff --git a/src/crates/concat/ui/app.slint b/src/crates/concat/ui/app.slint
index c34bfa97..00cd5550 100644
--- a/src/crates/concat/ui/app.slint
+++ b/src/crates/concat/ui/app.slint
@@ -612,6 +612,10 @@ export component App inherits Window {
// editor cuts with. The chord B above splits at the playhead.
// https://github.com/jub0t/Concat/issues/241
if (letter == "b") { Editor.shortcut("split-tool"); return accept; }
+ // Q and E are the big editors' trim keys: the selected clip is
+ // cut at the playhead, Q dropping its left, E its right.
+ if (letter == "q") { Editor.shortcut("cut-left"); return accept; }
+ if (letter == "e") { Editor.shortcut("cut-right"); return accept; }
if (letter == "n") { Editor.shortcut("snap"); return accept; }
if (letter == "s") { Editor.shortcut("preview-axis"); return accept; }
if (letter == "m") { Editor.shortcut("mute"); return accept; }