game_launcher
1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
a11y_utils.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
// ==============================================================================
3
// ui/qt/a11y_utils.h
4
// ==============================================================================
5
// Small accessibility helpers. The launcher uses FontAwesome glyphs as button
6
// text for many icon-only controls; those glyphs live in the Unicode Private
7
// Use Area and screen readers cannot speak them. Setting an explicit
8
// accessibleName is the right fix.
9
//
10
// Qt 6 QAccessibleWidget::text() looks up the accessible string in this
11
// order: accessibleName -> QWidget::text() -> toolTip -> whatsThis -> title.
12
// For normal text buttons, QWidget::text() is already readable, so
13
// setAccessibleName is only strictly needed where the button's text is a
14
// symbol/glyph or empty.
15
//
16
// Usage:
17
// a11y::describe(button, tr("Refresh library"),
18
// tr("Rescan all game libraries for changes"));
19
// Both arguments flow into accessibleName/accessibleDescription AND the
20
// widget's tooltip (so sighted users see the same description on hover).
21
// ==============================================================================
22
23
#pragma once
24
25
#include <QString>
26
#include <QWidget>
27
28
namespace
a11y
29
{
30
31
/// Set accessibleName (short, read first by screen readers), plus a matching
32
/// tooltip so sighted users get the same information. The description is
33
/// optional and provides the longer "accessibleDescription" read after the
34
/// name.
35
inline
void
describe
(QWidget* widget,
const
QString& name,
const
QString& description = QString())
36
{
37
if
(!widget)
38
return
;
39
widget->setAccessibleName(name);
40
if
(!description.isEmpty())
41
{
42
widget->setAccessibleDescription(description);
43
}
44
// If no tooltip set, default to the accessible name so sighted users
45
// aren't blind to the same information. Callers can override afterwards.
46
if
(widget->toolTip().isEmpty())
47
{
48
widget->setToolTip(description.isEmpty() ? name : description);
49
}
50
}
51
52
}
// namespace a11y
a11y
Definition
a11y_utils.h:29
a11y::describe
void describe(QWidget *widget, const QString &name, const QString &description=QString())
Set accessibleName (short, read first by screen readers), plus a matching tooltip so sighted users ge...
Definition
a11y_utils.h:35
ui
qt
a11y_utils.h
Generated by
1.16.1