feat: inner-app dialog API support
This commit is contained in:
parent
43b478ee68
commit
29f0489c8a
3 changed files with 23 additions and 2 deletions
|
|
@ -60,7 +60,6 @@ impl SettingsApp {
|
||||||
PageCommands::DesktopPanel => self.pages.page_id::<desktop::options::Page>(),
|
PageCommands::DesktopPanel => self.pages.page_id::<desktop::options::Page>(),
|
||||||
PageCommands::Displays => self.pages.page_id::<display::Page>(),
|
PageCommands::Displays => self.pages.page_id::<display::Page>(),
|
||||||
PageCommands::Firmware => self.pages.page_id::<system::firmware::Page>(),
|
PageCommands::Firmware => self.pages.page_id::<system::firmware::Page>(),
|
||||||
PageCommands::Keyboard => self.pages.page_id::<input::keyboard::Page>(),
|
|
||||||
PageCommands::Mouse => self.pages.page_id::<input::mouse::Page>(),
|
PageCommands::Mouse => self.pages.page_id::<input::mouse::Page>(),
|
||||||
PageCommands::Network => None,
|
PageCommands::Network => None,
|
||||||
PageCommands::Notifications => self.pages.page_id::<desktop::notifications::Page>(),
|
PageCommands::Notifications => self.pages.page_id::<desktop::notifications::Page>(),
|
||||||
|
|
@ -529,6 +528,12 @@ impl cosmic::Application for SettingsApp {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn dialog(&self) -> Option<Element<Self::Message>> {
|
||||||
|
self.pages
|
||||||
|
.dialog(self.active_page)
|
||||||
|
.map(|e| e.map(Message::PageMessage))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SettingsApp {
|
impl SettingsApp {
|
||||||
|
|
|
||||||
|
|
@ -136,13 +136,20 @@ impl<Message: 'static> Binder<Message> {
|
||||||
page.downcast_ref::<P>()
|
page.downcast_ref::<P>()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Obtain a reference to a page by its type ID.
|
/// Create a context drawer for the given page.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn context_drawer(&self, id: crate::Entity) -> Option<Element<'_, Message>> {
|
pub fn context_drawer(&self, id: crate::Entity) -> Option<Element<'_, Message>> {
|
||||||
let page = self.page.get(id)?;
|
let page = self.page.get(id)?;
|
||||||
page.context_drawer()
|
page.context_drawer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create a dialog for the given page.
|
||||||
|
#[must_use]
|
||||||
|
pub fn dialog(&self, id: crate::Entity) -> Option<Element<'_, Message>> {
|
||||||
|
let page = self.page.get(id)?;
|
||||||
|
page.dialog()
|
||||||
|
}
|
||||||
|
|
||||||
/// Obtain a reference to a page by its type ID.
|
/// Obtain a reference to a page by its type ID.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn page_mut<P: Page<Message>>(&mut self) -> Option<&mut P> {
|
pub fn page_mut<P: Page<Message>>(&mut self) -> Option<&mut P> {
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ pub trait Page<Message: 'static>: Downcast {
|
||||||
/// Information about the page
|
/// Information about the page
|
||||||
fn info(&self) -> Info;
|
fn info(&self) -> Info;
|
||||||
|
|
||||||
|
/// Initialize the sections used by this page.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
fn content(
|
fn content(
|
||||||
&self,
|
&self,
|
||||||
|
|
@ -36,20 +37,28 @@ pub trait Page<Message: 'static>: Downcast {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Display a context drawer for the page.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
fn context_drawer(&self) -> Option<Element<'_, Message>> {
|
fn context_drawer(&self) -> Option<Element<'_, Message>> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Display an inner app dialog for the page.
|
||||||
|
fn dialog(&self) -> Option<Element<'_, Message>> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
/// Response from a file chooser dialog request.
|
/// Response from a file chooser dialog request.
|
||||||
fn file_chooser(&mut self, _selected: Vec<url::Url>) -> Command<Message> {
|
fn file_chooser(&mut self, _selected: Vec<url::Url>) -> Command<Message> {
|
||||||
Command::none()
|
Command::none()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Alter the contents of the page's header view.
|
||||||
fn header_view(&self) -> Option<Element<'_, Message>> {
|
fn header_view(&self) -> Option<Element<'_, Message>> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Reload page metadata via a Command.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
fn reload(&mut self, page: crate::Entity) -> Command<Message> {
|
fn reload(&mut self, page: crate::Entity) -> Command<Message> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue