wip: hook up panel messages
This commit is contained in:
parent
ce15eebdb8
commit
e7996f69dd
6 changed files with 189 additions and 9 deletions
|
|
@ -20,7 +20,10 @@ use cosmic::{
|
|||
|
||||
use crate::{
|
||||
config::{self, Config},
|
||||
pages::{desktop, sound, system, time},
|
||||
pages::{
|
||||
desktop::{self, panel},
|
||||
sound, system, time,
|
||||
},
|
||||
widget::{page_title, parent_page_button, search_header, sub_page_button},
|
||||
};
|
||||
|
||||
|
|
@ -216,6 +219,11 @@ impl Application for SettingsApp {
|
|||
crate::pages::Message::Page(page) => {
|
||||
return self.activate_page(page);
|
||||
}
|
||||
crate::pages::Message::Panel(message) => {
|
||||
if let Some(page) = self.pages.page_mut::<panel::Page>() {
|
||||
page.update(message);
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
ret
|
||||
|
|
|
|||
|
|
@ -5,14 +5,16 @@ use cosmic::{
|
|||
Element,
|
||||
};
|
||||
|
||||
use super::Message;
|
||||
use apply::Apply;
|
||||
use cosmic_panel_config::{AutoHide, CosmicPanelConfig, CosmicPanelOuput, PanelAnchor, PanelSize};
|
||||
use cosmic_settings_page::Section;
|
||||
use cosmic_settings_page::{self as page, section};
|
||||
use slotmap::SlotMap;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Page;
|
||||
pub struct Page {
|
||||
panel_config: CosmicPanelConfig,
|
||||
}
|
||||
|
||||
impl page::Page<crate::pages::Message> for Page {
|
||||
#[allow(clippy::too_many_lines)]
|
||||
|
|
@ -20,7 +22,11 @@ impl page::Page<crate::pages::Message> for Page {
|
|||
&self,
|
||||
sections: &mut SlotMap<section::Entity, Section<crate::pages::Message>>,
|
||||
) -> Option<page::Content> {
|
||||
Some(vec![sections.insert(Section::default())])
|
||||
Some(vec![
|
||||
sections.insert(behavior_and_position()),
|
||||
sections.insert(style()),
|
||||
sections.insert(configuration()),
|
||||
])
|
||||
}
|
||||
|
||||
fn info(&self) -> page::Info {
|
||||
|
|
@ -31,3 +37,89 @@ impl page::Page<crate::pages::Message> for Page {
|
|||
}
|
||||
|
||||
impl page::AutoBind<crate::pages::Message> for Page {}
|
||||
|
||||
pub fn behavior_and_position() -> Section<crate::pages::Message> {
|
||||
Section::default()
|
||||
.title(fl!("panel-behavior-and-position"))
|
||||
.descriptions(vec![fl!("panel-behavior-and-position", "autohide")])
|
||||
.view::<Page>(|_binder, page, section| {
|
||||
let descriptions = §ion.descriptions;
|
||||
settings::view_section(§ion.title)
|
||||
.add(settings::item(
|
||||
&descriptions[0],
|
||||
toggler(None, page.panel_config.autohide.is_some(), |value| {
|
||||
Message::AutoHidePanel(value)
|
||||
}),
|
||||
))
|
||||
.apply(Element::from)
|
||||
.map(crate::pages::Message::Panel)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn style() -> Section<crate::pages::Message> {
|
||||
Section::default()
|
||||
.title(fl!("hot-corner"))
|
||||
.descriptions(vec![fl!("hot-corner", "top-left-corner")])
|
||||
.view::<Page>(|binder, _page, section| {
|
||||
let desktop = binder
|
||||
.page::<super::Page>()
|
||||
.expect("desktop page not found");
|
||||
|
||||
let descriptions = §ion.descriptions;
|
||||
settings::view_section(§ion.title)
|
||||
.apply(Element::from)
|
||||
.map(crate::pages::Message::Desktop)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn configuration() -> Section<crate::pages::Message> {
|
||||
Section::default()
|
||||
.title(fl!("hot-corner"))
|
||||
.descriptions(vec![fl!("hot-corner", "top-left-corner")])
|
||||
.view::<Page>(|binder, _page, section| {
|
||||
let desktop = binder
|
||||
.page::<super::Page>()
|
||||
.expect("desktop page not found");
|
||||
|
||||
let descriptions = §ion.descriptions;
|
||||
settings::view_section(§ion.title)
|
||||
.apply(Element::from)
|
||||
.map(crate::pages::Message::Desktop)
|
||||
})
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Message {
|
||||
// panel messages
|
||||
AutoHidePanel(bool),
|
||||
PanelAnchor(PanelAnchor),
|
||||
Output(CosmicPanelOuput),
|
||||
AnchorGap(bool),
|
||||
PanelSize(PanelSize),
|
||||
Appearance,
|
||||
ExtendToEdge(bool),
|
||||
Opacity(f64),
|
||||
Applets,
|
||||
}
|
||||
|
||||
impl Page {
|
||||
pub fn update(&mut self, message: Message) {
|
||||
match message {
|
||||
Message::AutoHidePanel(enabled) => {
|
||||
self.panel_config.autohide = enabled.then_some(AutoHide {
|
||||
wait_time: 1000,
|
||||
transition_time: 200,
|
||||
handle_size: 4,
|
||||
});
|
||||
}
|
||||
Message::PanelAnchor(_) => todo!(),
|
||||
Message::Output(_) => todo!(),
|
||||
Message::AnchorGap(_) => todo!(),
|
||||
Message::PanelSize(_) => todo!(),
|
||||
Message::Appearance => todo!(),
|
||||
Message::ExtendToEdge(_) => todo!(),
|
||||
Message::Opacity(_) => todo!(),
|
||||
Message::Applets => todo!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ pub enum Message {
|
|||
About(system::about::Message),
|
||||
DateAndTime(time::date::Message),
|
||||
Desktop(desktop::Message),
|
||||
Panel(desktop::panel::Message),
|
||||
External { id: String, message: Vec<u8> },
|
||||
Page(Entity),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue