Setting accessibleName and accessibleRole for objects

This commit is contained in:
Reza Bakhshi Laktasaraei
2025-10-22 13:09:24 +03:30
committed by John Preston
parent ce9c3b4ef8
commit b9c07e644f
13 changed files with 62 additions and 0 deletions

View File

@@ -39,6 +39,7 @@ CodeWidget::CodeWidget(
, _callTimeout(getData()->callTimeout)
, _callLabel(this, st::introDescription)
, _checkRequestTimer([=] { checkRequest(); }) {
setAccessibleRole(QAccessible::Role::Dialog);
Lang::Updated(
) | rpl::start_with_next([=] {
refreshLang();

View File

@@ -160,6 +160,8 @@ void CodeDigit::paintEvent(QPaintEvent *e) {
CodeInput::CodeInput(QWidget *parent)
: Ui::RpWidget(parent) {
setFocusPolicy(Qt::StrongFocus);
setAccessibleRole(QAccessible::Role::EditableText);
setAccessibleName(tr::lng_code_ph(tr::now));
}
void CodeInput::setDigitsCountMax(int digitsCount) {

View File

@@ -37,6 +37,7 @@ PasswordCheckWidget::PasswordCheckWidget(
, _codeField(this, st::introPassword, tr::lng_signin_code())
, _toRecover(this, tr::lng_signin_recover(tr::now))
, _toPassword(this, tr::lng_signin_try_password(tr::now)) {
setAccessibleRole(QAccessible::Role::Dialog);
Expects(_passwordState.hasPassword);
Lang::Updated(

View File

@@ -62,6 +62,9 @@ PhoneWidget::PhoneWidget(
st::introPhone,
[](const QString &s) { return Countries::Groups(s); })
, _checkRequestTimer([=] { checkRequest(); }) {
setAccessibleRole(QAccessible::Role::Dialog);
_code->setAccessibleName(tr::lng_country_code(tr::now));
_phone->setAccessibleName(tr::lng_phone_number(tr::now));
_phone->frontBackspaceEvent(
) | rpl::start_with_next([=](not_null<QKeyEvent*> e) {
_code->startErasing(e);

View File

@@ -80,6 +80,8 @@ namespace {
style::PaletteChanged()
);
auto result = Ui::CreateChild<Ui::RpWidget>(parent.get());
result->setAccessibleRole(QAccessible::Role::Graphic);
result->setAccessibleName(tr::lng_intro_qr_title(tr::now));
const auto state = result->lifetime().make_state<State>(
[=] { result->update(); });
state->waiting.start();
@@ -181,6 +183,20 @@ QrWidget::QrWidget(
setTitleText(rpl::single(QString()));
setDescriptionText(rpl::single(QString()));
setErrorCentered(true);
setAccessibleRole(QAccessible::Role::Dialog);
setAccessibleName(tr::lng_intro_qr_title(tr::now));
const auto texts = {
tr::lng_intro_qr_step1,
tr::lng_intro_qr_step2,
tr::lng_intro_qr_step3,
};
QString fullDescription;
int index = 1;
for (const auto& text : texts) {
fullDescription += QString::number(index++) + ". " + text(tr::now) + "\n";
}
setAccessibleDescription(fullDescription);
cancelNearestDcRequest();
@@ -410,6 +426,10 @@ void QrWidget::sendCheckPasswordRequest() {
void QrWidget::activate() {
Step::activate();
showChildren();
if (const auto skipButton = findChild<Ui::LinkButton*>()) {
skipButton->setFocus(Qt::OtherFocusReason);
}
}
void QrWidget::finished() {

View File

@@ -77,6 +77,7 @@ Step::Step(
_hasCover
? st::introCoverDescription
: st::introDescription)) {
setAccessibleRole(QAccessible::Pane);
hide();
style::PaletteChanged(
) | rpl::start_with_next([=] {
@@ -94,6 +95,7 @@ Step::Step(
_titleText.value(
) | rpl::start_with_next([=](const QString &text) {
_title->setText(text);
setAccessibleName(text);
updateLabelsPosition();
}, lifetime());
@@ -105,6 +107,7 @@ Step::Step(
EntityType::Spoiler,
&EntityInText::type);
label->setMarkedText(text);
setAccessibleDescription(text.text);
label->setAttribute(Qt::WA_TransparentForMouseEvents, hasSpoiler);
updateLabelsPosition();
}, lifetime());

View File

@@ -141,6 +141,7 @@ Widget::Widget(
}, lifetime());
_back->entity()->setClickedCallback([=] { backRequested(); });
_back->entity()->setAccessibleName(tr::lng_go_back(tr::now));
_back->hide(anim::type::instant);
if (_changeLanguage) {