cosmic-player/src/key_bind.rs
nz366 6f5040a953
[Feat] AB repeat and frame stepping (#241)
* feat: Add A-B repeat and frame  navigation features with new key binds and menu entries.

* playback options

* fix merge
2026-04-03 14:16:01 -04:00

35 lines
1.1 KiB
Rust

use cosmic::{iced::keyboard::Key, iced_core::keyboard::key::Named};
use std::collections::HashMap;
use crate::Action;
pub use cosmic::widget::menu::key_bind::{KeyBind, Modifier};
//TODO: load from config
pub fn key_binds() -> HashMap<KeyBind, Action> {
let mut key_binds = HashMap::new();
macro_rules! bind {
([$($modifier:ident),* $(,)?], $key:expr, $action:ident) => {{
key_binds.insert(
KeyBind {
modifiers: vec![$(Modifier::$modifier),*],
key: $key,
},
Action::$action,
);
}};
}
//TODO: key bindings
bind!([], Key::Character("f".into()), Fullscreen);
bind!([Alt], Key::Named(Named::Enter), Fullscreen);
bind!([], Key::Character(" ".into()), PlayPause);
bind!([], Key::Named(Named::ArrowLeft), SeekBackward);
bind!([], Key::Named(Named::ArrowRight), SeekForward);
bind!([], Key::Character(".".into()), NextFrame);
bind!([], Key::Character(",".into()), PreviousFrame);
bind!([], Key::Character("a".into()), AbRepeat);
key_binds
}