LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
desktop: fix Windows Explorer reveal path and platform file manager labels (#272)
peiyan038d2ff07c936
diff --git a/apps/lightcraft/src/main.rs b/apps/lightcraft/src/main.rsindex 4bb1c6ff9..9a8f7bec8 100644--- a/apps/lightcraft/src/main.rs+++ b/apps/lightcraft/src/main.rs@@ -272,7 +272,8 @@ fn services() -> Services {let status = if cfg!(target_os = "macos") {std::process::Command::new("open").args(["-R", path]).status()} else if cfg!(target_os = "windows") {- std::process::Command::new("explorer").arg(format!("/select,{path}")).status()+ let win_path = path.replace('/', "\\");+ std::process::Command::new("explorer").arg(format!("/select,{win_path}")).status()} else {let dir = std::path::Path::new(path).parent().map(|d| d.to_string_lossy().to_string()).unwrap_or_else(|| ".".into());std::process::Command::new("xdg-open").arg(dir).status()diff --git a/crates/ui-egui/locales/ja.json b/crates/ui-egui/locales/ja.jsonindex ca2089af2..adfb4a5a0 100644--- a/crates/ui-egui/locales/ja.json+++ b/crates/ui-egui/locales/ja.json@@ -803,6 +803,8 @@"Show destination gamut warning": "出力先の色域警告を表示","Show display gamut warning": "ディスプレイの色域警告を表示","Show file names": "ファイル名を表示",+ "Show in Explorer": "エクスプローラーで表示",+ "Show in File Manager": "ファイルマネージャーで表示","Show in Finder": "Finderで表示","Show on Map": "地図で表示","Show overlay (O)": "重ね表示(O)",diff --git a/crates/ui-egui/locales/pt-br.json b/crates/ui-egui/locales/pt-br.jsonindex 503b2edac..32c9d3d98 100644--- a/crates/ui-egui/locales/pt-br.json+++ b/crates/ui-egui/locales/pt-br.json@@ -1053,6 +1053,8 @@"Show destination gamut warning": "Mostrar aviso de gamut de destino","Show display gamut warning": "Mostrar aviso de gamut da tela","Show file names": "Mostrar nomes dos arquivos",+ "Show in Explorer": "Mostrar no Explorador de Arquivos",+ "Show in File Manager": "Mostrar no gerenciador de arquivos","Show in Finder": "Mostrar no Finder","Show on Map": "Mostrar no mapa","Show overlay (O)": "Mostrar sobreposição (O)",diff --git a/crates/ui-egui/locales/zh-hans.json b/crates/ui-egui/locales/zh-hans.jsonindex 2090461a4..e89682dd9 100644--- a/crates/ui-egui/locales/zh-hans.json+++ b/crates/ui-egui/locales/zh-hans.json@@ -1045,6 +1045,8 @@"Show destination gamut warning": "显示目标色域警告","Show display gamut warning": "显示显示器色域警告","Show file names": "显示文件名",+ "Show in Explorer": "在文件资源管理器中显示",+ "Show in File Manager": "在文件管理器中显示","Show in Finder": "在 Finder 中显示","Show on Map": "在地图上显示","Show overlay (O)": "显示叠加 (O)",diff --git a/crates/ui-egui/locales/zh-hant.json b/crates/ui-egui/locales/zh-hant.jsonindex db538f485..49e148d7f 100644--- a/crates/ui-egui/locales/zh-hant.json+++ b/crates/ui-egui/locales/zh-hant.json@@ -1045,6 +1045,8 @@"Show destination gamut warning": "顯示目標色域警告","Show display gamut warning": "顯示螢幕色域警告","Show file names": "顯示檔案名稱",+ "Show in Explorer": "在檔案總管中顯示",+ "Show in File Manager": "在檔案管理員中顯示","Show in Finder": "在 Finder 中顯示","Show on Map": "在地圖上顯示","Show overlay (O)": "顯示疊加(O)",diff --git a/crates/ui-egui/src/menubar.rs b/crates/ui-egui/src/menubar.rsindex 8012a26bb..ee4322a7a 100644--- a/crates/ui-egui/src/menubar.rs+++ b/crates/ui-egui/src/menubar.rs@@ -342,6 +342,7 @@ fn live_label(app: &LightcraftApp, id: &str, label: &str) -> String {"photo.delete" if n > 1 => crate::i18n::tr_format!("Delete {n} Photos", n = n),"photo.virtualCopy" if n > 1 => crate::i18n::tr_format!("Create {n} Virtual Copies", n = n),"dialog.rename" if n > 1 => crate::i18n::tr_format!("Rename {n} Photos…", n = n),+ "app.showInFinder" => crate::i18n::tr(crate::menus::reveal_label()).to_string(),_ => label.to_string(),}}diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rsindex 9e62a382c..afff2100a 100644--- a/crates/ui-egui/src/menus.rs+++ b/crates/ui-egui/src/menus.rs@@ -1329,6 +1329,17 @@ pub fn confirm_delete(app: &mut LightcraftApp) -> bool {true}+/// Platform-appropriate label for revealing a file in the system file manager.+pub fn reveal_label() -> &'static str {+ if cfg!(target_os = "macos") {+ "Show in Finder"+ } else if cfg!(target_os = "windows") {+ "Show in Explorer"+ } else {+ "Show in File Manager"+ }+}+/// Reveal the active photo's original in the system file manager.fn show_in_finder(app: &mut LightcraftApp) -> Result<Value, String> {let id = app.session.active().ok_or("no photo selected")?;diff --git a/crates/ui-egui/src/panels/grid.rs b/crates/ui-egui/src/panels/grid.rsindex 7dc07602a..0690ed5a3 100644--- a/crates/ui-egui/src/panels/grid.rs+++ b/crates/ui-egui/src/panels/grid.rs@@ -904,7 +904,7 @@ pub fn context_menu(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {if missing && ui.button(crate::i18n::tr("Locate Missing File…")).clicked() {let _ = app.run("photo.locate", json!({}));}- if ui.add_enabled(crate::menus::ui_enabled(app, "app.showInFinder"), egui::Button::new(crate::i18n::tr("Show in Finder"))).clicked() {+ if ui.add_enabled(crate::menus::ui_enabled(app, "app.showInFinder"), egui::Button::new(crate::i18n::tr(crate::menus::reveal_label()))).clicked() {let _ = app.run("app.showInFinder", json!({}));}if ui.button(crate::i18n::tr("Export…")).clicked() {diff --git a/crates/ui-egui/src/panels/left.rs b/crates/ui-egui/src/panels/left.rsindex f69b487f3..ca05df044 100644--- a/crates/ui-egui/src/panels/left.rs+++ b/crates/ui-egui/src/panels/left.rs@@ -521,7 +521,7 @@ fn folder_tree(}}if app.services.reveal.is_some()- && ui.button(crate::i18n::tr("Show in Finder")).clicked()+ && ui.button(crate::i18n::tr(crate::menus::reveal_label())).clicked()&& let Some(f) = app.services.reveal.as_mut(){let _ = f(path);diff --git a/crates/ui-egui/src/panels/right.rs b/crates/ui-egui/src/panels/right.rsindex 6985e1c99..10a6a146e 100644--- a/crates/ui-egui/src/panels/right.rs+++ b/crates/ui-egui/src/panels/right.rs@@ -482,7 +482,7 @@ fn info(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {ui.add(egui::Label::new(egui::RichText::new(path).size(12.0).color(t.text_label)).truncate());if crate::menus::ui_enabled(app, "app.showInFinder") {ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {- if crate::widgets::icon_button(ui, "infoReveal", Icon::Folder, vec2(20.0, 20.0), false, true, "Show in Finder").clicked() {+ if crate::widgets::icon_button(ui, "infoReveal", Icon::Folder, vec2(20.0, 20.0), false, true, crate::menus::reveal_label()).clicked() {let _ = app.run("app.showInFinder", json!({}));}});