diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 7c21f3c..a492034 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -610,6 +610,25 @@ async fn open_in_explorer(state: State<'_, AppState>, target: String) -> Result< Ok(()) } +/// Open a local file with its associated application (e.g. launch Unreal for a +/// `.uproject`). Uses the shell `start` so there are no path-scope restrictions. +#[tauri::command] +async fn launch_file(path: String) -> Result<(), String> { + if !std::path::Path::new(&path).exists() { + return Err(format!("File not found: {path}")); + } + let mut c = Command::new("cmd"); + #[cfg(windows)] + { + use std::os::windows::process::CommandExt; + c.creation_flags(0x0800_0000); + } + c.args(["/C", "start", "", &path]) + .spawn() + .map_err(|e| format!("Could not launch: {e}"))?; + Ok(()) +} + /// Look for an Unreal `.uproject` inside the working-folder scope (resolved to a /// local dir via `p4 where`). Checks the folder itself and one level of subdirs. /// Returns the local path of the first match, or "" if the scope isn't a UE project. @@ -751,6 +770,7 @@ pub fn run() { p4_undo_change, open_in_explorer, find_uproject, + launch_file, p4_describe, read_file, read_depot, diff --git a/src/App.tsx b/src/App.tsx index fd68d78..2dc7ab0 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -3,7 +3,6 @@ import type { MouseEvent as ReactMouseEvent, CSSProperties, ReactNode } from "re import { getCurrentWindow } from "@tauri-apps/api/window"; import { getCurrentWebview } from "@tauri-apps/api/webview"; import { listen } from "@tauri-apps/api/event"; -import { openPath } from "@tauri-apps/plugin-opener"; import ModelViewer from "./ModelViewer"; import UpdateBanner from "./Updater"; import "./App.css"; @@ -504,7 +503,7 @@ function Workbench({ info, session, light, toggleTheme, lang, setLang, zoom, set // launch Unreal by opening the detected .uproject (file association starts UE) async function launchUE() { if (!uproject) return; - try { await openPath(uproject); flash(t("Launching Unreal…")); } + try { await p4.launchFile(uproject); flash(t("Launching Unreal…")); } catch (e) { flash(String(e), true); } } @@ -564,6 +563,7 @@ function Workbench({ info, session, light, toggleTheme, lang, setLang, zoom, set if (errors.length) flash(errors.join(" · "), true); else flash(t("Sent to the server: {n} changelist(s).", { n })); await refresh(); + await loadHistory(); // the submit created a new submitted changelist — refresh History } async function doRevert(file: OpenedFile) { @@ -638,6 +638,7 @@ function Workbench({ info, session, light, toggleTheme, lang, setLang, zoom, set