mirror of
https://github.com/0PandaDEV/Qopy.git
synced 2025-04-21 21:24:05 +02:00
image handeling
This commit is contained in:
parent
296a844aaa
commit
2695d8cd4c
9 changed files with 427 additions and 112 deletions
29
src-tauri/src/hotkeys.rs
Normal file
29
src-tauri/src/hotkeys.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
use rdev::{listen, EventType, Key};
|
||||
use std::sync::mpsc;
|
||||
use tauri::Manager;
|
||||
|
||||
pub fn setup(app_handle: tauri::AppHandle) {
|
||||
let (tx, rx) = mpsc::channel();
|
||||
|
||||
std::thread::spawn(move || {
|
||||
listen(move |event| match event.event_type {
|
||||
EventType::KeyPress(Key::MetaLeft | Key::MetaRight) => {
|
||||
let _ = tx.send(true);
|
||||
}
|
||||
EventType::KeyRelease(Key::KeyV) => {
|
||||
if rx.try_recv().is_ok() {
|
||||
let window = app_handle.get_window("main").unwrap();
|
||||
let is_visible = window.is_visible().unwrap();
|
||||
if is_visible {
|
||||
window.hide().unwrap();
|
||||
} else {
|
||||
window.show().unwrap();
|
||||
window.set_focus().unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
})
|
||||
.unwrap();
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue