mirror of
https://github.com/project-gauntlet/gauntlet.git
synced 2025-12-23 10:35:53 +00:00
Global shortcut now hides the main window when the window is already open
This commit is contained in:
parent
8c017baedd
commit
c8b3cfe09c
4 changed files with 13 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -3,3 +3,4 @@
|
|||
/node_modules
|
||||
/.direnv
|
||||
result
|
||||
.DS_Store
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ For changes in `@project-gauntlet/tools` see [separate CHANGELOG.md](https://git
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
- Global shortcut how hides the main window if it is already open
|
||||
- It is now possible to run commands and open views using CLI command
|
||||
- Format: `gauntlet run <plugin-id> <entrypoint-id> <action-id>`
|
||||
- Plugin ID can be found in Settings UI
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ pub fn register_listener(msg_sender: Sender<AppMsg>) {
|
|||
|
||||
if let global_hotkey::HotKeyState::Released = e.state() {
|
||||
handle.spawn(async move {
|
||||
if let Err(err) = msg_sender.send(AppMsg::ShowWindow).await {
|
||||
if let Err(err) = msg_sender.send(AppMsg::ToggleWindowFocus).await {
|
||||
tracing::warn!(target = "rpc", "error occurred when receiving shortcut event {:?}", err)
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -245,6 +245,7 @@ pub enum AppMsg {
|
|||
FontLoaded(Result<(), font::Error>),
|
||||
ShowWindow,
|
||||
HideWindow,
|
||||
ToggleWindowFocus,
|
||||
ToggleActionPanel {
|
||||
keyboard: bool,
|
||||
},
|
||||
|
|
@ -1132,6 +1133,7 @@ fn update(state: &mut AppModel, message: AppMsg) -> Task<AppMsg> {
|
|||
result.expect("unable to load font");
|
||||
Task::none()
|
||||
}
|
||||
AppMsg::ToggleWindowFocus => state.toggle_window_focus(),
|
||||
AppMsg::ShowWindow => state.show_window(),
|
||||
AppMsg::HideWindow => state.hide_window(),
|
||||
AppMsg::ShowPreferenceRequiredView {
|
||||
|
|
@ -2203,6 +2205,14 @@ impl AppModel {
|
|||
}
|
||||
}
|
||||
|
||||
fn toggle_window_focus(&mut self) -> Task<AppMsg> {
|
||||
if self.focused {
|
||||
self.hide_window()
|
||||
} else {
|
||||
self.show_window()
|
||||
}
|
||||
}
|
||||
|
||||
fn hide_window(&mut self) -> Task<AppMsg> {
|
||||
self.focused = false;
|
||||
self.opened = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue