diff --git a/cosmic-settings/src/app.rs b/cosmic-settings/src/app.rs index a1dacf4..dd96440 100644 --- a/cosmic-settings/src/app.rs +++ b/cosmic-settings/src/app.rs @@ -60,7 +60,6 @@ impl SettingsApp { PageCommands::DesktopPanel => self.pages.page_id::(), PageCommands::Displays => self.pages.page_id::(), PageCommands::Firmware => self.pages.page_id::(), - PageCommands::Keyboard => self.pages.page_id::(), PageCommands::Mouse => self.pages.page_id::(), PageCommands::Network => None, PageCommands::Notifications => self.pages.page_id::(), @@ -529,6 +528,12 @@ impl cosmic::Application for SettingsApp { None } } + + fn dialog(&self) -> Option> { + self.pages + .dialog(self.active_page) + .map(|e| e.map(Message::PageMessage)) + } } impl SettingsApp { diff --git a/page/src/binder.rs b/page/src/binder.rs index 8f0d66b..309eb0e 100644 --- a/page/src/binder.rs +++ b/page/src/binder.rs @@ -136,13 +136,20 @@ impl Binder { page.downcast_ref::

() } - /// Obtain a reference to a page by its type ID. + /// Create a context drawer for the given page. #[must_use] pub fn context_drawer(&self, id: crate::Entity) -> Option> { let page = self.page.get(id)?; page.context_drawer() } + /// Create a dialog for the given page. + #[must_use] + pub fn dialog(&self, id: crate::Entity) -> Option> { + let page = self.page.get(id)?; + page.dialog() + } + /// Obtain a reference to a page by its type ID. #[must_use] pub fn page_mut>(&mut self) -> Option<&mut P> { diff --git a/page/src/lib.rs b/page/src/lib.rs index 2d9f423..7df1d3d 100644 --- a/page/src/lib.rs +++ b/page/src/lib.rs @@ -28,6 +28,7 @@ pub trait Page: Downcast { /// Information about the page fn info(&self) -> Info; + /// Initialize the sections used by this page. #[must_use] fn content( &self, @@ -36,20 +37,28 @@ pub trait Page: Downcast { None } + /// Display a context drawer for the page. #[must_use] fn context_drawer(&self) -> Option> { None } + /// Display an inner app dialog for the page. + fn dialog(&self) -> Option> { + None + } + /// Response from a file chooser dialog request. fn file_chooser(&mut self, _selected: Vec) -> Command { Command::none() } + /// Alter the contents of the page's header view. fn header_view(&self) -> Option> { None } + /// Reload page metadata via a Command. #[must_use] #[allow(unused)] fn reload(&mut self, page: crate::Entity) -> Command {