use crate::icon::Icon; /// Application metadata for the [`PredefinedMenuItem::about`]. #[derive(Debug, Clone, Default)] pub struct AboutMetadata { /// Sets the application name. pub name: Option, /// The application version. pub version: Option, /// The short version, e.g. "1.0". /// /// ## Platform-specific /// /// - **Windows / Linux:** Appended to the end of `version` in parentheses. pub short_version: Option, /// The authors of the application. /// /// ## Platform-specific /// /// - **macOS:** Unsupported. pub authors: Option>, /// Application comments. /// /// ## Platform-specific /// /// - **macOS:** Unsupported. pub comments: Option, /// The copyright of the application. pub copyright: Option, /// The license of the application. /// /// ## Platform-specific /// /// - **macOS:** Unsupported. pub license: Option, /// The application website. /// /// ## Platform-specific /// /// - **macOS:** Unsupported. pub website: Option, /// The website label. /// /// ## Platform-specific /// /// - **macOS:** Unsupported. pub website_label: Option, /// The credits. /// /// ## Platform-specific /// /// - **Windows / Linux:** Unsupported. pub credits: Option, /// The application icon. /// /// ## Platform-specific /// /// - **Windows:** Unsupported. pub icon: Option, } impl AboutMetadata { #[allow(unused)] pub(crate) fn full_version(&self) -> Option { Some(format!( "{}{}", (self.version.as_ref())?, (self.short_version.as_ref()) .map(|v| format!(" ({v})")) .unwrap_or_default() )) } } /// A builder type for [`AboutMetadata`]. #[derive(Clone, Debug, Default)] pub struct AboutMetadataBuilder(AboutMetadata); impl AboutMetadataBuilder { pub fn new() -> Self { Default::default() } /// Sets the application name. pub fn name>(mut self, name: Option) -> Self { self.0.name = name.map(|s| s.into()); self } /// Sets the application version. pub fn version>(mut self, version: Option) -> Self { self.0.version = version.map(|s| s.into()); self } /// Sets the short version, e.g. "1.0". /// /// ## Platform-specific /// /// - **Windows / Linux:** Appended to the end of `version` in parentheses. pub fn short_version>(mut self, short_version: Option) -> Self { self.0.short_version = short_version.map(|s| s.into()); self } /// Sets the authors of the application. /// /// ## Platform-specific /// /// - **macOS:** Unsupported. pub fn authors(mut self, authors: Option>) -> Self { self.0.authors = authors; self } /// Application comments. /// /// ## Platform-specific /// /// - **macOS:** Unsupported. pub fn comments>(mut self, comments: Option) -> Self { self.0.comments = comments.map(|s| s.into()); self } /// Sets the copyright of the application. pub fn copyright>(mut self, copyright: Option) -> Self { self.0.copyright = copyright.map(|s| s.into()); self } /// Sets the license of the application. /// /// ## Platform-specific /// /// - **macOS:** Unsupported. pub fn license>(mut self, license: Option) -> Self { self.0.license = license.map(|s| s.into()); self } /// Sets the application website. /// /// ## Platform-specific /// /// - **macOS:** Unsupported. pub fn website>(mut self, website: Option) -> Self { self.0.website = website.map(|s| s.into()); self } /// Sets the website label. /// /// ## Platform-specific /// /// - **macOS:** Unsupported. pub fn website_label>(mut self, website_label: Option) -> Self { self.0.website_label = website_label.map(|s| s.into()); self } /// Sets the credits. /// /// ## Platform-specific /// /// - **Windows / Linux:** Unsupported. pub fn credits>(mut self, credits: Option) -> Self { self.0.credits = credits.map(|s| s.into()); self } /// Sets the application icon. /// /// ## Platform-specific /// /// - **Windows:** Unsupported. pub fn icon(mut self, icon: Option) -> Self { self.0.icon = icon; self } /// Construct the final [`AboutMetadata`] pub fn build(self) -> AboutMetadata { self.0 } }