improv(about): support custom license URLs
This commit is contained in:
parent
4d06524f2c
commit
2dd6dce053
2 changed files with 10 additions and 5 deletions
|
|
@ -71,6 +71,7 @@ impl cosmic::Application for App {
|
||||||
.version("0.1.0")
|
.version("0.1.0")
|
||||||
.author("System 76")
|
.author("System 76")
|
||||||
.license("GPL-3.0-only")
|
.license("GPL-3.0-only")
|
||||||
|
//.license_url("https://www.some-custom-license-url.com")
|
||||||
.developers([("Michael Murphy", "mmstick@system76.com")])
|
.developers([("Michael Murphy", "mmstick@system76.com")])
|
||||||
.links([
|
.links([
|
||||||
("Website", "https://system76.com/cosmic"),
|
("Website", "https://system76.com/cosmic"),
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ pub struct About {
|
||||||
copyright: Option<String>,
|
copyright: Option<String>,
|
||||||
/// The license name.
|
/// The license name.
|
||||||
license: Option<String>,
|
license: Option<String>,
|
||||||
|
/// The license url. If None spdx.org url is used.
|
||||||
|
license_url: Option<String>,
|
||||||
/// Artists who contributed to the application.
|
/// Artists who contributed to the application.
|
||||||
#[setters(skip)]
|
#[setters(skip)]
|
||||||
artists: Vec<(String, String)>,
|
artists: Vec<(String, String)>,
|
||||||
|
|
@ -95,10 +97,12 @@ impl<'a> About {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn license_url(&self) -> Option<String> {
|
fn get_license_url(&self) -> Option<String> {
|
||||||
self.license.as_ref().and_then(|license_str| {
|
self.license_url.clone().or_else(|| {
|
||||||
let license: &dyn License = license_str.parse().ok()?;
|
self.license.as_ref().and_then(|license_str| {
|
||||||
Some(format!("https://spdx.org/licenses/{}.html", license.id()))
|
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 translators_section = section(&about.translators, "Translators");
|
||||||
let documenters_section = section(&about.documenters, "Documenters");
|
let documenters_section = section(&about.documenters, "Documenters");
|
||||||
let license = about.license.as_ref().map(|license| {
|
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::settings::section().title("License").add(
|
||||||
widget::button::custom(
|
widget::button::custom(
|
||||||
widget::row()
|
widget::row()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue