Skip to content

Commit

Permalink
feat(accessible_output): add option for Accessible Output in conversa…
Browse files Browse the repository at this point in the history
…tion settings

- Introduced a new configuration option `use_accessible_output` in the `ConversationSettings` class to enable or disable accessible output.
- Implemented conditional checks in `conversation_tab.py` to use accessible output based on the new configuration setting.
- Added a checkbox in the `PreferencesDialog` to allow users to enable or disable accessible output for spoken and braille feedback.
  • Loading branch information
AAClause committed Nov 3, 2024
1 parent 58fe91a commit 4dbaa80
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
1 change: 1 addition & 0 deletions basilisk/config/main_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class ConversationSettings(BaseModel):
role_label_assistant: str | None = Field(default=None)
nav_msg_select: bool = Field(default=False)
shift_enter_mode: bool = Field(default=False)
use_accessible_output: bool = Field(default=True)


class ImagesSettings(BaseModel):
Expand Down
15 changes: 10 additions & 5 deletions basilisk/gui/conversation_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,8 @@ def navigate_message(self, previous: bool):
else:
start, end = self.get_range_for_current_message()
current_message = self.messages.GetRange(start, end)
accessible_output.speak(current_message)
if config.conf().conversation.use_accessible_output:
accessible_output.speak(current_message)

def go_to_previous_message(self, event: wx.CommandEvent = None):
self.navigate_message(True)
Expand All @@ -557,14 +558,16 @@ def move_to_start_of_message(self, event: wx.CommandEvent = None):
self.message_segment_manager.absolute_position = cursor_pos
self.message_segment_manager.focus_content_block()
self.messages.SetInsertionPoint(self.message_segment_manager.start)
accessible_output.output(_("Start of message."))
if config.conf().conversation.use_accessible_output:
accessible_output.output(_("Start of message."))

def move_to_end_of_message(self, event: wx.CommandEvent = None):
cursor_pos = self.messages.GetInsertionPoint()
self.message_segment_manager.absolute_position = cursor_pos
self.message_segment_manager.focus_content_block()
self.messages.SetInsertionPoint(self.message_segment_manager.end - 1)
accessible_output.output(_("End of message."))
if config.conf().conversation.use_accessible_output:
accessible_output.output(_("End of message."))

def get_range_for_current_message(self) -> tuple[int, int]:
cursor_pos = self.messages.GetInsertionPoint()
Expand Down Expand Up @@ -594,7 +597,8 @@ def on_copy_message(self, event: wx.CommandEvent = None):
self.select_current_message()
self.messages.Copy()
self.messages.SetInsertionPoint(cursor_pos)
accessible_output.output(_("Message copied to clipboard."))
if config.conf().conversation.use_accessible_output:
accessible_output.output(_("Message copied to clipboard."))

def on_remove_message_block(self, event: wx.CommandEvent = None):
cursor_pos = self.messages.GetInsertionPoint()
Expand All @@ -606,7 +610,8 @@ def on_remove_message_block(self, event: wx.CommandEvent = None):
self.conversation.messages.remove(message_block)
self.refresh_messages()
self.messages.SetInsertionPoint(cursor_pos)
accessible_output.output(_("Message block removed."))
if config.conf().conversation.use_accessible_output:
accessible_output.output(_("Message block removed."))
else:
wx.Bell()

Expand Down
15 changes: 15 additions & 0 deletions basilisk/gui/preferences_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,18 @@ def init_ui(self):
self.shift_enter_mode.SetValue(self.conf.conversation.shift_enter_mode)
conversation_group_sizer.Add(self.shift_enter_mode, 0, wx.ALL, 5)

self.use_accessible_output = wx.CheckBox(
conversation_group,
# Translators: A label for a checkbox in the preferences dialog
label=_(
"Enable Accessible Output to provide spoken and braille feedback for actions and messages"
),
)
self.use_accessible_output.SetValue(
self.conf.conversation.use_accessible_output
)
conversation_group_sizer.Add(self.use_accessible_output, 0, wx.ALL, 5)

sizer.Add(conversation_group_sizer, 0, wx.ALL, 5)

images_group = wx.StaticBox(panel, label=_("Images"))
Expand Down Expand Up @@ -344,6 +356,9 @@ def on_ok(self, event):
self.conf.conversation.shift_enter_mode = (
self.shift_enter_mode.GetValue()
)
self.conf.conversation.use_accessible_output = (
self.use_accessible_output.GetValue()
)

self.conf.images.resize = self.image_resize.GetValue()
self.conf.images.max_height = int(self.image_max_height.GetValue())
Expand Down

0 comments on commit 4dbaa80

Please sign in to comment.