Accessibility: add labels for buttons history (#30213)

* Add labeling for buttons in history top bar widget
* Add labeling for send button
* Add labeling to buttons in history widget
* Add screen reader support for silent toggle button as checkbox.
* Add labeling to buttons in voice record bar
This commit is contained in:
K H Musthafal Mukthar
2026-02-07 00:30:20 +05:30
committed by GitHub
parent e94373f264
commit b0f7846832
6 changed files with 71 additions and 0 deletions
+14
View File
@@ -712,6 +712,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_shortcuts_record_round_message" = "Record Round Message";
"lng_shortcuts_admin_log" = "Group/Channel Recent Actions";
"lng_attach" = "Add attachment";
"lng_attach_replace" = "Replace attachment";
"lng_emoji_sticker_gif" = "Choose emoji, sticker or gif";
"lng_bot_keyboard_show" = "Show bot keyboard";
"lng_bot_keyboard_hide" = "Hide bot keyboard";
"lng_bot_commands_start" = "Bot commands start";
"lng_broadcast_silent" = "Silent broadcast";
"lng_settings_chat_reactions_title" = "Quick Reaction";
"lng_settings_chat_reactions_subtitle" = "Choose your favorite reaction";
"lng_settings_chat_message_reply_from" = "Bob Harris";
@@ -4533,6 +4541,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_record_listen_cancel_sure" = "Do you want to discard your recorded voice message?";
"lng_record_listen_cancel_sure_round" = "Do you want to discard your recorded video message?";
"lng_record_lock_discard" = "Discard";
"lng_record_lock" = "Lock recording";
"lng_record_lock_resume" = "Resume recording";
"lng_record_lock_delete" = "Delete recording";
"lng_record_lock_play" = "Play recording";
"lng_record_lock_pause" = "Pause recording";
"lng_record_cancel_recording" = "Cancel recording";
"lng_record_hold_tip" = "Please hold the mouse button pressed to record a voice message.";
"lng_record_voice_tip" = "Hold to record audio. Click to switch to video.";
"lng_record_video_tip" = "Hold to record video. Click to switch to audio.";
@@ -1060,6 +1060,14 @@ HistoryWidget::HistoryWidget(
setupSendAsToggle();
orderWidgets();
setupShortcuts();
_attachToggle->setAccessibleName(tr::lng_attach(tr::now));
_tabbedSelectorToggle->setAccessibleName(tr::lng_emoji_sticker_gif(tr::now));
_botKeyboardShow->setAccessibleName(tr::lng_bot_keyboard_show(tr::now));
_botKeyboardHide->setAccessibleName(tr::lng_bot_keyboard_hide(tr::now));
_botCommandStart->setAccessibleName(tr::lng_bot_commands_start(tr::now));
_fieldBarCancel->setAccessibleName(tr::lng_cancel(tr::now));
}
void HistoryWidget::setGeometryWithTopMoved(
@@ -2193,6 +2201,7 @@ void HistoryWidget::setupGiftToChannelButton() {
_giftToChannel = Ui::CreateChild<Ui::IconButton>(
_muteUnmute.data(),
st::historyGiftToChannel);
_giftToChannel->setAccessibleName(tr::lng_gift_channel_title(tr::now));
widthValue() | rpl::on_next([=](int width) {
_giftToChannel->moveToRight(0, 0, width);
}, _giftToChannel->lifetime());
@@ -2220,6 +2229,7 @@ void HistoryWidget::setupDirectMessageButton() {
_directMessage = Ui::CreateChild<Ui::IconButton>(
_muteUnmute.data(),
st::historyDirectMessage);
_directMessage->setAccessibleName(tr::lng_profile_direct_messages(tr::now));
widthValue() | rpl::on_next([=](int width) {
_directMessage->moveToLeft(0, 0, width);
}, _directMessage->lifetime());
@@ -3115,6 +3125,9 @@ bool HistoryWidget::updateReplaceMediaButton() {
_replaceMedia.create(
this,
_canReplaceMedia ? st::historyReplaceMedia : st::historyAddMedia);
_replaceMedia->setAccessibleName(_canReplaceMedia
? tr::lng_attach_replace(tr::now)
: tr::lng_attach(tr::now));
const auto hideDuration = st::historyReplaceMedia.ripple.hideDuration;
_replaceMedia->setClickedCallback([=] {
base::call_delayed(hideDuration, this, [=] {
@@ -3226,6 +3239,7 @@ void HistoryWidget::refreshScheduledToggle() {
&& (session().scheduledMessages().count(_history) > 0);
if (!_scheduled && has) {
_scheduled.create(this, st::historyScheduledToggle);
_scheduled->setAccessibleName(tr::lng_scheduled_messages(tr::now));
_scheduled->show();
_scheduled->addClickHandler([=] {
controller()->showSection(
@@ -3256,6 +3270,7 @@ void HistoryWidget::refreshSendGiftToggle() {
&& ((disallowed & all) != all);
if (!_giftToUser && has) {
_giftToUser.create(this, st::historyGiftToUser);
_giftToUser->setAccessibleName(tr::lng_gift_send_title(tr::now));
_giftToUser->show();
_giftToUser->addClickHandler([=] {
Ui::ShowStarGiftBox(controller(), _peer);
@@ -3338,6 +3353,7 @@ void HistoryWidget::refreshSendAsToggle() {
}
const auto &st = st::defaultComposeControls.chooseSendAs;
_sendAs.create(this, st.button);
_sendAs->setAccessibleName(tr::lng_send_as_title(tr::now));
Ui::SetupSendAsButton(_sendAs.data(), st, controller());
}
@@ -7868,6 +7884,8 @@ bool HistoryWidget::showSlowmodeError() {
void HistoryWidget::fieldTabbed() {
if (_supportAutocomplete) {
_supportAutocomplete->activate(_field.data());
}else{
focusNextPrevChild(true);
}
}
@@ -499,6 +499,9 @@ TTLButton::TTLButton(
}
}, lifetime());
setAccessibleName((recordingVideo
? tr::lng_in_dlg_video_message_ttl
: tr::lng_in_dlg_voice_message_ttl)(tr::now));
}
void TTLButton::clearState() {
@@ -607,6 +610,7 @@ ListenWrap::ListenWrap(
, _inactiveWaveformBar(
anim::with_alpha(_activeWaveformBar, kInactiveWaveformBarAlpha))
, _playPause(_playPauseSt, [=] { _playPauseButton->update(); }) {
_delete->setAccessibleName(tr::lng_record_lock_delete(tr::now));
init();
}
@@ -755,6 +759,7 @@ void ListenWrap::initPlayButton() {
const auto &width = _waveformBgFinalCenterRect.height();
_playPauseButton->resize(width, width);
_playPauseButton->show();
_playPauseButton->setAccessibleName(tr::lng_record_lock_play(tr::now));
_playPauseButton->paintRequest(
) | rpl::on_next([=](const QRect &clip) {
@@ -776,6 +781,9 @@ void ListenWrap::initPlayButton() {
const auto showPause = _lifetime.make_state<rpl::variable<bool>>(false);
showPause->changes(
) | rpl::on_next([=](bool pause) {
_playPauseButton->setAccessibleName(pause
? tr::lng_record_lock_pause(tr::now)
: tr::lng_record_lock_play(tr::now));
_playPause.setState(pause
? PlayButtonLayout::State::Pause
: PlayButtonLayout::State::Play);
@@ -1057,6 +1065,7 @@ void RecordLock::init() {
}
drawProgress(p);
}, lifetime());
setAccessibleName(tr::lng_record_lock(tr::now));
}
void RecordLock::drawProgress(QPainter &p) {
@@ -1303,6 +1312,7 @@ CancelButton::CancelButton(
, _width(st::historyRecordCancelButtonWidth)
, _rippleRect(QRect(0, (height - _width) / 2, _width, _width))
, _text(st::semiboldTextStyle, tr::lng_selected_clear(tr::now)) {
setAccessibleName(tr::lng_record_cancel_recording(tr::now));
resize(_width, height);
init();
}
@@ -1620,6 +1630,9 @@ void VoiceRecordBar::init() {
_paused.value() | rpl::distinct_until_changed(
) | rpl::on_next([=](bool paused) {
_lock->setAccessibleName(paused
? tr::lng_record_lock_resume(tr::now)
: tr::lng_record_lock(tr::now));
if (!paused) {
return;
}
@@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_chat.h"
#include "styles/style_chat_helpers.h"
#include "styles/style_layers.h"
#include "lang/lang_keys.h"
#include <QtMath>
@@ -280,6 +281,19 @@ void VoiceRecordButton::requestPaintColor(float64 progress) {
void VoiceRecordButton::setType(Type state) {
_state = state;
setAccessibleName([&] {
switch (state) {
case Type::Send:
return tr::lng_send_button(tr::now);
case Type::Record:
return tr::lng_send_action_record_round(tr::now);
case Type::Round:
return tr::lng_send_action_record_round(tr::now);
}
Unexpected("Voice record button type.");
}());
}
} // namespace HistoryView::Controls
@@ -28,6 +28,7 @@ SilentToggle::SilentToggle(QWidget *parent, not_null<ChannelData*> channel)
resize(_st.width, _st.height);
setMouseTracking(true);
setAccessibleName(tr::lng_broadcast_silent(tr::now));
clicks(
) | rpl::on_next([=] {
@@ -65,6 +66,7 @@ void SilentToggle::setChecked(bool checked) {
if (_checked != checked) {
_checked = checked;
update();
accessibilityStateChanged({ .checked = true });
// _crossLineAnimation.start(
// [=] { update(); },
// _checked ? 0. : 1.,
@@ -106,4 +108,12 @@ QImage SilentToggle::prepareRippleMask() const {
QSize(_st.rippleAreaSize, _st.rippleAreaSize));
}
QAccessible::Role SilentToggle::accessibilityRole() {
return QAccessible::Role::CheckBox;
}
Ui::AccessibilityState SilentToggle::accessibilityState() const {
return { .checkable = true, .checked = _checked };
}
} // namespace Ui
@@ -27,6 +27,8 @@ public:
QString tooltipText() const override;
QPoint tooltipPos() const override;
bool tooltipWindowActive() const override;
[[nodiscard]] QAccessible::Role accessibilityRole() override;
[[nodiscard]] AccessibilityState accessibilityState() const override;
protected:
void paintEvent(QPaintEvent *e) override;