Fix Windows build: hotkey ID hash, leptess import path

This commit is contained in:
Aether 2026-02-23 21:04:23 +00:00
parent 7e5d536748
commit 940b995951
No known key found for this signature in database
GPG Key ID: 95AFEE837E39AFD2
2 changed files with 17 additions and 3 deletions

View File

@ -65,8 +65,10 @@ impl HotkeyManager {
let hotkey = parse_shortcut(shortcut)?; let hotkey = parse_shortcut(shortcut)?;
// Register with global hotkey manager // Register with global hotkey manager
let hotkey_id = self.manager.register(hotkey).map_err(|e| e.to_string())?; self.manager.register(hotkey).map_err(|e| e.to_string())?;
let id = hotkey_id.id(); // Get the u32 id
// Use hash of shortcut as ID (since register returns ())
let id = Self::hash_shortcut(shortcut);
// Store in our map // Store in our map
let mut hotkeys = self.hotkeys.lock().unwrap(); let mut hotkeys = self.hotkeys.lock().unwrap();
@ -232,3 +234,15 @@ fn parse_key(key: &str) -> Result<global_hotkey::hotkey::Code, String> {
Ok(code) Ok(code)
} }
impl HotkeyManager {
fn hash_shortcut(shortcut: &str) -> u32 {
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
let mut hasher = DefaultHasher::new();
shortcut.hash(&mut hasher);
hasher.finish() as u32
}
}

View File

@ -1,6 +1,6 @@
use image::{DynamicImage, GrayImage, ImageBuffer, Luma}; use image::{DynamicImage, GrayImage, ImageBuffer, Luma};
use imageproc::contrast::{stretch_contrast, threshold}; use imageproc::contrast::{stretch_contrast, threshold};
use leptess::TessBaseApi; use leptess::tesseract::TessBaseApi;
use std::collections::HashMap; use std::collections::HashMap;
use tracing::{debug, error, info}; use tracing::{debug, error, info};