The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.
Rust ffmpegfree-video-editormodel-context-protocolnon-linear-editoroffline-firstopen-source-video-editorself-hostedvideo-editingvideo-editing-automationvideo-editing-softwarevideo-editing-toolsvideo-editorvoice-cloningyoutube-automationyoutube-shorts
refactor(ui): the relink dialog, the project sheet and the launch form are panes
Jareer7cc2f34a9274
diff --git a/src/crates/concat/src/lib.rs b/src/crates/concat/src/lib.rsindex 4b24ba19..fcbb2ffb 100644--- a/src/crates/concat/src/lib.rs+++ b/src/crates/concat/src/lib.rs@@ -53,8 +53,11 @@ use host::{Host, Shell, on_ui};use panes::Msg;use panes::captions::CaptionsMsg;use panes::export::ExportMsg;+use panes::project::ProjectMsg;+use panes::relink::RelinkMsg;use panes::settings::SettingsMsg;use panes::speech::SpeechMsg;+use panes::start::StartMsg;use studio::{Models, OUTPUTS, RESOLUTIONS, START_RATES, Studio};use ui::*;@@ -320,36 +323,31 @@ pub fn run() -> Result<(), slint::PlatformError> {// ── the launch screen ──app.on_start_name_edited(on_window!(|state, name: SharedString| {- state.start.name = name.to_string();+ state.handle(Msg::Start(StartMsg::NameEdited(name.to_string())));}));app.on_start_location_edited(on_window!(|state, path: SharedString| {- state.start.location = path.to_string();+ state.handle(Msg::Start(StartMsg::LocationEdited(path.to_string())));}));app.on_start_resolution_changed(on_window!(|state, index: i32| {- state.start.resolution = (index.max(0) as usize).min(RESOLUTIONS.len() - 1);+ state.handle(Msg::Start(StartMsg::ResolutionChanged(index)));}));app.on_start_rate_changed(on_window!(|state, index: i32| {- state.start.rate = (index.max(0) as usize).min(START_RATES.len() - 1);+ state.handle(Msg::Start(StartMsg::RateChanged(index)));}));app.on_start_dismiss_error(on_window!(|state| {- state.start.error.clear();+ state.handle(Msg::Start(StartMsg::DismissError));}));app.on_start_browse(on_window!(|state| {- if let Some(folder) = platform::pick_folder(- &i18n::t("Where should the project folder go?"),- &state.start.location,- ) {- state.start.location = folder.to_string_lossy().into_owned();- }+ state.handle(Msg::Start(StartMsg::Browse));}));app.on_start_create(on_window!(|state| {- state.create_project();+ state.handle(Msg::Start(StartMsg::Create));}));app.on_start_open_recent(on_window!(|state, path: SharedString| {- state.open_recent(path.as_str());+ state.handle(Msg::Start(StartMsg::OpenRecent(path.to_string())));}));app.on_start_forget_recent(on_window!(|state, path: SharedString| {- state.forget_recent(path.as_str());+ state.handle(Msg::Start(StartMsg::ForgetRecent(path.to_string())));}));// ── the workspace's arrangement ──@@ -921,30 +919,29 @@ pub fn run() -> Result<(), slint::PlatformError> {// ── the project sheet ──editor.on_modify_project(on_window!(|state| {- state.project_sheet_open();+ state.handle(Msg::Project(ProjectMsg::Open));}));app.on_project_closed(on_window!(|state| {- state.project_sheet.open = false;+ state.handle(Msg::Project(ProjectMsg::Close));}));app.on_project_name_edited(on_window!(|state, name: SharedString| {- state.project_sheet.name = name.to_string();+ state.handle(Msg::Project(ProjectMsg::NameEdited(name.to_string())));}));app.on_project_size_changed(on_window!(|state, index: i32| {- state.project_sheet.size = index;+ state.handle(Msg::Project(ProjectMsg::SizeChanged(index)));}));app.on_project_rate_changed(on_window!(|state, index: i32| {- state.project_sheet.rate = (index.max(0) as usize).min(START_RATES.len() - 1);+ state.handle(Msg::Project(ProjectMsg::RateChanged(index)));}));app.on_project_apply(on_window!(|state| {- state.project_apply();+ state.handle(Msg::Project(ProjectMsg::Apply));}));app.on_relink_all(on_window!(|state| {- state.relink_all();+ state.handle(Msg::Relink(RelinkMsg::RelinkAll));}));-app.on_relink_dismiss(on_window!(|state| {- state.relink.open = false;+ state.handle(Msg::Relink(RelinkMsg::Dismiss));}));// ── the dialogs ──@@ -1128,7 +1125,9 @@ pub fn run() -> Result<(), slint::PlatformError> {{let concat_json = path.join("concat.json");if concat_json.exists() {- state.open_recent(&path.to_string_lossy());+ state.handle(Msg::Start(StartMsg::OpenRecent(+ path.to_string_lossy().into_owned(),+ )));} else {state.notify("Not a valid project folder", true);}diff --git a/src/crates/concat/src/panes/mod.rs b/src/crates/concat/src/panes/mod.rsindex bc87172f..587568dd 100644--- a/src/crates/concat/src/panes/mod.rs+++ b/src/crates/concat/src/panes/mod.rs@@ -15,8 +15,11 @@pub mod captions;pub mod export;+pub mod project;+pub mod relink;pub mod settings;pub mod speech;+pub mod start;/// One thing that happened, to one pane.#[derive(Clone, Debug)]@@ -29,4 +32,10 @@ pub enum Msg {Captions(captions::CaptionsMsg),/// To the speech sheet.Speech(speech::SpeechMsg),+ /// To the missing media dialog.+ Relink(relink::RelinkMsg),+ /// To the project sheet.+ Project(project::ProjectMsg),+ /// To the launch screen's form.+ Start(start::StartMsg),}diff --git a/src/crates/concat/src/panes/project.rs b/src/crates/concat/src/panes/project.rsnew file mode 100644index 00000000..dfeb2752--- /dev/null+++ b/src/crates/concat/src/panes/project.rs@@ -0,0 +1,115 @@+// SPDX-License-Identifier: AGPL-3.0-or-later+// SPDX-FileCopyrightText: 2026 Jareer and Concat contributors++//! The project sheet: the Details panel's Modify button, as a form.++use concat_project::Command;+use slint::SharedString;++use crate::studio::{OUTPUTS, START_RATES, Studio};+use crate::ui::ProjectSheetData;++/// Everything that can happen to the project sheet.+#[derive(Clone, Debug)]+pub enum ProjectMsg {+ /// The Details panel's Modify button.+ Open,+ Close,+ NameEdited(String),+ SizeChanged(i32),+ RateChanged(i32),+ Apply,+}++/// The project sheet's state.+#[derive(Default)]+pub struct ProjectPane {+ pub open: bool,+ pub name: String,+ /// Row in `OUTPUTS`, or -1 for a frame the list does not carry.+ pub size: i32,+ /// Row in `START_RATES`.+ pub rate: usize,+}++impl ProjectPane {+ /// Applies one message. The studio is the rest of the window; while+ /// this runs the studio's copy of the pane is a blank it must not read.+ pub fn update(&mut self, msg: ProjectMsg, studio: &mut Studio) {+ match msg {+ ProjectMsg::Open => {+ // The project and its active timeline as they stand.+ let (width, height) = studio.output_size();+ let video = studio.project().active().video;+ let (num, den) = (video.rate_num, video.rate_den);+ *self = ProjectPane {+ open: true,+ name: studio.project_name.clone(),+ size: OUTPUTS+ .iter()+ .position(|size| *size == (width as i32, height as i32))+ .map_or(-1, |index| index as i32),+ rate: START_RATES+ .iter()+ .position(|(_, n, d)| (*n, *d) == (num, den))+ .unwrap_or(3),+ };+ }+ ProjectMsg::Close => self.open = false,+ ProjectMsg::NameEdited(name) => self.name = name,+ ProjectMsg::SizeChanged(index) => self.size = index,+ ProjectMsg::RateChanged(index) => {+ self.rate = (index.max(0) as usize).min(START_RATES.len() - 1);+ }+ ProjectMsg::Apply => self.apply(studio),+ }+ }++ /// Applies the sheet and closes it. The name is the project's; the frame+ /// and the rate are the active timeline's, and go as one edit so an undo+ /// takes both back together. The frame goes the way the monitor's picker+ /// sends it, so the two cannot disagree about what a size means.+ fn apply(&mut self, studio: &mut Studio) {+ let sheet = std::mem::take(self);+ let name = sheet.name.trim().to_owned();+ let size = usize::try_from(sheet.size)+ .ok()+ .and_then(|index| OUTPUTS.get(index).copied());+ let (_, num, den) = START_RATES[sheet.rate.min(START_RATES.len() - 1)];+ let Some(session) = studio.session.as_mut() else {+ return;+ };+ let mut video = session.video();+ if let Some((width, height)) = size {+ video.width = width as u32;+ video.height = height as u32;+ }+ video.rate_num = num;+ video.rate_den = den;+ session.prepare_save((!name.is_empty()).then_some(name.as_str()));+ if !name.is_empty() {+ studio.project_name = name;+ }+ let timeline_id = studio.project().active_timeline_id.clone();+ studio.apply(Command::SetTimelineVideo { timeline_id, video });+ studio.request_preview();+ }++ /// The sheet as Slint shows it.+ pub fn data(&self, studio: &Studio) -> ProjectSheetData {+ let folder: SharedString = studio+ .session+ .as_ref()+ .map(|session| session.path().to_owned())+ .unwrap_or_else(|| "—".to_owned())+ .into();+ ProjectSheetData {+ open: self.open,+ name: self.name.as_str().into(),+ folder,+ timeline: studio.timeline().name.as_str().into(),+ size: self.size,+ rate: self.rate as i32,+ }+ }+}diff --git a/src/crates/concat/src/panes/relink.rs b/src/crates/concat/src/panes/relink.rsnew file mode 100644index 00000000..0e1e0c6d--- /dev/null+++ b/src/crates/concat/src/panes/relink.rs@@ -0,0 +1,157 @@+// SPDX-License-Identifier: AGPL-3.0-or-later+// SPDX-FileCopyrightText: 2026 Jareer and Concat contributors++//! The missing media dialog: what a project cannot find, and one folder+//! to look for it in.++use std::collections::HashMap;+use std::path::PathBuf;++use concat_project::Command;+use concat_project::model::MissingMedia;+use slint::VecModel;++use crate::i18n::t;+use crate::platform;+use crate::studio::Studio;+use crate::ui::{MissingMediaItem, RelinkData};++/// Everything that can happen to the relink dialog.+#[derive(Clone, Debug)]+pub enum RelinkMsg {+ /// A project opened with files it cannot find.+ Show(Vec<MissingMedia>),+ /// Pick a folder and look for every missing file inside it.+ RelinkAll,+ Dismiss,+}++/// The relink dialog's state.+#[derive(Default)]+pub struct RelinkPane {+ pub open: bool,+ pub items: Vec<MissingMedia>,+}++impl RelinkPane {+ /// Applies one message. The studio is the rest of the window; while+ /// this runs the studio's copy of the pane is a blank it must not read.+ pub fn update(&mut self, msg: RelinkMsg, studio: &mut Studio) {+ match msg {+ RelinkMsg::Show(items) => {+ self.open = true;+ self.items = items;+ }+ RelinkMsg::RelinkAll => self.relink_all(studio),+ 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("Select folder containing media files"), "")+ else {+ return;+ };++ // 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+ .items+ .iter()+ .map(|m| (m.id.clone(), m.path.clone()))+ .collect();+ let total = items.len();+ if total == 0 {+ self.open = false;+ return;+ }++ // Build a basename -> full path index of every file under the folder+ // so the per-item lookup is O(1) rather than a walk each time.+ let mut index: HashMap<String, PathBuf> = HashMap::new();+ let mut stack = vec![folder.clone()];+ while let Some(dir) = stack.pop() {+ let Ok(entries) = std::fs::read_dir(&dir) else {+ continue;+ };+ for entry in entries.filter_map(|e| e.ok()) {+ let path = entry.path();+ if path.is_dir() {+ stack.push(path);+ } else if let Some(name) = path.file_name().and_then(|n| n.to_str()) {+ // First match wins: if the user has duplicates, the one+ // closest to the root is the most likely correct copy.+ index.entry(name.to_owned()).or_insert(path);+ }+ }+ }++ if studio.session.is_none() {+ return;+ }++ let mut relinked = 0usize;+ let mut commands: Vec<Command> = Vec::new();+ for (id, path) in items {+ let Some(basename) = std::path::Path::new(&path)+ .file_name()+ .and_then(|n| n.to_str())+ .map(|s| s.to_owned())+ else {+ continue;+ };+ if let Some(found) = index.get(&basename) {+ commands.push(Command::UpdateMediaPath {+ media_id: id,+ new_path: found.to_string_lossy().to_string(),+ });+ relinked += 1;+ }+ }++ if !commands.is_empty() {+ studio.apply(Command::Batch { commands });+ }++ // Re-check what is still missing: the dialog updates to the+ // remainder (often empty, in which case it closes).+ let remaining = studio.project().missing_media();+ if remaining.is_empty() {+ self.open = false;+ self.items.clear();+ } else {+ self.items = remaining;+ }++ studio.notify(+ &format!(+ "Relinked {relinked} of {total} file{}",+ if total == 1 { "" } else { "s" }+ ),+ false,+ );+ studio.request_media_art();+ studio.request_preview();+ }++ /// The dialog as Slint shows it.+ pub fn data(&self) -> RelinkData {+ RelinkData {+ open: self.open,+ items: slint::ModelRc::new(VecModel::from(+ self.items+ .iter()+ .map(|item| MissingMediaItem {+ id: item.id.clone().into(),+ name: item.name.clone().into(),+ path: item.path.clone().into(),+ })+ .collect::<Vec<_>>(),+ )),+ }+ }+}diff --git a/src/crates/concat/src/panes/speech.rs b/src/crates/concat/src/panes/speech.rsindex 802b0341..1c650ee3 100644--- a/src/crates/concat/src/panes/speech.rs+++ b/src/crates/concat/src/panes/speech.rs@@ -206,7 +206,9 @@ impl SpeechPane {let summary = media::probe(&spoken.path)?;Ok::<_, String>(summary)},- |studio, _, _, result| studio.handle(Msg::Speech(SpeechMsg::Finished(Box::new(result)))),+ |studio, _, _, result| {+ studio.handle(Msg::Speech(SpeechMsg::Finished(Box::new(result))))+ },);}diff --git a/src/crates/concat/src/panes/start.rs b/src/crates/concat/src/panes/start.rsnew file mode 100644index 00000000..f70ca0e5--- /dev/null+++ b/src/crates/concat/src/panes/start.rs@@ -0,0 +1,136 @@+// SPDX-License-Identifier: AGPL-3.0-or-later+// SPDX-FileCopyrightText: 2026 Jareer and Concat contributors++//! The launch screen's form: a new project's name, place, frame and+//! rate, and the recent list's verbs.++use concat_host::projects;++use crate::i18n::t;+use crate::platform;+use crate::studio::{RESOLUTIONS, START_RATES, Studio, home_folder};+use crate::ui::StartData;++/// Everything that can happen to the launch screen's form.+#[derive(Clone, Debug)]+pub enum StartMsg {+ NameEdited(String),+ LocationEdited(String),+ ResolutionChanged(i32),+ RateChanged(i32),+ DismissError,+ /// Pick where the project folder goes.+ Browse,+ Create,+ OpenRecent(String),+ ForgetRecent(String),+}++/// The form on the launch screen.+pub struct StartPane {+ pub name: String,+ pub location: String,+ pub resolution: usize,+ pub rate: usize,+ pub busy: bool,+ pub error: String,+}++impl Default for StartPane {+ fn default() -> Self {+ Self {+ name: "Untitled project".into(),+ // A phone has no desk: its projects live at the top of the+ // folder the file manager shows for the app.+ location: home_folder(if cfg!(target_os = "android") {+ "Concat"+ } else {+ "Desktop/Concat"+ }),+ resolution: 0,+ rate: 3,+ busy: false,+ error: String::new(),+ }+ }+}++impl StartPane {+ /// Applies one message. The studio is the rest of the window; while+ /// this runs the studio's copy of the pane is a blank it must not read.+ pub fn update(&mut self, msg: StartMsg, studio: &mut Studio) {+ match msg {+ StartMsg::NameEdited(name) => self.name = name,+ StartMsg::LocationEdited(path) => self.location = path,+ StartMsg::ResolutionChanged(index) => {+ self.resolution = (index.max(0) as usize).min(RESOLUTIONS.len() - 1);+ }+ StartMsg::RateChanged(index) => {+ self.rate = (index.max(0) as usize).min(START_RATES.len() - 1);+ }+ StartMsg::DismissError => self.error.clear(),+ StartMsg::Browse => {+ if let Some(folder) =+ platform::pick_folder(&t("Where should the project folder go?"), &self.location)+ {+ self.location = folder.to_string_lossy().into_owned();+ }+ }+ StartMsg::Create => self.create(studio),+ StartMsg::OpenRecent(path) => {+ let opened = projects::open(&path).and_then(|info| studio.open_project(info));+ self.opened(opened);+ }+ StartMsg::ForgetRecent(path) => {+ if let Err(error) = projects::forget(&studio.host.dirs.config, &path) {+ self.error = error;+ }+ studio.recents = projects::list(&studio.host.dirs.config);+ }+ }+ }++ /// Makes the project the form describes and opens it.+ fn create(&mut self, studio: &mut Studio) {+ let name = self.name.trim().to_owned();+ let name = if name.is_empty() {+ "Untitled project".to_owned()+ } else {+ name+ };+ let (_, width, height) = RESOLUTIONS[self.resolution.min(RESOLUTIONS.len() - 1)];+ let (_, num, den) = START_RATES[self.rate.min(START_RATES.len() - 1)];+ if self.location.trim().is_empty() {+ self.error = t("Choose where the project folder should go");+ return;+ }+ let opened = projects::create(&self.location, &name, width, height, num, den)+ .and_then(|info| studio.open_project(info));+ self.opened(opened);+ }++ /// The form after an open: at rest, and saying why when it failed.+ fn opened(&mut self, result: Result<(), String>) {+ self.busy = false;+ match result {+ Ok(()) => self.error.clear(),+ Err(error) => self.error = error,+ }+ }++ /// The form as Slint shows it.+ pub fn data(&self) -> StartData {+ let (_, width, height) = RESOLUTIONS[self.resolution.min(RESOLUTIONS.len() - 1)];+ let (_, num, den) = START_RATES[self.rate.min(START_RATES.len() - 1)];+ StartData {+ name: self.name.as_str().into(),+ location: self.location.as_str().into(),+ resolution: self.resolution as i32,+ rate: self.rate as i32,+ size_readout: format!("{width} x {height}").into(),+ rate_readout: format!("{num}/{den} fps").into(),+ busy: self.busy,+ error: self.error.as_str().into(),+ }+ }+}diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rsindex 1a4ce84d..abb9e158 100644--- a/src/crates/concat/src/studio.rs+++ b/src/crates/concat/src/studio.rs@@ -194,17 +194,6 @@ pub struct LibraryView {pub const SHELF_KINDS: [PackageKind; 3] =[PackageKind::Filter, PackageKind::Effect, PackageKind::Audio];-/// The project sheet: the Details panel's Modify button, as a form.-#[derive(Default)]-pub struct ProjectSheet {- pub open: bool,- pub name: String,- /// Row in `OUTPUTS`, or -1 for a frame the list does not carry.- pub size: i32,- /// Row in `START_RATES`.- pub rate: usize,-}-/// `name` under the home directory, as a path string; empty when there is/// no home to speak of, and the form then asks for a folder outright.pub(crate) fn home_folder(name: &str) -> String {@@ -213,13 +202,6 @@ pub(crate) fn home_folder(name: &str) -> String {.unwrap_or_default()}-/// The missing media relink dialog state.-#[derive(Default)]-pub struct RelinkState {- pub open: bool,- pub items: Vec<concat_project::model::MissingMedia>,-}-/// The bottom-right notice: one at a time. The token is what the panel/// watches, bumped per notice so the same sentence said twice blinks twice.#[derive(Default)]@@ -229,35 +211,6 @@ pub struct ToastState {pub failed: bool,}-/// The form on the launch screen.-pub struct StartState {- pub name: String,- pub location: String,- pub resolution: usize,- pub rate: usize,- pub busy: bool,- pub error: String,-}--impl Default for StartState {- fn default() -> Self {- Self {- name: "Untitled project".into(),- // A phone has no desk: its projects live at the top of the- // folder the file manager shows for the app.- location: home_folder(if cfg!(target_os = "android") {- "Concat"- } else {- "Desktop/Concat"- }),- resolution: 0,- rate: 3,- busy: false,- error: String::new(),- }- }-}-/// What the window knows about a lane that the document does not: whether/// it is locked, and how tall to draw it.#[derive(Clone, Copy)]@@ -630,7 +583,7 @@ pub struct Studio {// ── the sheets and menus ──pub export: crate::panes::export::ExportPane,pub settings: crate::panes::settings::SettingsPane,- pub relink: RelinkState,+ pub relink: crate::panes::relink::RelinkPane,pub open_menu: i32,pub menu_bar_token: i32,pub menu_target: Option<String>,@@ -639,7 +592,7 @@ pub struct Studio {// ── the launch screen ──pub on_start: bool,- pub start: StartState,+ pub start: crate::panes::start::StartPane,pub recents: Vec<ProjectInfo>,pub posters: HashMap<String, slint::Image>,posters_pending: HashSet<String>,@@ -707,7 +660,7 @@ pub struct Studio {#[allow(clippy::type_complexity)]pub title_blocks: HashMap<String, ((u32, u32), (i32, i32))>,pub drop: Option<DropPlan>,- pub project_sheet: ProjectSheet,+ pub project_sheet: crate::panes::project::ProjectPane,pub captions: crate::panes::captions::CaptionsPane,pub speech: crate::panes::speech::SpeechPane,/// Every speaker the voice engine offers, in its own order.@@ -1307,14 +1260,14 @@ impl Studio {preview_failed: false,export: Default::default(),settings: crate::panes::settings::SettingsPane::default(),- relink: RelinkState::default(),+ relink: crate::panes::relink::RelinkPane::default(),open_menu: -1,menu_bar_token: 0,menu_target: None,menu_token: 0,toast: ToastState::default(),on_start: true,- start: StartState::default(),+ start: crate::panes::start::StartPane::default(),recents,posters: HashMap::new(),posters_pending: HashSet::new(),@@ -1337,7 +1290,7 @@ impl Studio {last_commit: None,title_blocks: HashMap::new(),drop: None,- project_sheet: ProjectSheet::default(),+ project_sheet: crate::panes::project::ProjectPane::default(),captions: crate::panes::captions::CaptionsPane::default(),speech: crate::panes::speech::SpeechPane::default(),text_presets,@@ -2126,7 +2079,7 @@ impl Studio {/// and the waveform of its default audio stream - and, for every clip/// that plays another of its media's streams, that stream's waveform/// too, so a lane shows the sound it will make.- fn request_media_art(&mut self) {+ pub(crate) fn request_media_art(&mut self) {let Some(session) = self.session.as_ref() else {return;};@@ -4802,8 +4755,9 @@ impl Studio {// ── projects ──- /// Opens a project as the session and leaves the launch screen.- pub fn open_project(&mut self, info: ProjectInfo) {+ /// Opens a project as the session and leaves the launch screen, or+ /// says why it could not.+ pub fn open_project(&mut self, info: ProjectInfo) -> Result<(), String> {match Session::open_info(&info) {Ok(session) => {if let Err(error) = projects::remember(&self.host.dirs.config, &info) {@@ -4822,8 +4776,6 @@ impl Studio {self.scroll_left = 0.0;self.on_start = false;self.preview_failed = false;- self.start.busy = false;- self.start.error.clear();self.recents = projects::list(&self.host.dirs.config);self.host.monitor.clear();self.audition = None;@@ -4850,144 +4802,14 @@ impl Studio {}}- // Open relink dialog- self.relink.open = true;- self.relink.items = missing;+ self.handle(crate::panes::Msg::Relink(+ crate::panes::relink::RelinkMsg::Show(missing),+ ));}}+ Ok(())}- Err(error) => {- self.start.busy = false;- self.start.error = error;- }- }- }-- /// 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.- pub fn relink_all(&mut self) {- use concat_project::commands::Command;-- let Some(folder) = crate::platform::pick_folder(- &crate::i18n::t("Select folder containing media files"),- "",- ) else {- return;- };-- // 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- .relink- .items- .iter()- .map(|m| (m.id.clone(), m.path.clone()))- .collect();- let total = items.len();- if total == 0 {- self.relink.open = false;- return;- }-- // Build a basename -> full path index of every file under the folder- // so the per-item lookup is O(1) rather than a walk each time.- let mut index: std::collections::HashMap<String, std::path::PathBuf> =- std::collections::HashMap::new();- let mut stack = vec![folder.clone()];- while let Some(dir) = stack.pop() {- let Ok(entries) = std::fs::read_dir(&dir) else {- continue;- };- for entry in entries.filter_map(|e| e.ok()) {- let path = entry.path();- if path.is_dir() {- stack.push(path);- } else if let Some(name) = path.file_name().and_then(|n| n.to_str()) {- // First match wins: if the user has duplicates, the one- // closest to the root is the most likely correct copy.- index.entry(name.to_owned()).or_insert(path);- }- }- }-- let Some(session) = self.session.as_mut() else {- return;- };-- let mut relinked = 0usize;- let mut commands: Vec<Command> = Vec::new();- for (id, path) in items {- let Some(basename) = std::path::Path::new(&path)- .file_name()- .and_then(|n| n.to_str())- .map(|s| s.to_owned())- else {- continue;- };- if let Some(found) = index.get(&basename) {- commands.push(Command::UpdateMediaPath {- media_id: id,- new_path: found.to_string_lossy().to_string(),- });- relinked += 1;- }- }-- if !commands.is_empty() {- if let Err(error) = session.apply(Command::Batch { commands }) {- self.notify(&format!("Relink failed: {error}"), true);- return;- }- self.dirty = true;- self.revision += 1;- }-- // Re-check what is still missing: the dialog updates to the- // remainder (often empty, in which case it closes).- let remaining = session.project().missing_media();- if remaining.is_empty() {- self.relink.open = false;- self.relink.items.clear();- } else {- self.relink.items = remaining;- }-- self.notify(- &format!(- "Relinked {relinked} of {total} file{}",- if total == 1 { "" } else { "s" }- ),- false,- );- self.request_media_art();- self.request_preview();- }-- pub fn create_project(&mut self) {- let name = self.start.name.trim().to_owned();- let name = if name.is_empty() {- "Untitled project".to_owned()- } else {- name- };- let (_, width, height) = RESOLUTIONS[self.start.resolution.min(RESOLUTIONS.len() - 1)];- let (_, num, den) = START_RATES[self.start.rate.min(START_RATES.len() - 1)];- if self.start.location.trim().is_empty() {- self.start.error = t("Choose where the project folder should go");- return;- }- match projects::create(&self.start.location, &name, width, height, num, den) {- Ok(info) => self.open_project(info),- Err(error) => self.start.error = error,- }- }-- pub fn open_recent(&mut self, path: &str) {- match projects::open(path) {- Ok(info) => self.open_project(info),- Err(error) => self.start.error = error,+ Err(error) => Err(error),}}@@ -5008,13 +4830,6 @@ impl Studio {self.request_preview();}- pub fn forget_recent(&mut self, path: &str) {- if let Err(error) = projects::forget(&self.host.dirs.config, path) {- self.start.error = error;- }- self.recents = projects::list(&self.host.dirs.config);- }-/// Saves, then closes the session and returns to the launch screen.pub fn close_project(&mut self) {self.pause();@@ -5100,6 +4915,21 @@ impl Studio {pane.update(msg, self);self.speech = pane;}+ crate::panes::Msg::Relink(msg) => {+ let mut pane = std::mem::take(&mut self.relink);+ pane.update(msg, self);+ self.relink = pane;+ }+ crate::panes::Msg::Project(msg) => {+ let mut pane = std::mem::take(&mut self.project_sheet);+ pane.update(msg, self);+ self.project_sheet = pane;+ }+ crate::panes::Msg::Start(msg) => {+ let mut pane = std::mem::take(&mut self.start);+ pane.update(msg, self);+ self.start = pane;+ }}}@@ -5958,18 +5788,7 @@ impl Studio {message: self.toast.message.as_str().into(),failed: self.toast.failed,});- let (_, width, height) = RESOLUTIONS[self.start.resolution.min(RESOLUTIONS.len() - 1)];- let (_, num, den) = START_RATES[self.start.rate.min(START_RATES.len() - 1)];- app.set_start(StartData {- name: self.start.name.as_str().into(),- location: self.start.location.as_str().into(),- resolution: self.start.resolution as i32,- rate: self.start.rate as i32,- size_readout: format!("{width} x {height}").into(),- rate_readout: format!("{num}/{den} fps").into(),- busy: self.start.busy,- error: self.start.error.as_str().into(),- });+ app.set_start(self.start.data());sync(&models.recents,self.recents@@ -6119,14 +5938,7 @@ impl Studio {editor.set_count_media(self.project().media.len() as i32);editor.set_count_tracks(self.timeline().tracks.len() as i32);editor.set_count_clips(self.timeline().clips.len() as i32);- app.set_project_sheet(ProjectSheetData {- open: self.project_sheet.open,- name: self.project_sheet.name.as_str().into(),- folder,- timeline: timeline_name,- size: self.project_sheet.size,- rate: self.project_sheet.rate as i32,- });+ app.set_project_sheet(self.project_sheet.data(self));let rows = self.menu();editor.set_menu_height(Self::menu_height(&rows));@@ -6137,20 +5949,7 @@ impl Studio {app.set_settings(self.settings.data(self));sync(&models.transcribers, self.settings.transcriber_rows());sync(&models.voices, self.settings.voice_rows());- app.set_relink(RelinkData {- open: self.relink.open,- items: slint::ModelRc::new(VecModel::from(- self.relink- .items- .iter()- .map(|item| MissingMediaItem {- id: item.id.clone().into(),- name: item.name.clone().into(),- path: item.path.clone().into(),- })- .collect::<Vec<_>>(),- )),- });+ app.set_relink(self.relink.data());// The speech sheets, and the lists they choose from.let transcribers = installed(&self.settings.transcribers);@@ -6615,59 +6414,6 @@ impl Studio {self.request_preview();}- // ── the project sheet ──-- /// Opens the sheet on the project and its active timeline as they stand.- pub fn project_sheet_open(&mut self) {- let (width, height) = self.output_size();- let video = self.project().active().video;- let (num, den) = (video.rate_num, video.rate_den);- self.project_sheet = ProjectSheet {- open: true,- name: self.project_name.clone(),- size: OUTPUTS- .iter()- .position(|size| *size == (width as i32, height as i32))- .map_or(-1, |index| index as i32),- rate: START_RATES- .iter()- .position(|(_, n, d)| (*n, *d) == (num, den))- .unwrap_or(3),- };- }-- /// Applies the sheet and closes it. The name is the project's; the frame- /// and the rate are the active timeline's, and go as one edit so an undo- /// takes both back together. The frame goes the way the monitor's picker- /// sends it, so the two cannot disagree about what a size means.- pub fn project_apply(&mut self) {- let sheet = std::mem::take(&mut self.project_sheet);- let name = sheet.name.trim().to_owned();- let size = usize::try_from(sheet.size)- .ok()- .and_then(|index| OUTPUTS.get(index).copied());- let (_, num, den) = START_RATES[sheet.rate.min(START_RATES.len() - 1)];- let Some(session) = self.session.as_mut() else {- return;- };- let mut video = session.video();- if let Some((width, height)) = size {- video.width = width as u32;- video.height = height as u32;- }- video.rate_num = num;- video.rate_den = den;- session.prepare_save((!name.is_empty()).then_some(name.as_str()));- if !name.is_empty() {- self.project_name = name;- }- let timeline_id = self.project().active_timeline_id.clone();- self.apply(Command::SetTimelineVideo { timeline_id, video });- self.dirty = true;- self.schedule_autosave();- self.request_preview();- }-// ── the keyboard, and the menu's verbs ──/// A chord from the window's key table; see `Editor.shortcut`. The view