Add a QML plugin to debug focus chain in QtQuick windows
This introduces a new class "AccessibleDebugger" to help debug actvieFocusItem in Qt Quick windows. By setting targetWindow property and options, developers can get information about the focus chain, so they can fix a11y problems easier.
TestA11yHelper.qml
import QtQuick
import QtQuick.Controls as QQC
import org.kde.plasma.sdk.a11y as A11Y
Window {
id: window
width: 320
height: width
visible: true
title: "a window"
A11Y.AccessibleDebugger {
options: A11Y.AccessibleDebugger.Enabled
targetWindow: window
}
Component {
id: testComp
Row {
objectName: `row${count}`
property int count: 1
QQC.Button {
id: firstButton
objectName: text
focus: true
text: String(count)
onClicked: view.push(testComp, {
"count": count + 2
})
KeyNavigation.right: secondButton
KeyNavigation.down: secondButton
}
QQC.Button {
id: secondButton
objectName: text
text: String(count + 1)
onClicked: view.pop()
}
}
}
QQC.StackView {
id: view
objectName: "StackView"
anchors.fill: parent
focus: true
initialItem: testComp
}
}
Example command: QT_LOGGING_RULES="org.kde.plasma.sdk.a11y.debug=true" kqml ./TestA11yHelper.qml
Expected output (Press Tab 2 times):
org.kde.plasma.sdk.a11y: ======BEGIN Information======
org.kde.plasma.sdk.a11y: ActiveFocusItem in "a window": QQuickItem(nullptr)
org.kde.plasma.sdk.a11y: ======END Information======
org.kde.plasma.sdk.a11y: ======BEGIN Information======
org.kde.plasma.sdk.a11y: ActiveFocusItem in "a window": QQuickRow_QML_25(0x196d4c0, name="row1", parent=0x18f9dd0, geometry=0,0 320x320)
org.kde.plasma.sdk.a11y: PreviousItemInFocusChain: Button_QMLTYPE_22(0x167b1c0, name="2", parent=0x196d4c0, geometry=84,0 84x34)
org.kde.plasma.sdk.a11y: NextItemInFocusChain: Button_QMLTYPE_22(0x196add0, name="1", parent=0x196d4c0, geometry=0,0 84x34)
org.kde.plasma.sdk.a11y: ======END Information======
org.kde.plasma.sdk.a11y: ======BEGIN Information======
org.kde.plasma.sdk.a11y: ActiveFocusItem in "a window": Button_QMLTYPE_22(0x196add0, name="1", parent=0x196d4c0, geometry=0,0 84x34)
org.kde.plasma.sdk.a11y: PreviousItemInFocusChain: Button_QMLTYPE_22(0x167b1c0, name="2", parent=0x196d4c0, geometry=84,0 84x34)
org.kde.plasma.sdk.a11y: NextItemInFocusChain: Button_QMLTYPE_22(0x167b1c0, name="2", parent=0x196d4c0, geometry=84,0 84x34)
org.kde.plasma.sdk.a11y: KeyNavigation.up: QQuickItem(nullptr)
org.kde.plasma.sdk.a11y: KeyNavigation.down: Button_QMLTYPE_22(0x167b1c0, name="2", parent=0x196d4c0, geometry=84,0 84x34)
org.kde.plasma.sdk.a11y: KeyNavigation.left: QQuickItem(nullptr)
org.kde.plasma.sdk.a11y: KeyNavigation.right: Button_QMLTYPE_22(0x167b1c0, name="2", parent=0x196d4c0, geometry=84,0 84x34)
org.kde.plasma.sdk.a11y: KeyNavigation.tab: QQuickItem(nullptr)
org.kde.plasma.sdk.a11y: KeyNavigation.backtab: QQuickItem(nullptr)
org.kde.plasma.sdk.a11y: Accessible.name: "1"
org.kde.plasma.sdk.a11y: Accessible.description: ""
org.kde.plasma.sdk.a11y: Accessible.role: QAccessible::Button
org.kde.plasma.sdk.a11y: ======END Information======
org.kde.plasma.sdk.a11y: ======BEGIN Information======
org.kde.plasma.sdk.a11y: ActiveFocusItem in "a window": Button_QMLTYPE_22(0x167b1c0, name="2", parent=0x196d4c0, geometry=84,0 84x34)
org.kde.plasma.sdk.a11y: PreviousItemInFocusChain: Button_QMLTYPE_22(0x196add0, name="1", parent=0x196d4c0, geometry=0,0 84x34)
org.kde.plasma.sdk.a11y: NextItemInFocusChain: Button_QMLTYPE_22(0x196add0, name="1", parent=0x196d4c0, geometry=0,0 84x34)
org.kde.plasma.sdk.a11y: KeyNavigation.up: Button_QMLTYPE_22(0x196add0, name="1", parent=0x196d4c0, geometry=0,0 84x34)
org.kde.plasma.sdk.a11y: KeyNavigation.down: QQuickItem(nullptr)
org.kde.plasma.sdk.a11y: KeyNavigation.left: Button_QMLTYPE_22(0x196add0, name="1", parent=0x196d4c0, geometry=0,0 84x34)
org.kde.plasma.sdk.a11y: KeyNavigation.right: QQuickItem(nullptr)
org.kde.plasma.sdk.a11y: KeyNavigation.tab: QQuickItem(nullptr)
org.kde.plasma.sdk.a11y: KeyNavigation.backtab: QQuickItem(nullptr)
org.kde.plasma.sdk.a11y: Accessible.name: "2"
org.kde.plasma.sdk.a11y: Accessible.description: ""
org.kde.plasma.sdk.a11y: Accessible.role: QAccessible::Button
org.kde.plasma.sdk.a11y: ======END Information======
Edited by Fushan Wen