Updated spin_button changes

This commit is contained in:
Bryan Hyland 2024-11-19 14:39:54 -08:00 committed by Ashley Wulber
parent 4b8331117d
commit a394a169f5

View file

@ -17,14 +17,14 @@ use cosmic::cosmic_theme::{
CornerRadii, Density, Spacing, Theme, ThemeBuilder, ThemeMode, DARK_THEME_BUILDER_ID, CornerRadii, Density, Spacing, Theme, ThemeBuilder, ThemeMode, DARK_THEME_BUILDER_ID,
LIGHT_THEME_BUILDER_ID, LIGHT_THEME_BUILDER_ID,
}; };
use cosmic::iced_core::{alignment, Color, Length}; use cosmic::iced_core::{Alignment, Color, Length};
use cosmic::iced_widget::scrollable::{Direction, Scrollbar}; use cosmic::iced_widget::scrollable::{Direction, Scrollbar};
use cosmic::widget::icon::{from_name, icon}; use cosmic::widget::icon::{from_name, icon};
use cosmic::widget::{ use cosmic::widget::{
button, color_picker::ColorPickerUpdate, container, flex_row, horizontal_space, radio, row, button, color_picker::ColorPickerUpdate, container, flex_row, horizontal_space, radio, row,
scrollable, settings, spin_button, text, ColorPickerModel, scrollable, settings, spin_button, text, ColorPickerModel,
}; };
use cosmic::{Apply, Element, Task}; use cosmic::{widget, Apply, Element, Task};
#[cfg(feature = "wayland")] #[cfg(feature = "wayland")]
use cosmic_panel_config::CosmicPanelConfig; use cosmic_panel_config::CosmicPanelConfig;
use cosmic_settings_page::Section; use cosmic_settings_page::Section;
@ -286,7 +286,7 @@ pub enum Message {
FontConfig(font_config::Message), FontConfig(font_config::Message),
FontSearch(String), FontSearch(String),
FontSelect(bool, Arc<str>), FontSelect(bool, Arc<str>),
GapSize(i32), GapSize(u32),
IconTheme(usize), IconTheme(usize),
#[cfg(feature = "ashpd")] #[cfg(feature = "ashpd")]
ImportError, ImportError,
@ -305,7 +305,7 @@ pub enum Message {
#[cfg(feature = "ashpd")] #[cfg(feature = "ashpd")]
StartImport, StartImport,
UseDefaultWindowHint(bool), UseDefaultWindowHint(bool),
WindowHintSize(i32), WindowHintSize(u32),
Daytime(bool), Daytime(bool),
} }
@ -560,14 +560,14 @@ impl Page {
if self if self
.theme_builder .theme_builder
.set_active_hint(config, active_hint as u32) .set_active_hint(config, active_hint)
.unwrap_or_default() .unwrap_or_default()
{ {
self.theme_config_write("active_hint", active_hint); self.theme_config_write("active_hint", active_hint);
} }
} }
Message::GapSize(new_gap_size) => { Message::GapSize(gap) => {
needs_sync = true; needs_sync = true;
let Some(config) = self.theme_builder_config.as_ref() else { let Some(config) = self.theme_builder_config.as_ref() else {
@ -576,7 +576,7 @@ impl Page {
let mut gaps = self.theme_builder.gaps; let mut gaps = self.theme_builder.gaps;
gaps.1 = new_gap_size as u32; gaps.1 = gap;
if self if self
.theme_builder .theme_builder
@ -1307,8 +1307,6 @@ impl Page {
// TODO: cache panel and dock configs so that they needn't be re-read // TODO: cache panel and dock configs so that they needn't be re-read
#[cfg(feature = "wayland")] #[cfg(feature = "wayland")]
fn update_panel_radii(roundness: Roundness) { fn update_panel_radii(roundness: Roundness) {
use cosmic_config::CosmicConfigEntry;
let panel_config_helper = CosmicPanelConfig::cosmic_config("Panel").ok(); let panel_config_helper = CosmicPanelConfig::cosmic_config("Panel").ok();
let dock_config_helper = CosmicPanelConfig::cosmic_config("Dock").ok(); let dock_config_helper = CosmicPanelConfig::cosmic_config("Dock").ok();
@ -1355,8 +1353,6 @@ impl Page {
#[cfg(feature = "wayland")] #[cfg(feature = "wayland")]
fn update_panel_spacing(density: Density) { fn update_panel_spacing(density: Density) {
use cosmic_config::CosmicConfigEntry;
let panel_config_helper = CosmicPanelConfig::cosmic_config("Panel").ok(); let panel_config_helper = CosmicPanelConfig::cosmic_config("Panel").ok();
let dock_config_helper = CosmicPanelConfig::cosmic_config("Dock").ok(); let dock_config_helper = CosmicPanelConfig::cosmic_config("Dock").ok();
let mut panel_config = panel_config_helper.as_ref().and_then(|config_helper| { let mut panel_config = panel_config_helper.as_ref().and_then(|config_helper| {
@ -1423,7 +1419,7 @@ impl page::Page<crate::pages::Message> for Page {
.push(button::standard(fl!("export")).on_press(Message::StartExport)) .push(button::standard(fl!("export")).on_press(Message::StartExport))
.apply(container) .apply(container)
.width(Length::Fill) .width(Length::Fill)
.align_x(alignment::Horizontal::Right) .align_x(Alignment::End)
.apply(Element::from) .apply(Element::from)
.map(crate::pages::Message::Appearance); .map(crate::pages::Message::Appearance);
@ -1601,7 +1597,7 @@ pub fn mode_and_colors() -> Section<crate::pages::Message> {
] ]
.spacing(space_xxs) .spacing(space_xxs)
.width(Length::FillPortion(1)) .width(Length::FillPortion(1))
.align_x(cosmic::iced_core::Alignment::Center), .align_x(Alignment::Center),
cosmic::iced::widget::column![ cosmic::iced::widget::column![
button::custom( button::custom(
icon(light_mode_illustration.clone(),) icon(light_mode_illustration.clone(),)
@ -1616,14 +1612,13 @@ pub fn mode_and_colors() -> Section<crate::pages::Message> {
] ]
.spacing(space_xxs) .spacing(space_xxs)
.width(Length::FillPortion(1)) .width(Length::FillPortion(1))
.align_x(cosmic::iced_core::Alignment::Center) .align_x(Alignment::Center)
] ]
.spacing(48) .spacing(48)
.align_y(cosmic::iced_core::Alignment::Center) .align_y(Alignment::Center)
.width(Length::Fixed(424.0)), .width(Length::Fixed(424.0)),
) )
.width(Length::Fill) .center_x(Length::Fill),
.align_x(cosmic::iced_core::alignment::Horizontal::Center),
) )
.add( .add(
settings::item::builder(&descriptions[auto_switch]) settings::item::builder(&descriptions[auto_switch])
@ -1856,7 +1851,7 @@ pub fn style() -> Section<crate::pages::Message> {
] ]
.spacing(8) .spacing(8)
.width(Length::FillPortion(1)) .width(Length::FillPortion(1))
.align_x(cosmic::iced_core::Alignment::Center), .align_x(Alignment::Center),
cosmic::iced::widget::column![ cosmic::iced::widget::column![
button::custom( button::custom(
icon( icon(
@ -1878,7 +1873,7 @@ pub fn style() -> Section<crate::pages::Message> {
] ]
.spacing(8) .spacing(8)
.width(Length::FillPortion(1)) .width(Length::FillPortion(1))
.align_x(cosmic::iced_core::Alignment::Center), .align_x(Alignment::Center),
cosmic::iced::widget::column![ cosmic::iced::widget::column![
button::custom( button::custom(
icon( icon(
@ -1900,15 +1895,14 @@ pub fn style() -> Section<crate::pages::Message> {
text::body(&descriptions[square]) text::body(&descriptions[square])
] ]
.spacing(8) .spacing(8)
.align_x(cosmic::iced_core::Alignment::Center) .align_x(Alignment::Center)
.width(Length::FillPortion(1)) .width(Length::FillPortion(1))
] ]
.spacing(12) .spacing(12)
.width(Length::Fixed(628.0)) .width(Length::Fixed(628.0))
.align_y(cosmic::iced_core::Alignment::Center), .align_y(Alignment::Center),
) )
.width(Length::Fill) .center_x(Length::Fill),
.align_x(cosmic::iced_core::alignment::Horizontal::Center),
) )
.apply(Element::from) .apply(Element::from)
.map(crate::pages::Message::Appearance) .map(crate::pages::Message::Appearance)
@ -1976,26 +1970,26 @@ pub fn window_management() -> Section<crate::pages::Message> {
settings::section() settings::section()
.title(&section.title) .title(&section.title)
.add( .add(settings::item::builder(&descriptions[active_hint]).control(
settings::item::builder(&descriptions[active_hint]).control(spin_button( cosmic::widget::spin_button(
page.theme.active_hint.to_string(), page.theme_builder.active_hint.to_string(),
1, 1,
page.theme.active_hint as i32, page.theme.active_hint,
0, 0,
500, 500,
Message::WindowHintSize, Message::WindowHintSize,
)), ),
) ))
.add( .add(settings::item::builder(&descriptions[gaps]).control(
settings::item::builder(&descriptions[gaps]).control(spin_button( cosmic::widget::spin_button(
page.theme.gaps.1.to_string(), page.theme_builder.gaps.1.to_string(),
page.theme_builder.gaps.1.to_string(),
1, 1,
page.theme.gaps.1 as i32, page.theme.active_hint,
0,
500, 500,
Message::GapSize, Message::GapSize,
)), ),
) ))
.apply(Element::from) .apply(Element::from)
.map(crate::pages::Message::Appearance) .map(crate::pages::Message::Appearance)
}) })
@ -2084,4 +2078,4 @@ pub fn color_button<'a, Message: 'a + Clone>(
.width(Length::Fixed(f32::from(width))) .width(Length::Fixed(f32::from(width)))
.height(Length::Fixed(f32::from(height))) .height(Length::Fixed(f32::from(height)))
.into() .into()
} }