RAccessibleNameFilter
Class in GUI Module
Header: #include <src/gui/RAccessibleNameFilter.h>
Inherits: QObject
Description
Section titled “Description”Application wide event filter that gives input widgets without an accessible name the text of the label next to them.
Screen readers read the accessible name of an input widget (line edit, combo box, spin box, …) to tell the user what the widget is for. Qt derives that name from a QLabel that has the widget as its buddy. Most input widgets of QCAD are labeled differently: in tool options, the label is often a check box (“Length:” enables a fixed length), in dialogs and preference pages the labels are plain QLabels without buddy. Those widgets are read as anonymous “edit text” with a value.
This filter watches for input widgets being shown and, once the layout has settled, names every input widget without accessible name after the nearest label (QLabel, QCheckBox or QRadioButton with text) to its left on the same row or, failing that, above it. Accelerator markers and a trailing colon are removed (“&Length:” -> “Length”). Names set this way are marked with the widget property “RAccessibleNameFromLabel” and are recomputed when the widget is shown again, explicitly set names are never touched. For combo boxes, a QLabel found this way is also made their buddy: on macOS the accessible name of a combo box is its current text, the label is only heard as title element.
The filter also watches the opt in properties of RAccessibleFlatTree and drops the cached accessible interface of a tree widget when they are set (see RAccessibleFlatTree::invalidate).
Installed on the application by RMainWindowQt.
Public Functions
Section titled “Public Functions”RAccessibleNameFilter(QObject *parent=NULL) |
Static Public Functions
Section titled “Static Public Functions”| static QWidget * | findLabel(const QWidget *w) |
| static QString | findLabelText(const QWidget *w) |
| static bool | isInputWidget(const QWidget *w) |
| static void | updateAccessibleName(QWidget *w)Names the given input widget after its label, if it has no accessible name of its own. |
Protected Functions
Section titled “Protected Functions”| bool | eventFilter(QObject *obj, QEvent *event) override |
Private Attributes
Section titled “Private Attributes”| QList< QPointer< QWidget > > | pending |
| bool | scheduled |
Private Slots
Section titled “Private Slots”| void | processPending() |
Member Documentation
Section titled “Member Documentation”RAccessibleNameFilter
Section titled “RAccessibleNameFilter”explicit RAccessibleNameFilter::RAccessibleNameFilter(QObject *parent=NULL)explicit
findLabel
Section titled “findLabel”static QWidget * RAccessibleNameFilter::findLabel(const QWidget *w)static
Returns: The label widget (QLabel, QCheckBox or QRadioButton) nearest to the given input widget: to its left on the same row, else above it. NULL if none.
findLabelText
Section titled “findLabelText”static QString RAccessibleNameFilter::findLabelText(const QWidget *w)static
Returns: Name for the given input widget, derived from the nearest label, or an empty string if no label is found.
isInputWidget
Section titled “isInputWidget”static bool RAccessibleNameFilter::isInputWidget(const QWidget *w)static
Returns: True if the given widget is an input widget this filter names (line edits, combo boxes, spin boxes, sliders, text edits, item views).
updateAccessibleName
Section titled “updateAccessibleName”static void RAccessibleNameFilter::updateAccessibleName(QWidget *w)static
Names the given input widget after its label, if it has no accessible name of its own.
eventFilter
Section titled “eventFilter”bool RAccessibleNameFilter::eventFilter(QObject *obj, QEvent *event) overrideprotected
pending
Section titled “pending”QList<QPointer<QWidget> > RAccessibleNameFilter::pendingprivate
scheduled
Section titled “scheduled”bool RAccessibleNameFilter::scheduledprivate
processPending
Section titled “processPending”void RAccessibleNameFilter::processPending()private