-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework window management & config system
- Loading branch information
Showing
9 changed files
with
260 additions
and
110 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
use tauri::{AppHandle, GlobalShortcutManager, Manager, Window}; | ||
|
||
use crate::{config, window}; | ||
|
||
pub const DEFAULT_SHORTCUT: &str = "Cmd+Alt+Shift+C"; | ||
|
||
pub fn update_default( | ||
window: Window, | ||
old_shortcut: &str, | ||
new_shortcut: &str, | ||
) -> Result<(), tauri::Error> { | ||
let app = window.app_handle(); | ||
let mut shortcuts = app.global_shortcut_manager(); | ||
|
||
shortcuts.unregister(old_shortcut)?; | ||
shortcuts.register(new_shortcut, move || { | ||
if window.is_visible().unwrap() { | ||
window::hide(&window).unwrap(); | ||
} else { | ||
window::show(&window).unwrap(); | ||
} | ||
})?; | ||
|
||
Ok(()) | ||
} | ||
|
||
pub fn register_settings(app: &AppHandle) -> Result<(), anyhow::Error> { | ||
let mut shortcuts = app.global_shortcut_manager(); | ||
|
||
shortcuts.register("Cmd+,", move || { | ||
config::edit().unwrap(); | ||
})?; | ||
|
||
Ok(()) | ||
} | ||
|
||
pub fn unregister_settings(app: &AppHandle) -> Result<(), anyhow::Error> { | ||
let mut shortcuts = app.global_shortcut_manager(); | ||
|
||
shortcuts.unregister("Cmd+,")?; | ||
|
||
Ok(()) | ||
} | ||
|
||
pub fn register_escape(window: Window) -> Result<(), tauri::Error> { | ||
let app = window.app_handle(); | ||
let mut shortcuts = app.global_shortcut_manager(); | ||
|
||
shortcuts.register("Escape", move || { | ||
window::hide(&window).unwrap(); | ||
})?; | ||
|
||
Ok(()) | ||
} | ||
|
||
pub fn unregister_escape(app: &AppHandle) -> Result<(), tauri::Error> { | ||
let mut shortcuts = app.global_shortcut_manager(); | ||
|
||
shortcuts.unregister("Escape")?; | ||
|
||
Ok(()) | ||
} |
Oops, something went wrong.