Skip to content

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

fix(keys): shortcuts work on Windows and Linux, and every label names the keys of the platform it is on

Jareerd561476bf273
diff --git a/src/crates/concat/locales/de.json b/src/crates/concat/locales/de.json
index be6bc52f..7a50cdf7 100644
--- a/src/crates/concat/locales/de.json
+++ b/src/crates/concat/locales/de.json
@@ -966,11 +966,11 @@
"tray.panTool": "Pan tool (H)",
"tray.playerFollowsResizePlayhead": "Wiedergabe folgt dem Kürzen: Der Abspielkopf wandert mit der Kante, die du kürzt",
"tray.previewAxisOptions": "Optionen der Vorschauachse",
- "tray.redo": "Wiederholen (⇧⌘Z)",
- "tray.splitAtPlayhead": "Am Abspielkopf teilen (B, oder ⌘B für jeden Clip)",
+ "tray.redo": "Wiederholen ({0})",
+ "tray.splitAtPlayhead": "Am Abspielkopf teilen (B, oder {0} für jeden Clip)",
"tray.textToSpeech": "Text zu Sprache",
"tray.turnOffPreviewAxis": "Vorschauachse ausschalten (S)",
"tray.turnOnPreviewAxis": "Vorschauachse einschalten (S)",
- "tray.undo": "Rückgängig (⌘Z)",
+ "tray.undo": "Rückgängig ({0})",
"tray.zoomToFit": "Einpassen"
}
diff --git a/src/crates/concat/locales/en.json b/src/crates/concat/locales/en.json
index 6b2b0518..e7e0e987 100644
--- a/src/crates/concat/locales/en.json
+++ b/src/crates/concat/locales/en.json
@@ -966,11 +966,11 @@
"tray.panTool": "Pan tool (H)",
"tray.playerFollowsResizePlayhead": "Player follows the resize: the playhead rides the edge you trim",
"tray.previewAxisOptions": "Preview axis options",
- "tray.redo": "Redo (⇧⌘Z)",
- "tray.splitAtPlayhead": "Split at playhead (B, or ⌘B for every clip)",
+ "tray.redo": "Redo ({0})",
+ "tray.splitAtPlayhead": "Split at playhead (B, or {0} for every clip)",
"tray.textToSpeech": "Text to Speech",
"tray.turnOffPreviewAxis": "Turn off Preview Axis (S)",
"tray.turnOnPreviewAxis": "Turn on Preview Axis (S)",
- "tray.undo": "Undo (⌘Z)",
+ "tray.undo": "Undo ({0})",
"tray.zoomToFit": "Zoom to fit"
}
diff --git a/src/crates/concat/locales/es.json b/src/crates/concat/locales/es.json
index 0ab2c054..353d8718 100644
--- a/src/crates/concat/locales/es.json
+++ b/src/crates/concat/locales/es.json
@@ -966,11 +966,11 @@
"tray.panTool": "Pan tool (H)",
"tray.playerFollowsResizePlayhead": "El reproductor sigue el recorte: el cabezal de reproducción acompaña el borde que recortas",
"tray.previewAxisOptions": "Opciones del eje de previsualización",
- "tray.redo": "Rehacer (⇧⌘Z)",
- "tray.splitAtPlayhead": "Dividir en el cabezal (B, o ⌘B para todos los clips)",
+ "tray.redo": "Rehacer ({0})",
+ "tray.splitAtPlayhead": "Dividir en el cabezal (B, o {0} para todos los clips)",
"tray.textToSpeech": "Texto a voz",
"tray.turnOffPreviewAxis": "Desactivar el eje de previsualización (S)",
"tray.turnOnPreviewAxis": "Activar el eje de previsualización (S)",
- "tray.undo": "Deshacer (⌘Z)",
+ "tray.undo": "Deshacer ({0})",
"tray.zoomToFit": "Ajustar a la vista"
}
diff --git a/src/crates/concat/locales/fa.json b/src/crates/concat/locales/fa.json
index 30d0a4b4..bb0218b6 100644
--- a/src/crates/concat/locales/fa.json
+++ b/src/crates/concat/locales/fa.json
@@ -966,11 +966,11 @@
"tray.panTool": "ابزار Pan (H)",
"tray.playerFollowsResizePlayhead": "پخش‌کننده برش را دنبال می‌کند: نشانگر پخش همراه لبه‌ای که برش می‌دهید حرکت می‌کند",
"tray.previewAxisOptions": "گزینه‌های محور پیش‌نمایش",
- "tray.redo": "انجام مجدد (⇧⌘Z)",
- "tray.splitAtPlayhead": "تقسیم در نشانگر پخش (B، یا ⌘B برای همه کلیپ‌ها)",
+ "tray.redo": "انجام مجدد ({0})",
+ "tray.splitAtPlayhead": "تقسیم در نشانگر پخش (B، یا {0} برای همه کلیپ‌ها)",
"tray.textToSpeech": "تبدیل متن به گفتار",
"tray.turnOffPreviewAxis": "خاموش کردن محور پیش‌نمایش (S)",
"tray.turnOnPreviewAxis": "روشن کردن محور پیش‌نمایش (S)",
- "tray.undo": "واگرد (⌘Z)",
+ "tray.undo": "واگرد ({0})",
"tray.zoomToFit": "بزرگ‌نمایی متناسب"
}
diff --git a/src/crates/concat/locales/fr.json b/src/crates/concat/locales/fr.json
index f50251f9..c2ec47c8 100644
--- a/src/crates/concat/locales/fr.json
+++ b/src/crates/concat/locales/fr.json
@@ -966,11 +966,11 @@
"tray.panTool": "Pan tool (H)",
"tray.playerFollowsResizePlayhead": "Le lecteur suit le rognage : la tête de lecture accompagne le bord que vous rognez",
"tray.previewAxisOptions": "Options de l'axe d'aperçu",
- "tray.redo": "Rétablir (⇧⌘Z)",
- "tray.splitAtPlayhead": "Couper à la tête de lecture (B, ou ⌘B pour tous les clips)",
+ "tray.redo": "Rétablir ({0})",
+ "tray.splitAtPlayhead": "Couper à la tête de lecture (B, ou {0} pour tous les clips)",
"tray.textToSpeech": "Synthèse vocale",
"tray.turnOffPreviewAxis": "Désactiver l'axe d'aperçu (S)",
"tray.turnOnPreviewAxis": "Activer l'axe d'aperçu (S)",
- "tray.undo": "Annuler (⌘Z)",
+ "tray.undo": "Annuler ({0})",
"tray.zoomToFit": "Ajuster à la vue"
}
diff --git a/src/crates/concat/locales/hr.json b/src/crates/concat/locales/hr.json
index 239ce8c3..4d258a54 100644
--- a/src/crates/concat/locales/hr.json
+++ b/src/crates/concat/locales/hr.json
@@ -966,11 +966,11 @@
"tray.panTool": "Pan tool (H)",
"tray.playerFollowsResizePlayhead": "Reprodukcija prati skraćivanje: glava za reprodukciju prati rub koji skraćujete",
"tray.previewAxisOptions": "Mogućnosti osi pregleda",
- "tray.redo": "Ponovi (⇧⌘Z)",
- "tray.splitAtPlayhead": "Podijeli na playheadu (B, ili ⌘B za svaki klip)",
+ "tray.redo": "Ponovi ({0})",
+ "tray.splitAtPlayhead": "Podijeli na playheadu (B, ili {0} za svaki klip)",
"tray.textToSpeech": "Tekst u govor",
"tray.turnOffPreviewAxis": "Isključi os pregleda (S)",
"tray.turnOnPreviewAxis": "Uključi os pregleda (S)",
- "tray.undo": "Poništi (⌘Z)",
+ "tray.undo": "Poništi ({0})",
"tray.zoomToFit": "Povećaj da stane"
}
diff --git a/src/crates/concat/locales/it.json b/src/crates/concat/locales/it.json
index a78b178b..b20050c8 100644
--- a/src/crates/concat/locales/it.json
+++ b/src/crates/concat/locales/it.json
@@ -966,11 +966,11 @@
"tray.panTool": "Pan tool (H)",
"tray.playerFollowsResizePlayhead": "Il player segue l'accorciamento: la testina di riproduzione segue il bordo che accorci",
"tray.previewAxisOptions": "Opzioni dell'asse di anteprima",
- "tray.redo": "Ripeti (⇧⌘Z)",
- "tray.splitAtPlayhead": "Dividi alla testina (B, o ⌘B per tutte le clip)",
+ "tray.redo": "Ripeti ({0})",
+ "tray.splitAtPlayhead": "Dividi alla testina (B, o {0} per tutte le clip)",
"tray.textToSpeech": "Sintesi vocale",
"tray.turnOffPreviewAxis": "Disattiva l'asse di anteprima (S)",
"tray.turnOnPreviewAxis": "Attiva l'asse di anteprima (S)",
- "tray.undo": "Annulla (⌘Z)",
+ "tray.undo": "Annulla ({0})",
"tray.zoomToFit": "Adatta alla vista"
}
diff --git a/src/crates/concat/locales/ja.json b/src/crates/concat/locales/ja.json
index 399a7953..1526948e 100644
--- a/src/crates/concat/locales/ja.json
+++ b/src/crates/concat/locales/ja.json
@@ -966,11 +966,11 @@
"tray.panTool": "Pan tool (H)",
"tray.playerFollowsResizePlayhead": "プレーヤーがトリミングに追従:再生ヘッドがトリミング中の端に合わせて動きます",
"tray.previewAxisOptions": "プレビュー軸のオプション",
- "tray.redo": "やり直す (⇧⌘Z)",
- "tray.splitAtPlayhead": "再生ヘッドで分割 (B、すべてのクリップは ⌘B)",
+ "tray.redo": "やり直す ({0})",
+ "tray.splitAtPlayhead": "再生ヘッドで分割 (B、すべてのクリップは {0})",
"tray.textToSpeech": "テキスト読み上げ",
"tray.turnOffPreviewAxis": "プレビュー軸をオフにする (S)",
"tray.turnOnPreviewAxis": "プレビュー軸をオンにする (S)",
- "tray.undo": "取り消す (⌘Z)",
+ "tray.undo": "取り消す ({0})",
"tray.zoomToFit": "全体を表示"
}
diff --git a/src/crates/concat/locales/ko.json b/src/crates/concat/locales/ko.json
index 505761e8..e4280461 100644
--- a/src/crates/concat/locales/ko.json
+++ b/src/crates/concat/locales/ko.json
@@ -966,11 +966,11 @@
"tray.panTool": "Pan tool (H)",
"tray.playerFollowsResizePlayhead": "플레이어가 다듬기를 따라감: 재생 헤드가 다듬는 가장자리를 따라 움직입니다",
"tray.previewAxisOptions": "미리보기 축 옵션",
- "tray.redo": "다시 실행 (⇧⌘Z)",
- "tray.splitAtPlayhead": "재생 헤드에서 나누기 (B, 모든 클립은 ⌘B)",
+ "tray.redo": "다시 실행 ({0})",
+ "tray.splitAtPlayhead": "재생 헤드에서 나누기 (B, 모든 클립은 {0})",
"tray.textToSpeech": "텍스트 음성 변환",
"tray.turnOffPreviewAxis": "미리보기 축 끄기 (S)",
"tray.turnOnPreviewAxis": "미리보기 축 켜기 (S)",
- "tray.undo": "실행 취소 (⌘Z)",
+ "tray.undo": "실행 취소 ({0})",
"tray.zoomToFit": "화면에 맞추기"
}
diff --git a/src/crates/concat/locales/pt-BR.json b/src/crates/concat/locales/pt-BR.json
index 48c2a568..703bd4dc 100644
--- a/src/crates/concat/locales/pt-BR.json
+++ b/src/crates/concat/locales/pt-BR.json
@@ -966,11 +966,11 @@
"tray.panTool": "Pan tool (H)",
"tray.playerFollowsResizePlayhead": "O player acompanha o corte: a agulha segue a borda que você arrasta",
"tray.previewAxisOptions": "Opções do eixo de prévia",
- "tray.redo": "Refazer (⇧⌘Z)",
- "tray.splitAtPlayhead": "Dividir no cursor (B, ou ⌘B para todos os clipes)",
+ "tray.redo": "Refazer ({0})",
+ "tray.splitAtPlayhead": "Dividir no cursor (B, ou {0} para todos os clipes)",
"tray.textToSpeech": "Texto para fala",
"tray.turnOffPreviewAxis": "Desligar o eixo de prévia (S)",
"tray.turnOnPreviewAxis": "Ligar o eixo de prévia (S)",
- "tray.undo": "Desfazer (⌘Z)",
+ "tray.undo": "Desfazer ({0})",
"tray.zoomToFit": "Ajustar à janela"
}
diff --git a/src/crates/concat/locales/ru.json b/src/crates/concat/locales/ru.json
index 872ca778..401d997e 100644
--- a/src/crates/concat/locales/ru.json
+++ b/src/crates/concat/locales/ru.json
@@ -966,11 +966,11 @@
"tray.panTool": "Инструмент «Рука» (H)",
"tray.playerFollowsResizePlayhead": "Плеер следует за подрезкой: курсор движется вместе с краем, который вы подрезаете",
"tray.previewAxisOptions": "Параметры оси предпросмотра",
- "tray.redo": "Повторить (⇧⌘Z)",
- "tray.splitAtPlayhead": "Разрезать по курсору (B, или ⌘B для всех клипов)",
+ "tray.redo": "Повторить ({0})",
+ "tray.splitAtPlayhead": "Разрезать по курсору (B, или {0} для всех клипов)",
"tray.textToSpeech": "Озвучить текст",
"tray.turnOffPreviewAxis": "Выключить ось предпросмотра (S)",
"tray.turnOnPreviewAxis": "Включить ось предпросмотра (S)",
- "tray.undo": "Отменить (⌘Z)",
+ "tray.undo": "Отменить ({0})",
"tray.zoomToFit": "Вместить"
}
diff --git a/src/crates/concat/locales/tr.json b/src/crates/concat/locales/tr.json
index 9450bf53..2e850bbf 100644
--- a/src/crates/concat/locales/tr.json
+++ b/src/crates/concat/locales/tr.json
@@ -966,11 +966,11 @@
"tray.panTool": "Pan tool (H)",
"tray.playerFollowsResizePlayhead": "Oynatıcı kırpmayı izler: oynatma kafası kırptığınız kenarla birlikte hareket eder",
"tray.previewAxisOptions": "Önizleme ekseni seçenekleri",
- "tray.redo": "Yinele (⇧⌘Z)",
- "tray.splitAtPlayhead": "Playhead konumunda böl (B, her klip için ⌘B)",
+ "tray.redo": "Yinele ({0})",
+ "tray.splitAtPlayhead": "Playhead konumunda böl (B, her klip için {0})",
"tray.textToSpeech": "Metinden konuşmaya",
"tray.turnOffPreviewAxis": "Önizleme eksenini kapat (S)",
"tray.turnOnPreviewAxis": "Önizleme eksenini aç (S)",
- "tray.undo": "Geri al (⌘Z)",
+ "tray.undo": "Geri al ({0})",
"tray.zoomToFit": "Sığdır"
}
diff --git a/src/crates/concat/locales/zh-Hans.json b/src/crates/concat/locales/zh-Hans.json
index 2d7faa58..dc689d54 100644
--- a/src/crates/concat/locales/zh-Hans.json
+++ b/src/crates/concat/locales/zh-Hans.json
@@ -966,11 +966,11 @@
"tray.panTool": "平移工具 (H)",
"tray.playerFollowsResizePlayhead": "播放器跟随修剪:播放头随你修剪的边缘移动",
"tray.previewAxisOptions": "预览坐标轴选项",
- "tray.redo": "重做 (⇧⌘Z)",
- "tray.splitAtPlayhead": "在播放头处分割(B,或用 ⌘B 分割所有片段)",
+ "tray.redo": "重做 ({0})",
+ "tray.splitAtPlayhead": "在播放头处分割(B,或用 {0} 分割所有片段)",
"tray.textToSpeech": "文字转语音",
"tray.turnOffPreviewAxis": "关闭预览坐标轴 (S)",
"tray.turnOnPreviewAxis": "打开预览坐标轴 (S)",
- "tray.undo": "撤销 (⌘Z)",
+ "tray.undo": "撤销 ({0})",
"tray.zoomToFit": "缩放至适合"
}
diff --git a/src/crates/concat/locales/zh-TW.json b/src/crates/concat/locales/zh-TW.json
index a65764b0..10031877 100644
--- a/src/crates/concat/locales/zh-TW.json
+++ b/src/crates/concat/locales/zh-TW.json
@@ -966,11 +966,11 @@
"tray.panTool": "平移工具 (H)",
"tray.playerFollowsResizePlayhead": "播放器跟隨修剪:播放磁頭隨你修剪的邊緣移動",
"tray.previewAxisOptions": "預覽座標軸選項",
- "tray.redo": "重做 (⇧⌘Z)",
- "tray.splitAtPlayhead": "在播放磁頭處分割(B,或用 ⌘B 分割所有片段)",
+ "tray.redo": "重做 ({0})",
+ "tray.splitAtPlayhead": "在播放磁頭處分割(B,或用 {0} 分割所有片段)",
"tray.textToSpeech": "文字轉語音",
"tray.turnOffPreviewAxis": "關閉預覽座標軸 (S)",
"tray.turnOnPreviewAxis": "打開預覽座標軸 (S)",
- "tray.undo": "復原 (⌘Z)",
+ "tray.undo": "復原 ({0})",
"tray.zoomToFit": "縮放至符合大小"
}
diff --git a/src/crates/concat/src/platform.rs b/src/crates/concat/src/platform.rs
index 0fe8142e..3e8333af 100644
--- a/src/crates/concat/src/platform.rs
+++ b/src/crates/concat/src/platform.rs
@@ -304,6 +304,30 @@ pub fn report_startup_failure(error: &str) {
/// where the traffic lights stay the window's.
pub const OWN_WINDOW_BUTTONS: bool = !MACOS;
+/// A shortcut as this platform writes it, from the parts a `@keys` takes:
+/// `["Control", "Shift", "Z"]` reads ⇧⌘Z on a Mac and Ctrl+Shift+Z on
+/// Windows and Linux, because Slint takes `Control` for ⌘ there. The same
+/// parts as the binding in app.slint, so a menu row names the keys that
+/// work on the machine it is shown on.
+pub fn keys(parts: &[&str]) -> String {
+ slint::Keys::from_parts(parts.iter().copied())
+ .map(|keys| keys.to_string())
+ .unwrap_or_default()
+}
+
+/// The delete key as this platform writes it: ⌫ on a Mac, Del elsewhere,
+/// with Shift in front for the ripple delete. Either key deletes
+/// (app.slint); these are the names each platform's own menus use.
+pub fn delete_key(shift: bool) -> String {
+ let apple = cfg!(any(target_os = "macos", target_os = "ios"));
+ match (apple, shift) {
+ (true, false) => "⌫".into(),
+ (true, true) => "⇧⌫".into(),
+ (false, false) => "Del".into(),
+ (false, true) => "Shift+Del".into(),
+ }
+}
+
/// Minimises the window: the strip's first button.
pub fn minimize(window: &slint::Window) {
#[cfg(not(target_os = "android"))]
@@ -503,3 +527,23 @@ pub fn reveal(path: &str) -> Result<(), String> {
))
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ /// A menu row names the keys the way the platform it runs on does:
+ /// the Mac's glyphs there, Ctrl and Shift spelled out everywhere else.
+ #[test]
+ fn shortcuts_read_the_way_the_platform_writes_them() {
+ if cfg!(target_os = "macos") {
+ assert_eq!(keys(&["Control", "Shift", "Z"]), "⇧⌘Z");
+ assert_eq!(keys(&["Control", ","]), "⌘,");
+ assert_eq!(delete_key(true), "⇧⌫");
+ } else {
+ assert_eq!(keys(&["Control", "Shift", "Z"]), "Ctrl+Shift+Z");
+ assert_eq!(keys(&["Control", ","]), "Ctrl+,");
+ assert_eq!(delete_key(true), "Shift+Del");
+ }
+ }
+}
diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rs
index 5225b5cb..d84537d6 100644
--- a/src/crates/concat/src/studio.rs
+++ b/src/crates/concat/src/studio.rs
@@ -60,6 +60,7 @@ use crate::host::{
};
use crate::i18n::{self, t, tf};
use crate::panes::settings::installed;
+use crate::platform;
use crate::prefs::Preferences;
use crate::presets::{self, TextPreset};
use crate::ui::*;
@@ -8464,19 +8465,19 @@ impl Studio {
};
let mut rows = vec![
- action("copy", t("common.copy"), Glyph::Copy, "⌘C", true),
+ action("copy", t("common.copy"), Glyph::Copy, &platform::keys(&["Control", "C"]), true),
action(
"duplicate",
t("studio.duplicate"),
Glyph::Plus,
- "⌘D",
+ &platform::keys(&["Control", "D"]),
!locked,
),
action(
"paste",
t("studio.paste"),
Glyph::Plus,
- "⌘V",
+ &platform::keys(&["Control", "V"]),
self.clipboard.is_some(),
),
rule(),
@@ -8562,7 +8563,7 @@ impl Studio {
label: t("common.delete").into(),
kind: MenuRow::Action,
glyph: Glyph::Trash,
- shortcut: "⌫".into(),
+ shortcut: platform::delete_key(false).into(),
enabled: !locked,
danger: true,
checkable: false,
@@ -8573,7 +8574,7 @@ impl Studio {
label: t("studio.rippleDelete").into(),
kind: MenuRow::Action,
glyph: Glyph::Trash,
- shortcut: "⇧⌫".into(),
+ shortcut: platform::delete_key(true).into(),
enabled: !locked,
danger: true,
checkable: false,
@@ -8742,9 +8743,9 @@ impl Studio {
"",
has_selection_media,
),
- row("open", t("studio.openProject"), Glyph::Import, "⌘O", true),
- row("import", t("studio.importMedia"), Glyph::Import, "⌘I", true),
- row("save", t("studio.save"), Glyph::Import, "⌘S", true),
+ row("open", t("studio.openProject"), Glyph::Import, &platform::keys(&["Control", "O"]), true),
+ row("import", t("studio.importMedia"), Glyph::Import, &platform::keys(&["Control", "I"]), true),
+ row("save", t("studio.save"), Glyph::Import, &platform::keys(&["Control", "S"]), true),
row(
"export",
t("studio.export"),
@@ -8772,7 +8773,7 @@ impl Studio {
"settings",
t("studio.settings"),
Glyph::Settings,
- "⌘,",
+ &platform::keys(&["Control", ","]),
true,
),
rule(),
@@ -8788,7 +8789,7 @@ impl Studio {
label: t("studio.closeWindow").into(),
kind: MenuRow::Action,
glyph: Glyph::Close,
- shortcut: "⌘W".into(),
+ shortcut: platform::keys(&["Control", "W"]).into(),
enabled: true,
danger: true,
checkable: false,
@@ -8796,14 +8797,14 @@ impl Studio {
},
],
1 => vec![
- row("undo", t("studio.undo"), Glyph::Undo, "⌘Z", can_undo),
- row("redo", t("studio.redo"), Glyph::Redo, "⇧⌘Z", can_redo),
+ row("undo", t("studio.undo"), Glyph::Undo, &platform::keys(&["Control", "Z"]), can_undo),
+ row("redo", t("studio.redo"), Glyph::Redo, &platform::keys(&["Control", "Shift", "Z"]), can_redo),
rule(),
row(
"split",
t("studio.splitAtPlayhead"),
Glyph::Razor,
- "⌘B",
+ &platform::keys(&["Control", "B"]),
straddled,
),
MenuItemData {
@@ -8816,7 +8817,7 @@ impl Studio {
.into(),
kind: MenuRow::Action,
glyph: Glyph::Trash,
- shortcut: "⌫".into(),
+ shortcut: platform::delete_key(false).into(),
enabled: selected > 0,
danger: true,
checkable: false,
@@ -8832,7 +8833,7 @@ impl Studio {
.into(),
kind: MenuRow::Action,
glyph: Glyph::Trash,
- shortcut: "⇧⌫".into(),
+ shortcut: platform::delete_key(true).into(),
enabled: selected > 0,
danger: true,
checkable: false,
diff --git a/src/crates/concat/ui/app.slint b/src/crates/concat/ui/app.slint
index 2c2d7ccb..baad13b3 100644
--- a/src/crates/concat/ui/app.slint
+++ b/src/crates/concat/ui/app.slint
@@ -360,7 +360,11 @@ export component App inherits Window {
// rather than from a check on the target.
//
// `Control` in a binding is the platform's own command modifier: Slint
- // remaps it to ⌘ on macOS, which is also what the menu row beside it says.
+ // remaps it to ⌘ on macOS and leaves it Ctrl on Windows and Linux, and
+ // the menu row beside it is written from the same keys (platform.rs,
+ // `keys`), so what a row says is what works on the machine it is on.
+ // Bindings rather than letters compared in `key-pressed`: a binding
+ // matches whatever the case, so Caps Lock does not turn every chord off.
keys := FocusScope {
width: 100%;
height: 100%;
@@ -388,6 +392,80 @@ export component App inherits Window {
enabled: !root.on-start;
activated => { root.app-menu-selected("redo"); }
}
+ // Windows and Linux redo on Ctrl+Y as well; on a Mac ⌘Y is not redo.
+ KeyBinding {
+ keys: @keys(Control + Y);
+ enabled: !root.on-start && !root.macos;
+ activated => { root.app-menu-selected("redo"); }
+ }
+ // Open and Close Window work from the launch screen too: it opens
+ // projects, and it is a window.
+ KeyBinding {
+ keys: @keys(Control + O);
+ activated => { root.app-menu-selected("open"); }
+ }
+ KeyBinding {
+ keys: @keys(Control + W);
+ activated => { root.app-menu-selected("close-window"); }
+ }
+ // The editor's chords, each the shortcut its menu row names.
+ KeyBinding {
+ keys: @keys(Control + B);
+ enabled: !root.on-start;
+ activated => { Editor.shortcut("split"); }
+ }
+ KeyBinding {
+ keys: @keys(Control + A);
+ enabled: !root.on-start;
+ activated => { Editor.shortcut("select-all"); }
+ }
+ KeyBinding {
+ keys: @keys(Control + C);
+ enabled: !root.on-start;
+ activated => { Editor.shortcut("copy"); }
+ }
+ KeyBinding {
+ keys: @keys(Control + V);
+ enabled: !root.on-start;
+ activated => { Editor.shortcut("paste"); }
+ }
+ KeyBinding {
+ keys: @keys(Control + D);
+ enabled: !root.on-start;
+ activated => { Editor.shortcut("duplicate"); }
+ }
+ KeyBinding {
+ keys: @keys(Control + E);
+ enabled: !root.on-start;
+ activated => { Editor.shortcut("export"); }
+ }
+ KeyBinding {
+ keys: @keys(Control + I);
+ enabled: !root.on-start;
+ activated => { Editor.shortcut("import"); }
+ }
+ KeyBinding {
+ keys: @keys(Control + ",");
+ enabled: !root.on-start;
+ activated => { Editor.shortcut("settings"); }
+ }
+ // Zoom in on = as well as +: they share a key on most layouts, and
+ // nobody reaches for Shift to zoom.
+ KeyBinding {
+ keys: @keys(Control + "=");
+ enabled: !root.on-start;
+ activated => { Editor.shortcut("zoom-in"); }
+ }
+ KeyBinding {
+ keys: @keys(Control + Plus);
+ enabled: !root.on-start;
+ activated => { Editor.shortcut("zoom-in"); }
+ }
+ KeyBinding {
+ keys: @keys(Control + "-");
+ enabled: !root.on-start;
+ activated => { Editor.shortcut("zoom-out"); }
+ }
// The rest of the keyboard, laid out the way every editor has
// taught its users: the chord key with a letter for an edit, a
@@ -400,25 +478,10 @@ export component App inherits Window {
if (root.on-start) {
return reject;
}
- // The command key arrives as meta on a Mac and as control
- // everywhere else; either is the chord key.
+ // A chord is the bindings' above; one they did not take is
+ // nobody's, and must not fall through to the bare letters
+ // below - Ctrl+H is not the hand.
if (event.modifiers.control || event.modifiers.meta) {
- if (event.modifiers.shift || event.modifiers.alt) {
- return reject;
- }
- if (event.text == "b") { Editor.shortcut("split"); return accept; }
- if (event.text == "a") { Editor.shortcut("select-all"); return accept; }
- if (event.text == "c") { Editor.shortcut("copy"); return accept; }
- if (event.text == "v") { Editor.shortcut("paste"); return accept; }
- if (event.text == "d") { Editor.shortcut("duplicate"); return accept; }
- if (event.text == "e") { Editor.shortcut("export"); return accept; }
- if (event.text == "i") { Editor.shortcut("import"); return accept; }
- if (event.text == ",") { Editor.shortcut("settings"); return accept; }
- if (event.text == "=" || event.text == "+") {
- Editor.shortcut("zoom-in");
- return accept;
- }
- if (event.text == "-") { Editor.shortcut("zoom-out"); return accept; }
return reject;
}
if (event.modifiers.alt) {
@@ -450,19 +513,21 @@ export component App inherits Window {
if (event.modifiers.shift) {
return reject;
}
+ // Lower-cased, so Caps Lock leaves the letters alone.
+ let letter = event.text.to-lowercase();
// B splits the selected clips at the playhead, or every clip
- // when nothing is selected; ⌘B above splits every clip either
- // way. There was a razor tool on B and this split on S, and
- // the two did the same thing by different pointers.
- if (event.text == "b") { Editor.shortcut("split-selected"); return accept; }
- if (event.text == "n") { Editor.shortcut("snap"); return accept; }
- if (event.text == "s") { Editor.shortcut("preview-axis"); return accept; }
- if (event.text == "m") { Editor.shortcut("mute"); return accept; }
+ // when nothing is selected; the chord B above splits every clip
+ // either way. There was a razor tool on B and this split on S,
+ // and the two did the same thing by different pointers.
+ if (letter == "b") { Editor.shortcut("split-selected"); 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; }
// H is the hand: the pan tool, on and off, the key every
// editor's canvas grabs with. It and J were the flips once;
// flipping is the inspector's and the clip menu's now, and J
// is free.
- if (event.text == "h") { Editor.shortcut("pan"); return accept; }
+ if (letter == "h") { Editor.shortcut("pan"); return accept; }
return reject;
}
diff --git a/src/crates/concat/ui/timeline/tray.slint b/src/crates/concat/ui/timeline/tray.slint
index 43c0bc8d..20881720 100644
--- a/src/crates/concat/ui/timeline/tray.slint
+++ b/src/crates/concat/ui/timeline/tray.slint
@@ -135,14 +135,14 @@ export component TimelineTray inherits Rectangle {
TrayButton {
glyph: Glyph.undo;
- label: I18n.t("tray.undo");
+ label: I18n.t1("tray.undo", @keys(Control + Z).to-string());
icon-size: 16px;
enabled: root.can-undo;
clicked => { root.undo(); }
}
TrayButton {
glyph: Glyph.redo;
- label: I18n.t("tray.redo");
+ label: I18n.t1("tray.redo", @keys(Control + Shift + Z).to-string());
icon-size: 16px;
enabled: root.can-redo;
clicked => { root.redo(); }
@@ -155,7 +155,7 @@ export component TimelineTray inherits Rectangle {
// already where you were looking.
TrayButton {
glyph: Glyph.split;
- label: I18n.t("tray.splitAtPlayhead");
+ label: I18n.t1("tray.splitAtPlayhead", @keys(Control + B).to-string());
icon-size: 16px;
clicked => { root.split(); }
}