Skip to content
This repository has been archived by the owner on May 20, 2023. It is now read-only.

Commit

Permalink
fix shortcur
Browse files Browse the repository at this point in the history
  • Loading branch information
fzdwx committed Mar 24, 2023
1 parent aed34c5 commit 4c2414b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src-tauri/src/setting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,18 @@ impl Config {
}
}

pub fn refresh_shortcuts(_old: Config, new: Config, app: tauri::AppHandle) -> anyhow::Result<()> {
pub fn refresh_shortcuts(old: Config, new: Config, app: tauri::AppHandle) -> anyhow::Result<()> {
let mut manager = app.global_shortcut_manager();
let main_window = app.get_window("main").unwrap();

manager.unregister_all()?;
if let Some(shortcurs) = old.shortcuts {
if let Ok(b) = manager.is_registered(&shortcurs.toggle) {
if b {
manager.unregister(&shortcurs.toggle)?;
}
}
}

let shortcuts = new.shortcuts.unwrap_or_default();
manager.register(&shortcuts.toggle, move || {
if main_window.is_visible().unwrap() {
Expand Down

0 comments on commit 4c2414b

Please sign in to comment.