fix(touchpad): update page to match design

This commit is contained in:
Vukašin Vojinović 2024-08-25 16:43:18 +02:00 • committed by Michael Murphy
parent ddbdc6251b
commit 852f554763
7 changed files with 117 additions and 79 deletions

View file

@ -57,8 +57,8 @@ impl page::AutoBind<crate::pages::Message> for Page {
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub enum Message { pub enum Message {
ShowMinimizeButton(bool),
ShowMaximizeButton(bool), ShowMaximizeButton(bool),
ShowMinimizeButton(bool),
} }
impl Page { impl Page {

View file

@ -107,8 +107,8 @@ pub fn super_key_action() -> Section<crate::pages::Message> {
pub fn window_controls() -> Section<crate::pages::Message> { pub fn window_controls() -> Section<crate::pages::Message> {
let mut descriptions = Slab::new(); let mut descriptions = Slab::new();
let minimize = descriptions.insert(fl!("window-controls", "minimize"));
let maximize = descriptions.insert(fl!("window-controls", "maximize")); let maximize = descriptions.insert(fl!("window-controls", "maximize"));
let minimize = descriptions.insert(fl!("window-controls", "minimize"));
Section::default() Section::default()
.title(fl!("window-controls")) .title(fl!("window-controls"))
@ -120,14 +120,6 @@ pub fn window_controls() -> Section<crate::pages::Message> {
let descriptions = &section.descriptions; let descriptions = &section.descriptions;
settings::view_section(&section.title) settings::view_section(&section.title)
.add(settings::item(
&descriptions[minimize],
toggler(
None,
desktop.cosmic_tk.show_minimize,
super::Message::ShowMinimizeButton,
),
))
.add(settings::item( .add(settings::item(
&descriptions[maximize], &descriptions[maximize],
toggler( toggler(
@ -136,6 +128,14 @@ pub fn window_controls() -> Section<crate::pages::Message> {
super::Message::ShowMaximizeButton, super::Message::ShowMaximizeButton,
), ),
)) ))
.add(settings::item(
&descriptions[minimize],
toggler(
None,
desktop.cosmic_tk.show_minimize,
super::Message::ShowMinimizeButton,
),
))
.apply(Element::from) .apply(Element::from)
.map(crate::pages::Message::Desktop) .map(crate::pages::Message::Desktop)
}) })

View file

@ -76,9 +76,9 @@ pub enum Message {
/// Configures mirroring status of a display. /// Configures mirroring status of a display.
Mirroring(Mirroring), Mirroring(Mirroring),
/// Handle night light preferences. /// Handle night light preferences.
// NightLight(NightLight), // NightLight(NightLight),
/// Show the night light mode context drawer. /// Show the night light mode context drawer.
// NightLightContext, // NightLightContext,
/// Set the orientation of a display. /// Set the orientation of a display.
Orientation(Transform), Orientation(Transform),
/// Pan the displays view /// Pan the displays view
@ -128,7 +128,7 @@ pub struct Page {
background_service: Option<tokio::task::JoinHandle<()>>, background_service: Option<tokio::task::JoinHandle<()>>,
config: Config, config: Config,
cache: ViewCache, cache: ViewCache,
// context: Option<ContextDrawer>, // context: Option<ContextDrawer>,
display_arrangement_scrollable: widget::Id, display_arrangement_scrollable: widget::Id,
/// Tracks the last pan status. /// Tracks the last pan status.
last_pan: f32, last_pan: f32,
@ -150,7 +150,7 @@ impl Default for Page {
background_service: None, background_service: None,
config: Config::default(), config: Config::default(),
cache: ViewCache::default(), cache: ViewCache::default(),
// context: None, // context: None,
display_arrangement_scrollable: widget::Id::unique(), display_arrangement_scrollable: widget::Id::unique(),
last_pan: 0.5, last_pan: 0.5,
dialog: None, dialog: None,
@ -163,7 +163,7 @@ impl Default for Page {
#[derive(Default)] #[derive(Default)]
struct Config { struct Config {
/// Whether night light is enabled. /// Whether night light is enabled.
// night_light_enabled: bool, // night_light_enabled: bool,
refresh_rate: Option<u32>, refresh_rate: Option<u32>,
resolution: Option<(u32, u32)>, resolution: Option<(u32, u32)>,
scale: u32, scale: u32,
@ -191,15 +191,15 @@ impl page::Page<crate::pages::Message> for Page {
) -> Option<page::Content> { ) -> Option<page::Content> {
Some(vec![ Some(vec![
// Night light // Night light
// sections.insert( // sections.insert(
// Section::default() // Section::default()
// .descriptions(vec![ // .descriptions(vec![
// text::NIGHT_LIGHT.as_str().into(), // text::NIGHT_LIGHT.as_str().into(),
// text::NIGHT_LIGHT_AUTO.as_str().into(), // text::NIGHT_LIGHT_AUTO.as_str().into(),
// text::NIGHT_LIGHT_DESCRIPTION.as_str().into(), // text::NIGHT_LIGHT_DESCRIPTION.as_str().into(),
// ]) // ])
// .view::<Page>(move |_binder, page, _section| page.night_light_view()), // .view::<Page>(move |_binder, page, _section| page.night_light_view()),
// ), // ),
// Display arrangement // Display arrangement
sections.insert(display_arrangement()), sections.insert(display_arrangement()),
// Display configuration // Display configuration
@ -305,14 +305,14 @@ impl page::Page<crate::pages::Message> for Page {
}) })
} }
// fn context_drawer(&self) -> Option<Element<pages::Message>> { // fn context_drawer(&self) -> Option<Element<pages::Message>> {
// Some(match self.context { // Some(match self.context {
// Some(ContextDrawer::NightLight) => self.night_light_context_view(), // Some(ContextDrawer::NightLight) => self.night_light_context_view(),
// None => return None, // None => return None,
// }) // })
// } // }
/// Opens a dialog to confirm the display settings. /// Opens a dialog to confirm the display settings.
/// ///
@ -413,14 +413,14 @@ impl Page {
} // Mirroring::ProjectToAll => (), } // Mirroring::ProjectToAll => (),
}, },
// Message::NightLight(night_light) => {} // Message::NightLight(night_light) => {}
// //
// Message::NightLightContext => { // Message::NightLightContext => {
// self.context = Some(ContextDrawer::NightLight); // self.context = Some(ContextDrawer::NightLight);
// return cosmic::command::message(app::Message::OpenContextDrawer( // return cosmic::command::message(app::Message::OpenContextDrawer(
// text::NIGHT_LIGHT.clone().into(), // text::NIGHT_LIGHT.clone().into(),
// )); // ));
// } // }
Message::Orientation(orientation) => return self.set_orientation(orientation), Message::Orientation(orientation) => return self.set_orientation(orientation),
Message::Pan(pan) => { Message::Pan(pan) => {
@ -480,9 +480,9 @@ impl Page {
} }
/// Displays the night light context drawer. /// Displays the night light context drawer.
// pub fn night_light_context_view(&self) -> Element<pages::Message> { // pub fn night_light_context_view(&self) -> Element<pages::Message> {
// column().into() // column().into()
// } // }
/// Reloads the display list, and all information relevant to the active display. /// Reloads the display list, and all information relevant to the active display.
pub fn update_displays(&mut self, list: List) { pub fn update_displays(&mut self, list: List) {

View file

@ -1,16 +1,36 @@
use cosmic::cosmic_config::ConfigGet;
use cosmic::iced::{Alignment, Length}; use cosmic::iced::{Alignment, Length};
use cosmic::widget::{self, row, settings, text}; use cosmic::widget::{self, row, settings, text};
use cosmic::{Apply, Element}; use cosmic::{Apply, Element};
use cosmic_comp_config::input::{AccelProfile, ClickMethod, ScrollMethod}; use cosmic_comp_config::input::{AccelProfile, ClickMethod, ScrollMethod};
use cosmic_comp_config::workspace::{WorkspaceConfig, WorkspaceLayout};
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 slab::Slab; use slab::Slab;
use slotmap::SlotMap; use slotmap::SlotMap;
use tracing::error;
use super::Message; use super::Message;
#[derive(Default)] pub struct Page {
pub struct Page; comp_workspace_config: WorkspaceConfig,
}
impl Default for Page {
fn default() -> Self {
let comp_config = cosmic_config::Config::new("com.system76.CosmicComp", 1).unwrap();
let comp_workspace_config = comp_config.get("workspaces").unwrap_or_else(|err| {
if !matches!(err, cosmic_config::Error::NoConfigDirectory) {
error!(?err, "Failed to read config 'workspaces'");
}
WorkspaceConfig::default()
});
Self {
comp_workspace_config,
}
}
}
impl page::Page<crate::pages::Message> for Page { impl page::Page<crate::pages::Message> for Page {
fn content( fn content(
@ -21,7 +41,7 @@ impl page::Page<crate::pages::Message> for Page {
sections.insert(touchpad()), sections.insert(touchpad()),
sections.insert(click_behavior()), sections.insert(click_behavior()),
sections.insert(scrolling()), sections.insert(scrolling()),
sections.insert(swiping()), sections.insert(gestures()),
]) ])
} }
@ -38,6 +58,7 @@ fn touchpad() -> Section<crate::pages::Message> {
let mut descriptions = Slab::new(); let mut descriptions = Slab::new();
let primary_button = descriptions.insert(fl!("primary-button")); let primary_button = descriptions.insert(fl!("primary-button"));
let primary_button_desc = descriptions.insert(fl!("primary-button", "desc"));
let touchpad_speed = descriptions.insert(fl!("touchpad", "speed")); let touchpad_speed = descriptions.insert(fl!("touchpad", "speed"));
let acceleration = descriptions.insert(fl!("touchpad", "acceleration")); let acceleration = descriptions.insert(fl!("touchpad", "acceleration"));
let acceleration_desc = descriptions.insert(fl!("acceleration-desc")); let acceleration_desc = descriptions.insert(fl!("acceleration-desc"));
@ -51,12 +72,17 @@ fn touchpad() -> Section<crate::pages::Message> {
let theme = cosmic::theme::active(); let theme = cosmic::theme::active();
settings::view_section(&section.title) settings::view_section(&section.title)
.add(settings::flex_item( .add(
&descriptions[primary_button], settings::item::builder(&descriptions[primary_button])
cosmic::widget::segmented_control::horizontal(&input.touchpad_primary_button) .description(&descriptions[primary_button_desc])
.minimum_button_width(0) .flex_control(
.on_activate(|x| Message::PrimaryButtonSelected(x, true)), cosmic::widget::segmented_control::horizontal(
)) &input.touchpad_primary_button,
)
.minimum_button_width(0)
.on_activate(|x| Message::PrimaryButtonSelected(x, true)),
),
)
.add( .add(
settings::item::builder(&descriptions[touchpad_speed]).flex_control({ settings::item::builder(&descriptions[touchpad_speed]).flex_control({
let value = (input let value = (input
@ -238,25 +264,27 @@ fn scrolling() -> Section<crate::pages::Message> {
}) })
} }
fn swiping() -> Section<crate::pages::Message> { fn gestures() -> Section<crate::pages::Message> {
let mut descriptions = Slab::new(); let mut descriptions = Slab::new();
let four_finger_down = descriptions.insert(fl!("gestures", "four-finger-down")); // let four_finger_down = descriptions.insert(fl!("gestures", "four-finger-down"));
// let four_finger_left = descriptions.insert(fl!("gestures", "four-finger-left")); // let four_finger_left = descriptions.insert(fl!("gestures", "four-finger-left"));
// let four_finger_right = descriptions.insert(fl!("gestures", "four-finger-right")); // let four_finger_right = descriptions.insert(fl!("gestures", "four-finger-right"));
let four_finger_up = descriptions.insert(fl!("gestures", "four-finger-up")); // let four_finger_up = descriptions.insert(fl!("gestures", "four-finger-up"));
// let three_finger_any = descriptions.insert(fl!("gestures", "three-finger-any")); // let three_finger_any = descriptions.insert(fl!("gestures", "three-finger-any"));
let switch_workspaces = descriptions.insert(fl!("switch-workspaces"));
let switch_workspaces_horizontal = descriptions.insert(fl!("switch-workspaces", "horizontal"));
let switch_workspaces_vertical = descriptions.insert(fl!("switch-workspaces", "vertical"));
// let open_application_library = descriptions.insert(fl!("open-application-library")); // let open_application_library = descriptions.insert(fl!("open-application-library"));
// let open_workspaces_view = descriptions.insert(fl!("open-workspaces-view")); // let open_workspaces_view = descriptions.insert(fl!("open-workspaces-view"));
// let switch_between_windows = descriptions.insert(fl!("switch-between-windows")); // let switch_between_windows = descriptions.insert(fl!("switch-between-windows"));
let switch_to_next_workspace = descriptions.insert(fl!("switch-to-next-workspace"));
let switch_to_prev_workspace = descriptions.insert(fl!("switch-to-prev-workspace"));
Section::default() Section::default()
.title(fl!("gestures")) .title(fl!("gestures"))
.descriptions(descriptions) .descriptions(descriptions)
.view::<Page>(move |_binder, _page, section| { .view::<Page>(move |_binder, page, section| {
let descriptions = &section.descriptions; let descriptions = &section.descriptions;
settings::view_section(&*section.title) settings::view_section(&*section.title)
@ -265,12 +293,13 @@ fn swiping() -> Section<crate::pages::Message> {
// .flex_control(text(&descriptions[switch_between_windows])), // .flex_control(text(&descriptions[switch_between_windows])),
// ) // )
.add( .add(
settings::item::builder(&descriptions[four_finger_up]) settings::item::builder(
.flex_control(text(&descriptions[switch_to_prev_workspace])), &descriptions[match page.comp_workspace_config.workspace_layout {
) WorkspaceLayout::Horizontal => switch_workspaces_horizontal,
.add( WorkspaceLayout::Vertical => switch_workspaces_vertical,
settings::item::builder(&descriptions[four_finger_down]) }],
.flex_control(text(&descriptions[switch_to_next_workspace])), )
.flex_control(text(&descriptions[switch_workspaces])),
) )
// .add( // .add(
// settings::item::builder(&descriptions[four_finger_left]) // settings::item::builder(&descriptions[four_finger_left])

View file

@ -312,6 +312,7 @@ input-devices = Input Devices
.desc = Input Devices .desc = Input Devices
primary-button = Primary button primary-button = Primary button
.desc = Sets the order of physical buttons.
.left = Left .left = Left
.right = Right .right = Right
@ -510,9 +511,11 @@ gestures = Gestures
.four-finger-up = Four-finger swipe up .four-finger-up = Four-finger swipe up
.three-finger-any = Three-finger swipe any direction .three-finger-any = Three-finger swipe any direction
switch-workspaces = Switch workspaces
.horizontal = Four-finger swipe left/right
.vertical = Four-finger swipe up/down
switch-between-windows = Switch between windows switch-between-windows = Switch between windows
switch-to-next-workspace = Switch to next workspace
switch-to-prev-workspace = Switch to prev workspace
open-application-library = Open Application Library open-application-library = Open Application Library
open-workspaces-view = Open Workspaces Overview open-workspaces-view = Open Workspaces Overview

View file

@ -104,7 +104,7 @@ style = Стил
.square = Четвртаст .square = Четвртаст
# interface density left out for now # interface density left out for now
window-management = Управљање прозорима window-management-appearance = Управљање прозорима
.active-hint = Дебљина наговештаја активног прозора .active-hint = Дебљина наговештаја активног прозора
.gaps = Празнине око сложених прозора .gaps = Празнине око сложених прозора
@ -312,6 +312,7 @@ input-devices = Унос
.desc = Унос .desc = Унос
primary-button = Примарно дугме primary-button = Примарно дугме
.desc = Одређује редослед физичких дугмади.
.left = Лево .left = Лево
.right = Десно .right = Десно
@ -504,15 +505,17 @@ touchpad = Додирна табла
## Input: Gestures ## Input: Gestures
swiping = Покрети swiping = Покрети
.four-finger-down = Превуците према доле са четири прста .four-finger-down = Превуци према доле са четири прста
.four-finger-left = Превуците према лево са четири прста .four-finger-left = Превуци према лево са четири прста
.four-finger-right = Превуците према десно са четири прста .four-finger-right = Превуци према десно са четири прста
.four-finger-up = Превуците према горе са четири прста .four-finger-up = Превуци према горе са четири прста
.three-finger-any = Превуците са три прста у било ком смеру .three-finger-any = Превуци са три прста у било ком смеру
switch-workspaces = Промени радни простор
.horizontal = Превуци према лево/десно са четири прста
.vertical = Превуци према горе/доле са четири прста
switch-between-windows = Пребацивање између прозора switch-between-windows = Пребацивање између прозора
switch-to-next-workspace = Пређи на следећи радни простор
switch-to-prev-workspace = Пређи на претходни радни простор
open-application-library = Отвори библиотеку апликација open-application-library = Отвори библиотеку апликација
open-workspaces-view = Отвори преглед радних простора open-workspaces-view = Отвори преглед радних простора

View file

@ -104,7 +104,7 @@ style = Stil
.square = Četvrtast .square = Četvrtast
# interface density left out for now # interface density left out for now
window-management = Upravljanje prozorima window-management-appearance = Upravljanje prozorima
.active-hint = Debljina nagoveštaja aktivnog prozora .active-hint = Debljina nagoveštaja aktivnog prozora
.gaps = Praznine oko složenih prozora .gaps = Praznine oko složenih prozora
@ -312,6 +312,7 @@ input-devices = Unos
.desc = Unos .desc = Unos
primary-button = Primarno dugme primary-button = Primarno dugme
.desc = Određuje redosled fizičkih dugmadi.
.left = Levo .left = Levo
.right = Desno .right = Desno
@ -504,15 +505,17 @@ touchpad = Dodirna tabla
## Input: Gestures ## Input: Gestures
swiping = Pokreti swiping = Pokreti
.four-finger-down = Prevucite prema dole sa četiri prsta .four-finger-down = Prevuci prema dole sa četiri prsta
.four-finger-left = Prevucite prema levo sa četiri prsta .four-finger-left = Prevuci prema levo sa četiri prsta
.four-finger-right = Prevucite prema desno sa četiri prsta .four-finger-right = Prevuci prema desno sa četiri prsta
.four-finger-up = Prevucite prema gore sa četiri prsta .four-finger-up = Prevuci prema gore sa četiri prsta
.three-finger-any = Prevucite sa tri prsta u bilo kom smeru .three-finger-any = Prevuci sa tri prsta u bilo kom smeru
switch-workspaces = Promeni radni prostor
.horizontal = Prevuci prema levo/desno sa četiri prsta
.vertical = Prevuci prema gore/dole sa četiri prsta
switch-between-windows = Prebacivanje između prozora switch-between-windows = Prebacivanje između prozora
switch-to-next-workspace = Pređi na sledeći radni prostor
switch-to-prev-workspace = Pređi na prethodni radni prostor
open-application-library = Otvori biblioteku aplikacija open-application-library = Otvori biblioteku aplikacija
open-workspaces-view = Otvori pregled radnih prostora open-workspaces-view = Otvori pregled radnih prostora