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",
|
||||
]
|
||||
|
||||
[[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]]
|
||||
name = "cosmic-dbus-networkmanager"
|
||||
version = "0.1.0"
|
||||
|
|
@ -1784,9 +1792,10 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cosmic-settings-subscriptions"
|
||||
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 = [
|
||||
"bluez-zbus",
|
||||
"cosmic-dbus-a11y",
|
||||
"cosmic-dbus-networkmanager",
|
||||
"futures",
|
||||
"iced_futures",
|
||||
|
|
@ -3268,7 +3277,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_accessibility"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic#7aadfe6ba627236173405144c4deb4bdcff8208c"
|
||||
source = "git+https://github.com/pop-os/libcosmic#264b9d83678e2125b51f9dc5de964d6a804d633e"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"accesskit_winit",
|
||||
|
|
@ -3277,7 +3286,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_core"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic#7aadfe6ba627236173405144c4deb4bdcff8208c"
|
||||
source = "git+https://github.com/pop-os/libcosmic#264b9d83678e2125b51f9dc5de964d6a804d633e"
|
||||
dependencies = [
|
||||
"bitflags 2.9.0",
|
||||
"bytes",
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ pwhash = "1"
|
|||
[dependencies.cosmic-settings-subscriptions]
|
||||
git = "https://github.com/pop-os/cosmic-settings-subscriptions"
|
||||
#TODO: only select features as needed
|
||||
features = ["network_manager", "pipewire", "pulse", "bluetooth"]
|
||||
features = ["accessibility", "network_manager", "pipewire", "pulse", "bluetooth"]
|
||||
optional = true
|
||||
|
||||
[dependencies.icu]
|
||||
|
|
|
|||
|
|
@ -42,6 +42,10 @@ use cosmic::{
|
|||
#[cfg(feature = "wayland")]
|
||||
use cosmic_panel_config::CosmicPanelConfig;
|
||||
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")]
|
||||
use desktop::{
|
||||
dock,
|
||||
|
|
@ -339,6 +343,12 @@ impl cosmic::Application for SettingsApp {
|
|||
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,
|
||||
section::{self, Section},
|
||||
};
|
||||
use cosmic_settings_subscriptions::accessibility::{self, DBusRequest, DBusUpdate};
|
||||
use num_traits::FromPrimitive;
|
||||
use slotmap::SlotMap;
|
||||
|
||||
pub mod magnifier;
|
||||
mod wayland;
|
||||
use tokio::sync::mpsc::UnboundedSender;
|
||||
pub use wayland::{AccessibilityEvent, AccessibilityRequest, ColorFilter};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -35,12 +37,15 @@ pub struct Page {
|
|||
high_contrast: Option<bool>,
|
||||
daemon_config: CosmicSettingsDaemonConfig,
|
||||
daemon_helper: cosmic_config::Config,
|
||||
dbus_sender: Option<UnboundedSender<DBusRequest>>,
|
||||
reader_enabled: bool,
|
||||
}
|
||||
|
||||
impl Default for Page {
|
||||
fn default() -> Self {
|
||||
let daemon_helper = CosmicSettingsDaemonConfig::config().unwrap();
|
||||
Page {
|
||||
dbus_sender: None,
|
||||
entity: page::Entity::default(),
|
||||
magnifier_state: false,
|
||||
screen_inverted: false,
|
||||
|
|
@ -62,6 +67,7 @@ impl Default for Page {
|
|||
daemon_config: CosmicSettingsDaemonConfig::get_entry(&daemon_helper)
|
||||
.unwrap_or_default(),
|
||||
daemon_helper,
|
||||
reader_enabled: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -78,6 +84,8 @@ pub enum Message {
|
|||
SetScreenFilterSelection(ColorFilter),
|
||||
Surface(surface::Action),
|
||||
SetSoundMono(bool),
|
||||
DBusUpdate(DBusUpdate),
|
||||
ScreenReaderEnabled(bool),
|
||||
}
|
||||
|
||||
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> {
|
||||
crate::slab!(descriptions {
|
||||
screen_reader = fl!("accessibility", "screen-reader");
|
||||
magnifier = fl!("magnifier");
|
||||
vision = fl!("accessibility", "vision");
|
||||
on = fl!("accessibility", "on");
|
||||
|
|
@ -171,6 +180,13 @@ pub fn vision() -> section::Section<crate::pages::Message> {
|
|||
|
||||
settings::section()
|
||||
.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({
|
||||
let (magnifier_entity, _magnifier_info) = binder
|
||||
.info
|
||||
|
|
@ -404,6 +420,28 @@ impl Page {
|
|||
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()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@ accessibility = Accessibility
|
|||
.on = On
|
||||
.off = Off
|
||||
.unavailable = Unavailable
|
||||
.screen-reader = Screen reader
|
||||
.high-contrast = High contrast mode
|
||||
.invert-colors = Invert Colors
|
||||
.color-filters = Color filters
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue