Skip to content

Commit

Permalink
Add file menu, improve naming of subtitles
Browse files Browse the repository at this point in the history
  • Loading branch information
jackpot51 committed Dec 5, 2024
1 parent 214e894 commit 7f9d56a
Show file tree
Hide file tree
Showing 6 changed files with 210 additions and 72 deletions.
36 changes: 31 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
gstreamer-tag = "0.23"
lazy_static = "1"
serde = { version = "1", features = ["serde_derive"] }
tokio = "1"
Expand Down Expand Up @@ -32,7 +33,8 @@ version = "0.2.1"
features = ["serde"]

[features]
default = ["wgpu"]
default = ["xdg-portal", "wgpu"]
xdg-portal = ["libcosmic/xdg-portal"]
wgpu = ["iced_video_player/wgpu", "libcosmic/wgpu"]

[profile.release-with-debug]
Expand Down
9 changes: 9 additions & 0 deletions i18n/en/cosmic_player.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,12 @@ theme = Theme
match-desktop = Match desktop
dark = Dark
light = Light
# Menu

## File
file = File
open-media = Open media...
open-recent-media = Open recent media
close-file = Close file
quit = Quit
45 changes: 3 additions & 42 deletions src/key_bind.rs
Original file line number Diff line number Diff line change
@@ -1,48 +1,9 @@
use cosmic::{
iced::keyboard::{Key, Modifiers},
iced_core::keyboard::key::Named,
};
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, fmt};
use cosmic::{iced::keyboard::Key, iced_core::keyboard::key::Named};
use std::collections::HashMap;

use crate::Action;

#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
pub enum Modifier {
Super,
Ctrl,
Alt,
Shift,
}

#[derive(Clone, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
pub struct KeyBind {
pub modifiers: Vec<Modifier>,
pub key: Key,
}

impl KeyBind {
pub fn matches(&self, modifiers: Modifiers, key: &Key) -> bool {
key == &self.key
&& modifiers.logo() == self.modifiers.contains(&Modifier::Super)
&& modifiers.control() == self.modifiers.contains(&Modifier::Ctrl)
&& modifiers.alt() == self.modifiers.contains(&Modifier::Alt)
&& modifiers.shift() == self.modifiers.contains(&Modifier::Shift)
}
}

impl fmt::Display for KeyBind {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
for modifier in self.modifiers.iter() {
write!(f, "{:?} + ", modifier)?;
}
match &self.key {
Key::Character(c) => write!(f, "{}", c.to_uppercase()),
Key::Named(named) => write!(f, "{:?}", named),
other => write!(f, "{:?}", other),
}
}
}
pub use cosmic::widget::menu::key_bind::{KeyBind, Modifier};

//TODO: load from config
pub fn key_binds() -> HashMap<KeyBind, Action> {
Expand Down
Loading

0 comments on commit 7f9d56a

Please sign in to comment.