-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(shortcuts): add platform specific global shortcuts to toggle dev…
…tools
- Loading branch information
Showing
7 changed files
with
176 additions
and
9 deletions.
There are no files selected for viewing
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,5 @@ | ||
--- | ||
"zaku": patch | ||
--- | ||
|
||
Add platform specific global shortcuts to toggle devtools |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod commands; | ||
pub mod space; | ||
pub mod utils; |
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,38 @@ | ||
use tauri::{AppHandle, Manager}; | ||
use tauri_plugin_global_shortcut::{Code, Modifiers}; | ||
|
||
pub enum ShortcutCombination { | ||
CommandOptionI, | ||
ControlShiftI, | ||
} | ||
|
||
pub fn shortcut_combination( | ||
shortcut: &tauri_plugin_global_shortcut::Shortcut, | ||
) -> Option<ShortcutCombination> { | ||
let modifiers = shortcut.mods; | ||
let code = shortcut.key; | ||
|
||
if modifiers.contains(Modifiers::SUPER) | ||
&& modifiers.contains(Modifiers::ALT) | ||
&& code == Code::KeyI | ||
{ | ||
return Some(ShortcutCombination::CommandOptionI); | ||
} else if modifiers.contains(Modifiers::CONTROL) | ||
&& modifiers.contains(Modifiers::SHIFT) | ||
&& code == Code::KeyI | ||
{ | ||
return Some(ShortcutCombination::ControlShiftI); | ||
} else { | ||
return None; | ||
} | ||
} | ||
|
||
pub fn toggle_devtools(app_handle: &AppHandle) { | ||
let webview_window = app_handle.get_webview_window("main").unwrap(); | ||
|
||
if webview_window.is_devtools_open() { | ||
webview_window.close_devtools(); | ||
} else { | ||
webview_window.open_devtools(); | ||
} | ||
} |
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