Manual implementation

- Added manual implementation to allow the property to be set to None.
This commit is contained in:
Eduardo Flores 2023-08-09 21:23:45 -07:00
parent 09dab77317
commit 2aba821067

View file

@ -26,7 +26,7 @@ pub struct Settings {
pub(crate) default_font: Font, pub(crate) default_font: Font,
/// Name of the icon theme to search by default. /// Name of the icon theme to search by default.
#[setters(into, strip_option)] #[setters(skip)]
pub(crate) default_icon_theme: Option<String>, pub(crate) default_icon_theme: Option<String>,
/// Default size of fonts. /// Default size of fonts.
@ -53,6 +53,19 @@ pub struct Settings {
pub(crate) transparent: bool, pub(crate) transparent: bool,
} }
impl Settings {
/// Sets the default icon theme, passing an empty string will unset the theme.
pub fn default_icon_theme(mut self, value: impl Into<String>) -> Self {
let value: String = value.into();
self.default_icon_theme = if value.is_empty() {
None
} else {
Some(value.to_string())
};
self
}
}
impl Default for Settings { impl Default for Settings {
fn default() -> Self { fn default() -> Self {
Self { Self {