improv: section descriptions may now be stored as static strings
This commit is contained in:
parent
1460ab723d
commit
926692200d
14 changed files with 261 additions and 250 deletions
|
|
@ -33,6 +33,11 @@ use super::wallpaper::widgets::color_image;
|
||||||
|
|
||||||
pub static COLOR_PICKER_DIALOG_ID: Lazy<window::Id> = Lazy::new(window::Id::unique);
|
pub static COLOR_PICKER_DIALOG_ID: Lazy<window::Id> = Lazy::new(window::Id::unique);
|
||||||
|
|
||||||
|
crate::cache_dynamic_lazy! {
|
||||||
|
static HEX: String = fl!("hex");
|
||||||
|
static RGB: String = fl!("rgb");
|
||||||
|
}
|
||||||
|
|
||||||
enum NamedColorPicker {
|
enum NamedColorPicker {
|
||||||
CustomAccent,
|
CustomAccent,
|
||||||
ApplicationBackground,
|
ApplicationBackground,
|
||||||
|
|
@ -116,38 +121,38 @@ impl From<(Option<Config>, ThemeMode, Option<Config>, ThemeBuilder)> for Page {
|
||||||
},
|
},
|
||||||
roundness: theme_builder.corner_radii.into(),
|
roundness: theme_builder.corner_radii.into(),
|
||||||
custom_accent: ColorPickerModel::new(
|
custom_accent: ColorPickerModel::new(
|
||||||
fl!("hex"),
|
&*HEX,
|
||||||
fl!("rgb"),
|
&*RGB,
|
||||||
None,
|
None,
|
||||||
custom_accent.map(Color::from),
|
custom_accent.map(Color::from),
|
||||||
),
|
),
|
||||||
application_background: ColorPickerModel::new(
|
application_background: ColorPickerModel::new(
|
||||||
fl!("hex"),
|
&*HEX,
|
||||||
fl!("rgb"),
|
&*RGB,
|
||||||
Some(theme.background.base.into()),
|
Some(theme.background.base.into()),
|
||||||
theme_builder.bg_color.map(Color::from),
|
theme_builder.bg_color.map(Color::from),
|
||||||
),
|
),
|
||||||
container_background: ColorPickerModel::new(
|
container_background: ColorPickerModel::new(
|
||||||
fl!("hex"),
|
&*HEX,
|
||||||
fl!("rgb"),
|
&*RGB,
|
||||||
None,
|
None,
|
||||||
theme_builder.primary_container_bg.map(Color::from),
|
theme_builder.primary_container_bg.map(Color::from),
|
||||||
),
|
),
|
||||||
interface_text: ColorPickerModel::new(
|
interface_text: ColorPickerModel::new(
|
||||||
fl!("hex"),
|
&*HEX,
|
||||||
fl!("rgb"),
|
&*RGB,
|
||||||
Some(theme.background.on.into()),
|
Some(theme.background.on.into()),
|
||||||
theme_builder.text_tint.map(Color::from),
|
theme_builder.text_tint.map(Color::from),
|
||||||
),
|
),
|
||||||
control_component: ColorPickerModel::new(
|
control_component: ColorPickerModel::new(
|
||||||
fl!("hex"),
|
&*HEX,
|
||||||
fl!("rgb"),
|
&*RGB,
|
||||||
Some(theme.palette.neutral_5.into()),
|
Some(theme.palette.neutral_5.into()),
|
||||||
theme_builder.neutral_tint.map(Color::from),
|
theme_builder.neutral_tint.map(Color::from),
|
||||||
),
|
),
|
||||||
accent_window_hint: ColorPickerModel::new(
|
accent_window_hint: ColorPickerModel::new(
|
||||||
fl!("hex"),
|
&*HEX,
|
||||||
fl!("rgb"),
|
&*RGB,
|
||||||
None,
|
None,
|
||||||
theme_builder.window_hint.map(Color::from),
|
theme_builder.window_hint.map(Color::from),
|
||||||
),
|
),
|
||||||
|
|
@ -634,7 +639,7 @@ impl Page {
|
||||||
async {
|
async {
|
||||||
SelectedFiles::open_file()
|
SelectedFiles::open_file()
|
||||||
.modal(true)
|
.modal(true)
|
||||||
.filter(FileFilter::glob(FileFilter::new("ron"), "*.ron"))
|
.filter(FileFilter::glob(FileFilter::new("ron").into(), "*.ron"))
|
||||||
.send()
|
.send()
|
||||||
.await?
|
.await?
|
||||||
.response()
|
.response()
|
||||||
|
|
@ -999,29 +1004,29 @@ pub fn mode_and_colors() -> Section<crate::pages::Message> {
|
||||||
.title(fl!("mode-and-colors"))
|
.title(fl!("mode-and-colors"))
|
||||||
.descriptions(vec![
|
.descriptions(vec![
|
||||||
// 0
|
// 0
|
||||||
fl!("auto-switch"),
|
fl!("auto-switch").into(),
|
||||||
fl!("auto-switch", "desc"),
|
fl!("auto-switch", "desc").into(),
|
||||||
//2
|
//2
|
||||||
fl!("accent-color"),
|
fl!("accent-color").into(),
|
||||||
//3
|
//3
|
||||||
fl!("app-background"),
|
fl!("app-background").into(),
|
||||||
//4
|
//4
|
||||||
fl!("container-background"),
|
fl!("container-background").into(),
|
||||||
fl!("container-background", "desc"),
|
fl!("container-background", "desc").into(),
|
||||||
fl!("container-background", "desc-detail"),
|
fl!("container-background", "desc-detail").into(),
|
||||||
fl!("container-background", "reset"),
|
fl!("container-background", "reset").into(),
|
||||||
// 8
|
// 8
|
||||||
fl!("text-tint"),
|
fl!("text-tint").into(),
|
||||||
fl!("text-tint", "desc"),
|
fl!("text-tint", "desc").into(),
|
||||||
// 10
|
// 10
|
||||||
fl!("control-tint"),
|
fl!("control-tint").into(),
|
||||||
fl!("control-tint", "desc"),
|
fl!("control-tint", "desc").into(),
|
||||||
// 12
|
// 12
|
||||||
fl!("window-hint-accent-toggle"),
|
fl!("window-hint-accent-toggle").into(),
|
||||||
fl!("window-hint-accent"),
|
fl!("window-hint-accent").into(),
|
||||||
// 14
|
// 14
|
||||||
fl!("dark"),
|
fl!("dark").into(),
|
||||||
fl!("light"),
|
fl!("light").into(),
|
||||||
])
|
])
|
||||||
.view::<Page>(|_binder, page, section| {
|
.view::<Page>(|_binder, page, section| {
|
||||||
let descriptions = §ion.descriptions;
|
let descriptions = §ion.descriptions;
|
||||||
|
|
@ -1044,7 +1049,7 @@ pub fn mode_and_colors() -> Section<crate::pages::Message> {
|
||||||
.padding([8, 0])
|
.padding([8, 0])
|
||||||
.selected(page.theme_mode.is_dark)
|
.selected(page.theme_mode.is_dark)
|
||||||
.on_press(Message::DarkMode(true)),
|
.on_press(Message::DarkMode(true)),
|
||||||
text(&descriptions[14])
|
text(&*descriptions[14])
|
||||||
]
|
]
|
||||||
.spacing(8)
|
.spacing(8)
|
||||||
.width(Length::FillPortion(1))
|
.width(Length::FillPortion(1))
|
||||||
|
|
@ -1059,7 +1064,7 @@ pub fn mode_and_colors() -> Section<crate::pages::Message> {
|
||||||
.selected(!page.theme_mode.is_dark)
|
.selected(!page.theme_mode.is_dark)
|
||||||
.padding([8, 0])
|
.padding([8, 0])
|
||||||
.on_press(Message::DarkMode(false)),
|
.on_press(Message::DarkMode(false)),
|
||||||
text(&descriptions[15])
|
text(&*descriptions[15])
|
||||||
]
|
]
|
||||||
.spacing(8)
|
.spacing(8)
|
||||||
.width(Length::FillPortion(1))
|
.width(Length::FillPortion(1))
|
||||||
|
|
@ -1073,13 +1078,13 @@ pub fn mode_and_colors() -> Section<crate::pages::Message> {
|
||||||
.align_x(cosmic::iced_core::alignment::Horizontal::Center),
|
.align_x(cosmic::iced_core::alignment::Horizontal::Center),
|
||||||
)
|
)
|
||||||
.add(
|
.add(
|
||||||
settings::item::builder(&descriptions[0])
|
settings::item::builder(&*descriptions[0])
|
||||||
.description(&descriptions[1])
|
.description(&*descriptions[1])
|
||||||
.toggler(page.theme_mode.auto_switch, Message::Autoswitch),
|
.toggler(page.theme_mode.auto_switch, Message::Autoswitch),
|
||||||
)
|
)
|
||||||
.add(
|
.add(
|
||||||
cosmic::iced::widget::column![
|
cosmic::iced::widget::column![
|
||||||
text(&descriptions[2]),
|
text(&*descriptions[2]),
|
||||||
scrollable(
|
scrollable(
|
||||||
cosmic::iced::widget::row![
|
cosmic::iced::widget::row![
|
||||||
color_button(
|
color_button(
|
||||||
|
|
@ -1175,7 +1180,7 @@ pub fn mode_and_colors() -> Section<crate::pages::Message> {
|
||||||
.spacing(8),
|
.spacing(8),
|
||||||
)
|
)
|
||||||
.add(
|
.add(
|
||||||
settings::item::builder(&descriptions[3]).control(
|
settings::item::builder(&*descriptions[3]).control(
|
||||||
page.application_background
|
page.application_background
|
||||||
.picker_button(Message::ApplicationBackground, Some(24))
|
.picker_button(Message::ApplicationBackground, Some(24))
|
||||||
.width(Length::Fixed(48.0))
|
.width(Length::Fixed(48.0))
|
||||||
|
|
@ -1183,8 +1188,8 @@ pub fn mode_and_colors() -> Section<crate::pages::Message> {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.add(
|
.add(
|
||||||
settings::item::builder(&descriptions[4])
|
settings::item::builder(&*descriptions[4])
|
||||||
.description(&descriptions[5])
|
.description(&*descriptions[5])
|
||||||
.control(
|
.control(
|
||||||
if let Some(c) = page.container_background.get_applied_color() {
|
if let Some(c) = page.container_background.get_applied_color() {
|
||||||
container(color_button(
|
container(color_button(
|
||||||
|
|
@ -1208,8 +1213,8 @@ pub fn mode_and_colors() -> Section<crate::pages::Message> {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.add(
|
.add(
|
||||||
settings::item::builder(&descriptions[8])
|
settings::item::builder(&*descriptions[8])
|
||||||
.description(&descriptions[9])
|
.description(&*descriptions[9])
|
||||||
.control(
|
.control(
|
||||||
page.interface_text
|
page.interface_text
|
||||||
.picker_button(Message::InterfaceText, Some(24))
|
.picker_button(Message::InterfaceText, Some(24))
|
||||||
|
|
@ -1218,8 +1223,8 @@ pub fn mode_and_colors() -> Section<crate::pages::Message> {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.add(
|
.add(
|
||||||
settings::item::builder(&descriptions[10])
|
settings::item::builder(&*descriptions[10])
|
||||||
.description(&descriptions[11])
|
.description(&*descriptions[11])
|
||||||
.control(
|
.control(
|
||||||
page.control_component
|
page.control_component
|
||||||
.picker_button(Message::ControlComponent, Some(24))
|
.picker_button(Message::ControlComponent, Some(24))
|
||||||
|
|
@ -1228,12 +1233,12 @@ pub fn mode_and_colors() -> Section<crate::pages::Message> {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.add(
|
.add(
|
||||||
settings::item::builder(&descriptions[12])
|
settings::item::builder(&*descriptions[12])
|
||||||
.toggler(page.no_custom_window_hint, Message::UseDefaultWindowHint),
|
.toggler(page.no_custom_window_hint, Message::UseDefaultWindowHint),
|
||||||
);
|
);
|
||||||
if !page.no_custom_window_hint {
|
if !page.no_custom_window_hint {
|
||||||
section = section.add(
|
section = section.add(
|
||||||
settings::item::builder(&descriptions[13]).control(
|
settings::item::builder(&*descriptions[13]).control(
|
||||||
page.accent_window_hint
|
page.accent_window_hint
|
||||||
.picker_button(Message::AccentWindowHint, Some(24))
|
.picker_button(Message::AccentWindowHint, Some(24))
|
||||||
.width(Length::Fixed(48.0))
|
.width(Length::Fixed(48.0))
|
||||||
|
|
@ -1252,11 +1257,11 @@ pub fn style() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("style"))
|
.title(fl!("style"))
|
||||||
.descriptions(vec![
|
.descriptions(vec![
|
||||||
fl!("style", "round"),
|
fl!("style", "round").into(),
|
||||||
fl!("style", "slightly-round"),
|
fl!("style", "slightly-round").into(),
|
||||||
fl!("style", "square"),
|
fl!("style", "square").into(),
|
||||||
fl!("frosted"),
|
fl!("frosted").into(),
|
||||||
fl!("frosted", "desc"),
|
fl!("frosted", "desc").into(),
|
||||||
])
|
])
|
||||||
.view::<Page>(|_binder, page, section| {
|
.view::<Page>(|_binder, page, section| {
|
||||||
let descriptions = §ion.descriptions;
|
let descriptions = §ion.descriptions;
|
||||||
|
|
@ -1282,7 +1287,7 @@ pub fn style() -> Section<crate::pages::Message> {
|
||||||
.style(button::Style::Image)
|
.style(button::Style::Image)
|
||||||
.padding(8)
|
.padding(8)
|
||||||
.on_press(Message::Roundness(Roundness::Round)),
|
.on_press(Message::Roundness(Roundness::Round)),
|
||||||
text(&descriptions[0])
|
text(&*descriptions[0])
|
||||||
]
|
]
|
||||||
.spacing(8)
|
.spacing(8)
|
||||||
.width(Length::FillPortion(1))
|
.width(Length::FillPortion(1))
|
||||||
|
|
@ -1304,7 +1309,7 @@ pub fn style() -> Section<crate::pages::Message> {
|
||||||
.style(button::Style::Image)
|
.style(button::Style::Image)
|
||||||
.padding(8)
|
.padding(8)
|
||||||
.on_press(Message::Roundness(Roundness::SlightlyRound)),
|
.on_press(Message::Roundness(Roundness::SlightlyRound)),
|
||||||
text(&descriptions[1])
|
text(&*descriptions[1])
|
||||||
]
|
]
|
||||||
.spacing(8)
|
.spacing(8)
|
||||||
.width(Length::FillPortion(1))
|
.width(Length::FillPortion(1))
|
||||||
|
|
@ -1327,7 +1332,7 @@ pub fn style() -> Section<crate::pages::Message> {
|
||||||
.style(button::Style::Image)
|
.style(button::Style::Image)
|
||||||
.padding(8)
|
.padding(8)
|
||||||
.on_press(Message::Roundness(Roundness::Square)),
|
.on_press(Message::Roundness(Roundness::Square)),
|
||||||
text(&descriptions[2])
|
text(&*descriptions[2])
|
||||||
]
|
]
|
||||||
.spacing(8)
|
.spacing(8)
|
||||||
.align_items(cosmic::iced_core::Alignment::Center)
|
.align_items(cosmic::iced_core::Alignment::Center)
|
||||||
|
|
@ -1341,8 +1346,8 @@ pub fn style() -> Section<crate::pages::Message> {
|
||||||
.align_x(cosmic::iced_core::alignment::Horizontal::Center),
|
.align_x(cosmic::iced_core::alignment::Horizontal::Center),
|
||||||
)
|
)
|
||||||
.add(
|
.add(
|
||||||
settings::item::builder(&descriptions[3])
|
settings::item::builder(&*descriptions[3])
|
||||||
.description(&descriptions[4])
|
.description(&*descriptions[4])
|
||||||
.toggler(page.theme_builder.is_frosted, Message::Frosted),
|
.toggler(page.theme_builder.is_frosted, Message::Frosted),
|
||||||
)
|
)
|
||||||
.apply(Element::from)
|
.apply(Element::from)
|
||||||
|
|
@ -1355,20 +1360,20 @@ pub fn window_management() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("window-management"))
|
.title(fl!("window-management"))
|
||||||
.descriptions(vec![
|
.descriptions(vec![
|
||||||
fl!("window-management", "active-hint"),
|
fl!("window-management", "active-hint").into(),
|
||||||
fl!("window-management", "gaps"),
|
fl!("window-management", "gaps").into(),
|
||||||
])
|
])
|
||||||
.view::<Page>(|_binder, page, section| {
|
.view::<Page>(|_binder, page, section| {
|
||||||
let descriptions = §ion.descriptions;
|
let descriptions = §ion.descriptions;
|
||||||
|
|
||||||
settings::view_section(§ion.title)
|
settings::view_section(§ion.title)
|
||||||
.add(settings::item::builder(&descriptions[0]).control(
|
.add(settings::item::builder(&*descriptions[0]).control(
|
||||||
cosmic::widget::spin_button(
|
cosmic::widget::spin_button(
|
||||||
page.theme_builder.active_hint.to_string(),
|
page.theme_builder.active_hint.to_string(),
|
||||||
Message::WindowHintSize,
|
Message::WindowHintSize,
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
.add(settings::item::builder(&descriptions[1]).control(
|
.add(settings::item::builder(&*descriptions[1]).control(
|
||||||
cosmic::widget::spin_button(
|
cosmic::widget::spin_button(
|
||||||
page.theme_builder.gaps.1.to_string(),
|
page.theme_builder.gaps.1.to_string(),
|
||||||
Message::GapSize,
|
Message::GapSize,
|
||||||
|
|
@ -1382,12 +1387,12 @@ pub fn window_management() -> Section<crate::pages::Message> {
|
||||||
#[allow(clippy::too_many_lines)]
|
#[allow(clippy::too_many_lines)]
|
||||||
pub fn reset_button() -> Section<crate::pages::Message> {
|
pub fn reset_button() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.descriptions(vec![fl!("reset-default")])
|
.descriptions(vec![fl!("reset-default").into()])
|
||||||
.view::<Page>(|_binder, page, section| {
|
.view::<Page>(|_binder, page, section| {
|
||||||
let spacing = &page.theme_builder.spacing;
|
let spacing = &page.theme_builder.spacing;
|
||||||
let descriptions = §ion.descriptions;
|
let descriptions = §ion.descriptions;
|
||||||
if page.can_reset {
|
if page.can_reset {
|
||||||
cosmic::iced::widget::row![button(text(&descriptions[0]))
|
cosmic::iced::widget::row![button(text(&*descriptions[0]))
|
||||||
.on_press(Message::Reset)
|
.on_press(Message::Reset)
|
||||||
.padding([spacing.space_xxs, spacing.space_xs])]
|
.padding([spacing.space_xxs, spacing.space_xs])]
|
||||||
.apply(Element::from)
|
.apply(Element::from)
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ impl Default for Page {
|
||||||
|
|
||||||
pub(crate) fn enable() -> Section<crate::pages::Message> {
|
pub(crate) fn enable() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.descriptions(vec![fl!("dock")])
|
.descriptions(vec![fl!("dock").into()])
|
||||||
.view::<Page>(|_binder, page, section| {
|
.view::<Page>(|_binder, page, section| {
|
||||||
let descriptions = §ion.descriptions;
|
let descriptions = §ion.descriptions;
|
||||||
let Some(container_config) = page.inner.container_config.as_ref() else {
|
let Some(container_config) = page.inner.container_config.as_ref() else {
|
||||||
|
|
@ -134,7 +134,7 @@ pub(crate) fn enable() -> Section<crate::pages::Message> {
|
||||||
};
|
};
|
||||||
settings::view_section(§ion.title)
|
settings::view_section(§ion.title)
|
||||||
.add(settings::item(
|
.add(settings::item(
|
||||||
&descriptions[0],
|
&*descriptions[0],
|
||||||
toggler(
|
toggler(
|
||||||
None,
|
None,
|
||||||
container_config
|
container_config
|
||||||
|
|
|
||||||
|
|
@ -48,24 +48,24 @@ pub fn super_key_action() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("super-key-action"))
|
.title(fl!("super-key-action"))
|
||||||
.descriptions(vec![
|
.descriptions(vec![
|
||||||
fl!("super-key-action", "launcher"),
|
fl!("super-key-action", "launcher").into(),
|
||||||
fl!("super-key-action", "workspaces"),
|
fl!("super-key-action", "workspaces").into(),
|
||||||
fl!("super-key-action", "applications"),
|
fl!("super-key-action", "applications").into(),
|
||||||
])
|
])
|
||||||
.view::<Page>(|_binder, _page, section| {
|
.view::<Page>(|_binder, _page, section| {
|
||||||
let descriptions = §ion.descriptions;
|
let descriptions = §ion.descriptions;
|
||||||
|
|
||||||
settings::view_section(§ion.title)
|
settings::view_section(§ion.title)
|
||||||
.add(settings::item(
|
.add(settings::item(
|
||||||
&descriptions[0],
|
&*descriptions[0],
|
||||||
horizontal_space(Length::Fill),
|
horizontal_space(Length::Fill),
|
||||||
))
|
))
|
||||||
.add(settings::item(
|
.add(settings::item(
|
||||||
&descriptions[1],
|
&*descriptions[1],
|
||||||
horizontal_space(Length::Fill),
|
horizontal_space(Length::Fill),
|
||||||
))
|
))
|
||||||
.add(settings::item(
|
.add(settings::item(
|
||||||
&descriptions[2],
|
&*descriptions[2],
|
||||||
horizontal_space(Length::Fill),
|
horizontal_space(Length::Fill),
|
||||||
))
|
))
|
||||||
.into()
|
.into()
|
||||||
|
|
@ -76,8 +76,8 @@ pub fn window_controls() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("window-controls"))
|
.title(fl!("window-controls"))
|
||||||
.descriptions(vec![
|
.descriptions(vec![
|
||||||
fl!("window-controls", "minimize"),
|
fl!("window-controls", "minimize").into(),
|
||||||
fl!("window-controls", "maximize"),
|
fl!("window-controls", "maximize").into(),
|
||||||
])
|
])
|
||||||
.view::<Page>(|binder, _page, section| {
|
.view::<Page>(|binder, _page, section| {
|
||||||
let desktop = binder
|
let desktop = binder
|
||||||
|
|
@ -87,7 +87,7 @@ pub fn window_controls() -> Section<crate::pages::Message> {
|
||||||
|
|
||||||
settings::view_section(§ion.title)
|
settings::view_section(§ion.title)
|
||||||
.add(settings::item(
|
.add(settings::item(
|
||||||
&descriptions[0],
|
&*descriptions[0],
|
||||||
toggler(
|
toggler(
|
||||||
None,
|
None,
|
||||||
desktop.show_minimize_button,
|
desktop.show_minimize_button,
|
||||||
|
|
@ -95,7 +95,7 @@ pub fn window_controls() -> Section<crate::pages::Message> {
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
.add(settings::item(
|
.add(settings::item(
|
||||||
&descriptions[1],
|
&*descriptions[1],
|
||||||
toggler(
|
toggler(
|
||||||
None,
|
None,
|
||||||
desktop.show_maximize_button,
|
desktop.show_maximize_button,
|
||||||
|
|
|
||||||
|
|
@ -78,9 +78,9 @@ pub(crate) fn behavior_and_position<
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("panel-behavior-and-position"))
|
.title(fl!("panel-behavior-and-position"))
|
||||||
.descriptions(vec![
|
.descriptions(vec![
|
||||||
p.autohide_label(),
|
p.autohide_label().into(),
|
||||||
fl!("panel-behavior-and-position", "position"),
|
fl!("panel-behavior-and-position", "position").into(),
|
||||||
fl!("panel-behavior-and-position", "display"),
|
fl!("panel-behavior-and-position", "display").into(),
|
||||||
])
|
])
|
||||||
.view::<P>(move |_binder, page, section| {
|
.view::<P>(move |_binder, page, section| {
|
||||||
let descriptions = §ion.descriptions;
|
let descriptions = §ion.descriptions;
|
||||||
|
|
@ -90,13 +90,13 @@ pub(crate) fn behavior_and_position<
|
||||||
};
|
};
|
||||||
settings::view_section(§ion.title)
|
settings::view_section(§ion.title)
|
||||||
.add(settings::item(
|
.add(settings::item(
|
||||||
&descriptions[0],
|
&*descriptions[0],
|
||||||
toggler(None, panel_config.autohide.is_some(), |value| {
|
toggler(None, panel_config.autohide.is_some(), |value| {
|
||||||
Message::AutoHidePanel(value)
|
Message::AutoHidePanel(value)
|
||||||
}),
|
}),
|
||||||
))
|
))
|
||||||
.add(settings::item(
|
.add(settings::item(
|
||||||
&descriptions[1],
|
&*descriptions[1],
|
||||||
dropdown(
|
dropdown(
|
||||||
page.anchors.as_slice(),
|
page.anchors.as_slice(),
|
||||||
Some(panel_config.anchor as usize),
|
Some(panel_config.anchor as usize),
|
||||||
|
|
@ -104,7 +104,7 @@ pub(crate) fn behavior_and_position<
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
.add(settings::item(
|
.add(settings::item(
|
||||||
&descriptions[2],
|
&*descriptions[2],
|
||||||
dropdown(
|
dropdown(
|
||||||
page.outputs.as_slice(),
|
page.outputs.as_slice(),
|
||||||
match &panel_config.output {
|
match &panel_config.output {
|
||||||
|
|
@ -130,11 +130,11 @@ pub(crate) fn style<
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("panel-style"))
|
.title(fl!("panel-style"))
|
||||||
.descriptions(vec![
|
.descriptions(vec![
|
||||||
p.gap_label(),
|
p.gap_label().into(),
|
||||||
p.extend_label(),
|
p.extend_label().into(),
|
||||||
fl!("panel-style", "appearance"),
|
fl!("panel-style", "appearance").into(),
|
||||||
fl!("panel-style", "size"),
|
fl!("panel-style", "size").into(),
|
||||||
fl!("panel-style", "background-opacity"),
|
fl!("panel-style", "background-opacity").into(),
|
||||||
])
|
])
|
||||||
.view::<P>(move |_binder, page, section| {
|
.view::<P>(move |_binder, page, section| {
|
||||||
let descriptions = §ion.descriptions;
|
let descriptions = §ion.descriptions;
|
||||||
|
|
@ -144,19 +144,19 @@ pub(crate) fn style<
|
||||||
};
|
};
|
||||||
settings::view_section(§ion.title)
|
settings::view_section(§ion.title)
|
||||||
.add(settings::item(
|
.add(settings::item(
|
||||||
&descriptions[0],
|
&*descriptions[0],
|
||||||
toggler(None, panel_config.anchor_gap, |value| {
|
toggler(None, panel_config.anchor_gap, |value| {
|
||||||
Message::AnchorGap(value)
|
Message::AnchorGap(value)
|
||||||
}),
|
}),
|
||||||
))
|
))
|
||||||
.add(settings::item(
|
.add(settings::item(
|
||||||
&descriptions[1],
|
&*descriptions[1],
|
||||||
toggler(None, panel_config.expand_to_edges, |value| {
|
toggler(None, panel_config.expand_to_edges, |value| {
|
||||||
Message::ExtendToEdge(value)
|
Message::ExtendToEdge(value)
|
||||||
}),
|
}),
|
||||||
))
|
))
|
||||||
.add(settings::item(
|
.add(settings::item(
|
||||||
&descriptions[2],
|
&*descriptions[2],
|
||||||
dropdown(
|
dropdown(
|
||||||
inner.backgrounds.as_slice(),
|
inner.backgrounds.as_slice(),
|
||||||
match panel_config.background {
|
match panel_config.background {
|
||||||
|
|
@ -169,7 +169,7 @@ pub(crate) fn style<
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
.add(settings::item(
|
.add(settings::item(
|
||||||
&descriptions[3],
|
&*descriptions[3],
|
||||||
// TODO custom discrete slider variant
|
// TODO custom discrete slider variant
|
||||||
row::with_children(vec![
|
row::with_children(vec![
|
||||||
text(fl!("small")).into(),
|
text(fl!("small")).into(),
|
||||||
|
|
@ -202,7 +202,7 @@ pub(crate) fn style<
|
||||||
.spacing(12),
|
.spacing(12),
|
||||||
))
|
))
|
||||||
.add(settings::item(
|
.add(settings::item(
|
||||||
&descriptions[4],
|
&*descriptions[4],
|
||||||
row::with_children(vec![
|
row::with_children(vec![
|
||||||
text(fl!("number", HashMap::from_iter(vec![("number", 0)]))).into(),
|
text(fl!("number", HashMap::from_iter(vec![("number", 0)]))).into(),
|
||||||
slider(0..=100, (panel_config.opacity * 100.0) as i32, |v| {
|
slider(0..=100, (panel_config.opacity * 100.0) as i32, |v| {
|
||||||
|
|
@ -223,7 +223,7 @@ pub(crate) fn configuration<P: page::Page<crate::pages::Message> + PanelPage>(
|
||||||
) -> Section<crate::pages::Message> {
|
) -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("panel-applets"))
|
.title(fl!("panel-applets"))
|
||||||
.descriptions(vec![p.configure_applets_label()])
|
.descriptions(vec![p.configure_applets_label().into()])
|
||||||
.view::<P>(move |binder, page, section| {
|
.view::<P>(move |binder, page, section| {
|
||||||
let mut settings = settings::view_section(§ion.title);
|
let mut settings = settings::view_section(§ion.title);
|
||||||
let descriptions = §ion.descriptions;
|
let descriptions = §ion.descriptions;
|
||||||
|
|
@ -238,7 +238,7 @@ pub(crate) fn configuration<P: page::Page<crate::pages::Message> + PanelPage>(
|
||||||
]);
|
]);
|
||||||
|
|
||||||
settings.add(
|
settings.add(
|
||||||
settings::item::builder(&descriptions[0])
|
settings::item::builder(&*descriptions[0])
|
||||||
.control(control)
|
.control(control)
|
||||||
.spacing(16)
|
.spacing(16)
|
||||||
.apply(container)
|
.apply(container)
|
||||||
|
|
@ -265,8 +265,8 @@ pub(crate) fn add_panel<
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("panel-missing"))
|
.title(fl!("panel-missing"))
|
||||||
.descriptions(vec![
|
.descriptions(vec![
|
||||||
fl!("panel-missing", "desc"),
|
fl!("panel-missing", "desc").into(),
|
||||||
fl!("panel-missing", "fix"),
|
fl!("panel-missing", "fix").into(),
|
||||||
])
|
])
|
||||||
.view::<P>(move |_binder, _page, section| {
|
.view::<P>(move |_binder, _page, section| {
|
||||||
// _descriptions = §ion.descriptions;
|
// _descriptions = §ion.descriptions;
|
||||||
|
|
@ -282,10 +282,10 @@ pub struct Anchor(PanelAnchor);
|
||||||
impl ToString for Anchor {
|
impl ToString for Anchor {
|
||||||
fn to_string(&self) -> String {
|
fn to_string(&self) -> String {
|
||||||
match self.0 {
|
match self.0 {
|
||||||
PanelAnchor::Top => fl!("panel-top"),
|
PanelAnchor::Top => fl!("panel-top").into(),
|
||||||
PanelAnchor::Bottom => fl!("panel-bottom"),
|
PanelAnchor::Bottom => fl!("panel-bottom").into(),
|
||||||
PanelAnchor::Left => fl!("panel-left"),
|
PanelAnchor::Left => fl!("panel-left").into(),
|
||||||
PanelAnchor::Right => fl!("panel-right"),
|
PanelAnchor::Right => fl!("panel-right").into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ use cosmic_settings_wallpaper::{self as wallpaper, Entry, ScalingMode};
|
||||||
use image::imageops::FilterType::Lanczos3;
|
use image::imageops::FilterType::Lanczos3;
|
||||||
use image::{ImageBuffer, Rgba};
|
use image::{ImageBuffer, Rgba};
|
||||||
use slotmap::{DefaultKey, SecondaryMap, SlotMap};
|
use slotmap::{DefaultKey, SecondaryMap, SlotMap};
|
||||||
use static_init::dynamic;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
const ZOOM: usize = 0;
|
const ZOOM: usize = 0;
|
||||||
const FIT: usize = 1;
|
const FIT: usize = 1;
|
||||||
|
|
@ -1056,26 +1056,21 @@ pub async fn change_folder(current_folder: PathBuf) -> Context {
|
||||||
update
|
update
|
||||||
}
|
}
|
||||||
|
|
||||||
#[dynamic]
|
crate::cache_dynamic_lazy! {
|
||||||
static WALLPAPER_SAME: String = fl!("wallpaper", "same");
|
static WALLPAPER_SAME: String = fl!("wallpaper", "same");
|
||||||
|
static WALLPAPER_FIT: String = fl!("wallpaper", "fit");
|
||||||
#[dynamic]
|
static WALLPAPER_SLIDE: String = fl!("wallpaper", "slide");
|
||||||
static WALLPAPER_FIT: String = fl!("wallpaper", "fit");
|
static WALLPAPER_CHANGE: String = fl!("wallpaper", "change");
|
||||||
|
}
|
||||||
#[dynamic]
|
|
||||||
static WALLPAPER_SLIDE: String = fl!("wallpaper", "slide");
|
|
||||||
|
|
||||||
#[dynamic]
|
|
||||||
static WALLPAPER_CHANGE: String = fl!("wallpaper", "change");
|
|
||||||
|
|
||||||
#[allow(clippy::too_many_lines)]
|
#[allow(clippy::too_many_lines)]
|
||||||
pub fn settings() -> Section<crate::pages::Message> {
|
pub fn settings() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.descriptions(vec![
|
.descriptions(vec![
|
||||||
WALLPAPER_SAME.clone(),
|
WALLPAPER_SAME.as_str().into(),
|
||||||
WALLPAPER_FIT.clone(),
|
WALLPAPER_FIT.as_str().into(),
|
||||||
WALLPAPER_SLIDE.clone(),
|
WALLPAPER_SLIDE.as_str().into(),
|
||||||
WALLPAPER_CHANGE.clone(),
|
WALLPAPER_CHANGE.as_str().into(),
|
||||||
])
|
])
|
||||||
.view::<Page>(|_binder, page, _section| {
|
.view::<Page>(|_binder, page, _section| {
|
||||||
let mut children = Vec::with_capacity(3);
|
let mut children = Vec::with_capacity(3);
|
||||||
|
|
|
||||||
|
|
@ -133,21 +133,21 @@ fn multi_behavior() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("workspaces-multi-behavior"))
|
.title(fl!("workspaces-multi-behavior"))
|
||||||
.descriptions(vec![
|
.descriptions(vec![
|
||||||
fl!("workspaces-multi-behavior", "span"),
|
fl!("workspaces-multi-behavior", "span").into(),
|
||||||
fl!("workspaces-multi-behavior", "separate"),
|
fl!("workspaces-multi-behavior", "separate").into(),
|
||||||
])
|
])
|
||||||
.view::<Page>(|_binder, page, section| {
|
.view::<Page>(|_binder, page, section| {
|
||||||
let descriptions = §ion.descriptions;
|
let descriptions = §ion.descriptions;
|
||||||
settings::view_section(§ion.title)
|
settings::view_section(§ion.title)
|
||||||
.add(settings::item_row(vec![radio(
|
.add(settings::item_row(vec![radio(
|
||||||
&descriptions[0],
|
&*descriptions[0],
|
||||||
WorkspaceMode::Global,
|
WorkspaceMode::Global,
|
||||||
Some(page.comp_workspace_config.workspace_mode),
|
Some(page.comp_workspace_config.workspace_mode),
|
||||||
Message::SetWorkspaceMode,
|
Message::SetWorkspaceMode,
|
||||||
)
|
)
|
||||||
.into()]))
|
.into()]))
|
||||||
.add(settings::item_row(vec![radio(
|
.add(settings::item_row(vec![radio(
|
||||||
&descriptions[1],
|
&*descriptions[1],
|
||||||
WorkspaceMode::OutputBound,
|
WorkspaceMode::OutputBound,
|
||||||
Some(page.comp_workspace_config.workspace_mode),
|
Some(page.comp_workspace_config.workspace_mode),
|
||||||
Message::SetWorkspaceMode,
|
Message::SetWorkspaceMode,
|
||||||
|
|
@ -162,18 +162,18 @@ fn overview_thumbnails() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("workspaces-overview-thumbnails"))
|
.title(fl!("workspaces-overview-thumbnails"))
|
||||||
.descriptions(vec![
|
.descriptions(vec![
|
||||||
fl!("workspaces-overview-thumbnails", "show-number"),
|
fl!("workspaces-overview-thumbnails", "show-number").into(),
|
||||||
fl!("workspaces-overview-thumbnails", "show-name"),
|
fl!("workspaces-overview-thumbnails", "show-name").into(),
|
||||||
])
|
])
|
||||||
.view::<Page>(|_binder, page, section| {
|
.view::<Page>(|_binder, page, section| {
|
||||||
let descriptions = §ion.descriptions;
|
let descriptions = §ion.descriptions;
|
||||||
settings::view_section(§ion.title)
|
settings::view_section(§ion.title)
|
||||||
.add(
|
.add(
|
||||||
settings::item::builder(&descriptions[0])
|
settings::item::builder(&*descriptions[0])
|
||||||
.toggler(page.show_workspace_number, Message::SetShowNumber),
|
.toggler(page.show_workspace_number, Message::SetShowNumber),
|
||||||
)
|
)
|
||||||
.add(
|
.add(
|
||||||
settings::item::builder(&descriptions[1])
|
settings::item::builder(&*descriptions[1])
|
||||||
.toggler(page.show_workspace_name, Message::SetShowName),
|
.toggler(page.show_workspace_name, Message::SetShowName),
|
||||||
)
|
)
|
||||||
.apply(Element::from)
|
.apply(Element::from)
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ use apply::Apply;
|
||||||
use arrangement::Arrangement;
|
use arrangement::Arrangement;
|
||||||
use cosmic::iced::Length;
|
use cosmic::iced::Length;
|
||||||
use cosmic::iced_widget::scrollable::{Direction, Properties, RelativeOffset};
|
use cosmic::iced_widget::scrollable::{Direction, Properties, RelativeOffset};
|
||||||
use cosmic::prelude::CollectionWidget;
|
|
||||||
use cosmic::widget::{
|
use cosmic::widget::{
|
||||||
column, container, dropdown, list_column, segmented_button, toggler, view_switcher,
|
column, container, dropdown, list_column, segmented_button, toggler, view_switcher,
|
||||||
};
|
};
|
||||||
|
|
@ -18,6 +17,7 @@ use cosmic::{command, Command, Element};
|
||||||
use cosmic_randr_shell::{List, Output, OutputKey, Transform};
|
use cosmic_randr_shell::{List, Output, OutputKey, Transform};
|
||||||
use cosmic_settings_page::{self as page, section, Section};
|
use cosmic_settings_page::{self as page, section, Section};
|
||||||
use slotmap::{Key, SlotMap};
|
use slotmap::{Key, SlotMap};
|
||||||
|
use std::borrow::Cow;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::{process::ExitStatus, sync::Arc};
|
use std::{process::ExitStatus, sync::Arc};
|
||||||
|
|
||||||
|
|
@ -174,14 +174,14 @@ impl page::Page<crate::pages::Message> for Page {
|
||||||
sections.insert(
|
sections.insert(
|
||||||
Section::default()
|
Section::default()
|
||||||
.descriptions(vec![
|
.descriptions(vec![
|
||||||
text::GRAPHICS_MODE.clone(),
|
text::GRAPHICS_MODE.as_str().into(),
|
||||||
text::GRAPHICS_MODE_COMPUTE_DESC.clone(),
|
text::GRAPHICS_MODE_COMPUTE_DESC.as_str().into(),
|
||||||
text::GRAPHICS_MODE_HYBRID_DESC.clone(),
|
text::GRAPHICS_MODE_HYBRID_DESC.as_str().into(),
|
||||||
text::GRAPHICS_MODE_INTEGRATED_DESC.clone(),
|
text::GRAPHICS_MODE_INTEGRATED_DESC.as_str().into(),
|
||||||
text::GRAPHICS_MODE_NVIDIA_DESC.clone(),
|
text::GRAPHICS_MODE_NVIDIA_DESC.as_str().into(),
|
||||||
text::NIGHT_LIGHT.clone(),
|
text::NIGHT_LIGHT.as_str().into(),
|
||||||
text::NIGHT_LIGHT_AUTO.clone(),
|
text::NIGHT_LIGHT_AUTO.as_str().into(),
|
||||||
text::NIGHT_LIGHT_DESCRIPTION.clone(),
|
text::NIGHT_LIGHT_DESCRIPTION.as_str().into(),
|
||||||
])
|
])
|
||||||
.view::<Page>(|_binder, page, _section| page.graphics_mode_view()),
|
.view::<Page>(|_binder, page, _section| page.graphics_mode_view()),
|
||||||
),
|
),
|
||||||
|
|
@ -190,8 +190,8 @@ impl page::Page<crate::pages::Message> for Page {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(&*text::DISPLAY_ARRANGEMENT)
|
.title(&*text::DISPLAY_ARRANGEMENT)
|
||||||
.descriptions(vec![
|
.descriptions(vec![
|
||||||
text::DISPLAY_ARRANGEMENT.clone(),
|
text::DISPLAY_ARRANGEMENT.as_str().into(),
|
||||||
text::DISPLAY_ARRANGEMENT_DESC.clone(),
|
text::DISPLAY_ARRANGEMENT_DESC.as_str().into(),
|
||||||
])
|
])
|
||||||
// Show section when there is more than 1 display
|
// Show section when there is more than 1 display
|
||||||
.show_while::<Page>(|page| page.list.outputs.len() > 1)
|
.show_while::<Page>(|page| page.list.outputs.len() > 1)
|
||||||
|
|
@ -200,13 +200,13 @@ impl page::Page<crate::pages::Message> for Page {
|
||||||
// Display configuration
|
// Display configuration
|
||||||
sections.insert(
|
sections.insert(
|
||||||
Section::default()
|
Section::default()
|
||||||
.descriptions(vec![
|
.descriptions([
|
||||||
text::DISPLAY.clone(),
|
text::DISPLAY.as_str().into(),
|
||||||
text::DISPLAY_REFRESH_RATE.clone(),
|
text::DISPLAY_REFRESH_RATE.as_str().into(),
|
||||||
text::DISPLAY_SCALE.clone(),
|
text::DISPLAY_SCALE.as_str().into(),
|
||||||
text::ORIENTATION.clone(),
|
text::ORIENTATION.as_str().into(),
|
||||||
text::ORIENTATION_LANDSCAPE.clone(),
|
text::ORIENTATION_LANDSCAPE.as_str().into(),
|
||||||
text::ORIENTATION_PORTRAIT.clone(),
|
text::ORIENTATION_PORTRAIT.as_str().into(),
|
||||||
])
|
])
|
||||||
.view::<Page>(|_binder, page, _section| page.display_view()),
|
.view::<Page>(|_binder, page, _section| page.display_view()),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -265,8 +265,8 @@ fn special_character_entry() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("keyboard-special-char"))
|
.title(fl!("keyboard-special-char"))
|
||||||
.descriptions(vec![
|
.descriptions(vec![
|
||||||
fl!("keyboard-special-char", "alternate"),
|
fl!("keyboard-special-char", "alternate").into(),
|
||||||
fl!("keyboard-special-char", "compose"),
|
fl!("keyboard-special-char", "compose").into(),
|
||||||
])
|
])
|
||||||
.view::<Page>(|_binder, _page, section| {
|
.view::<Page>(|_binder, _page, section| {
|
||||||
let descriptions = §ion.descriptions;
|
let descriptions = §ion.descriptions;
|
||||||
|
|
@ -274,11 +274,11 @@ fn special_character_entry() -> Section<crate::pages::Message> {
|
||||||
// TODO dialogs
|
// TODO dialogs
|
||||||
settings::view_section(§ion.title)
|
settings::view_section(§ion.title)
|
||||||
.add(go_next_item(
|
.add(go_next_item(
|
||||||
&descriptions[0],
|
&*descriptions[0],
|
||||||
Message::OpenSpecialCharacterDialog(SpecialKey::AlternateCharacters),
|
Message::OpenSpecialCharacterDialog(SpecialKey::AlternateCharacters),
|
||||||
))
|
))
|
||||||
.add(go_next_item(
|
.add(go_next_item(
|
||||||
&descriptions[1],
|
&*descriptions[1],
|
||||||
Message::OpenSpecialCharacterDialog(SpecialKey::Compose),
|
Message::OpenSpecialCharacterDialog(SpecialKey::Compose),
|
||||||
))
|
))
|
||||||
.apply(cosmic::Element::from)
|
.apply(cosmic::Element::from)
|
||||||
|
|
@ -289,7 +289,7 @@ fn special_character_entry() -> Section<crate::pages::Message> {
|
||||||
fn keyboard_shortcuts() -> Section<crate::pages::Message> {
|
fn keyboard_shortcuts() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("keyboard-shortcuts"))
|
.title(fl!("keyboard-shortcuts"))
|
||||||
.descriptions(vec![fl!("keyboard-shortcuts", "desc")])
|
.descriptions(vec![fl!("keyboard-shortcuts", "desc").into()])
|
||||||
.view::<Page>(|binder, _page, section| {
|
.view::<Page>(|binder, _page, section| {
|
||||||
let descriptions = §ion.descriptions;
|
let descriptions = §ion.descriptions;
|
||||||
|
|
||||||
|
|
@ -300,7 +300,7 @@ fn keyboard_shortcuts() -> Section<crate::pages::Message> {
|
||||||
.find(|(_, v)| v.id == "keyboard-shortcuts")
|
.find(|(_, v)| v.id == "keyboard-shortcuts")
|
||||||
{
|
{
|
||||||
section = section.add(go_next_item(
|
section = section.add(go_next_item(
|
||||||
&descriptions[0],
|
&*descriptions[0],
|
||||||
crate::pages::Message::Page(shortcuts_entity),
|
crate::pages::Message::Page(shortcuts_entity),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,12 +40,12 @@ impl page::AutoBind<crate::pages::Message> for Page {}
|
||||||
fn mouse() -> Section<crate::pages::Message> {
|
fn mouse() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.descriptions(vec![
|
.descriptions(vec![
|
||||||
fl!("mouse", "primary-button"),
|
fl!("mouse", "primary-button").into(),
|
||||||
fl!("mouse", "speed"),
|
fl!("mouse", "speed").into(),
|
||||||
fl!("mouse", "acceleration"),
|
fl!("mouse", "acceleration").into(),
|
||||||
fl!("mouse", "acceleration-desc"),
|
fl!("mouse", "acceleration-desc").into(),
|
||||||
fl!("mouse", "double-click-speed"),
|
fl!("mouse", "double-click-speed").into(),
|
||||||
fl!("mouse", "double-click-speed-desc"),
|
fl!("mouse", "double-click-speed-desc").into(),
|
||||||
])
|
])
|
||||||
.view::<Page>(|binder, _page, section| {
|
.view::<Page>(|binder, _page, section| {
|
||||||
let descriptions = §ion.descriptions;
|
let descriptions = §ion.descriptions;
|
||||||
|
|
@ -54,12 +54,12 @@ fn mouse() -> Section<crate::pages::Message> {
|
||||||
|
|
||||||
settings::view_section(§ion.title)
|
settings::view_section(§ion.title)
|
||||||
.add(settings::item(
|
.add(settings::item(
|
||||||
&descriptions[0],
|
&*descriptions[0],
|
||||||
cosmic::widget::segmented_selection::horizontal(&input.primary_button)
|
cosmic::widget::segmented_selection::horizontal(&input.primary_button)
|
||||||
.on_activate(|x| Message::PrimaryButtonSelected(x, false)),
|
.on_activate(|x| Message::PrimaryButtonSelected(x, false)),
|
||||||
))
|
))
|
||||||
.add(
|
.add(
|
||||||
settings::item::builder(&descriptions[1]).control(widget::slider(
|
settings::item::builder(&*descriptions[1]).control(widget::slider(
|
||||||
0.0..=100.0,
|
0.0..=100.0,
|
||||||
(input
|
(input
|
||||||
.input_default
|
.input_default
|
||||||
|
|
@ -72,8 +72,8 @@ fn mouse() -> Section<crate::pages::Message> {
|
||||||
)),
|
)),
|
||||||
)
|
)
|
||||||
.add(
|
.add(
|
||||||
settings::item::builder(&descriptions[2])
|
settings::item::builder(&*descriptions[2])
|
||||||
.description(&descriptions[3])
|
.description(&*descriptions[3])
|
||||||
.toggler(
|
.toggler(
|
||||||
input
|
input
|
||||||
.input_default
|
.input_default
|
||||||
|
|
@ -84,8 +84,8 @@ fn mouse() -> Section<crate::pages::Message> {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.add(
|
.add(
|
||||||
settings::item::builder(&descriptions[4])
|
settings::item::builder(&*descriptions[4])
|
||||||
.description(&descriptions[5])
|
.description(&*descriptions[5])
|
||||||
.control(widget::slider(0..=100, 0, |x| {
|
.control(widget::slider(0..=100, 0, |x| {
|
||||||
Message::SetDoubleClickSpeed(x, false)
|
Message::SetDoubleClickSpeed(x, false)
|
||||||
})),
|
})),
|
||||||
|
|
@ -99,9 +99,9 @@ fn scrolling() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("mouse-scrolling"))
|
.title(fl!("mouse-scrolling"))
|
||||||
.descriptions(vec![
|
.descriptions(vec![
|
||||||
fl!("mouse-scrolling", "speed"),
|
fl!("mouse-scrolling", "speed").into(),
|
||||||
fl!("mouse-scrolling", "natural"),
|
fl!("mouse-scrolling", "natural").into(),
|
||||||
fl!("mouse-scrolling", "natural-desc"),
|
fl!("mouse-scrolling", "natural-desc").into(),
|
||||||
])
|
])
|
||||||
.view::<Page>(|binder, _page, section| {
|
.view::<Page>(|binder, _page, section| {
|
||||||
let descriptions = §ion.descriptions;
|
let descriptions = §ion.descriptions;
|
||||||
|
|
@ -110,7 +110,7 @@ fn scrolling() -> Section<crate::pages::Message> {
|
||||||
|
|
||||||
settings::view_section(§ion.title)
|
settings::view_section(§ion.title)
|
||||||
.add(settings::item(
|
.add(settings::item(
|
||||||
&descriptions[0],
|
&*descriptions[0],
|
||||||
// TODO show numeric value
|
// TODO show numeric value
|
||||||
// TODO desired range?
|
// TODO desired range?
|
||||||
widget::slider(
|
widget::slider(
|
||||||
|
|
@ -128,8 +128,8 @@ fn scrolling() -> Section<crate::pages::Message> {
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
.add(
|
.add(
|
||||||
settings::item::builder(&descriptions[1])
|
settings::item::builder(&*descriptions[1])
|
||||||
.description(&descriptions[2])
|
.description(&*descriptions[2])
|
||||||
.toggler(
|
.toggler(
|
||||||
input
|
input
|
||||||
.input_default
|
.input_default
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,22 @@ use cosmic_comp_config::input::AccelProfile;
|
||||||
use cosmic_settings_page::Section;
|
use cosmic_settings_page::Section;
|
||||||
use cosmic_settings_page::{self as page, section};
|
use cosmic_settings_page::{self as page, section};
|
||||||
use slotmap::SlotMap;
|
use slotmap::SlotMap;
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use super::Message;
|
use super::Message;
|
||||||
|
|
||||||
|
crate::cache_dynamic_lazy! {
|
||||||
|
static MOUSE_SCROLL_SPEED: String = fl!("mouse-scrolling", "speed");
|
||||||
|
static MOUSE_SCROLL_NATURAL: String = fl!("mouse-scrolling", "natural");
|
||||||
|
static MOUSE_SCROLL_NATURAL_DESC: String = fl!("mouse-scrolling", "natural-desc");
|
||||||
|
static TOUCHPAD_PRIMARY_BUTTON: String = fl!("touchpad", "primary-button");
|
||||||
|
static TOUCHPAD_SPEED: String = fl!("touchpad", "speed");
|
||||||
|
static TOUCHPAD_ACCELERAION: String = fl!("touchpad", "acceleration");
|
||||||
|
static TOUCHPAD_ACCELERAION_DESC: String = fl!("touchpad", "acceleration-desc");
|
||||||
|
static TOUCHPAD_DOUBLE_CLICK_SPEED: String = fl!("touchpad", "double-click-speed");
|
||||||
|
static TOUCHPAD_DOUBLE_CLICK_SPEED_DESC: String = fl!("touchpad", "double-click-speed-desc");
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Page;
|
pub struct Page;
|
||||||
|
|
||||||
|
|
@ -34,26 +47,24 @@ impl page::AutoBind<crate::pages::Message> for Page {}
|
||||||
fn touchpad() -> Section<crate::pages::Message> {
|
fn touchpad() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.descriptions(vec![
|
.descriptions(vec![
|
||||||
fl!("touchpad", "primary-button"),
|
TOUCHPAD_PRIMARY_BUTTON.as_str().into(),
|
||||||
fl!("touchpad", "speed"),
|
TOUCHPAD_SPEED.as_str().into(),
|
||||||
fl!("touchpad", "acceleration"),
|
TOUCHPAD_ACCELERAION.as_str().into(),
|
||||||
fl!("touchpad", "acceleration-desc"),
|
TOUCHPAD_ACCELERAION_DESC.as_str().into(),
|
||||||
fl!("touchpad", "double-click-speed"),
|
TOUCHPAD_DOUBLE_CLICK_SPEED.as_str().into(),
|
||||||
fl!("touchpad", "double-click-speed-desc"),
|
TOUCHPAD_DOUBLE_CLICK_SPEED_DESC.as_str().into(),
|
||||||
])
|
])
|
||||||
.view::<Page>(|binder, _page, section| {
|
.view::<Page>(|binder, _page, section| {
|
||||||
let descriptions = §ion.descriptions;
|
|
||||||
|
|
||||||
let input = binder.page::<super::Page>().expect("input page not found");
|
let input = binder.page::<super::Page>().expect("input page not found");
|
||||||
|
|
||||||
settings::view_section(§ion.title)
|
settings::view_section(§ion.title)
|
||||||
.add(settings::item(
|
.add(settings::item(
|
||||||
&descriptions[0],
|
&*TOUCHPAD_PRIMARY_BUTTON,
|
||||||
cosmic::widget::segmented_selection::horizontal(&input.touchpad_primary_button)
|
cosmic::widget::segmented_selection::horizontal(&input.touchpad_primary_button)
|
||||||
.on_activate(|x| Message::PrimaryButtonSelected(x, true)),
|
.on_activate(|x| Message::PrimaryButtonSelected(x, true)),
|
||||||
))
|
))
|
||||||
.add(
|
.add(
|
||||||
settings::item::builder(&descriptions[1]).control(widget::slider(
|
settings::item::builder(&*TOUCHPAD_SPEED).control(widget::slider(
|
||||||
0.0..=100.0,
|
0.0..=100.0,
|
||||||
(input
|
(input
|
||||||
.input_touchpad
|
.input_touchpad
|
||||||
|
|
@ -66,8 +77,8 @@ fn touchpad() -> Section<crate::pages::Message> {
|
||||||
)),
|
)),
|
||||||
)
|
)
|
||||||
.add(
|
.add(
|
||||||
settings::item::builder(&descriptions[2])
|
settings::item::builder(&*TOUCHPAD_ACCELERAION)
|
||||||
.description(&descriptions[3])
|
.description(&*TOUCHPAD_ACCELERAION_DESC)
|
||||||
.toggler(
|
.toggler(
|
||||||
input
|
input
|
||||||
.input_touchpad
|
.input_touchpad
|
||||||
|
|
@ -79,8 +90,8 @@ fn touchpad() -> Section<crate::pages::Message> {
|
||||||
)
|
)
|
||||||
// TODO disable while typing
|
// TODO disable while typing
|
||||||
.add(
|
.add(
|
||||||
settings::item::builder(&descriptions[4])
|
settings::item::builder(&*TOUCHPAD_DOUBLE_CLICK_SPEED)
|
||||||
.description(&descriptions[5])
|
.description(&*TOUCHPAD_DOUBLE_CLICK_SPEED_DESC)
|
||||||
.control(widget::slider(0..=100, 0, |x| {
|
.control(widget::slider(0..=100, 0, |x| {
|
||||||
Message::SetDoubleClickSpeed(x, true)
|
Message::SetDoubleClickSpeed(x, true)
|
||||||
})),
|
})),
|
||||||
|
|
@ -94,18 +105,16 @@ fn scrolling() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("mouse-scrolling"))
|
.title(fl!("mouse-scrolling"))
|
||||||
.descriptions(vec![
|
.descriptions(vec![
|
||||||
fl!("mouse-scrolling", "speed"),
|
MOUSE_SCROLL_SPEED.as_str().into(),
|
||||||
fl!("mouse-scrolling", "natural"),
|
MOUSE_SCROLL_NATURAL.as_str().into(),
|
||||||
fl!("mouse-scrolling", "natural-desc"),
|
MOUSE_SCROLL_NATURAL_DESC.as_str().into(),
|
||||||
])
|
])
|
||||||
.view::<Page>(|binder, _page, section| {
|
.view::<Page>(|binder, _page, section| {
|
||||||
let descriptions = §ion.descriptions;
|
|
||||||
|
|
||||||
let input = binder.page::<super::Page>().expect("input page not found");
|
let input = binder.page::<super::Page>().expect("input page not found");
|
||||||
|
|
||||||
settings::view_section(§ion.title)
|
settings::view_section(§ion.title)
|
||||||
.add(settings::item(
|
.add(settings::item(
|
||||||
&descriptions[0],
|
&*MOUSE_SCROLL_SPEED,
|
||||||
// TODO show numeric value
|
// TODO show numeric value
|
||||||
// TODO desired range?
|
// TODO desired range?
|
||||||
widget::slider(
|
widget::slider(
|
||||||
|
|
@ -123,8 +132,8 @@ fn scrolling() -> Section<crate::pages::Message> {
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
.add(
|
.add(
|
||||||
settings::item::builder(&descriptions[1])
|
settings::item::builder(&*MOUSE_SCROLL_NATURAL)
|
||||||
.description(&descriptions[2])
|
.description(&*MOUSE_SCROLL_NATURAL_DESC)
|
||||||
.toggler(
|
.toggler(
|
||||||
input
|
input
|
||||||
.input_touchpad
|
.input_touchpad
|
||||||
|
|
|
||||||
|
|
@ -51,13 +51,13 @@ fn alerts() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("sound-alerts"))
|
.title(fl!("sound-alerts"))
|
||||||
.descriptions(vec![
|
.descriptions(vec![
|
||||||
fl!("sound-alerts", "volume"),
|
fl!("sound-alerts", "volume").into(),
|
||||||
fl!("sound-alerts", "sound"),
|
fl!("sound-alerts", "sound").into(),
|
||||||
])
|
])
|
||||||
.view::<Page>(|_binder, _page, section| {
|
.view::<Page>(|_binder, _page, section| {
|
||||||
settings::view_section(§ion.title)
|
settings::view_section(§ion.title)
|
||||||
.add(settings::item(§ion.descriptions[0], text("TODO")))
|
.add(settings::item(&*section.descriptions[0], text("TODO")))
|
||||||
.add(settings::item(§ion.descriptions[1], text("TODO")))
|
.add(settings::item(&*section.descriptions[1], text("TODO")))
|
||||||
.into()
|
.into()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -65,10 +65,10 @@ fn alerts() -> Section<crate::pages::Message> {
|
||||||
fn applications() -> Section<crate::pages::Message> {
|
fn applications() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("sound-applications"))
|
.title(fl!("sound-applications"))
|
||||||
.descriptions(vec![fl!("sound-applications", "desc")])
|
.descriptions(vec![fl!("sound-applications", "desc").into()])
|
||||||
.view::<Page>(|_binder, _page, section| {
|
.view::<Page>(|_binder, _page, section| {
|
||||||
settings::view_section(§ion.title)
|
settings::view_section(§ion.title)
|
||||||
.add(settings::item(§ion.descriptions[0], text("TODO")))
|
.add(settings::item(&*section.descriptions[0], text("TODO")))
|
||||||
.into()
|
.into()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -77,15 +77,15 @@ fn input() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("sound-input"))
|
.title(fl!("sound-input"))
|
||||||
.descriptions(vec![
|
.descriptions(vec![
|
||||||
fl!("sound-input", "volume"),
|
fl!("sound-input", "volume").into(),
|
||||||
fl!("sound-input", "device"),
|
fl!("sound-input", "device").into(),
|
||||||
fl!("sound-input", "level"),
|
fl!("sound-input", "level").into(),
|
||||||
])
|
])
|
||||||
.view::<Page>(|_binder, _page, section| {
|
.view::<Page>(|_binder, _page, section| {
|
||||||
settings::view_section(§ion.title)
|
settings::view_section(§ion.title)
|
||||||
.add(settings::item(§ion.descriptions[0], text("TODO")))
|
.add(settings::item(&*section.descriptions[0], text("TODO")))
|
||||||
.add(settings::item(§ion.descriptions[1], text("TODO")))
|
.add(settings::item(&*section.descriptions[1], text("TODO")))
|
||||||
.add(settings::item(§ion.descriptions[2], text("TODO")))
|
.add(settings::item(&*section.descriptions[2], text("TODO")))
|
||||||
.into()
|
.into()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -94,18 +94,18 @@ fn output() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("sound-output"))
|
.title(fl!("sound-output"))
|
||||||
.descriptions(vec![
|
.descriptions(vec![
|
||||||
fl!("sound-output", "volume"),
|
fl!("sound-output", "volume").into(),
|
||||||
fl!("sound-output", "device"),
|
fl!("sound-output", "device").into(),
|
||||||
fl!("sound-output", "level"),
|
fl!("sound-output", "level").into(),
|
||||||
fl!("sound-output", "config"),
|
fl!("sound-output", "config").into(),
|
||||||
fl!("sound-output", "balance"),
|
fl!("sound-output", "balance").into(),
|
||||||
])
|
])
|
||||||
.view::<Page>(|_binder, _page, section| {
|
.view::<Page>(|_binder, _page, section| {
|
||||||
settings::view_section(§ion.title)
|
settings::view_section(§ion.title)
|
||||||
.add(settings::item(§ion.descriptions[0], text("TODO")))
|
.add(settings::item(&*section.descriptions[0], text("TODO")))
|
||||||
.add(settings::item(§ion.descriptions[1], text("TODO")))
|
.add(settings::item(&*section.descriptions[1], text("TODO")))
|
||||||
.add(settings::item(§ion.descriptions[2], text("TODO")))
|
.add(settings::item(&*section.descriptions[2], text("TODO")))
|
||||||
.add(settings::item(§ion.descriptions[3], text("TODO")))
|
.add(settings::item(&*section.descriptions[3], text("TODO")))
|
||||||
.into()
|
.into()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,8 @@
|
||||||
|
|
||||||
use cosmic_settings_page::{self as page, section, Section};
|
use cosmic_settings_page::{self as page, section, Section};
|
||||||
|
|
||||||
|
use cosmic::widget::{list_column, settings, text};
|
||||||
use cosmic::{command, Command};
|
use cosmic::{command, Command};
|
||||||
use cosmic::{
|
|
||||||
iced::{
|
|
||||||
widget::{horizontal_space, row},
|
|
||||||
Length,
|
|
||||||
},
|
|
||||||
widget::{icon, list_column, settings, text},
|
|
||||||
};
|
|
||||||
use cosmic_settings_system::about::Info;
|
use cosmic_settings_system::about::Info;
|
||||||
use slotmap::SlotMap;
|
use slotmap::SlotMap;
|
||||||
|
|
||||||
|
|
@ -63,11 +57,14 @@ impl Page {
|
||||||
|
|
||||||
fn device() -> Section<crate::pages::Message> {
|
fn device() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.descriptions(vec![fl!("about-device"), fl!("about-device", "desc")])
|
.descriptions(vec![
|
||||||
|
fl!("about-device").into(),
|
||||||
|
fl!("about-device", "desc").into(),
|
||||||
|
])
|
||||||
.view::<Page>(|_binder, page, section| {
|
.view::<Page>(|_binder, page, section| {
|
||||||
let desc = §ion.descriptions;
|
let desc = §ion.descriptions;
|
||||||
let device_name = settings::item::builder(&desc[0])
|
let device_name = settings::item::builder(&*desc[0])
|
||||||
.description(&desc[1])
|
.description(&*desc[1])
|
||||||
.control(text(&page.info.device_name));
|
.control(text(&page.info.device_name));
|
||||||
|
|
||||||
list_column().add(device_name).into()
|
list_column().add(device_name).into()
|
||||||
|
|
@ -78,26 +75,26 @@ fn hardware() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("about-hardware"))
|
.title(fl!("about-hardware"))
|
||||||
.descriptions(vec![
|
.descriptions(vec![
|
||||||
fl!("about-hardware", "model"),
|
fl!("about-hardware", "model").into(),
|
||||||
fl!("about-hardware", "memory"),
|
fl!("about-hardware", "memory").into(),
|
||||||
fl!("about-hardware", "processor"),
|
fl!("about-hardware", "processor").into(),
|
||||||
fl!("about-hardware", "graphics"),
|
fl!("about-hardware", "graphics").into(),
|
||||||
fl!("about-hardware", "disk-capacity"),
|
fl!("about-hardware", "disk-capacity").into(),
|
||||||
])
|
])
|
||||||
.view::<Page>(|_binder, page, section| {
|
.view::<Page>(|_binder, page, section| {
|
||||||
let desc = §ion.descriptions;
|
let desc = §ion.descriptions;
|
||||||
|
|
||||||
let mut sections = settings::view_section(§ion.title)
|
let mut sections = settings::view_section(§ion.title)
|
||||||
.add(settings::item(&desc[0], text(&page.info.hardware_model)))
|
.add(settings::item(&*desc[0], text(&page.info.hardware_model)))
|
||||||
.add(settings::item(&desc[1], text(&page.info.memory)))
|
.add(settings::item(&*desc[1], text(&page.info.memory)))
|
||||||
.add(settings::item(&desc[2], text(&page.info.processor)));
|
.add(settings::item(&*desc[2], text(&page.info.processor)));
|
||||||
|
|
||||||
for card in &page.info.graphics {
|
for card in &page.info.graphics {
|
||||||
sections = sections.add(settings::item(&desc[3], text(card.as_str())));
|
sections = sections.add(settings::item(&*desc[3], text(card.as_str())));
|
||||||
}
|
}
|
||||||
|
|
||||||
sections
|
sections
|
||||||
.add(settings::item(&desc[4], text(&page.info.disk_capacity)))
|
.add(settings::item(&*desc[4], text(&page.info.disk_capacity)))
|
||||||
.into()
|
.into()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -106,21 +103,21 @@ fn os() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("about-os"))
|
.title(fl!("about-os"))
|
||||||
.descriptions(vec![
|
.descriptions(vec![
|
||||||
fl!("about-os", "os"),
|
fl!("about-os", "os").into(),
|
||||||
fl!("about-os", "os-architecture"),
|
fl!("about-os", "os-architecture").into(),
|
||||||
fl!("about-os", "desktop-environment"),
|
fl!("about-os", "desktop-environment").into(),
|
||||||
fl!("about-os", "windowing-system"),
|
fl!("about-os", "windowing-system").into(),
|
||||||
])
|
])
|
||||||
.view::<Page>(|_binder, page, section| {
|
.view::<Page>(|_binder, page, section| {
|
||||||
let desc = §ion.descriptions;
|
let desc = §ion.descriptions;
|
||||||
settings::view_section(§ion.title)
|
settings::view_section(§ion.title)
|
||||||
.add(settings::item(&desc[0], text(&page.info.operating_system)))
|
.add(settings::item(&*desc[0], text(&page.info.operating_system)))
|
||||||
.add(settings::item(&desc[1], text(&page.info.os_architecture)))
|
.add(settings::item(&*desc[1], text(&page.info.os_architecture)))
|
||||||
.add(settings::item(
|
.add(settings::item(
|
||||||
&desc[2],
|
&*desc[2],
|
||||||
text(&page.info.desktop_environment),
|
text(&page.info.desktop_environment),
|
||||||
))
|
))
|
||||||
.add(settings::item(&desc[3], text(&page.info.windowing_system)))
|
.add(settings::item(&*desc[3], text(&page.info.windowing_system)))
|
||||||
.into()
|
.into()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -128,10 +125,10 @@ fn os() -> Section<crate::pages::Message> {
|
||||||
fn related() -> Section<crate::pages::Message> {
|
fn related() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("about-related"))
|
.title(fl!("about-related"))
|
||||||
.descriptions(vec![fl!("about-related", "support")])
|
.descriptions(vec![fl!("about-related", "support").into()])
|
||||||
.view::<Page>(|_binder, _page, section| {
|
.view::<Page>(|_binder, _page, section| {
|
||||||
settings::view_section(§ion.title)
|
settings::view_section(§ion.title)
|
||||||
.add(settings::item(§ion.descriptions[0], text("TODO")))
|
.add(settings::item(&*section.descriptions[0], text("TODO")))
|
||||||
.into()
|
.into()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,15 +61,18 @@ impl page::AutoBind<crate::pages::Message> for Page {}
|
||||||
fn date() -> Section<crate::pages::Message> {
|
fn date() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("time-date"))
|
.title(fl!("time-date"))
|
||||||
.descriptions(vec![fl!("time-date", "auto"), fl!("time-date")])
|
.descriptions(vec![
|
||||||
|
fl!("time-date", "auto").into(),
|
||||||
|
fl!("time-date").into(),
|
||||||
|
])
|
||||||
.view::<Page>(|_binder, page, section| {
|
.view::<Page>(|_binder, page, section| {
|
||||||
settings::view_section(§ion.title)
|
settings::view_section(§ion.title)
|
||||||
.add(
|
.add(
|
||||||
settings::item::builder(§ion.descriptions[0])
|
settings::item::builder(&*section.descriptions[0])
|
||||||
.toggler(page.auto, Message::Automatic),
|
.toggler(page.auto, Message::Automatic),
|
||||||
)
|
)
|
||||||
.add(settings::item(
|
.add(settings::item(
|
||||||
§ion.descriptions[1],
|
&*section.descriptions[1],
|
||||||
horizontal_space(Length::Fill),
|
horizontal_space(Length::Fill),
|
||||||
))
|
))
|
||||||
.apply(cosmic::Element::from)
|
.apply(cosmic::Element::from)
|
||||||
|
|
@ -81,19 +84,19 @@ fn format() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("time-format"))
|
.title(fl!("time-format"))
|
||||||
.descriptions(vec![
|
.descriptions(vec![
|
||||||
fl!("time-format", "twenty-four"),
|
fl!("time-format", "twenty-four").into(),
|
||||||
fl!("time-format", "first"),
|
fl!("time-format", "first").into(),
|
||||||
])
|
])
|
||||||
.view::<Page>(|_binder, page, section| {
|
.view::<Page>(|_binder, page, section| {
|
||||||
settings::view_section(§ion.title)
|
settings::view_section(§ion.title)
|
||||||
// 24-hour toggle
|
// 24-hour toggle
|
||||||
.add(
|
.add(
|
||||||
settings::item::builder(§ion.descriptions[0])
|
settings::item::builder(&*section.descriptions[0])
|
||||||
.toggler(page.military_time, Message::MilitaryTime),
|
.toggler(page.military_time, Message::MilitaryTime),
|
||||||
)
|
)
|
||||||
// First day of week
|
// First day of week
|
||||||
.add(settings::item(
|
.add(settings::item(
|
||||||
§ion.descriptions[1],
|
&*section.descriptions[1],
|
||||||
horizontal_space(Length::Fill),
|
horizontal_space(Length::Fill),
|
||||||
))
|
))
|
||||||
.apply(cosmic::Element::from)
|
.apply(cosmic::Element::from)
|
||||||
|
|
@ -105,21 +108,21 @@ fn timezone() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("time-zone"))
|
.title(fl!("time-zone"))
|
||||||
.descriptions(vec![
|
.descriptions(vec![
|
||||||
fl!("time-zone", "auto"),
|
fl!("time-zone", "auto").into(),
|
||||||
fl!("time-zone", "auto-info"),
|
fl!("time-zone", "auto-info").into(),
|
||||||
fl!("time-zone"),
|
fl!("time-zone").into(),
|
||||||
])
|
])
|
||||||
.view::<Page>(|_binder, page, section| {
|
.view::<Page>(|_binder, page, section| {
|
||||||
settings::view_section(§ion.title)
|
settings::view_section(§ion.title)
|
||||||
// Automatic timezone toggle
|
// Automatic timezone toggle
|
||||||
.add(
|
.add(
|
||||||
settings::item::builder(§ion.descriptions[0])
|
settings::item::builder(&*section.descriptions[0])
|
||||||
.description(§ion.descriptions[1])
|
.description(&*section.descriptions[1])
|
||||||
.toggler(page.auto_timezone, Message::AutomaticTimezone),
|
.toggler(page.auto_timezone, Message::AutomaticTimezone),
|
||||||
)
|
)
|
||||||
// Time zone select
|
// Time zone select
|
||||||
.add(
|
.add(
|
||||||
settings::item::builder(§ion.descriptions[2])
|
settings::item::builder(&*section.descriptions[2])
|
||||||
.control(horizontal_space(Length::Fill)),
|
.control(horizontal_space(Length::Fill)),
|
||||||
)
|
)
|
||||||
.apply(cosmic::Element::from)
|
.apply(cosmic::Element::from)
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
use derive_setters::Setters;
|
use derive_setters::Setters;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use crate::{Binder, Page};
|
use crate::{Binder, Page};
|
||||||
|
|
||||||
|
|
@ -29,7 +30,8 @@ pub type ViewFn<Message> = Box<
|
||||||
pub struct Section<Message> {
|
pub struct Section<Message> {
|
||||||
#[setters(into)]
|
#[setters(into)]
|
||||||
pub title: String,
|
pub title: String,
|
||||||
pub descriptions: Vec<String>,
|
#[setters(into)]
|
||||||
|
pub descriptions: Vec<Cow<'static, str>>,
|
||||||
#[setters(skip)]
|
#[setters(skip)]
|
||||||
pub show_while: Option<ShowWhileFn<Message>>,
|
pub show_while: Option<ShowWhileFn<Message>>,
|
||||||
#[setters(skip)]
|
#[setters(skip)]
|
||||||
|
|
@ -61,8 +63,8 @@ impl<Message: 'static> Section<Message> {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for description in &self.descriptions {
|
for description in &*self.descriptions {
|
||||||
if rule.is_match(description.as_str()) {
|
if rule.is_match(description) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue