summaryrefslogtreecommitdiffstats
path: root/src/widgets/accessible
Commit message (Collapse)AuthorAgeFilesLines
* QToolButton a11y: Take menu from default action into accountMichael Weghorn6 days2-7/+22
| | | | | | | | | | | | | | | | | | | | | If a menu is set, QAccessibleToolButton takes it into account for its role, for the QAccessible::State::hasPopup state and for reporting it as an accessible child. So far, this was only working when the menu was directly set using QToolButton::setMenu, but not when the menu came from the default action set via QToolButton::setDefaultAction. From a user perspective, that doesn't make a difference, so also treat these equally on the a11y layer, by taking into account the default action's menu as well. Fixes: QTBUG-138172 Pick-to: 6.10 6.9 Change-Id: Ida6915e983f026db7d9840542e4b5f5c14ae13e1 Reviewed-by: Volker Hilsheimer <[email protected]>
* QToolButton a11y: Use existing method to get QToolButtonMichael Weghorn6 days1-2/+1
| | | | | | | | | Use existing QAccessibleToolButton::toolButton instead of QAccessibleButton::button and casting manually. Pick-to: 6.10 6.9 Change-Id: Ib63553075f5a0a64d436276703e8717a20cc310f Reviewed-by: Volker Hilsheimer <[email protected]>
* a11y: Move qt_accStripAmp helper to private QtGui headerMichael Weghorn2025-06-205-46/+10
| | | | | | | | | | | | | | | | | The qt_accStripAmp helper function takes a string that may contain an accelerator/mnemonic and escaped ampersand characters and returns a "plain text" version of this that is suitable for an accessible name of the widget/control containing that text. Move the helper function to a new private header (and source file) in QtGui in order to be able to reuse this in Qt Quick in an upcoming qtdeclarative commit. Task-number: QTBUG-134208 Pick-to: 6.10 6.9 6.8 6.5 Change-Id: I4dfac2d179baf36101066962b6a5f542b3a6fc03 Reviewed-by: Volker Hilsheimer <[email protected]>
* QLineEdit a11y: Report displayText on a11y layerMichael Weghorn2025-06-161-21/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of reporting no/empty text on the a11y layer when using a QLineEdit::EchoMode that doesn't display the actual text as is (e.g. in case of a password field), use QLineEdit::displayText, which already prevents exposing the actual text unless it's also displayed on screen. Previously, the character count and caret/cursor position was still reported for the actual text, but an empty string was reported for the text itself, which was inconsistent. (A cursor position of 3 within an allegedly empty text doesn't make sense, and empty text cannot have a character count of 5.) With this commit in place, entering "hello" in the QLineEdit from the sample app from QTBUG-109599 now results in replacement/mask characters as shown on screen being reported for the text on the a11y layer as well as long as QLineEdit::Password is used. Demo using Accerciser's IPython console on Linux, with the QLineEdit's accessible object selected in Accerciser's treeview of the sample app's a11y hierarchy. Without this commit in place: In [11]: text = acc.queryText() In [12]: text.characterCount Out[12]: 5 In [13]: text.getText(0, -1) Out[13]: '' With this commit in place: In [16]: text = acc.queryText() In [17]: text.characterCount Out[17]: 5 In [18]: text.getText(0, -1) Out[18]: '●●●●●' The Orca screen reader now announces "circle" as expected when moving the cursor between the individual characters. This also fixes the assert/crash seen with Narrator as mentioned in QTBUG-109599, due to the above-mentioned mismatch between reported character count and actual text length. (QWindowsUiaTextRangeProvider::ExpandToEnclosingUnit relies on the reported character count, then accesses the character by index, but the actual string was empty.) The QAccessibleLineEdit::text(QAccessible::Value) case previously had manual handling to report mask characters. Use the displayText there, too. Adjust tst_QAccessibility::lineEditTest accordingly and extend it to test the QAccessibleTextInterface in addition. Since mask characters for passwords in QLineEdit::displayText are platform-dependent, don't compare the text reported via a11y interfaces to a hard-coded string, but instead check it matches the displayText, but differs from the (plain) text. Fixes: QTBUG-109599 Pick-to: 6.10 6.9 Change-Id: Ifebb4502b71e11d431b708eea613cb2a10e3f237 Reviewed-by: Volker Hilsheimer <[email protected]>
* QAccessibleWidget: replace QString default arg with overloadMarc Mutz2025-06-132-5/+15
| | | | | | | | | | | | | | | | | | | | | | We should not use defaulted arguments of non-trivial type, because their construction and destruction, even if not passed, is repeated at every call site, producing O(n) executable code. By overloading out-of-line, we execute the same code at runtime, but we have only one copy of the arg construction and destruction, in the library, O(1) executable code production. Found in API-review of QAccessibleWidgetV2. Amends the start of the public history. Can't pick further than (unreleased) 6.10, because this adds a new symbol. Pick-to: 6.10 Task-number: QTBUG-98117 Change-Id: I705bca764992d9e7a2aa1021e0f94006b6817177 Reviewed-by: Volker Hilsheimer <[email protected]>
* QAccessibleWidgetV2: make the dtor protectedMarc Mutz2025-06-131-0/+3
| | | | | | | | | | | | | | | QAccessibleWidget (i.e. V1) has a protected dtor, so V2, which merely extends V1 because we can't add new virtuals (via a new base class) due to BC constraints, shouldn't differ in this respect. Amends bb2121551c3d7b1af1553710bc211ba0e39b4212. Found in API-review. Pick-to: 6.10 Change-Id: I0c9a00691a14c600b020ff1a9f433634bb7c8d24 Reviewed-by: Michael Weghorn <[email protected]> Reviewed-by: Volker Hilsheimer <[email protected]>
* QAccessibleWidgetV2: de-inline ctors and avoid QString default argMarc Mutz2025-06-132-4/+13
| | | | | | | | | | | | | | | | | | | | | | We should not use defaulted arguments of non-trivial type, because their construction and destruction, even if not passed, is repeated at every call site, producing O(n) executable code. By overloading out-of-line, we execute the same code at runtime, but a) we have only one copy of the arg construction and destruction, in the library, O(1) executable code production, and b) being out-of-line in the library, the compiler can optimize the call to the base class ctor away, if it wants to, because it sees its implementation. Found in API-review. Amends bb2121551c3d7b1af1553710bc211ba0e39b4212. Pick-to: 6.10 Task-number: QTBUG-98117 Change-Id: Ib6a3b15cc861893797c0445a91691132b21bbf2c Reviewed-by: Ivan Solovev <[email protected]> Reviewed-by: Volker Hilsheimer <[email protected]>
* a11y: Report QWidget localeMichael Weghorn2025-05-2913-96/+148
| | | | | | | | | | | | | | | | | | | Implement support for QAccessible::Attribute::Locale (newly introduced in a previous commit) for QWidget by introducing QAccessibleWidgetV2 which subclasses QAccessibleWidget and implements the QAccessibleAttributesInterface to report the QWidget::locale property for QAccessible::Attribute::Locale. (Leave QAccessibleWidget unchanged for ABI compatibility.) Switch QAccessibleWidget subclasses to subclass the newly introduced QAccessibleWidgetV2. Add a corresponding unit test. Task-number: QTBUG-137144 Change-Id: I61385b17ee1272801ad769da5a807ca4e068cfb2 Reviewed-by: Volker Hilsheimer <[email protected]>
* QComboBox: close the container explicitly before destroying itVolker Hilsheimer2025-03-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QComboBox destroys the container of the view in its own destructor, before the QWidget destructor is entered. The container is a toplevel widget, so destroying that will destroy a platform window, triggering an accessibility update cycle that calls back into Qt. As the QComboBox has not yet reached the QWidget destructor, it still considers itself as visible and focused. The accessibility query will therefore operate on it, as the focused object. Probing the state accesses the view. The view however is already partially destroyed, as the container's destruction has already passed the QWidget destructor deleting all its children. As a result, we are returning a pointer to a QAbstractItemView that's already in the QWidget destructor, resulting in a crash. Options for fixing this would be resetting the view pointer in ~QComboBoxPrivateContainer to nullptr and to test for that in client code. Doing that triggered crashes in tests, as QComboBox::view() so far has never returned a nullptr no matter the state of the combobox. So instead, close the container explicitly before destroying it. This way, any update cycle resulting in reentrancy (such as accessibility of backingstore flushing when the container closes) will be completed before objects are destroyed. This amends fde358dd9069d0695f113ec6ba98efebedd1e520, which added the explicit destruction of the container, for similar reasons. This seems to be a combobox-specific problem due to the combination of explicit destruction of (toplevel) child widgets, resulting event processing, and exposing of internal widget states through public API as part of the widget's accessible state. Pick-to: 6.9 6.8 6.5 Fixes: QTBUG-132310 Change-Id: I74df5b71906ce8153b12ddc35b897a44e7752907 Reviewed-by: Axel Spoerl <[email protected]>
* Style: pass widget to styleHint() where appropriateChristian Ehrlicher2025-03-021-1/+1
| | | | | | | | | | QStyle::styleHint() take the QWidget as optional third parameter. Add this to calls to styleHint() where appropriate. Task-number: QTBUG-2501 Pick-to: 6.9 6.8 Change-Id: I62aa251f7dd9d78178ea8aefc1e2882d3ac040be Reviewed-by: Volker Hilsheimer <[email protected]>
* a11y: Port qt_accHotKey() to QKeySequence::mnemonic()Vlad Zahorodnii2025-01-101-3/+1
| | | | | | | | | | | | QKeySequence::mnemonic() contains additional input sanitization logic and in combination with the toString() function, it provides a platform agnostic way to get the shortcut text for the mnemonic. tst_QAccessibility was adjusted because mnemonics don't work by default on macOS. See qt_set_sequence_auto_mnemonic(). Change-Id: I96842a6c18140a559aeaeb8f687e32011e5e2e77 Reviewed-by: Volker Hilsheimer <[email protected]>
* Replace all QPair/qMakePair with std::pair in qtbase/widgetsIsak Fyksen2025-01-095-17/+17
| | | | | | | | | | As a drive-by replace QList::append and operator<< with emplace_back, to avoid repeating value_type. Task-number: QTBUG-115841 Pick-to: 6.9 6.8 Change-Id: I6fb790f959b41b0feb49e3a0f0b6b3631e24a232 Reviewed-by: Marc Mutz <[email protected]>
* a11y: add more nullptr checks for the viewVolker Hilsheimer2024-11-011-7/+26
| | | | | | | | | | | | | | | | | Interface implementations related to child navigation might be called while the object is getting destroyed, in which case the view might already be degenerated to a widget. In that case, qobject_cast will fail and we would dereference a nullptr later. Prevent that by adding more nullptr checks. As a drive-by, reuse the down-cast pointer in more of the implementation. Pick-to: 6.8 6.5 Fixes: QTBUG-129582 Change-Id: I06a80576a5d71150787f493e2b6c9a58696eac99 Reviewed-by: Michael Weghorn <[email protected]> Reviewed-by: Dheerendra Purohit <[email protected]> Reviewed-by: Volker Hilsheimer <[email protected]>
* a11y: Report QMessageBox accessible IDMichael Weghorn2024-10-101-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit b8b7c58402740204da72e1b1f4ea7321b7bfa540 introduced QWidget::setAccessibleIdentifier for setting the accessible ID of a widget. When calling that on a QMessageBox, the ID set this way would however not get reported on the platform level, e.g. AT-SPI2 on Linux. This is because QAccessibleMessageBox overrides the default implementation of QAccessibleWidget::text and so far didn't explicitly handle QAccessible::Identifier, but returned an empty string for the default case instead. Call the base class implementation for the default case to make this work and also handle other currently unhandled cases (Accelerator, DebugDescription), and potential QAccessible::Text enum values that might get added in the future. While at it, unify to call the base class implementation for QAccessible::Description as well instead of manually calling QWidget::accessibleDescription. That is what the base class implementation does as well, and it includes an additional fallback to use the tooltip if no accessible description is explicitly set. Change-Id: I0f3c53624b1c71ca666f836ba353f1bb1da9a8bc Reviewed-by: Jan Arve Sæther <[email protected]>
* a11y: Remember QTreeView's a11y child interfacesMichael Weghorn2024-09-171-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | In the same way that QAccessibleTable::child already does, also make use of the childToId hash in QAccessibleTree::child to remember and reuse previously created child interfaces instead of creating new ones for the same index every time the method gets called. When items in the tree view change, QTreeViewPrivate::updateAccessibility already sends a QAccessibleTableModelChangeEvent event of type QAccessibleTableModelChangeEvent::ModelReset, which ensures that the then outdated cache is cleared in the base class's QAccessibleTable::modelChange method. This addresses an old FIXME comment added in 2013 commit b2ec0da95641d9cec006fa9699e6d082ad35db0b and fixes the issue reported in QTBUG-128558. Fixes: QTBUG-128558 Pick-to: 6.8 6.7 Change-Id: Ia2a518ac26f3c9b9ba8ab1870bb656c8e9014a77 Reviewed-by: Volker Hilsheimer <[email protected]>
* a11y: Report the actual (platform) window name as a11y name (xcb)Michael Weghorn2024-08-221-7/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At least on Linux and Windows, Qt does not just set the window name explicitly set using e.g. QWidget::setWindowName for the actual platform window shown on screen, but appends the application name (see QPlatformWindow::setWindowTitle). So far, that logic was not applied on the a11y layer when determining an accessible name for a window, meaning that the information presented on screen and on the accessibility layer was not consistent. Align the accessible name with the actually displayed window title by adding a QPlatformWindow::windowTitle method to retrieve the window title that is actually used for the platform window and use that one when asked for the accessible name of the window and none has explicitly been set. Besides the default implementation, that simply returns the window title set for the platform window's associated QWindow, this commit implements the new method for QXcbWindow. Implementations for further platforms will be done in separate commits. (For qtwayland, QWaylandWindow already has a suitable QWaylandWindow::windowTitle method that only needs to be marked to override the base class implementation.) Adjust tst_QAccessibility::messageBoxTest to show the message box before checking the window title (and other accessible attributes), as the associated QWindow and QPlatformWindow only get created when a QWidget gets first shown (see QWidget::create/QWidgetPrivate::create). It seems appropriate to only assume that the accessible name matches the window title once a window actually exists. (Before the message box gets shown, box->windowHandle() would still return nullptr.) As long as the asociated QWindow hasn't been created yet, the message box isn't yet considered a part of the application's accessibility tree anyway (see QAccessibleApplication::child which only considers top level windows), meaning that in practice, assistive technology won't become aware of the message box until the QWindow gets created. Also set the QMessageBox::Option::DontUseNativeDialog option introduced in commit 29b2506e8cf0c792821a3ddb28e62080cd66ae28 in tst_QAccessibility::messageBoxTest instead of skipping event tests on platforms that would otherwise use native dialogs that don't emit the corresponding events. Task-number: QTBUG-127563 Change-Id: I1dfba82a044dda7cf99510c059fe7392237f4c61 Reviewed-by: Axel Spoerl <[email protected]> Reviewed-by: Volker Hilsheimer <[email protected]>
* a11y: Add property for QWidget's accessible IDMichael Weghorn2024-07-191-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 9ec1de2528b871099d416d15592fcc5ef9242a64 added an Identifier role to QAccessible that can be used to provide an identfier for reliable identification by assistive technologies, e.g. in automated tests. As discussed in that commit's Gerrit change, add a corresponding accessibleIdentifier property to QWidget to allow easily setting a specific identifier for widgets, in the same way that an accessible name or description can be set. This provides more flexibility than the default logic that generates an identifier to be used in platform bridges that is based on the object or class names of the objects in the widget's subtree. (The only alternative so far to set a particular ID not including the "object path" would have been to provide a custom QAccessibleInterface implementation with a corresponding QAccessibleInterface::text implementation.) Add an autotest testing both, the default platform bridge logic and that the the newly added property overrides that. [ChangeLog][QtWidgets][QWidget] Add an accessibleId property that allows to easily set a particular accessible identifier for QWidgets that can be used by assistive technologies to identify the widget. Change-Id: If24e138c7d8fe4c78f25d3f0629a9520c352bacc Reviewed-by: Volker Hilsheimer <[email protected]>
* Fix accessibility of list views with underlying multi-column modelIngo Klöcker2024-06-263-9/+131
| | | | | | | | | | | | | | | | | | | | | | | A list view should always expose a table with a single column to accessibility tools even if the underlying model has multiple columns. Several functions need to be changed so that they only consider the model column that was set on the list view. For a list view logicalIndex() must only consider indexes for the model column. For valid indexes the logical index is simply the row because list views have neither row headers nor column headers. The column count for list views is always 1 (unless the model has no columns). The child count needs to use the column count of the accessible table instead of the column count of the underlying model. child(), cellAt(), selectedCellCount(), and selectedCells() get separate implementation for list views. Fixes: QTBUG-33786 Pick-to: 6.8 6.7 6.6 Change-Id: I18c604efa2014267bb6e3b68e403e436bdcbc4ce Reviewed-by: Jan Arve Sæther <[email protected]>
* Use QModelIndex::data()Albert Astals Cid2024-06-211-1/+1
| | | | | | | | | | idx.data(role) is much nicer to read than idx.model()->data(idx, role) As a drive-by, mark some QVariants const. Pick-to: 6.8 Change-Id: I00c0a5ac311a03095050b2542a5c396a6c1c2c6a Reviewed-by: Marc Mutz <[email protected]>
* Remove undefined method logicalIndexIngo Klöcker2024-04-231-2/+0
| | | | | | | The method isn't used and not even defined. Change-Id: If442806e8d4b7e5ac8f83bc783163c02bbabf47f Reviewed-by: Volker Hilsheimer <[email protected]>
* Remove obsolete commentIngo Klöcker2024-04-231-1/+0
| | | | | | | | The code this comment applied to was removed with b2ec0da95641d9cec006fa9699e6d082ad35db0b Change-Id: I15191c0e9f134375069647d1276a0d60d6360813 Reviewed-by: Volker Hilsheimer <[email protected]>
* Replace expensive inherits with cheaper qobject_cast (1)Volker Hilsheimer2024-04-181-2/+2
| | | | | | | | | | | The accessibility implementations require the type to be fully defined anyway in order to call type-specific APIs, so there's no need to use inherits(). Use qobject_cast instead. Pick-to: 6.7 Change-Id: I5c013be57f48272a748451f4888911fe6aa6574e Reviewed-by: Pavel Dubsky <[email protected]> Reviewed-by: Santhosh Kumar <[email protected]>
* Fix -Wimplicit-fallthrough for clangTim Blechmann2024-03-011-0/+2
| | | | | | | | | | | | | | | | | | | Clang's `-Wimplicit-fallthrough` warnings are a little stricter than gcc's interpretation: switch (i) { case 0: foo(); case 4: break; } While gcc accepts the implicit fallthrough, if the following statement is a trivial `break`, clang will warn about it. Pick-to: 6.7 Change-Id: I38e0817f1bc034fbb552aeac21de1516edcbcbb0 Reviewed-by: Volker Hilsheimer <[email protected]>
* a11y: Implement QAccessibleSelectionInterface for QAccessibleTabBarMichael Weghorn2023-11-162-1/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | So far, there was custom handling for exposing the selection of tab bars on Windows via UIA, s. QWindowsUiaSelectionProvider. Implement QAccessibleSelectionInterface for QAccessibleTabBar, so selection is exposed via the platform a11y bridge on all platforms. (This makes the custom handling for tab bars in QWindowsUiaSelectionProvider obsolete for qtbase's own classes, but there are 4 more uses of the QAccessible::PageTabList role in qtdeclarative that might need a closer look before dropping the custom handling from QWindowsUiaSelectionProvider.) For consistency, also set the selectable/selected state for the tab buttons (that are the selectable children of the tab bar). Sample use via AT-SPI on Linux using Accerciser to interact on the a11y level (check the current selection, then select the second tab): 1) run the qtabbar example (tests/manual/qtabbar) 2) start Accerciser 3) select the tab bar in Accerciser's tree view of the a11y hierarchy 4) query for currently selected item, switch selection from "Tab 0" to "Tab 1" by using the following commands in Accerciser's IPython console: In [10]: sel = acc.querySelection() In [11]: sel.nSelectedChildren Out[11]: 1 In [12]: sel.getSelectedChild(0) Out[12]: <Atspi.Accessible object at 0x7fe01ce8a240 (AtspiAccessible at 0x43928c0)> In [13]: sel.getSelectedChild(0).name Out[13]: 'Tab 0' In [14]: sel.selectChild(1) Out[14]: True In [15]: sel.getSelectedChild(0).name Out[15]: 'Tab 1' Equivalent on Windows using NVDA's Python console: 1) start NVDA 2) run the qtabbar example (tests/manual/qtabbar) 3) click on the first tab ("Tab 0") in the tab bar 4) press Numpad_insert+control+z to start the NVDA Python console and capture snapshot variables 5) query and use the interfaces using NVDA's Python console: >>> import UIAHandler >>> tabbar = focus.parent >>> selectionpattern2 = tabbar.UIAElement.GetCurrentPattern(10034).QueryInterface(UIAHandler.IUIAutomationSelectionPattern2) >>> selectionpattern2.CurrentFirstSelectedItem.CurrentName 'Tab 0' >>> selectionpattern2.CurrentLastSelectedItem.CurrentName 'Tab 0' >>> selectionpattern2.CurrentItemCount 1 >>> selectionitempattern = tabbar.children[1].UIAElement.GetCurrentPattern(10010).QueryInterface(UIAHandler.IUIAutomationSelectionItemPattern) >>> selectionitempattern.Select() 0 >>> selectionpattern2.CurrentFirstSelectedItem.CurrentName 'Tab 1' Fixes: QTBUG-104602 Change-Id: I49b05bb84852c86a2b8669d7843fe173caf28e18 Reviewed-by: Jan Arve Sæther <[email protected]>
* a11y: Report strikethrough via text attributeMichael Weghorn2023-11-151-0/+2
| | | | | | | | | | | | | | | | | | | | | | Let `QAccessibleTextWidget::attributes` report whether strikeout is applied to text via the "text-line-through-type" IAccessible2 text attribute [1]. Use a value of "single" when strikeout is applied, and "none" otherwise. A previous change already implemented bridging that to the corresponding AT-SPI "strikethrough" attribute. Update the existing test tst_QAccessibility::textAttributes_data to take into account that this attribute is reported as well now. [1] https://wiki.linuxfoundation.org/accessibility/iaccessible2/textattributes Fixes: QTBUG-118106 Change-Id: I0416f00b1c11709d9cd0ca0ee38cc6df6caa6dcf Reviewed-by: Jan Arve Sæther <[email protected]>
* QAccessibleComboBox: Cleanup comboBox() callsLiang Qi2023-09-271-52/+66
| | | | | | | | | | Handle comboBox() returning nullptr. Avoid repeated qobject_cast by calling comboBox() once per function. Fixes: QTBUG-115161 Pick-to: 6.6 6.5 6.2 Change-Id: I3d102cebe807da379fa4d9ee2aee1e72b8fdf004 Reviewed-by: Volker Hilsheimer <[email protected]>
* Remove redundant QPair includesAhmad Samir2023-09-061-1/+0
| | | | | | | | Nothing in those files uses QPair; and a local build finished fine without them. Task-number: QTBUG-115841 Change-Id: I669cfecaa9129bce6b31e464826287f138b159db Reviewed-by: Thiago Macieira <[email protected]>
* QAccessible: consistently respect rootIndex of item viewsVolker Hilsheimer2023-09-011-83/+141
| | | | | | | | | | | | | | | | | | | | | | | | | | | Accessibility implementations rely on correct information about the model dimensions when operating on item views. An item view that has a root index set needs to report it's size based on the root index, rather than for the view's model directly. Pass the rootIndex to all calls to QAbstractItemModel::column/rowCount. Refactor the code to avoid excessive dereferencing of a QPointer, apply const and fix/improve coding style in touched lines. Emit a ModelReset notification when the root index changes, or (in the case of QListView) when the model column changes. Split long Q_ASSERTs into multiple lines to be able to better trace the exact reason for an assertion, and replace the assert with an early return of nil when it's plausible that a cached cell is no longer part of the view (i.e. because the root index changed). Add a test case that verifies that changing the root index changes the dimension of the view as reported through the accessibility interface. Pick-to: 6.6 6.5 Fixes: QTBUG-114423 Change-Id: I7897b79b2e1d10c789cc866b7f5c5dabdabe6770 Reviewed-by: Jan Arve Sæther <[email protected]>
* QAccessibleWidget: Remove pointless ZWSP in warning messageFabian Kosmale2023-08-301-1/+1
| | | | | | | | | | | There doesn't seem to be reason for it to exist, and apparently it causes compilation failures with icc. Pick-to: 6.6 6.5 5.15 Fixes: QTBUG-116517 Initial-patch-by: Yorick Bosman Change-Id: Ic2ed1d4318d522851278afa7f9791441af4fa709 Reviewed-by: Volker Hilsheimer <[email protected]>
* a11y: Report app as parent for top-level item viewsMichael Weghorn2023-07-101-1/+1
| | | | | | | | | | | | | | | | | | | As happens for other widgets (s. QAccessibleWidget::parentObject), report the app as accessible parent for item views that don't have another parent set. Otherwise, the accessible tree is broken when there's a top-level item view: The application has the item view as a child, but the child does not have any parent set. Extend a QListView autotest accordingly. Fixes: QTBUG-115135 Pick-to: 6.6 6.5 Change-Id: Ie06874681180a30fc6248dc98f80c4158d837278 Reviewed-by: Volker Hilsheimer <[email protected]>
* a11y: Don't add scrollbar container as a11y child if scroll bar is re-parentedTor Arne Vestbø2023-05-101-2/+8
| | | | | | | | | | | | | | | If someone has, for unknown reasons, re-parented the scroll bar of a scroll area to outside the scroll area, we should not blindly add the parent widget of the scroll bar as an a11y child of the scroll area. We don't need to explicitly add the scroll bar itself as a child either, as that will be handled by whoever is the new parent widget, as a normal scroll bar would. Fixes: QTBUG-93768 Pick-to: 6.5 6.2 Change-Id: Ib26f31674602e2221311e864ad31bbf141cad8f6 Reviewed-by: Richard Moe Gustavsen <[email protected]>
* a11y: even checkable buttons are pressableHarald Sitter2023-03-011-4/+2
| | | | | | | | | | | | | | otherwise there is no way to synthesize a "click" through the a11y API. toggleAction only leads to a toggled() signal but the user may be more discerning and only listen to clicked() (or QAction::triggered) to react to **user** events not all toggle events. as such pressAction is always superior to toggleAction when user input is meant to be synthesized through a11y tooling. Change-Id: I7f024d57087b545d3cfd1805026ea538b0b3e166 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Mårten Nordheim <[email protected]> Reviewed-by: Jan Arve Sæther <[email protected]>
* Fix qtbase build when all deprecated code are disabledYuhang Zhao2023-02-221-4/+4
| | | | | | | | | Adjust the callers to use the non-deprecated APIs. Pick-to: 6.5 Change-Id: I8e96f25684a2d613bc400a8626dc9e3af2bb8dcf Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Volker Hilsheimer <[email protected]>
* Fix build with -no-feature-dialogbuttonboxTasuku Suzuki2023-01-171-1/+0
| | | | | | Pick-to: 6.5 Change-Id: Ia6ac9e6acffda80794a5949793fddc3ab849a98a Reviewed-by: Volker Hilsheimer <[email protected]>
* Fix build with -no-feature-messageboxTasuku Suzuki2023-01-173-0/+8
| | | | | | Pick-to: 6.5 Change-Id: I4c34f6aa2106afc528f182d7925442acf82b7000 Reviewed-by: Volker Hilsheimer <[email protected]>
* QtWidgets: Disambiguate static functions/variables and definesFriedemann Kleint2023-01-143-28/+15
| | | | | | | | | | | | | They cause clashes in CMake Unity (Jumbo) builds. Properly prefixing the childWidgets() function also prevents it from cluttering static builds. Task-number: QTBUG-109394 Pick-to: 6.5 Change-Id: Idd2b1ec748f33cfae8f3213847c43b3fb0550377 Reviewed-by: Axel Spoerl <[email protected]> Reviewed-by: Jan Arve Sæther <[email protected]> Reviewed-by: Qt CI Bot <[email protected]>
* Treat the accessible non-editable combobox as ButtonMenu on macOSMikolaj Boc2022-12-161-0/+1
| | | | | | | | | | | | | | Following the system design, we should treat the non-editable combobox as a ButtonMenu. All of the similar elements in macOS's UI are called ButtonMenu with the screen reader. This fixes the case when ctrl+option+space does not invoke the popup menu with options. Fixes: QTBUG-106162 Change-Id: I0b439c56d72d1fe5b32a60eb7c001f863c00adc1 Reviewed-by: Jan Arve Sæther <[email protected]> Reviewed-by: Tor Arne Vestbø <[email protected]>
* a11y: Implement QAccessibleSelectionInterface for item viewsMichael Weghorn2022-11-142-1/+91
| | | | | | | | | | | | | | | | | | | In QAccessibleTable's model, cells (rather than rows or columns) are direct children of the table and therefore items handled in the selection, so forward/make use of the corresponding methods that handle cells. (In QAccessibleTable::select and QAccessibleTable::unselect, cast the child cell to QAccessibleTableCell*, as is already done in QAccessibleTable::indexOfChild and QAccessibleTree::indexOfChild.) This can be tested e.g. by calling the methods from the AT-SPI Selection interface using Accerciser and the "interview" example (qtbase/examples/widgets/itemviews/interview/interview). Change-Id: Ic650a8a01b56653cae4f2cb26e28aed4dc566a7e Reviewed-by: Jan Arve Sæther <[email protected]>
* Windows: Inform accessibility system about the focused child itemVolker Hilsheimer2022-11-112-0/+11
| | | | | | | | | | | | | | | | | | | | | | | When a complex object (i.e. one with children that are themselves not fully exposed objects) gets focus, then we need to inform the accessibility system about which child object actually has focus. This was only done for item views, but not for other complex widgets. An editable QComboBoxes is the focus proxy for its line edit. The line edit never gets focus itself (QComboBox forwards relevant events), and is the accessible child item with index 1. So when an editable combobox gets focus, it needs to raise the automation event for the line edit child. Implement QAccessibleComboBox::focusChild to return the interface to the lineedit for editable comboboxes so that the UI Automation bridge can correctly notify about the focus being moved to an editable text input field. Fixes: QTBUG-107572 Pick-to: 6.4 6.2 Change-Id: Id60e2791ec859365255baa9bfd01547979cd2b44 Reviewed-by: Jan Arve Sæther <[email protected]>
* Port from container::count() and length() to size() - V5Marc Mutz2022-11-033-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that the on() matcher has been replaced by one that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Added two NOLINTNEXTLINEs in tst_qbitarray and tst_qcontiguouscache, to avoid porting calls that explicitly test count(). Change-Id: Icfb8808c2ff4a30187e9935a51cad26987451c22 Reviewed-by: Ivan Solovev <[email protected]> Reviewed-by: Qt CI Bot <[email protected]>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-113-4/+4
| | | | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace, with manual unstaging of the actual definition and documentation in dist/, src/corelib/doc/ and src/corelib/global/. Task-number: QTBUG-99313 Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541 Reviewed-by: Ivan Solovev <[email protected]>
* Port from container.count()/length() to size()Marc Mutz2022-10-045-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Volker Hilsheimer <[email protected]>
* QtWidgets: Use remove instead of replaceMate Barany2022-09-271-1/+1
| | | | | | | | | | This commit addresses on of the comments from the review of QTBUG-98434. Use remove instead of replace to delete from the string. Task-number: QTBUG-103100 Change-Id: Ifa00a9bae24767eb42d6fa5da0ffdbaa230d5d96 Reviewed-by: Marc Mutz <[email protected]>
* Fix tree/table/list accessibility stateAndré de la Rocha2022-08-311-1/+21
| | | | | | | | | | | The accessibility class associated with trees, tables and lists was reporting a default/empty state, causing issues with accessibility tools. Fixes: QTBUG-92964 Pick-to: 6.4 6.3 6.2 Change-Id: I9c8ee5e7e582fd6b6a59cd70437eeddad0f4eb8e Reviewed-by: Volker Hilsheimer <[email protected]>
* Add ExpandCollapse UI Automation pattern to combo boxesAndré de la Rocha2022-06-222-0/+12
| | | | | | | | | | | Also add support to expandable/expanded states to QAccessibleComboBox in widgets. QtDeclarative will still require updates so that QML combo boxes report the expanded/collapsed state and react to UIA actions. Task-number: QTBUG-103591 Pick-to: 6.4 6.3 Change-Id: Iff8ba5e3143778ce17998dbe7f5f76cae658dc19 Reviewed-by: Volker Hilsheimer <[email protected]>
* Implement a dedicated QAccessibleInterface for QMessageBoxVolker Hilsheimer2022-06-163-1/+55
| | | | | | | | | | | | | | | QMessageBox has text values that an accessible client should be able to read directly without having to navigate through the text labels. Add test coverage. Windows Narrator is inconsistent in reading the contents of a message box. It might skip them completely, even though the text property is read through the interface. Task-number: QTBUG-101585 Change-Id: I639c2210a627733c093743790c6a6b83f4bb80d0 Reviewed-by: Jan Arve Sæther <[email protected]>
* Replace QT_NO_ACCESSIBILITY with QT_CONFIG(accessibility)Allan Sandfeld Jensen2022-06-1515-30/+30
| | | | | | | Pick-to: 6.4 Change-Id: Iee4bd8970810be1b23bdba65a74de912401dca65 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Marc Mutz <[email protected]>
* Use SPDX license identifiersLucie Gérard2022-05-1616-608/+32
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Lars Knoll <[email protected]> Reviewed-by: Jörg Bornemann <[email protected]>
* QtWidgets: replace remaining uses of QL1String with QL1StringViewSona Kurazyan2022-05-022-2/+2
| | | | | | | Task-number: QTBUG-98434 Change-Id: If20e217e6e4fecd18c7707bf94650f5ba856893f Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Marc Mutz <[email protected]>
* QtWidgets: use _L1 for for creating Latin-1 string literalsSona Kurazyan2022-05-026-73/+85
| | | | | | Task-number: QTBUG-98434 Change-Id: I310ea8f19d73a79d985ebfb8bfbff7a02c424360 Reviewed-by: Volker Hilsheimer <[email protected]>