feat(accessibility): screen reader toggle
This commit is contained in:
parent
f67162a867
commit
af75e4832a
5 changed files with 62 additions and 4 deletions
15
Cargo.lock
generated
15
Cargo.lock
generated
|
|
@ -1550,6 +1550,14 @@ dependencies = [
|
||||||
"syn 1.0.109",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cosmic-dbus-a11y"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/pop-os/dbus-settings-bindings#0eee63a96c8b1f6555ca797b5c12545c372b1a1b"
|
||||||
|
dependencies = [
|
||||||
|
"zbus 4.4.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-dbus-networkmanager"
|
name = "cosmic-dbus-networkmanager"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
@ -1784,9 +1792,10 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-settings-subscriptions"
|
name = "cosmic-settings-subscriptions"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/cosmic-settings-subscriptions#752429e70dc5a06f28922ce159afe52002683088"
|
source = "git+https://github.com/pop-os/cosmic-settings-subscriptions#650f0bc1dbfdce2e541c104674257d1621b2de4c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bluez-zbus",
|
"bluez-zbus",
|
||||||
|
"cosmic-dbus-a11y",
|
||||||
"cosmic-dbus-networkmanager",
|
"cosmic-dbus-networkmanager",
|
||||||
"futures",
|
"futures",
|
||||||
"iced_futures",
|
"iced_futures",
|
||||||
|
|
@ -3268,7 +3277,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_accessibility"
|
name = "iced_accessibility"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#7aadfe6ba627236173405144c4deb4bdcff8208c"
|
source = "git+https://github.com/pop-os/libcosmic#264b9d83678e2125b51f9dc5de964d6a804d633e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"accesskit",
|
"accesskit",
|
||||||
"accesskit_winit",
|
"accesskit_winit",
|
||||||
|
|
@ -3277,7 +3286,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_core"
|
name = "iced_core"
|
||||||
version = "0.14.0-dev"
|
version = "0.14.0-dev"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#7aadfe6ba627236173405144c4deb4bdcff8208c"
|
source = "git+https://github.com/pop-os/libcosmic#264b9d83678e2125b51f9dc5de964d6a804d633e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.0",
|
"bitflags 2.9.0",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ pwhash = "1"
|
||||||
[dependencies.cosmic-settings-subscriptions]
|
[dependencies.cosmic-settings-subscriptions]
|
||||||
git = "https://github.com/pop-os/cosmic-settings-subscriptions"
|
git = "https://github.com/pop-os/cosmic-settings-subscriptions"
|
||||||
#TODO: only select features as needed
|
#TODO: only select features as needed
|
||||||
features = ["network_manager", "pipewire", "pulse", "bluetooth"]
|
features = ["accessibility", "network_manager", "pipewire", "pulse", "bluetooth"]
|
||||||
optional = true
|
optional = true
|
||||||
|
|
||||||
[dependencies.icu]
|
[dependencies.icu]
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,10 @@ use cosmic::{
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(feature = "wayland")]
|
||||||
use cosmic_panel_config::CosmicPanelConfig;
|
use cosmic_panel_config::CosmicPanelConfig;
|
||||||
use cosmic_settings_page::{self as page, section};
|
use cosmic_settings_page::{self as page, section};
|
||||||
|
#[cfg(feature = "page-accessibility")]
|
||||||
|
use cosmic_settings_subscriptions::accessibility::{
|
||||||
|
DBusRequest, DBusUpdate, subscription as a11y_subscription,
|
||||||
|
};
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(feature = "wayland")]
|
||||||
use desktop::{
|
use desktop::{
|
||||||
dock,
|
dock,
|
||||||
|
|
@ -339,6 +343,12 @@ impl cosmic::Application for SettingsApp {
|
||||||
pages::desktop::wallpaper::Message::UpdateState(update.config),
|
pages::desktop::wallpaper::Message::UpdateState(update.config),
|
||||||
))
|
))
|
||||||
}),
|
}),
|
||||||
|
#[cfg(feature = "page-accessibility")]
|
||||||
|
a11y_subscription().map(|m| {
|
||||||
|
Message::PageMessage(pages::Message::Accessibility(
|
||||||
|
pages::accessibility::Message::DBusUpdate(m),
|
||||||
|
))
|
||||||
|
}),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,13 @@ use cosmic_settings_page::{
|
||||||
self as page, Insert,
|
self as page, Insert,
|
||||||
section::{self, Section},
|
section::{self, Section},
|
||||||
};
|
};
|
||||||
|
use cosmic_settings_subscriptions::accessibility::{self, DBusRequest, DBusUpdate};
|
||||||
use num_traits::FromPrimitive;
|
use num_traits::FromPrimitive;
|
||||||
use slotmap::SlotMap;
|
use slotmap::SlotMap;
|
||||||
|
|
||||||
pub mod magnifier;
|
pub mod magnifier;
|
||||||
mod wayland;
|
mod wayland;
|
||||||
|
use tokio::sync::mpsc::UnboundedSender;
|
||||||
pub use wayland::{AccessibilityEvent, AccessibilityRequest, ColorFilter};
|
pub use wayland::{AccessibilityEvent, AccessibilityRequest, ColorFilter};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
@ -35,12 +37,15 @@ pub struct Page {
|
||||||
high_contrast: Option<bool>,
|
high_contrast: Option<bool>,
|
||||||
daemon_config: CosmicSettingsDaemonConfig,
|
daemon_config: CosmicSettingsDaemonConfig,
|
||||||
daemon_helper: cosmic_config::Config,
|
daemon_helper: cosmic_config::Config,
|
||||||
|
dbus_sender: Option<UnboundedSender<DBusRequest>>,
|
||||||
|
reader_enabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Page {
|
impl Default for Page {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
let daemon_helper = CosmicSettingsDaemonConfig::config().unwrap();
|
let daemon_helper = CosmicSettingsDaemonConfig::config().unwrap();
|
||||||
Page {
|
Page {
|
||||||
|
dbus_sender: None,
|
||||||
entity: page::Entity::default(),
|
entity: page::Entity::default(),
|
||||||
magnifier_state: false,
|
magnifier_state: false,
|
||||||
screen_inverted: false,
|
screen_inverted: false,
|
||||||
|
|
@ -62,6 +67,7 @@ impl Default for Page {
|
||||||
daemon_config: CosmicSettingsDaemonConfig::get_entry(&daemon_helper)
|
daemon_config: CosmicSettingsDaemonConfig::get_entry(&daemon_helper)
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
daemon_helper,
|
daemon_helper,
|
||||||
|
reader_enabled: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -78,6 +84,8 @@ pub enum Message {
|
||||||
SetScreenFilterSelection(ColorFilter),
|
SetScreenFilterSelection(ColorFilter),
|
||||||
Surface(surface::Action),
|
Surface(surface::Action),
|
||||||
SetSoundMono(bool),
|
SetSoundMono(bool),
|
||||||
|
DBusUpdate(DBusUpdate),
|
||||||
|
ScreenReaderEnabled(bool),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl page::Page<crate::pages::Message> for Page {
|
impl page::Page<crate::pages::Message> for Page {
|
||||||
|
|
@ -152,6 +160,7 @@ impl page::AutoBind<crate::pages::Message> for Page {
|
||||||
|
|
||||||
pub fn vision() -> section::Section<crate::pages::Message> {
|
pub fn vision() -> section::Section<crate::pages::Message> {
|
||||||
crate::slab!(descriptions {
|
crate::slab!(descriptions {
|
||||||
|
screen_reader = fl!("accessibility", "screen-reader");
|
||||||
magnifier = fl!("magnifier");
|
magnifier = fl!("magnifier");
|
||||||
vision = fl!("accessibility", "vision");
|
vision = fl!("accessibility", "vision");
|
||||||
on = fl!("accessibility", "on");
|
on = fl!("accessibility", "on");
|
||||||
|
|
@ -171,6 +180,13 @@ pub fn vision() -> section::Section<crate::pages::Message> {
|
||||||
|
|
||||||
settings::section()
|
settings::section()
|
||||||
.title(§ion.title)
|
.title(§ion.title)
|
||||||
|
.add(
|
||||||
|
cosmic::Element::from(
|
||||||
|
settings::item::builder(&descriptions[screen_reader])
|
||||||
|
.toggler(page.reader_enabled, Message::ScreenReaderEnabled),
|
||||||
|
)
|
||||||
|
.map(crate::pages::Message::Accessibility),
|
||||||
|
)
|
||||||
.add({
|
.add({
|
||||||
let (magnifier_entity, _magnifier_info) = binder
|
let (magnifier_entity, _magnifier_info) = binder
|
||||||
.info
|
.info
|
||||||
|
|
@ -404,6 +420,28 @@ impl Page {
|
||||||
tracing::error!("{err:?}");
|
tracing::error!("{err:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Message::DBusUpdate(update) => match update {
|
||||||
|
DBusUpdate::Error(err) => {
|
||||||
|
tracing::error!("{err}");
|
||||||
|
let _ = self.dbus_sender.take();
|
||||||
|
self.reader_enabled = false;
|
||||||
|
}
|
||||||
|
DBusUpdate::Status(enabled) => {
|
||||||
|
self.reader_enabled = enabled;
|
||||||
|
}
|
||||||
|
DBusUpdate::Init(enabled, tx) => {
|
||||||
|
self.reader_enabled = enabled;
|
||||||
|
self.dbus_sender = Some(tx);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Message::ScreenReaderEnabled(enabled) => {
|
||||||
|
if let Some(tx) = &self.dbus_sender {
|
||||||
|
self.reader_enabled = enabled;
|
||||||
|
let _ = tx.send(DBusRequest::Status(enabled));
|
||||||
|
} else {
|
||||||
|
self.reader_enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cosmic::iced::Task::none()
|
cosmic::iced::Task::none()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,7 @@ accessibility = Accessibility
|
||||||
.on = On
|
.on = On
|
||||||
.off = Off
|
.off = Off
|
||||||
.unavailable = Unavailable
|
.unavailable = Unavailable
|
||||||
|
.screen-reader = Screen reader
|
||||||
.high-contrast = High contrast mode
|
.high-contrast = High contrast mode
|
||||||
.invert-colors = Invert Colors
|
.invert-colors = Invert Colors
|
||||||
.color-filters = Color filters
|
.color-filters = Color filters
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue