place shortcuts in existing config
This commit is contained in:
parent
e520b7b0e3
commit
d5f1ac4e91
5 changed files with 24 additions and 62 deletions
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
use cosmic::widget::menu::key_bind::{KeyBind, Modifier};
|
||||
use cosmic::{
|
||||
cosmic_config::{self, CosmicConfigEntry, cosmic_config_derive::CosmicConfigEntry},
|
||||
iced::keyboard::{Key, Modifiers},
|
||||
iced_core::keyboard::key::Named,
|
||||
};
|
||||
|
|
@ -11,9 +10,6 @@ use std::collections::{BTreeMap, HashMap};
|
|||
|
||||
use crate::Action;
|
||||
|
||||
pub const SHORTCUTS_CONFIG_ID: &str = "com.system76.CosmicTerm.Shortcuts";
|
||||
pub const SHORTCUTS_CONFIG_VERSION: u64 = 1;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
|
||||
pub enum ModifierName {
|
||||
Ctrl,
|
||||
|
|
@ -167,7 +163,7 @@ pub struct ResolvedBinding {
|
|||
pub source: BindingSource,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize, CosmicConfigEntry)]
|
||||
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
|
||||
pub struct ShortcutsConfig {
|
||||
pub defaults: Shortcuts,
|
||||
pub custom: Shortcuts,
|
||||
|
|
@ -231,25 +227,6 @@ impl ShortcutsConfig {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn load() -> (Option<cosmic_config::Config>, ShortcutsConfig) {
|
||||
match cosmic_config::Config::new(SHORTCUTS_CONFIG_ID, SHORTCUTS_CONFIG_VERSION) {
|
||||
Ok(config_handler) => {
|
||||
let config = match ShortcutsConfig::get_entry(&config_handler) {
|
||||
Ok(config) => config,
|
||||
Err((errors, config)) => {
|
||||
log::info!("errors loading shortcuts config: {:?}", errors);
|
||||
config
|
||||
}
|
||||
};
|
||||
(Some(config_handler), config)
|
||||
}
|
||||
Err(err) => {
|
||||
log::error!("failed to create shortcuts config handler: {}", err);
|
||||
(None, ShortcutsConfig::default())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn action_label(action: KeyBindAction) -> &'static str {
|
||||
match action {
|
||||
KeyBindAction::Unbind => "Unbind",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue