This commit is contained in:
2026-10-30 14:15:14 +07:00
parent 41837e487b
commit 348504c33a
5 changed files with 87 additions and 31 deletions
+8 -5
View File
@@ -14,7 +14,8 @@ use gpui_kit::component::button::{Button, ButtonVariants as _};
use gpui_kit::component::clipboard::Clipboard;
use gpui_kit::component::menu::{DropdownMenu as _, PopupMenu, PopupMenuItem};
use gpui_kit::component::{
ActiveTheme, InteractiveElementExt as _, Sizable as _, StyledExt as _, h_flex, v_flex,
ActiveTheme, Disableable, InteractiveElementExt as _, Sizable as _, StyledExt as _, h_flex,
v_flex,
};
use smallvec::SmallVec;
@@ -605,7 +606,7 @@ pub struct MessageActions {
reactions: SmallVec<[(&'static str, SharedClickListener); 4]>,
reply: Option<SharedClickListener>,
copy: Option<(ElementId, SharedString)>,
speech: Option<SharedClickListener>,
speech: Option<(bool, SharedClickListener)>,
dropdown: Option<DropdownBuilder>,
}
@@ -645,12 +646,13 @@ impl MessageActions {
self
}
/// Add the read-aloud button.
/// Add the read-aloud button, disabled while a message is already being spoken.
pub fn speech(
mut self,
disabled: bool,
handler: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static,
) -> Self {
self.speech = Some(Rc::new(handler));
self.speech = Some((disabled, Rc::new(handler)));
self
}
@@ -727,13 +729,14 @@ impl RenderOnce for MessageActions {
.when_some(copy, |this, (id, value)| {
this.child(Clipboard::new(id).value(value).tooltip("Copy").small())
})
.when_some(speech, |this, speech| {
.when_some(speech, |this, (disabled, speech)| {
this.child(
Button::new("speech")
.icon(crate::IconName::Speech)
.tooltip("Read aloud")
.small()
.ghost()
.disabled(disabled)
.on_click(move |event, window, cx| speech(event, window, cx)),
)
})