diff --git a/i18n/en/cosmic_ext_tweaks.ftl b/i18n/en/cosmic_ext_tweaks.ftl index 5c1f873..cb22e61 100644 --- a/i18n/en/cosmic_ext_tweaks.ftl +++ b/i18n/en/cosmic_ext_tweaks.ftl @@ -20,6 +20,9 @@ padding-description = Padding is the space between the contents and the borders spacing = Spacing spacing-description = Spacing is the space between the icons in the dock or panel. +border_radius = Border radius +border-radius-description = Radius for the dock or panel. + save = Save cancel = Cancel save-current-color-scheme = Save current color scheme diff --git a/src/pages/dock.rs b/src/pages/dock.rs index 4543246..ed659df 100644 --- a/src/pages/dock.rs +++ b/src/pages/dock.rs @@ -12,6 +12,7 @@ pub struct Dock { pub dock_config: Option, pub padding: u32, pub spacing: u32, + pub border_radius: u32, } impl Default for Dock { @@ -29,11 +30,16 @@ impl Default for Dock { .clone() .map(|config| config.spacing) .unwrap_or(0); + let border_radius = dock_config + .clone() + .map(|config| config.border_radius) + .unwrap_or(0); Self { dock_helper, dock_config, padding, spacing, + border_radius, } } } @@ -42,6 +48,7 @@ impl Default for Dock { pub enum Message { SetPadding(u32), SetSpacing(u32), + SetBorder(u32), } impl Dock { @@ -72,6 +79,19 @@ impl Dock { ]) .spacing(spacing.space_xxs), ), + ) + .add( + widget::settings::item::builder(fl!("border_radius")) + .description(fl!("border-radius-description")) + .icon(icons::get_icon("size-horizontally-symbolic", 18)) + .control( + widget::row::with_children(vec![ + widget::slider(0..=28, self.border_radius, Message::SetBorder) + .into(), + widget::text::text(format!("{} px", self.border_radius)).into(), + ]) + .spacing(spacing.space_xxs), + ), ), ) .into() @@ -100,6 +120,13 @@ impl Dock { eprintln!("Error updating dock spacing: {}", err); } } + Message::SetBorder(border_radius) => { + self.border_radius = border_radius; + let update = dock_config.set_border_radius(dock_helper, self.border_radius); + if let Err(err) = update { + eprintln!("Error updating dock border radius: {}", err); + } + } } Command::none() } diff --git a/src/pages/panel.rs b/src/pages/panel.rs index 385d267..5922aec 100644 --- a/src/pages/panel.rs +++ b/src/pages/panel.rs @@ -13,6 +13,7 @@ pub struct Panel { pub panel_config: Option, pub padding: u32, pub spacing: u32, + pub border_radius: u32, pub show_panel: bool, pub cosmic_panel_config: CosmicPanel, pub cosmic_panel_config_helper: Option, @@ -65,12 +66,17 @@ impl Default for Panel { .clone() .map(|config| config.spacing) .unwrap_or(0); + let border_radius = panel_config + .clone() + .map(|config| config.border_radius) + .unwrap_or(0); let show_panel = cosmic_panel_config.entries.iter().any(|e| e == "Panel"); Self { panel_helper, panel_config, padding, spacing, + border_radius, show_panel, cosmic_panel_config, cosmic_panel_config_helper, @@ -82,6 +88,7 @@ impl Default for Panel { pub enum Message { SetPadding(u32), SetSpacing(u32), + SetBorder(u32), ShowPanel(bool), } @@ -118,6 +125,19 @@ impl Panel { ]) .spacing(spacing.space_xxs), ), + ) + .add( + widget::settings::item::builder(fl!("border_radius")) + .description(fl!("border-radius-description")) + .icon(icons::get_icon("size-horizontally-symbolic", 18)) + .control( + widget::row::with_children(vec![ + widget::slider(0..=28, self.border_radius, Message::SetBorder) + .into(), + widget::text::text(format!("{} px", self.border_radius)).into(), + ]) + .spacing(spacing.space_xxs), + ), ), ) .into() @@ -146,6 +166,13 @@ impl Panel { eprintln!("Error updating panel spacing: {}", err); } } + Message::SetBorder(border_radius) => { + self.border_radius = border_radius; + let update = panel_config.set_border_radius(panel_helper, self.border_radius); + if let Err(err) = update { + eprintln!("Error updating panel border radius: {}", err); + } + } Message::ShowPanel(show) => { if show { if !self