Skip to content

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

fix(export): the sheet asks before replacing a file, refuses a name that is not a file's, and no dialog opens under the studio borrow

Jareer9a2e5f201e36
diff --git a/src/crates/concat/locales/de.json b/src/crates/concat/locales/de.json
index 83b248a6..740a71ce 100644
--- a/src/crates/concat/locales/de.json
+++ b/src/crates/concat/locales/de.json
@@ -567,6 +567,7 @@
"export.high": "Hoch",
"export.master": "Master",
"export.mixingAudio": "Ton wird gemischt",
+ "export.nameNeedsToBeAFileName": "Der Name muss ein Dateiname sein: nicht leer und ohne / \\ : * ? \" < > |",
"export.notOnThisDevice": "Nicht auf diesem Gerät",
"export.nothingTimelineExport": "Auf der Zeitleiste gibt es nichts zu exportieren",
"export.nothingToExport": "Nichts zu exportieren",
@@ -574,6 +575,9 @@
"export.playsEverywhere": "Läuft überall",
"export.recommended": "Empfohlen",
"export.renderingVideo": "Video wird gerendert",
+ "export.replace": "Ersetzen",
+ "export.replaceFileMessage": "{0} ist schon da. Der Export ersetzt sie.",
+ "export.replaceFileTitle": "Datei ersetzen?",
"export.resolution": "Auflösung",
"export.screenContent": "Bildschirminhalt",
"export.share": "Teilen",
diff --git a/src/crates/concat/locales/en.json b/src/crates/concat/locales/en.json
index 52293a75..ddf710eb 100644
--- a/src/crates/concat/locales/en.json
+++ b/src/crates/concat/locales/en.json
@@ -567,6 +567,7 @@
"export.high": "High",
"export.master": "Master",
"export.mixingAudio": "Mixing audio",
+ "export.nameNeedsToBeAFileName": "The name has to be a file name: not empty, and none of / \\ : * ? \" < > |",
"export.notOnThisDevice": "Not on this device",
"export.nothingTimelineExport": "There is nothing on the timeline to export",
"export.nothingToExport": "Nothing to export",
@@ -574,6 +575,9 @@
"export.playsEverywhere": "Plays everywhere",
"export.recommended": "Recommended",
"export.renderingVideo": "Rendering video",
+ "export.replace": "Replace",
+ "export.replaceFileMessage": "{0} is already there. Exporting replaces it.",
+ "export.replaceFileTitle": "Replace the file?",
"export.resolution": "Resolution",
"export.screenContent": "Screen content",
"export.share": "Share",
diff --git a/src/crates/concat/locales/es.json b/src/crates/concat/locales/es.json
index 198e0c84..6f1fc84e 100644
--- a/src/crates/concat/locales/es.json
+++ b/src/crates/concat/locales/es.json
@@ -567,6 +567,7 @@
"export.high": "Alta",
"export.master": "Máster",
"export.mixingAudio": "Mezclando el audio",
+ "export.nameNeedsToBeAFileName": "El nombre tiene que ser un nombre de archivo: no vacío y sin / \\ : * ? \" < > |",
"export.notOnThisDevice": "No disponible en este dispositivo",
"export.nothingTimelineExport": "No hay nada en la línea de tiempo que exportar",
"export.nothingToExport": "Nada que exportar",
@@ -574,6 +575,9 @@
"export.playsEverywhere": "Se reproduce en todas partes",
"export.recommended": "Recomendada",
"export.renderingVideo": "Renderizando el vídeo",
+ "export.replace": "Reemplazar",
+ "export.replaceFileMessage": "{0} ya existe. Exportar lo reemplaza.",
+ "export.replaceFileTitle": "¿Reemplazar el archivo?",
"export.resolution": "Resolución",
"export.screenContent": "Contenido de pantalla",
"export.share": "Compartir",
diff --git a/src/crates/concat/locales/fa.json b/src/crates/concat/locales/fa.json
index a70d2546..1dcbb5b5 100644
--- a/src/crates/concat/locales/fa.json
+++ b/src/crates/concat/locales/fa.json
@@ -567,6 +567,7 @@
"export.high": "بالا",
"export.master": "اصلی (Master)",
"export.mixingAudio": "در حال میکس کردن صدا",
+ "export.nameNeedsToBeAFileName": "نام باید نام یک فایل باشد: خالی نباشد و بدون / \\ : * ? \" < > |",
"export.notOnThisDevice": "در این دستگاه نیست",
"export.nothingTimelineExport": "چیزی روی تایم‌لاین برای خروجی گرفتن وجود ندارد",
"export.nothingToExport": "چیزی برای خروجی گرفتن وجود ندارد",
@@ -574,6 +575,9 @@
"export.playsEverywhere": "همه‌جا قابل پخش است",
"export.recommended": "پیشنهادی",
"export.renderingVideo": "در حال رندر کردن ویدئو",
+ "export.replace": "جایگزینی",
+ "export.replaceFileMessage": "{0} از قبل وجود دارد. خروجی گرفتن آن را جایگزین می‌کند.",
+ "export.replaceFileTitle": "فایل جایگزین شود؟",
"export.resolution": "رزولوشن",
"export.screenContent": "محتوای صفحه",
"export.share": "اشتراک‌گذاری",
diff --git a/src/crates/concat/locales/fr.json b/src/crates/concat/locales/fr.json
index 22357e48..92adbad0 100644
--- a/src/crates/concat/locales/fr.json
+++ b/src/crates/concat/locales/fr.json
@@ -567,6 +567,7 @@
"export.high": "Haute",
"export.master": "Master",
"export.mixingAudio": "Mixage de l'audio",
+ "export.nameNeedsToBeAFileName": "Le nom doit être un nom de fichier : non vide et sans / \\ : * ? \" < > |",
"export.notOnThisDevice": "Pas sur cet appareil",
"export.nothingTimelineExport": "Il n'y a rien à exporter sur la timeline",
"export.nothingToExport": "Rien à exporter",
@@ -574,6 +575,9 @@
"export.playsEverywhere": "Lisible partout",
"export.recommended": "Recommandée",
"export.renderingVideo": "Rendu de la vidéo",
+ "export.replace": "Remplacer",
+ "export.replaceFileMessage": "{0} existe déjà. L’export le remplace.",
+ "export.replaceFileTitle": "Remplacer le fichier ?",
"export.resolution": "Résolution",
"export.screenContent": "Contenu d'écran",
"export.share": "Partage",
diff --git a/src/crates/concat/locales/hr.json b/src/crates/concat/locales/hr.json
index 1edcc670..413716f1 100644
--- a/src/crates/concat/locales/hr.json
+++ b/src/crates/concat/locales/hr.json
@@ -567,6 +567,7 @@
"export.high": "Visoko",
"export.master": "Master",
"export.mixingAudio": "Miksanje zvuka",
+ "export.nameNeedsToBeAFileName": "Naziv mora biti naziv datoteke: ne prazan i bez / \\ : * ? \" < > |",
"export.notOnThisDevice": "Nije na ovom uređaju",
"export.nothingTimelineExport": "Na vremenskoj liniji nema ničega za izvoz",
"export.nothingToExport": "Ništa za izvoz",
@@ -574,6 +575,9 @@
"export.playsEverywhere": "Radi svugdje",
"export.recommended": "Preporučeno",
"export.renderingVideo": "Renderiranje videa",
+ "export.replace": "Zamijeni",
+ "export.replaceFileMessage": "{0} već postoji. Izvoz će je zamijeniti.",
+ "export.replaceFileTitle": "Zamijeniti datoteku?",
"export.resolution": "Rezolucija",
"export.screenContent": "Sadržaj zaslona",
"export.share": "Podijeli",
diff --git a/src/crates/concat/locales/it.json b/src/crates/concat/locales/it.json
index 851f471c..1a9fc113 100644
--- a/src/crates/concat/locales/it.json
+++ b/src/crates/concat/locales/it.json
@@ -567,6 +567,7 @@
"export.high": "Alta",
"export.master": "Master",
"export.mixingAudio": "Mixaggio dell'audio",
+ "export.nameNeedsToBeAFileName": "Il nome deve essere un nome di file: non vuoto e senza / \\ : * ? \" < > |",
"export.notOnThisDevice": "Non su questo dispositivo",
"export.nothingTimelineExport": "Non c'è nulla sulla timeline da esportare",
"export.nothingToExport": "Niente da esportare",
@@ -574,6 +575,9 @@
"export.playsEverywhere": "Si riproduce ovunque",
"export.recommended": "Consigliata",
"export.renderingVideo": "Rendering del video",
+ "export.replace": "Sostituisci",
+ "export.replaceFileMessage": "{0} esiste già. L’esportazione lo sostituisce.",
+ "export.replaceFileTitle": "Sostituire il file?",
"export.resolution": "Risoluzione",
"export.screenContent": "Contenuto dello schermo",
"export.share": "Condivisione",
diff --git a/src/crates/concat/locales/ja.json b/src/crates/concat/locales/ja.json
index ffa12c23..d805ceed 100644
--- a/src/crates/concat/locales/ja.json
+++ b/src/crates/concat/locales/ja.json
@@ -567,6 +567,7 @@
"export.high": "高",
"export.master": "マスター",
"export.mixingAudio": "オーディオをミックス中",
+ "export.nameNeedsToBeAFileName": "名前はファイル名にしてください。空にせず、/ \\ : * ? \" < > | は使えません",
"export.notOnThisDevice": "このデバイスでは使用不可",
"export.nothingTimelineExport": "タイムラインに書き出すものがありません",
"export.nothingToExport": "書き出すものがありません",
@@ -574,6 +575,9 @@
"export.playsEverywhere": "どこでも再生可能",
"export.recommended": "推奨",
"export.renderingVideo": "映像をレンダリング中",
+ "export.replace": "置き換える",
+ "export.replaceFileMessage": "{0} はすでにあります。書き出すと置き換えられます。",
+ "export.replaceFileTitle": "ファイルを置き換えますか?",
"export.resolution": "解像度",
"export.screenContent": "画面収録",
"export.share": "共有",
diff --git a/src/crates/concat/locales/ko.json b/src/crates/concat/locales/ko.json
index c3ef845c..a6ae16f6 100644
--- a/src/crates/concat/locales/ko.json
+++ b/src/crates/concat/locales/ko.json
@@ -567,6 +567,7 @@
"export.high": "높음",
"export.master": "마스터",
"export.mixingAudio": "오디오 믹싱 중",
+ "export.nameNeedsToBeAFileName": "이름은 파일 이름이어야 합니다. 비워 둘 수 없고 / \\ : * ? \" < > | 는 쓸 수 없습니다",
"export.notOnThisDevice": "이 기기에서 사용 불가",
"export.nothingTimelineExport": "타임라인에 내보낼 것이 없습니다",
"export.nothingToExport": "내보낼 것이 없습니다",
@@ -574,6 +575,9 @@
"export.playsEverywhere": "어디서나 재생",
"export.recommended": "권장",
"export.renderingVideo": "영상 렌더링 중",
+ "export.replace": "바꾸기",
+ "export.replaceFileMessage": "{0} 이(가) 이미 있습니다. 내보내면 바뀝니다.",
+ "export.replaceFileTitle": "파일을 바꿀까요?",
"export.resolution": "해상도",
"export.screenContent": "화면 콘텐츠",
"export.share": "공유",
diff --git a/src/crates/concat/locales/pt-BR.json b/src/crates/concat/locales/pt-BR.json
index 4d1f7077..6c4cabbc 100644
--- a/src/crates/concat/locales/pt-BR.json
+++ b/src/crates/concat/locales/pt-BR.json
@@ -567,6 +567,7 @@
"export.high": "Alta",
"export.master": "Master",
"export.mixingAudio": "Mixando o áudio",
+ "export.nameNeedsToBeAFileName": "O nome precisa ser um nome de arquivo: não vazio e sem / \\ : * ? \" < > |",
"export.notOnThisDevice": "Indisponível neste dispositivo",
"export.nothingTimelineExport": "Não há nada na linha do tempo para exportar",
"export.nothingToExport": "Nada para exportar",
@@ -574,6 +575,9 @@
"export.playsEverywhere": "Reproduz em qualquer lugar",
"export.recommended": "Recomendada",
"export.renderingVideo": "Renderizando o vídeo",
+ "export.replace": "Substituir",
+ "export.replaceFileMessage": "{0} já existe. Exportar o substitui.",
+ "export.replaceFileTitle": "Substituir o arquivo?",
"export.resolution": "Resolução",
"export.screenContent": "Conteúdo de tela",
"export.share": "Compartilhar",
diff --git a/src/crates/concat/locales/ru.json b/src/crates/concat/locales/ru.json
index d4e22563..067ea8c3 100644
--- a/src/crates/concat/locales/ru.json
+++ b/src/crates/concat/locales/ru.json
@@ -567,6 +567,7 @@
"export.high": "Высокое",
"export.master": "Мастер",
"export.mixingAudio": "Сведение звука",
+ "export.nameNeedsToBeAFileName": "Имя должно быть именем файла: не пустым и без / \\ : * ? \" < > |",
"export.notOnThisDevice": "Недоступно на этом устройстве",
"export.nothingTimelineExport": "На таймлайне нечего экспортировать",
"export.nothingToExport": "Нечего экспортировать",
@@ -574,6 +575,9 @@
"export.playsEverywhere": "Воспроизводится везде",
"export.recommended": "Рекомендуется",
"export.renderingVideo": "Рендеринг видео",
+ "export.replace": "Заменить",
+ "export.replaceFileMessage": "{0} уже есть. Экспорт заменит его.",
+ "export.replaceFileTitle": "Заменить файл?",
"export.resolution": "Разрешение",
"export.screenContent": "Содержимое экрана",
"export.share": "Для отправки",
diff --git a/src/crates/concat/locales/tr.json b/src/crates/concat/locales/tr.json
index 48af63a8..cf91118c 100644
--- a/src/crates/concat/locales/tr.json
+++ b/src/crates/concat/locales/tr.json
@@ -567,6 +567,7 @@
"export.high": "Yüksek",
"export.master": "Master",
"export.mixingAudio": "Ses karıştırılıyor",
+ "export.nameNeedsToBeAFileName": "Ad bir dosya adı olmalı: boş olmamalı ve / \\ : * ? \" < > | içermemeli",
"export.notOnThisDevice": "Bu cihazda yok",
"export.nothingTimelineExport": "Zaman çizelgesinde dışa aktarılacak bir şey yok",
"export.nothingToExport": "Dışa aktarılacak bir şey yok",
@@ -574,6 +575,9 @@
"export.playsEverywhere": "Her yerde oynatılır",
"export.recommended": "Önerilen",
"export.renderingVideo": "Video işleniyor",
+ "export.replace": "Değiştir",
+ "export.replaceFileMessage": "{0} zaten var. Dışa aktarma onu değiştirir.",
+ "export.replaceFileTitle": "Dosya değiştirilsin mi?",
"export.resolution": "Çözünürlük",
"export.screenContent": "Ekran içeriği",
"export.share": "Paylaşım",
diff --git a/src/crates/concat/locales/zh-Hans.json b/src/crates/concat/locales/zh-Hans.json
index c16ed932..7cdd5429 100644
--- a/src/crates/concat/locales/zh-Hans.json
+++ b/src/crates/concat/locales/zh-Hans.json
@@ -567,6 +567,7 @@
"export.high": "高",
"export.master": "母版",
"export.mixingAudio": "正在混合音频",
+ "export.nameNeedsToBeAFileName": "名称必须是文件名:不能为空,也不能含有 / \\ : * ? \" < > |",
"export.notOnThisDevice": "此设备不支持",
"export.nothingTimelineExport": "时间线上没有可导出的内容",
"export.nothingToExport": "没有可导出的内容",
@@ -574,6 +575,9 @@
"export.playsEverywhere": "随处可播",
"export.recommended": "推荐",
"export.renderingVideo": "正在渲染视频",
+ "export.replace": "替换",
+ "export.replaceFileMessage": "{0} 已经存在。导出会将其替换。",
+ "export.replaceFileTitle": "替换文件?",
"export.resolution": "分辨率",
"export.screenContent": "屏幕内容",
"export.share": "分享",
diff --git a/src/crates/concat/locales/zh-TW.json b/src/crates/concat/locales/zh-TW.json
index 3e0bd005..aadeb5b0 100644
--- a/src/crates/concat/locales/zh-TW.json
+++ b/src/crates/concat/locales/zh-TW.json
@@ -567,6 +567,7 @@
"export.high": "高",
"export.master": "母帶",
"export.mixingAudio": "正在混合音訊",
+ "export.nameNeedsToBeAFileName": "名稱必須是檔案名稱:不能為空,也不能含有 / \\ : * ? \" < > |",
"export.notOnThisDevice": "此裝置不支援",
"export.nothingTimelineExport": "時間軸上沒有可匯出的內容",
"export.nothingToExport": "沒有可匯出的內容",
@@ -574,6 +575,9 @@
"export.playsEverywhere": "隨處可播",
"export.recommended": "推薦",
"export.renderingVideo": "正在渲染影片",
+ "export.replace": "取代",
+ "export.replaceFileMessage": "{0} 已經存在。匯出會將其取代。",
+ "export.replaceFileTitle": "取代檔案?",
"export.resolution": "解析度",
"export.screenContent": "螢幕內容",
"export.share": "分享",
diff --git a/src/crates/concat/src/host.rs b/src/crates/concat/src/host.rs
index ac2c7098..f8770a41 100644
--- a/src/crates/concat/src/host.rs
+++ b/src/crates/concat/src/host.rs
@@ -337,6 +337,36 @@ pub fn on_ui_in_project(
on_ui_gated(Some(epoch), body);
}
+/// Asks a native dialog on the event-loop thread with the studio
+/// unborrowed, and hands its answer to `then` with the studio borrowed,
+/// publishing after. For every file and folder dialog.
+///
+/// A dialog blocks, and on macOS it pumps Slint's timers while it is up;
+/// the transport timer and the meters both `borrow_mut` the studio. A
+/// dialog opened inside a handler, where the studio is already borrowed
+/// for the handler's whole run, was a `BorrowMutError` the moment a timer
+/// fired under it - Export › Browse while playing (audit 2026-10-09,
+/// finding 6). Here `ask` runs on its own turn of the loop before anything
+/// is borrowed, and nothing is published for an answer of `None`: a
+/// cancelled dialog changed nothing.
+pub fn after_dialog<T: Send + 'static>(
+ ask: impl FnOnce() -> Option<T> + Send + 'static,
+ then: impl FnOnce(&mut Studio, &App, &Models, T) + Send + 'static,
+) {
+ let _ = slint::invoke_from_event_loop(move || {
+ let Some(answer) = ask() else {
+ return;
+ };
+ Shell::with(|shell, app| {
+ {
+ let mut studio = shell.studio.borrow_mut();
+ then(&mut studio, &app, &shell.models, answer);
+ }
+ shell.studio.borrow().publish(&app, &shell.models);
+ });
+ });
+}
+
fn on_ui_gated(epoch: Option<u64>, body: impl FnOnce(&mut Studio, &App, &Models) + Send + 'static) {
let _ = slint::invoke_from_event_loop(move || {
Shell::with(|shell, app| {
diff --git a/src/crates/concat/src/panes/export.rs b/src/crates/concat/src/panes/export.rs
index 46a7c345..33a5e9f9 100644
--- a/src/crates/concat/src/panes/export.rs
+++ b/src/crates/concat/src/panes/export.rs
@@ -54,9 +54,13 @@ pub enum ExportMsg {
Again,
/// Pick the destination folder.
Browse,
+ /// The folder the picker answered with.
+ FolderChosen(String),
/// Show the finished file in the file manager.
Reveal,
Start,
+ /// Start over a file already there: the confirmation sheet's answer.
+ Overwrite,
Cancel,
/// The render's worker reporting where it is.
Progress {
@@ -187,13 +191,21 @@ impl ExportPane {
self.phase = ExportPhase::Idle;
self.progress = 0.0;
}
+ // The picker runs with the studio unborrowed and answers as a
+ // message of its own; see `host::after_dialog`.
ExportMsg::Browse => {
- if let Some(folder) =
- platform::pick_folder(&i18n::t("export.exportTo"), &self.folder)
- {
- self.folder = folder.to_string_lossy().into_owned();
- }
+ let title = i18n::t("export.exportTo");
+ let current = self.folder.clone();
+ crate::host::after_dialog(
+ move || platform::pick_folder(&title, &current),
+ |studio, _, _, folder| {
+ studio.handle(Msg::Export(ExportMsg::FolderChosen(
+ folder.to_string_lossy().into_owned(),
+ )));
+ },
+ );
}
+ ExportMsg::FolderChosen(folder) => self.folder = folder,
ExportMsg::Reveal => {
if !self.written.is_empty()
&& let Err(error) = platform::reveal(&self.written)
@@ -202,6 +214,7 @@ impl ExportPane {
}
}
ExportMsg::Start => self.start(studio),
+ ExportMsg::Overwrite => self.begin(studio, true),
ExportMsg::Cancel => {
studio.host.exporter.cancel();
self.phase = ExportPhase::Idle;
@@ -406,16 +419,40 @@ impl ExportPane {
}
}
- /// Starts the render on a worker. Its reports come back as messages.
+ /// Starts the render on a worker, once the name is a file's and no
+ /// file is already there; its reports come back as messages.
fn start(&mut self, studio: &mut Studio) {
- let Some(session) = studio.session.as_ref() else {
+ self.begin(studio, false);
+ }
+
+ /// [`ExportPane::start`], with `overwrite` saying the person has
+ /// answered the sheet that asked about the file already there.
+ fn begin(&mut self, studio: &mut Studio, overwrite: bool) {
+ if studio.session.is_none() {
return;
- };
+ }
if studio.timeline().clips.is_empty() {
self.phase = ExportPhase::Failed;
self.message = t("export.nothingTimelineExport");
return;
}
+ // The name is a file's, or the sheet says what is wrong with it: an
+ // empty one wrote a hidden `.mp4`, and a slash made folders (audit
+ // 2026-10-09, finding 7).
+ let Some(name) = file_name(&self.name) else {
+ self.phase = ExportPhase::Failed;
+ self.message = t("export.nameNeedsToBeAFileName");
+ return;
+ };
+ let output = format!("{}/{name}.mp4", self.folder.trim_end_matches('/'));
+ // A file already there is replaced once the person has said so:
+ // the confirmation sheet asks, and its answer comes back as
+ // `Overwrite`. Nothing is written until then; the engine renders
+ // beside the file and renames over it at the end.
+ if !overwrite && std::path::Path::new(&output).exists() {
+ studio.confirm = Some(crate::studio::Confirm::ReplaceExport { path: output });
+ return;
+ }
let job = match studio.host.exporter.begin() {
Ok(job) => job,
Err(error) => {
@@ -424,11 +461,9 @@ impl ExportPane {
return;
}
};
- let output = format!(
- "{}/{}.mp4",
- self.folder.trim_end_matches('/'),
- self.name.trim()
- );
+ let Some(session) = studio.session.as_ref() else {
+ return;
+ };
let spec = ExportSpec {
output: output.clone(),
crf: EXPORT_CRF[self.quality.min(2)],
@@ -520,9 +555,14 @@ impl ExportPane {
name: self.name.as_str().into(),
// Where the file ends up: on a phone, the folder its gallery
// shows, not the app's own that the export writes into.
+ // The name as it will be written: trimmed, as `begin` trims it.
path: match platform::published_folder() {
- Some(folder) => format!("{folder}/{}.mp4", self.name),
- None => format!("{}/{}.mp4", self.folder.trim_end_matches('/'), self.name),
+ Some(folder) => format!("{folder}/{}.mp4", self.name.trim()),
+ None => format!(
+ "{}/{}.mp4",
+ self.folder.trim_end_matches('/'),
+ self.name.trim()
+ ),
}
.into(),
format: format!("{width} × {height} · {rate:.2} fps").into(),
@@ -654,10 +694,39 @@ impl ExportPane {
}
}
+/// The typed name as the file's, or `None` for one that cannot be: empty
+/// once trimmed, a dot or two, or holding a character no file system
+/// here takes. The set is Windows' - a slash and a backslash, the colon,
+/// the quote and the wildcards, the angle brackets and the bar - on every
+/// platform, so a project's export is named the same wherever it is
+/// opened; a control character is refused with them.
+fn file_name(typed: &str) -> Option<String> {
+ let name = typed.trim();
+ if name.is_empty() || name.chars().all(|c| c == '.') {
+ return None;
+ }
+ let refused = |c: char| c.is_control() || r#"/\:*?"<>|"#.contains(c);
+ (!name.chars().any(refused)).then(|| name.to_owned())
+}
+
#[cfg(test)]
mod tests {
use super::*;
+ /// A name is a file's or the export does not start: trimmed, never
+ /// empty, never a path, and none of the characters Windows refuses.
+ #[test]
+ fn the_file_name_is_a_file_name() {
+ assert_eq!(file_name(" My cut "), Some("My cut".to_owned()));
+ assert_eq!(file_name("cut.final"), Some("cut.final".to_owned()));
+ assert_eq!(file_name("Ünïcödé 日本"), Some("Ünïcödé 日本".to_owned()));
+ for bad in [
+ "", " ", ".", "..", "a/b", r"a\b", "c:d", "a?b", "<a>", "a|b", "a\"b", "a*", "a\tb",
+ ] {
+ assert_eq!(file_name(bad), None, "{bad:?}");
+ }
+ }
+
/// The timeline's rate leads the list and is not offered twice; the
/// NTSC fractions keep their camera names.
#[test]
diff --git a/src/crates/concat/src/panes/relink.rs b/src/crates/concat/src/panes/relink.rs
index 0beed484..c9c843dd 100644
--- a/src/crates/concat/src/panes/relink.rs
+++ b/src/crates/concat/src/panes/relink.rs
@@ -23,6 +23,8 @@ pub enum RelinkMsg {
Show(Vec<MissingMedia>),
/// Pick a folder and look for every missing file inside it.
RelinkAll,
+ /// The folder the picker answered with: look inside it.
+ RelinkIn(PathBuf),
Dismiss,
}
@@ -42,21 +44,27 @@ impl RelinkPane {
self.open = true;
self.items = items;
}
- RelinkMsg::RelinkAll => self.relink_all(studio),
+ // The picker runs with the studio unborrowed and answers as a
+ // message of its own; see `host::after_dialog`.
+ RelinkMsg::RelinkAll => {
+ let title = t("relink.selectFolderContainingMedia");
+ crate::host::after_dialog(
+ move || platform::pick_folder(&title, ""),
+ |studio, _, _, folder| {
+ studio.handle(crate::panes::Msg::Relink(RelinkMsg::RelinkIn(folder)));
+ },
+ );
+ }
+ RelinkMsg::RelinkIn(folder) => self.relink_in(studio, folder),
RelinkMsg::Dismiss => self.open = false,
}
}
- /// Relinks missing media by searching a folder (recursively) for files
- /// whose basename matches. The user picks one folder; each missing item
- /// looks for its own filename inside it. Successful relinks go through
- /// the editor as `UpdateMediaPath`, so undo covers the whole batch.
- fn relink_all(&mut self, studio: &mut Studio) {
- let Some(folder) = platform::pick_folder(&t("relink.selectFolderContainingMedia"), "")
- else {
- return;
- };
-
+ /// Relinks missing media by searching `folder` (recursively) for files
+ /// whose basename matches: each missing item looks for its own filename
+ /// inside it. Successful relinks go through the editor as
+ /// `UpdateMediaPath`, so undo covers the whole batch.
+ fn relink_in(&mut self, studio: &mut Studio, folder: PathBuf) {
// Snapshot the missing list now: as relinks land the list shrinks,
// and we want a stable target for the toast count.
let items: Vec<(String, String)> = self
diff --git a/src/crates/concat/src/panes/start.rs b/src/crates/concat/src/panes/start.rs
index c7c0b1c6..13244854 100644
--- a/src/crates/concat/src/panes/start.rs
+++ b/src/crates/concat/src/panes/start.rs
@@ -35,6 +35,8 @@ pub enum StartMsg {
DismissError,
/// Pick where the project folder goes.
Browse,
+ /// The folder the picker answered with.
+ FolderChosen(String),
Create,
/// Open a project that already exists, picked from disk.
Open,
@@ -139,13 +141,21 @@ impl StartPane {
}
StartMsg::CustomFps(fps) => self.custom_rate = custom_rate(f64::from(fps)),
StartMsg::DismissError => self.error.clear(),
+ // The picker runs with the studio unborrowed and answers as a
+ // message of its own; see `host::after_dialog`.
StartMsg::Browse => {
- if let Some(folder) =
- platform::pick_folder(&t("start.whereShouldProjectFolder"), &self.location)
- {
- self.location = folder.to_string_lossy().into_owned();
- }
+ let title = t("start.whereShouldProjectFolder");
+ let current = self.location.clone();
+ crate::host::after_dialog(
+ move || platform::pick_folder(&title, &current),
+ |studio, _, _, folder| {
+ studio.handle(crate::panes::Msg::Start(StartMsg::FolderChosen(
+ folder.to_string_lossy().into_owned(),
+ )));
+ },
+ );
}
+ StartMsg::FolderChosen(folder) => self.location = folder,
StartMsg::Create => self.create(studio),
StartMsg::Open => self.open(studio),
// Both of the grid's verbs report through the toast, as Open
diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rs
index 6b057534..53ea82a7 100644
--- a/src/crates/concat/src/studio.rs
+++ b/src/crates/concat/src/studio.rs
@@ -1880,6 +1880,8 @@ fn few(names: &[String]) -> String {
pub enum Confirm {
/// Deleting a whole track, and every clip on it.
RemoveTrack { track_id: String },
+ /// Exporting over a file that is already at `path`.
+ ReplaceExport { path: String },
}
/// Each rewritten link as "Old → New", the new one by its package's name.
@@ -2109,8 +2111,16 @@ impl Studio {
/// The confirmation sheet's answer: go ahead with what it asked about.
pub fn confirm_accepted(&mut self) {
- if let Some(Confirm::RemoveTrack { track_id }) = self.confirm.take() {
- self.apply(Command::RemoveTrack { track_id });
+ match self.confirm.take() {
+ Some(Confirm::RemoveTrack { track_id }) => {
+ self.apply(Command::RemoveTrack { track_id });
+ }
+ Some(Confirm::ReplaceExport { .. }) => {
+ self.handle(crate::panes::Msg::Export(
+ crate::panes::export::ExportMsg::Overwrite,
+ ));
+ }
+ None => {}
}
}
@@ -2139,6 +2149,12 @@ impl Studio {
action: t("common.delete").into(),
}
}
+ Confirm::ReplaceExport { path } => crate::ui::ConfirmData {
+ open: true,
+ title: t("export.replaceFileTitle").into(),
+ message: tf("export.replaceFileMessage", &[path]).into(),
+ action: t("export.replace").into(),
+ },
}
}
@@ -5757,33 +5773,39 @@ impl Studio {
// through a timer, and a blocking dialog opened inside a timer's
// callback spins the loop back into Slint's timers - "Recursion in
// timer code", and the app aborts (on macOS; Windows and Linux
- // were spared only by their dialogs not pumping the loop).
+ // were spared only by their dialogs not pumping the loop). And
+ // with the studio unborrowed, for the timers that borrow it; see
+ // `host::after_dialog`.
let name = clip.name.clone();
let title = t("lib.exportAudio");
let family = t("lib.wavAudio");
- crate::host::on_ui(move |studio, _, _| {
- let file = if cfg!(any(target_os = "android", target_os = "ios")) {
- out_dir.join(&suggested)
- } else {
- let Some(chosen) = crate::platform::save_file(
+ let ask_in = out_dir.clone();
+ crate::host::after_dialog(
+ move || {
+ if cfg!(any(target_os = "android", target_os = "ios")) {
+ return Some(ask_in.join(&suggested));
+ }
+ let chosen = crate::platform::save_file(
&title,
- &out_dir,
+ &ask_in,
&suggested,
(family.as_str(), &["wav"]),
- ) else {
- return;
- };
- if chosen
- .extension()
- .is_some_and(|ext| ext.eq_ignore_ascii_case("wav"))
- {
- chosen
- } else {
- chosen.with_extension("wav")
- }
- };
- studio.write_clip_audio(&name, pieces, duration, file, out_dir);
- });
+ )?;
+ Some(
+ if chosen
+ .extension()
+ .is_some_and(|ext| ext.eq_ignore_ascii_case("wav"))
+ {
+ chosen
+ } else {
+ chosen.with_extension("wav")
+ },
+ )
+ },
+ move |studio, _, _, file| {
+ studio.write_clip_audio(&name, pieces, duration, file, out_dir);
+ },
+ );
}
/// Mixes `pieces` - one clip's sound, `duration` seconds of it - into
@@ -6357,69 +6379,73 @@ impl Studio {
);
let title = t("lib.saveFrame");
let family = t("lib.pngImage");
- crate::host::on_ui(move |studio, _, _| {
- let file = if cfg!(any(target_os = "android", target_os = "ios")) {
- out_dir.join(&suggested)
- } else {
- let Some(chosen) = crate::platform::save_file(
+ // With the studio unborrowed too; see `host::after_dialog`.
+ crate::host::after_dialog(
+ move || {
+ if cfg!(any(target_os = "android", target_os = "ios")) {
+ return Some(out_dir.join(&suggested));
+ }
+ let chosen = crate::platform::save_file(
&title,
&out_dir,
&suggested,
(family.as_str(), &["png"]),
- ) else {
- return;
- };
- if chosen
- .extension()
- .is_some_and(|ext| ext.eq_ignore_ascii_case("png"))
- {
- chosen
- } else {
- chosen.with_extension("png")
- }
- };
- let written = file.to_string_lossy().into_owned();
- studio.notify(&t("studio.savingFrame"), false);
- spawn_in_project(
- move || -> Result<concat_host::media::MediaSummary, String> {
- let pixels = monitor.frame(clips, &settings, spec)?;
- let image = image::RgbaImage::from_raw(width, height, pixels)
- .ok_or_else(|| "the frame came back the wrong size".to_owned())?;
- if let Some(parent) = file.parent() {
- std::fs::create_dir_all(parent).map_err(|error| {
- format!("could not create {}: {error}", parent.display())
- })?;
- }
- image.save(&file).map_err(|error| error.to_string())?;
- concat_host::media::probe(&file.to_string_lossy())
- },
- move |studio, _, _, result| match result {
- Ok(summary) => {
- let item = summary.to_new_media();
- let path = item.path.clone();
- let minted = studio.apply(Command::AddMedia { item }).or_else(|| {
- studio
- .project()
- .media
- .iter()
- .find(|item| item.path == path)
- .map(|item| item.id.clone())
- });
- studio.media.filter = MediaFilter::All;
- studio.media.selected.clear();
- if let Some(id) = minted {
- studio.media.selected.insert(id);
+ )?;
+ Some(
+ if chosen
+ .extension()
+ .is_some_and(|ext| ext.eq_ignore_ascii_case("png"))
+ {
+ chosen
+ } else {
+ chosen.with_extension("png")
+ },
+ )
+ },
+ move |studio, _, _, file| {
+ let written = file.to_string_lossy().into_owned();
+ studio.notify(&t("studio.savingFrame"), false);
+ spawn_in_project(
+ move || -> Result<concat_host::media::MediaSummary, String> {
+ let pixels = monitor.frame(clips, &settings, spec)?;
+ let image = image::RgbaImage::from_raw(width, height, pixels)
+ .ok_or_else(|| "the frame came back the wrong size".to_owned())?;
+ if let Some(parent) = file.parent() {
+ std::fs::create_dir_all(parent).map_err(|error| {
+ format!("could not create {}: {error}", parent.display())
+ })?;
}
- studio.media_jump += 1;
- studio.notify(&tf("studio.frameSaved", &[&written]), false);
- }
- Err(error) => {
- log::warn!("save frame: {error}");
- studio.notify(&tf("studio.couldNotSaveFrame", &[&error]), true);
- }
- },
- );
- });
+ image.save(&file).map_err(|error| error.to_string())?;
+ concat_host::media::probe(&file.to_string_lossy())
+ },
+ move |studio, _, _, result| match result {
+ Ok(summary) => {
+ let item = summary.to_new_media();
+ let path = item.path.clone();
+ let minted = studio.apply(Command::AddMedia { item }).or_else(|| {
+ studio
+ .project()
+ .media
+ .iter()
+ .find(|item| item.path == path)
+ .map(|item| item.id.clone())
+ });
+ studio.media.filter = MediaFilter::All;
+ studio.media.selected.clear();
+ if let Some(id) = minted {
+ studio.media.selected.insert(id);
+ }
+ studio.media_jump += 1;
+ studio.notify(&tf("studio.frameSaved", &[&written]), false);
+ }
+ Err(error) => {
+ log::warn!("save frame: {error}");
+ studio.notify(&tf("studio.couldNotSaveFrame", &[&error]), true);
+ }
+ },
+ );
+ },
+ );
}
/// The volume line on clip `id` dragged to `gain`: written the way the