fix(shortcuts): modified count for accessibility and tiling

These weren't being set previously, so they never showed up.
Also updates remaining things here to use ListButton.
This commit is contained in:
Vukašin Vojinović 2026-04-17 13:03:32 +02:00 committed by Michael Murphy
parent 48eae39858
commit 317de19eb3
6 changed files with 51 additions and 68 deletions

36
Cargo.lock generated
View file

@ -1199,7 +1199,7 @@ checksum = "fe6d2e5af09e8c8ad56c969f2157a3d4238cebc7c55f0a517728c38f7b200f81"
dependencies = [
"serde",
"termcolor",
"unicode-width 0.1.14",
"unicode-width 0.2.2",
]
[[package]]
@ -1391,7 +1391,7 @@ dependencies = [
[[package]]
name = "cosmic-config"
version = "1.0.0"
source = "git+https://github.com/pop-os/libcosmic#3f9e93067b31d9ba81a4e3a28653b3380c61c352"
source = "git+https://github.com/pop-os/libcosmic#c423ad1bfc25057922406c687f2ddc75ead5ab67"
dependencies = [
"atomicwrites",
"cosmic-config-derive",
@ -1412,7 +1412,7 @@ dependencies = [
[[package]]
name = "cosmic-config-derive"
version = "1.0.0"
source = "git+https://github.com/pop-os/libcosmic#3f9e93067b31d9ba81a4e3a28653b3380c61c352"
source = "git+https://github.com/pop-os/libcosmic#c423ad1bfc25057922406c687f2ddc75ead5ab67"
dependencies = [
"quote",
"syn 2.0.117",
@ -1827,7 +1827,7 @@ dependencies = [
[[package]]
name = "cosmic-theme"
version = "1.0.0"
source = "git+https://github.com/pop-os/libcosmic#3f9e93067b31d9ba81a4e3a28653b3380c61c352"
source = "git+https://github.com/pop-os/libcosmic#c423ad1bfc25057922406c687f2ddc75ead5ab67"
dependencies = [
"almost",
"configparser",
@ -3250,7 +3250,7 @@ dependencies = [
[[package]]
name = "iced"
version = "0.14.0"
source = "git+https://github.com/pop-os/libcosmic#3f9e93067b31d9ba81a4e3a28653b3380c61c352"
source = "git+https://github.com/pop-os/libcosmic#c423ad1bfc25057922406c687f2ddc75ead5ab67"
dependencies = [
"dnd",
"iced_accessibility",
@ -3271,7 +3271,7 @@ dependencies = [
[[package]]
name = "iced_accessibility"
version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic#3f9e93067b31d9ba81a4e3a28653b3380c61c352"
source = "git+https://github.com/pop-os/libcosmic#c423ad1bfc25057922406c687f2ddc75ead5ab67"
dependencies = [
"accesskit",
"accesskit_winit",
@ -3280,7 +3280,7 @@ dependencies = [
[[package]]
name = "iced_core"
version = "0.14.0"
source = "git+https://github.com/pop-os/libcosmic#3f9e93067b31d9ba81a4e3a28653b3380c61c352"
source = "git+https://github.com/pop-os/libcosmic#c423ad1bfc25057922406c687f2ddc75ead5ab67"
dependencies = [
"bitflags 2.11.1",
"bytes",
@ -3305,7 +3305,7 @@ dependencies = [
[[package]]
name = "iced_debug"
version = "0.14.0"
source = "git+https://github.com/pop-os/libcosmic#3f9e93067b31d9ba81a4e3a28653b3380c61c352"
source = "git+https://github.com/pop-os/libcosmic#c423ad1bfc25057922406c687f2ddc75ead5ab67"
dependencies = [
"iced_core",
"iced_futures",
@ -3315,7 +3315,7 @@ dependencies = [
[[package]]
name = "iced_futures"
version = "0.14.0"
source = "git+https://github.com/pop-os/libcosmic#3f9e93067b31d9ba81a4e3a28653b3380c61c352"
source = "git+https://github.com/pop-os/libcosmic#c423ad1bfc25057922406c687f2ddc75ead5ab67"
dependencies = [
"futures",
"iced_core",
@ -3329,7 +3329,7 @@ dependencies = [
[[package]]
name = "iced_graphics"
version = "0.14.0"
source = "git+https://github.com/pop-os/libcosmic#3f9e93067b31d9ba81a4e3a28653b3380c61c352"
source = "git+https://github.com/pop-os/libcosmic#c423ad1bfc25057922406c687f2ddc75ead5ab67"
dependencies = [
"bitflags 2.11.1",
"bytemuck",
@ -3350,7 +3350,7 @@ dependencies = [
[[package]]
name = "iced_program"
version = "0.14.0"
source = "git+https://github.com/pop-os/libcosmic#3f9e93067b31d9ba81a4e3a28653b3380c61c352"
source = "git+https://github.com/pop-os/libcosmic#c423ad1bfc25057922406c687f2ddc75ead5ab67"
dependencies = [
"iced_graphics",
"iced_runtime",
@ -3359,7 +3359,7 @@ dependencies = [
[[package]]
name = "iced_renderer"
version = "0.14.0"
source = "git+https://github.com/pop-os/libcosmic#3f9e93067b31d9ba81a4e3a28653b3380c61c352"
source = "git+https://github.com/pop-os/libcosmic#c423ad1bfc25057922406c687f2ddc75ead5ab67"
dependencies = [
"iced_graphics",
"iced_tiny_skia",
@ -3371,7 +3371,7 @@ dependencies = [
[[package]]
name = "iced_runtime"
version = "0.14.0"
source = "git+https://github.com/pop-os/libcosmic#3f9e93067b31d9ba81a4e3a28653b3380c61c352"
source = "git+https://github.com/pop-os/libcosmic#c423ad1bfc25057922406c687f2ddc75ead5ab67"
dependencies = [
"bytes",
"cosmic-client-toolkit",
@ -3387,7 +3387,7 @@ dependencies = [
[[package]]
name = "iced_tiny_skia"
version = "0.14.0"
source = "git+https://github.com/pop-os/libcosmic#3f9e93067b31d9ba81a4e3a28653b3380c61c352"
source = "git+https://github.com/pop-os/libcosmic#c423ad1bfc25057922406c687f2ddc75ead5ab67"
dependencies = [
"bytemuck",
"cosmic-text",
@ -3404,7 +3404,7 @@ dependencies = [
[[package]]
name = "iced_wgpu"
version = "0.14.0"
source = "git+https://github.com/pop-os/libcosmic#3f9e93067b31d9ba81a4e3a28653b3380c61c352"
source = "git+https://github.com/pop-os/libcosmic#c423ad1bfc25057922406c687f2ddc75ead5ab67"
dependencies = [
"as-raw-xcb-connection",
"bitflags 2.11.1",
@ -3435,7 +3435,7 @@ dependencies = [
[[package]]
name = "iced_widget"
version = "0.14.2"
source = "git+https://github.com/pop-os/libcosmic#3f9e93067b31d9ba81a4e3a28653b3380c61c352"
source = "git+https://github.com/pop-os/libcosmic#c423ad1bfc25057922406c687f2ddc75ead5ab67"
dependencies = [
"cosmic-client-toolkit",
"dnd",
@ -3455,7 +3455,7 @@ dependencies = [
[[package]]
name = "iced_winit"
version = "0.14.0"
source = "git+https://github.com/pop-os/libcosmic#3f9e93067b31d9ba81a4e3a28653b3380c61c352"
source = "git+https://github.com/pop-os/libcosmic#c423ad1bfc25057922406c687f2ddc75ead5ab67"
dependencies = [
"cosmic-client-toolkit",
"cursor-icon",
@ -4567,7 +4567,7 @@ checksum = "52ff2c0fe9bc6cb6b14a0592c2ff4fa9ceb83eea9db979b0487cd054946a2b8f"
[[package]]
name = "libcosmic"
version = "1.0.0"
source = "git+https://github.com/pop-os/libcosmic#3f9e93067b31d9ba81a4e3a28653b3380c61c352"
source = "git+https://github.com/pop-os/libcosmic#c423ad1bfc25057922406c687f2ddc75ead5ab67"
dependencies = [
"apply",
"ashpd 0.12.3",

View file

@ -8,7 +8,7 @@ use cosmic::iced::keyboard::{Key, Location, Modifiers};
use cosmic::iced::platform_specific::shell::wayland::commands::keyboard_shortcuts_inhibit;
use cosmic::iced::platform_specific::shell::wayland::keymap;
use cosmic::iced::{self, Alignment, Length};
use cosmic::widget::{self, button, icon, settings, text};
use cosmic::widget::{self, button, icon, list, settings, text};
use cosmic::{Apply, Element, Task, theme};
use cosmic_config::{ConfigGet, ConfigSet};
use cosmic_settings_config::shortcuts::{self, Action, Binding, Shortcuts};
@ -865,13 +865,11 @@ fn context_drawer<'a>(
}
/// Display a shortcut as a list item
fn shortcut_item(custom: bool, id: usize, data: &ShortcutModel) -> Element<'_, ShortcutMessage> {
#[derive(Copy, Clone, Debug)]
enum LocalMessage {
Remove,
Show,
}
fn shortcut_item(
custom: bool,
id: usize,
data: &ShortcutModel,
) -> list::ListButton<'_, ShortcutMessage> {
let bindings = data
.bindings
.iter()
@ -880,7 +878,7 @@ fn shortcut_item(custom: bool, id: usize, data: &ShortcutModel) -> Element<'_, S
.map(|(_, shortcut)| text::body(shortcut.binding.to_string()).into())
.collect::<Vec<_>>();
let shortcuts: Element<LocalMessage> = if bindings.is_empty() {
let shortcuts: Element<ShortcutMessage> = if bindings.is_empty() {
text::body(fl!("disabled")).into()
} else {
widget::column::with_children(bindings)
@ -900,7 +898,7 @@ fn shortcut_item(custom: bool, id: usize, data: &ShortcutModel) -> Element<'_, S
.push(icon::from_name("go-next-symbolic").size(16))
.push_maybe(custom.then(|| {
widget::button::icon(icon::from_name("edit-delete-symbolic"))
.on_press(LocalMessage::Remove)
.on_press(ShortcutMessage::DeleteShortcut(id))
}))
.align_y(Alignment::Center)
.spacing(8);
@ -909,14 +907,7 @@ fn shortcut_item(custom: bool, id: usize, data: &ShortcutModel) -> Element<'_, S
.flex_control(control)
.align_items(Alignment::Center)
.spacing(16)
.apply(widget::container)
.class(theme::Container::List)
.apply(widget::button::custom)
.class(theme::Button::Transparent)
.on_press(LocalMessage::Show)
.apply(Element::from)
.map(move |message| match message {
LocalMessage::Show => ShortcutMessage::ShowShortcut(id, data.description.clone()),
LocalMessage::Remove => ShortcutMessage::DeleteShortcut(id),
})
.width(Length::Shrink)
.apply(list::button)
.on_press(ShortcutMessage::ShowShortcut(id, data.description.clone()))
}

View file

@ -15,8 +15,8 @@ pub mod tiling;
use cosmic::app::ContextDrawer;
use cosmic::iced::Length;
use cosmic::widget::{self, icon, settings, text};
use cosmic::{Apply, Element, Task, theme};
use cosmic::widget::{self, list::ListButton, settings, text};
use cosmic::{Apply, Element, Task};
use cosmic_config::ConfigGet;
use cosmic_settings_config::Binding;
use cosmic_settings_config::shortcuts::action::{
@ -222,11 +222,13 @@ impl Page {
self.search.localized = SecondaryMap::new();
self.search.input = String::new();
self.search_model.on_clear();
self.modified.custom = 0;
self.modified.accessibility = 0;
self.modified.manage_windows = 0;
self.modified.move_windows = 0;
self.modified.nav = 0;
self.modified.system = 0;
self.modified.window_tiling = 0;
self.modified.custom = 0;
}
fn reload_search(&mut self) {
@ -497,32 +499,18 @@ fn shortcuts() -> Section<crate::pages::Message> {
}
/// Display a category as a list item
fn category_item(category: Category, name: &str, modified: u16) -> Element<'_, Message> {
let icon = icon::from_name("go-next-symbolic").size(16);
let control = if modified == 0 {
Element::from(icon)
} else {
widget::row::with_capacity(2)
.push(text::body(fl!("modified", count = modified)))
.push(icon)
.into()
};
settings::item::builder(name)
.control(control)
.spacing(16)
.apply(widget::container)
.class(theme::Container::List)
.apply(widget::button::custom)
.class(theme::Button::Transparent)
.width(Length::Fill)
.on_press(Message::Category(category))
.into()
fn category_item(category: Category, name: &str, modified: u16) -> ListButton<'_, Message> {
crate::widget::go_next_with_item(
name,
(modified > 0).then(|| text::body(fl!("modified", count = modified)).apply(Element::from)),
Message::Category(category),
)
}
fn action_category(action: &Action) -> Option<Category> {
Some(if manage_windows::actions().contains(action) {
Some(if accessibility::actions().contains(action) {
Category::Accessibility
} else if manage_windows::actions().contains(action) {
Category::ManageWindow
} else if move_window::actions().contains(action) {
Category::MoveWindow
@ -530,6 +518,8 @@ fn action_category(action: &Action) -> Option<Category> {
Category::Nav
} else if system::actions().contains(action) {
Category::System
} else if tiling::actions().contains(action) {
Category::WindowTiling
} else {
return None;
})

View file

@ -8,7 +8,7 @@ use cosmic::{
cosmic_config::{self, ConfigGet, ConfigSet},
iced::core::text::Wrapping,
surface,
widget::{self, dropdown, list, settings},
widget::{self, dropdown, settings},
};
use cosmic_settings_page::{self as page, Section, section};
use icu::{

View file

@ -7,7 +7,7 @@ use std::sync::Arc;
use crate::widget::selection_context_item;
use cosmic::app::{ContextDrawer, context_drawer};
use cosmic::iced::{Alignment, Length};
use cosmic::widget::{self, button, list};
use cosmic::widget::{self, button};
use cosmic::{Apply, Element};
use cosmic_config::{ConfigGet, ConfigSet};
use cosmic_settings_page::Section;

View file

@ -206,8 +206,10 @@ pub fn go_next_with_item<'a, Msg: 'static>(
msg_opt: impl Into<Option<Msg>>,
) -> list::ListButton<'a, Msg> {
settings::item_row(vec![
text::body(description).wrapping(Wrapping::Word).into(),
horizontal().into(),
text::body(description)
.width(Length::Fill)
.wrapping(Wrapping::Word)
.into(),
row::with_capacity(2)
.push(item)
.push(icon::from_name("go-next-symbolic").size(16).icon())