Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input devices improvements #159

Merged
merged 8 commits into from
Feb 20, 2024
Merged
150 changes: 77 additions & 73 deletions app/src/pages/desktop/appearance.rs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions app/src/pages/desktop/dock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ impl Default for Page {

pub(crate) fn enable() -> Section<crate::pages::Message> {
Section::default()
.descriptions(vec![fl!("dock")])
.descriptions(vec![fl!("dock").into()])
.view::<Page>(|_binder, page, section| {
let descriptions = &section.descriptions;
let Some(container_config) = page.inner.container_config.as_ref() else {
return Element::from(text(fl!("unknown")));
};
settings::view_section(&section.title)
.add(settings::item(
&descriptions[0],
&*descriptions[0],
toggler(
None,
container_config
Expand Down
20 changes: 10 additions & 10 deletions app/src/pages/desktop/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,24 @@ pub fn super_key_action() -> Section<crate::pages::Message> {
Section::default()
.title(fl!("super-key-action"))
.descriptions(vec![
fl!("super-key-action", "launcher"),
fl!("super-key-action", "workspaces"),
fl!("super-key-action", "applications"),
fl!("super-key-action", "launcher").into(),
fl!("super-key-action", "workspaces").into(),
fl!("super-key-action", "applications").into(),
])
.view::<Page>(|_binder, _page, section| {
let descriptions = &section.descriptions;

settings::view_section(&section.title)
.add(settings::item(
&descriptions[0],
&*descriptions[0],
horizontal_space(Length::Fill),
))
.add(settings::item(
&descriptions[1],
&*descriptions[1],
horizontal_space(Length::Fill),
))
.add(settings::item(
&descriptions[2],
&*descriptions[2],
horizontal_space(Length::Fill),
))
.into()
Expand All @@ -76,8 +76,8 @@ pub fn window_controls() -> Section<crate::pages::Message> {
Section::default()
.title(fl!("window-controls"))
.descriptions(vec![
fl!("window-controls", "minimize"),
fl!("window-controls", "maximize"),
fl!("window-controls", "minimize").into(),
fl!("window-controls", "maximize").into(),
])
.view::<Page>(|binder, _page, section| {
let desktop = binder
Expand All @@ -87,15 +87,15 @@ pub fn window_controls() -> Section<crate::pages::Message> {

settings::view_section(&section.title)
.add(settings::item(
&descriptions[0],
&*descriptions[0],
toggler(
None,
desktop.show_minimize_button,
Message::ShowMinimizeButton,
),
))
.add(settings::item(
&descriptions[1],
&*descriptions[1],
toggler(
None,
desktop.show_maximize_button,
Expand Down
8 changes: 1 addition & 7 deletions app/src/pages/desktop/panel/applets_inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,13 +434,7 @@ impl Page {
list.retain(|id| id != &to_remove);
self.save();
}
Message::DetailStart(_) => {
// TODO ask design team
}
Message::DetailCenter(_) => {
// TODO ask design team
}
Message::DetailEnd(_) => {
Message::DetailStart(_) | Message::DetailCenter(_) | Message::DetailEnd(_) => {
// TODO ask design team
}
Message::Cancel => {
Expand Down
52 changes: 26 additions & 26 deletions app/src/pages/desktop/panel/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ pub struct PageInner {
impl Default for PageInner {
fn default() -> Self {
Self {
config_helper: Default::default(),
panel_config: Default::default(),
config_helper: Option::default(),
panel_config: Option::default(),
outputs: vec![fl!("all")],
anchors: vec![
Anchor(PanelAnchor::Left).to_string(),
Expand All @@ -46,8 +46,8 @@ impl Default for PageInner {
Appearance::Light.to_string(),
Appearance::Dark.to_string(),
],
container_config: Default::default(),
outputs_map: Default::default(),
container_config: Option::default(),
outputs_map: HashMap::default(),
}
}
}
Expand Down Expand Up @@ -78,9 +78,9 @@ pub(crate) fn behavior_and_position<
Section::default()
.title(fl!("panel-behavior-and-position"))
.descriptions(vec![
p.autohide_label(),
fl!("panel-behavior-and-position", "position"),
fl!("panel-behavior-and-position", "display"),
p.autohide_label().into(),
fl!("panel-behavior-and-position", "position").into(),
fl!("panel-behavior-and-position", "display").into(),
])
.view::<P>(move |_binder, page, section| {
let descriptions = &section.descriptions;
Expand All @@ -90,21 +90,21 @@ pub(crate) fn behavior_and_position<
};
settings::view_section(&section.title)
.add(settings::item(
&descriptions[0],
&*descriptions[0],
toggler(None, panel_config.autohide.is_some(), |value| {
Message::AutoHidePanel(value)
}),
))
.add(settings::item(
&descriptions[1],
&*descriptions[1],
dropdown(
page.anchors.as_slice(),
Some(panel_config.anchor as usize),
Message::PanelAnchor,
),
))
.add(settings::item(
&descriptions[2],
&*descriptions[2],
dropdown(
page.outputs.as_slice(),
match &panel_config.output {
Expand All @@ -130,11 +130,11 @@ pub(crate) fn style<
Section::default()
.title(fl!("panel-style"))
.descriptions(vec![
p.gap_label(),
p.extend_label(),
fl!("panel-style", "appearance"),
fl!("panel-style", "size"),
fl!("panel-style", "background-opacity"),
p.gap_label().into(),
p.extend_label().into(),
fl!("panel-style", "appearance").into(),
fl!("panel-style", "size").into(),
fl!("panel-style", "background-opacity").into(),
])
.view::<P>(move |_binder, page, section| {
let descriptions = &section.descriptions;
Expand All @@ -144,19 +144,19 @@ pub(crate) fn style<
};
settings::view_section(&section.title)
.add(settings::item(
&descriptions[0],
&*descriptions[0],
toggler(None, panel_config.anchor_gap, |value| {
Message::AnchorGap(value)
}),
))
.add(settings::item(
&descriptions[1],
&*descriptions[1],
toggler(None, panel_config.expand_to_edges, |value| {
Message::ExtendToEdge(value)
}),
))
.add(settings::item(
&descriptions[2],
&*descriptions[2],
dropdown(
inner.backgrounds.as_slice(),
match panel_config.background {
Expand All @@ -169,7 +169,7 @@ pub(crate) fn style<
),
))
.add(settings::item(
&descriptions[3],
&*descriptions[3],
// TODO custom discrete slider variant
row::with_children(vec![
text(fl!("small")).into(),
Expand Down Expand Up @@ -202,7 +202,7 @@ pub(crate) fn style<
.spacing(12),
))
.add(settings::item(
&descriptions[4],
&*descriptions[4],
row::with_children(vec![
text(fl!("number", HashMap::from_iter(vec![("number", 0)]))).into(),
slider(0..=100, (panel_config.opacity * 100.0) as i32, |v| {
Expand All @@ -223,7 +223,7 @@ pub(crate) fn configuration<P: page::Page<crate::pages::Message> + PanelPage>(
) -> Section<crate::pages::Message> {
Section::default()
.title(fl!("panel-applets"))
.descriptions(vec![p.configure_applets_label()])
.descriptions(vec![p.configure_applets_label().into()])
.view::<P>(move |binder, page, section| {
let mut settings = settings::view_section(&section.title);
let descriptions = &section.descriptions;
Expand All @@ -238,7 +238,7 @@ pub(crate) fn configuration<P: page::Page<crate::pages::Message> + PanelPage>(
]);

settings.add(
settings::item::builder(&descriptions[0])
settings::item::builder(&*descriptions[0])
.control(control)
.spacing(16)
.apply(container)
Expand All @@ -265,8 +265,8 @@ pub(crate) fn add_panel<
Section::default()
.title(fl!("panel-missing"))
.descriptions(vec![
fl!("panel-missing", "desc"),
fl!("panel-missing", "fix"),
fl!("panel-missing", "desc").into(),
fl!("panel-missing", "fix").into(),
])
.view::<P>(move |_binder, _page, section| {
// _descriptions = &section.descriptions;
Expand Down Expand Up @@ -349,7 +349,7 @@ impl PageInner {
#[allow(clippy::too_many_lines)]
pub fn update(&mut self, message: Message) {
let helper = self.config_helper.as_ref().unwrap();
let Some(mut panel_config) = self.panel_config.as_mut() else {
let Some(panel_config) = self.panel_config.as_mut() else {
return;
};

Expand Down Expand Up @@ -384,7 +384,7 @@ impl PageInner {
if i == 0 {
panel_config.output = CosmicPanelOuput::All;
} else {
panel_config.output = CosmicPanelOuput::Name(self.outputs[i].clone())
panel_config.output = CosmicPanelOuput::Name(self.outputs[i].clone());
}
}
Message::AnchorGap(enabled) => {
Expand Down
26 changes: 10 additions & 16 deletions app/src/pages/desktop/wallpaper/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ use cosmic_settings_wallpaper::{self as wallpaper, Entry, ScalingMode};
use image::imageops::FilterType::Lanczos3;
use image::{ImageBuffer, Rgba};
use slotmap::{DefaultKey, SecondaryMap, SlotMap};
use static_init::dynamic;

const ZOOM: usize = 0;
const FIT: usize = 1;
Expand Down Expand Up @@ -1056,26 +1055,21 @@ pub async fn change_folder(current_folder: PathBuf) -> Context {
update
}

#[dynamic]
static WALLPAPER_SAME: String = fl!("wallpaper", "same");

#[dynamic]
static WALLPAPER_FIT: String = fl!("wallpaper", "fit");

#[dynamic]
static WALLPAPER_SLIDE: String = fl!("wallpaper", "slide");

#[dynamic]
static WALLPAPER_CHANGE: String = fl!("wallpaper", "change");
crate::cache_dynamic_lazy! {
static WALLPAPER_SAME: String = fl!("wallpaper", "same");
static WALLPAPER_FIT: String = fl!("wallpaper", "fit");
static WALLPAPER_SLIDE: String = fl!("wallpaper", "slide");
static WALLPAPER_CHANGE: String = fl!("wallpaper", "change");
}

#[allow(clippy::too_many_lines)]
pub fn settings() -> Section<crate::pages::Message> {
Section::default()
.descriptions(vec![
WALLPAPER_SAME.clone(),
WALLPAPER_FIT.clone(),
WALLPAPER_SLIDE.clone(),
WALLPAPER_CHANGE.clone(),
WALLPAPER_SAME.as_str().into(),
WALLPAPER_FIT.as_str().into(),
WALLPAPER_SLIDE.as_str().into(),
WALLPAPER_CHANGE.as_str().into(),
])
.view::<Page>(|_binder, page, _section| {
let mut children = Vec::with_capacity(3);
Expand Down
16 changes: 8 additions & 8 deletions app/src/pages/desktop/workspaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,21 @@ fn multi_behavior() -> Section<crate::pages::Message> {
Section::default()
.title(fl!("workspaces-multi-behavior"))
.descriptions(vec![
fl!("workspaces-multi-behavior", "span"),
fl!("workspaces-multi-behavior", "separate"),
fl!("workspaces-multi-behavior", "span").into(),
fl!("workspaces-multi-behavior", "separate").into(),
])
.view::<Page>(|_binder, page, section| {
let descriptions = &section.descriptions;
settings::view_section(&section.title)
.add(settings::item_row(vec![radio(
&descriptions[0],
&*descriptions[0],
WorkspaceMode::Global,
Some(page.comp_workspace_config.workspace_mode),
Message::SetWorkspaceMode,
)
.into()]))
.add(settings::item_row(vec![radio(
&descriptions[1],
&*descriptions[1],
WorkspaceMode::OutputBound,
Some(page.comp_workspace_config.workspace_mode),
Message::SetWorkspaceMode,
Expand All @@ -162,18 +162,18 @@ fn overview_thumbnails() -> Section<crate::pages::Message> {
Section::default()
.title(fl!("workspaces-overview-thumbnails"))
.descriptions(vec![
fl!("workspaces-overview-thumbnails", "show-number"),
fl!("workspaces-overview-thumbnails", "show-name"),
fl!("workspaces-overview-thumbnails", "show-number").into(),
fl!("workspaces-overview-thumbnails", "show-name").into(),
])
.view::<Page>(|_binder, page, section| {
let descriptions = &section.descriptions;
settings::view_section(&section.title)
.add(
settings::item::builder(&descriptions[0])
settings::item::builder(&*descriptions[0])
.toggler(page.show_workspace_number, Message::SetShowNumber),
)
.add(
settings::item::builder(&descriptions[1])
settings::item::builder(&*descriptions[1])
.toggler(page.show_workspace_name, Message::SetShowName),
)
.apply(Element::from)
Expand Down
Loading
Loading