mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-15 19:10:47 +02:00
# Description of Changes - Adds a reusable banner component/system to the core app - Adds banner at the top of the desktop app if Stirling isn't your default PDF editor, with a button to make it your default - Adds a permanent button in the settings to do it manually (in case you've dismissed the banner) - Simplifies the file loading logic to fix a bug where the input file could be duplicated occasionally. Now, the TS just receives files from one buffer, regardless of how they've been passed to the app in Rust. ## Caveats I've only been able to get the setting of default apps working properly on Mac. The Windows build isn't signed (yet) so we can't use the proper API for it, so currently it just sends you to the Settings UI. I've also not been able to test it on Linux at all.
36 lines
1.2 KiB
Rust
36 lines
1.2 KiB
Rust
use crate::utils::add_log;
|
|
use std::sync::Mutex;
|
|
|
|
// Store the opened file paths globally (supports multiple files)
|
|
static OPENED_FILES: Mutex<Vec<String>> = Mutex::new(Vec::new());
|
|
|
|
// Add an opened file path
|
|
pub fn add_opened_file(file_path: String) {
|
|
let mut opened_files = OPENED_FILES.lock().unwrap();
|
|
opened_files.push(file_path.clone());
|
|
add_log(format!("📂 File stored for later retrieval: {}", file_path));
|
|
}
|
|
|
|
// Command to get opened file paths (if app was launched with files)
|
|
#[tauri::command]
|
|
pub async fn get_opened_files() -> Result<Vec<String>, String> {
|
|
// Get all files from the OPENED_FILES store
|
|
// Command line args are processed in setup() callback and added to this store
|
|
// Additional files from second instances or events are also added here
|
|
let opened_files = OPENED_FILES.lock().unwrap();
|
|
let all_files = opened_files.clone();
|
|
|
|
add_log(format!("📂 Returning {} opened file(s)", all_files.len()));
|
|
Ok(all_files)
|
|
}
|
|
|
|
// Command to clear the opened files (after processing)
|
|
#[tauri::command]
|
|
pub async fn clear_opened_files() -> Result<(), String> {
|
|
let mut opened_files = OPENED_FILES.lock().unwrap();
|
|
opened_files.clear();
|
|
add_log("📂 Cleared opened files".to_string());
|
|
Ok(())
|
|
}
|
|
|