diff --git a/examples/about/src/main.rs b/examples/about/src/main.rs index 5450b47e..957433f0 100644 --- a/examples/about/src/main.rs +++ b/examples/about/src/main.rs @@ -71,6 +71,7 @@ impl cosmic::Application for App { .version("0.1.0") .author("System 76") .license("GPL-3.0-only") + //.license_url("https://www.some-custom-license-url.com") .developers([("Michael Murphy", "mmstick@system76.com")]) .links([ ("Website", "https://system76.com/cosmic"), diff --git a/src/widget/about.rs b/src/widget/about.rs index 13fcea23..aea92991 100644 --- a/src/widget/about.rs +++ b/src/widget/about.rs @@ -25,6 +25,8 @@ pub struct About { copyright: Option, /// The license name. license: Option, + /// The license url. If None spdx.org url is used. + license_url: Option, /// Artists who contributed to the application. #[setters(skip)] artists: Vec<(String, String)>, @@ -95,10 +97,12 @@ impl<'a> About { self } - fn license_url(&self) -> Option { - self.license.as_ref().and_then(|license_str| { - let license: &dyn License = license_str.parse().ok()?; - Some(format!("https://spdx.org/licenses/{}.html", license.id())) + fn get_license_url(&self) -> Option { + self.license_url.clone().or_else(|| { + self.license.as_ref().and_then(|license_str| { + let license: &dyn License = license_str.parse().ok()?; + Some(format!("https://spdx.org/licenses/{}.html", license.id())) + }) }) } } @@ -153,7 +157,7 @@ pub fn about<'a, Message: Clone + 'static>( let translators_section = section(&about.translators, "Translators"); let documenters_section = section(&about.documenters, "Documenters"); let license = about.license.as_ref().map(|license| { - let url = about.license_url(); + let url = about.get_license_url(); widget::settings::section().title("License").add( widget::button::custom( widget::row()