feat: add typing assist section with keyboard repeat rate and delay
This commit is contained in:
parent
2f54c11604
commit
79b01f211d
2 changed files with 84 additions and 1 deletions
|
|
@ -5,7 +5,7 @@ use cosmic::{
|
||||||
iced::{self, Length},
|
iced::{self, Length},
|
||||||
iced_core::Border,
|
iced_core::Border,
|
||||||
iced_style, theme,
|
iced_style, theme,
|
||||||
widget::{self, button, container, icon, radio, settings},
|
widget::{self, button, container, icon, radio, row, settings},
|
||||||
Apply, Command, Element,
|
Apply, Command, Element,
|
||||||
};
|
};
|
||||||
use cosmic_comp_config::XkbConfig;
|
use cosmic_comp_config::XkbConfig;
|
||||||
|
|
@ -48,6 +48,8 @@ pub enum Message {
|
||||||
SourceAdd(DefaultKey),
|
SourceAdd(DefaultKey),
|
||||||
SourceContext(SourceContext),
|
SourceContext(SourceContext),
|
||||||
SpecialCharacterSelect(Option<&'static str>),
|
SpecialCharacterSelect(Option<&'static str>),
|
||||||
|
SetRepeatKeysDelay(u32),
|
||||||
|
SetRepeatKeysRate(u32),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
|
@ -63,6 +65,13 @@ pub type Locale = String;
|
||||||
pub type Variant = String;
|
pub type Variant = String;
|
||||||
pub type Description = String;
|
pub type Description = String;
|
||||||
|
|
||||||
|
const KB_REPEAT_DELAY_DEFAULT: u32 = 600;
|
||||||
|
const KB_REPEAT_RATE_DEFAULT: u32 = 25;
|
||||||
|
const KB_REPEAT_DELAY_MAX: u32 = 1000;
|
||||||
|
const KB_REPEAT_DELAY_MIN: u32 = 200;
|
||||||
|
const KB_REPEAT_RATE_MAX: u32 = 45;
|
||||||
|
const KB_REPEAT_RATE_MIN: u32 = 5;
|
||||||
|
|
||||||
pub struct Page {
|
pub struct Page {
|
||||||
config: cosmic_config::Config,
|
config: cosmic_config::Config,
|
||||||
context: Option<Context>,
|
context: Option<Context>,
|
||||||
|
|
@ -233,6 +242,7 @@ impl page::Page<crate::pages::Message> for Page {
|
||||||
sections.insert(input_sources()),
|
sections.insert(input_sources()),
|
||||||
sections.insert(special_character_entry()),
|
sections.insert(special_character_entry()),
|
||||||
sections.insert(keyboard_shortcuts()),
|
sections.insert(keyboard_shortcuts()),
|
||||||
|
sections.insert(keyboard_typing_assist()),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -440,6 +450,14 @@ impl Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Message::SetRepeatKeysDelay(delay) => {
|
||||||
|
self.xkb.repeat_delay = delay;
|
||||||
|
self.update_xkb_config();
|
||||||
|
}
|
||||||
|
Message::SetRepeatKeysRate(rate) => {
|
||||||
|
self.xkb.repeat_rate = rate;
|
||||||
|
self.update_xkb_config();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Command::none()
|
Command::none()
|
||||||
|
|
@ -623,6 +641,63 @@ fn keyboard_shortcuts() -> Section<crate::pages::Message> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn keyboard_typing_assist() -> Section<crate::pages::Message> {
|
||||||
|
Section::default()
|
||||||
|
.title(fl!("keyboard-typing-assist"))
|
||||||
|
.descriptions(vec![
|
||||||
|
fl!("keyboard-typing-assist", "repeat-delay").into(),
|
||||||
|
fl!("keyboard-typing-assist", "repeat-rate").into(),
|
||||||
|
fl!("short").into(),
|
||||||
|
fl!("long").into(),
|
||||||
|
fl!("slow").into(),
|
||||||
|
fl!("fast").into(),
|
||||||
|
])
|
||||||
|
.view::<Page>(|_binder, page, section| {
|
||||||
|
let descriptions = §ion.descriptions;
|
||||||
|
let theme = cosmic::theme::active();
|
||||||
|
|
||||||
|
settings::view_section(§ion.title)
|
||||||
|
.add(settings::item(&*descriptions[0], {
|
||||||
|
// Delay
|
||||||
|
let delay_slider = cosmic::widget::slider(
|
||||||
|
KB_REPEAT_DELAY_MIN..=KB_REPEAT_DELAY_MAX,
|
||||||
|
page.xkb.repeat_delay,
|
||||||
|
Message::SetRepeatKeysDelay,
|
||||||
|
)
|
||||||
|
.width(250.0)
|
||||||
|
.breakpoints(&[KB_REPEAT_DELAY_DEFAULT])
|
||||||
|
.step(50_u32);
|
||||||
|
|
||||||
|
row::with_capacity(3)
|
||||||
|
.align_items(iced::Alignment::Center)
|
||||||
|
.spacing(theme.cosmic().space_s())
|
||||||
|
.push(&*descriptions[2])
|
||||||
|
.push(delay_slider)
|
||||||
|
.push(&*descriptions[3])
|
||||||
|
}))
|
||||||
|
.add(settings::item(&*descriptions[1], {
|
||||||
|
// Repeat rate
|
||||||
|
let rate_slider = cosmic::widget::slider(
|
||||||
|
KB_REPEAT_RATE_MIN..=KB_REPEAT_RATE_MAX,
|
||||||
|
page.xkb.repeat_rate,
|
||||||
|
Message::SetRepeatKeysRate,
|
||||||
|
)
|
||||||
|
.width(250.0)
|
||||||
|
.breakpoints(&[KB_REPEAT_RATE_DEFAULT])
|
||||||
|
.step(5_u32);
|
||||||
|
|
||||||
|
row::with_capacity(3)
|
||||||
|
.align_items(iced::Alignment::Center)
|
||||||
|
.spacing(theme.cosmic().space_s())
|
||||||
|
.push(&*descriptions[4])
|
||||||
|
.push(rate_slider)
|
||||||
|
.push(&*descriptions[5])
|
||||||
|
}))
|
||||||
|
.apply(cosmic::Element::from)
|
||||||
|
.map(crate::pages::Message::Keyboard)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fn go_next_control<Msg: Clone + 'static>() -> cosmic::Element<'static, Msg> {
|
fn go_next_control<Msg: Clone + 'static>() -> cosmic::Element<'static, Msg> {
|
||||||
widget::row::with_children(vec![
|
widget::row::with_children(vec![
|
||||||
widget::horizontal_space(Length::Fill).into(),
|
widget::horizontal_space(Length::Fill).into(),
|
||||||
|
|
|
||||||
|
|
@ -369,6 +369,10 @@ scrolling = Scrolling
|
||||||
|
|
||||||
## Input: Keyboard
|
## Input: Keyboard
|
||||||
|
|
||||||
|
slow = Slow
|
||||||
|
fast = Fast
|
||||||
|
short = Short
|
||||||
|
long = Long
|
||||||
keyboard = Keyboard
|
keyboard = Keyboard
|
||||||
.desc = Keyboard input
|
.desc = Keyboard input
|
||||||
|
|
||||||
|
|
@ -385,6 +389,10 @@ keyboard-special-char = Special Character Entry
|
||||||
.alternate = Alternate characters key
|
.alternate = Alternate characters key
|
||||||
.compose = Compose key
|
.compose = Compose key
|
||||||
|
|
||||||
|
keyboard-typing-assist = Typing
|
||||||
|
.repeat-rate = Repeat rate
|
||||||
|
.repeat-delay = Repeat delay
|
||||||
|
|
||||||
added = Added
|
added = Added
|
||||||
type-to-search = Type to search...
|
type-to-search = Type to search...
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue