input: Use existing message to open keyboard shortcuts
This commit is contained in:
parent
154c67ee6a
commit
750cd299b2
3 changed files with 14 additions and 16 deletions
|
|
@ -272,11 +272,6 @@ impl Application for SettingsApp {
|
||||||
page::update!(self.pages, message, desktop::wallpaper::Page);
|
page::update!(self.pages, message, desktop::wallpaper::Page);
|
||||||
}
|
}
|
||||||
crate::pages::Message::Input(message) => {
|
crate::pages::Message::Input(message) => {
|
||||||
if matches!(message, input::Message::OpenKeyboardShortcuts) {
|
|
||||||
if let Some(id) = self.pages.page_id::<input::keyboard::shortcuts::Page>() {
|
|
||||||
return self.activate_page(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if let Some(page) = self.pages.page_mut::<input::Page>() {
|
if let Some(page) = self.pages.page_mut::<input::Page>() {
|
||||||
return page.update(message);
|
return page.update(message);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -291,20 +291,25 @@ fn keyboard_shortcuts() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("keyboard-shortcuts"))
|
.title(fl!("keyboard-shortcuts"))
|
||||||
.descriptions(vec![fl!("keyboard-shortcuts", "desc")])
|
.descriptions(vec![fl!("keyboard-shortcuts", "desc")])
|
||||||
.view::<Page>(|_binder, _page, section| {
|
.view::<Page>(|binder, _page, section| {
|
||||||
let descriptions = §ion.descriptions;
|
let descriptions = §ion.descriptions;
|
||||||
|
|
||||||
settings::view_section(§ion.title)
|
let mut section = settings::view_section(§ion.title);
|
||||||
.add(go_next_item(
|
if let Some((shortcuts_entity, _)) = binder
|
||||||
|
.info
|
||||||
|
.iter()
|
||||||
|
.find(|(_, v)| v.id == "keyboard-shortcuts")
|
||||||
|
{
|
||||||
|
section = section.add(go_next_item(
|
||||||
&descriptions[0],
|
&descriptions[0],
|
||||||
Message::OpenKeyboardShortcuts,
|
crate::pages::Message::Page(shortcuts_entity),
|
||||||
))
|
));
|
||||||
.apply(cosmic::Element::from)
|
}
|
||||||
.map(crate::pages::Message::Input)
|
section.apply(cosmic::Element::from)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn go_next_control() -> cosmic::Element<'static, Message> {
|
fn go_next_control<Msg: Clone + 'static>() -> cosmic::Element<'static, Msg> {
|
||||||
widget::row!(
|
widget::row!(
|
||||||
horizontal_space(Length::Fill),
|
horizontal_space(Length::Fill),
|
||||||
cosmic::widget::icon("go-next-symbolic", 20).style(cosmic::theme::Svg::Symbolic)
|
cosmic::widget::icon("go-next-symbolic", 20).style(cosmic::theme::Svg::Symbolic)
|
||||||
|
|
@ -312,7 +317,7 @@ fn go_next_control() -> cosmic::Element<'static, Message> {
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn go_next_item(description: &str, msg: Message) -> cosmic::Element<'_, Message> {
|
fn go_next_item<Msg: Clone + 'static>(description: &str, msg: Msg) -> cosmic::Element<'_, Msg> {
|
||||||
settings::item(description, go_next_control())
|
settings::item(description, go_next_control())
|
||||||
.apply(widget::container)
|
.apply(widget::container)
|
||||||
.style(cosmic::theme::Container::custom(
|
.style(cosmic::theme::Container::custom(
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ pub enum Message {
|
||||||
PrimaryButtonSelected(cosmic::widget::segmented_button::Entity),
|
PrimaryButtonSelected(cosmic::widget::segmented_button::Entity),
|
||||||
// seperate close message, to make sure another isn't closed?
|
// seperate close message, to make sure another isn't closed?
|
||||||
ExpandInputSourcePopover(Option<String>),
|
ExpandInputSourcePopover(Option<String>),
|
||||||
OpenKeyboardShortcuts,
|
|
||||||
OpenSpecialCharacterDialog(keyboard::SpecialKey),
|
OpenSpecialCharacterDialog(keyboard::SpecialKey),
|
||||||
CloseSpecialCharacterDialog,
|
CloseSpecialCharacterDialog,
|
||||||
SpecialCharacterSelect(Option<&'static str>),
|
SpecialCharacterSelect(Option<&'static str>),
|
||||||
|
|
@ -146,7 +145,6 @@ impl Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::OpenKeyboardShortcuts => {}
|
|
||||||
}
|
}
|
||||||
iced::Command::none()
|
iced::Command::none()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue