feat(ui): add drawing tab context menu

Refs #493
This commit is contained in:
Hakan Seven 2026-07-27 12:02:50 +03:00
commit 9d973a0fd6
8 changed files with 388 additions and 26 deletions

View file

@ -17,6 +17,37 @@ pub fn open_url(url: &str) {
}
}
/// Reveal a saved drawing in the native platform's file manager.
#[cfg(not(target_arch = "wasm32"))]
pub fn reveal_in_file_manager(path: &std::path::Path) -> Result<(), String> {
#[cfg(target_os = "windows")]
let status = std::process::Command::new("explorer.exe")
.arg("/select,")
.arg(path)
.status();
#[cfg(target_os = "macos")]
let status = std::process::Command::new("open")
.arg("-R")
.arg(path)
.status();
#[cfg(not(any(target_os = "windows", target_os = "macos")))]
{
let folder = path
.parent()
.ok_or_else(|| format!("Path has no parent folder: {}", path.display()))?;
return open::that(folder).map_err(|e| e.to_string());
}
#[cfg(any(target_os = "windows", target_os = "macos"))]
match status {
Ok(status) if status.success() => Ok(()),
Ok(status) => Err(format!("File manager exited with {status}")),
Err(error) => Err(error.to_string()),
}
}
/// Web: read text from the system clipboard via the async Clipboard API.
/// iced's own `clipboard::read` is a no-op on the web (the browser clipboard is
/// async + permission-gated), so the editor paste paths use this instead. The