Files
metabuilder/qml/MetaBuilder/CSidebar.qml
johndoe6345789 d9ca84628b feat(a11y): deep keyboard accessibility pass across all QML components
Second-pass a11y work across all 12 component groups. Every interactive
element now has activeFocusOnTab, Keys.onReturnPressed/SpacePressed, and
context-aware Accessible.name/description bindings.

Highlights:
- Dialogs: keyboard handlers with enabled-guard on confirm buttons
- CDropdownMenu: full keyboard nav (Up/Down/Enter/Escape)
- CLoginForm: explicit KeyNavigation.tab chain (username→password→submit)
- CNotificationBell: dynamic "3 notifications"/"No notifications" name
- CJobProgressBar: Accessible.minimumValue/maximumValue/currentValue
- CExecutionStatusDot: "Execution status: Running/Passed/Failed" binding
- CKeyboardShortcuts: invisible Repeater exposes all shortcuts to a11y tree
- CDataTable rows: "Row N of M" descriptions
- Canvas elements: Accessible.Canvas role + keyboard zoom (+/- keys)
- DropdownExpandedList: focus-highlight extended to :activeFocus
- Dynamic names reflect loading state (e.g. "Signing in, please wait")

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19 20:53:53 +00:00

158 lines
5.1 KiB
QML

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QmlComponents 1.0
// Left sidebar with navigation header, static items, dynamic package items,
// Settings
Rectangle {
id: root
Accessible.role: Accessible.Pane
Accessible.name: "Navigation"
property string currentView: "frontpage"
property int currentLevel: 1
property bool loggedIn: false
// PackageLoader helper — caller must provide this function
// to convert a package object to a view name
property var packageViewName: function(pkg) {
return pkg.navLabel
? pkg.navLabel.toLowerCase()
.replace(/ /g, "-")
: pkg.packageId
}
signal navigate(string view)
visible: loggedIn
color: Theme.paper
border.color: Theme.border
border.width: 1
implicitWidth: 220
ColumnLayout {
anchors.fill: parent
anchors.margins: 12
spacing: 4
CText {
variant: "subtitle2"
text: "Navigation"
Layout.bottomMargin: 8
}
// Static core nav items
Repeater {
model: {
var items = [
{ label: "Dashboard",
view: "dashboard",
icon: "~", level: 2 },
{ label: "Profile",
view: "profile",
icon: "P", level: 2 },
{ label: "Comments",
view: "comments",
icon: "C", level: 2 },
{ label: "Mod Tools",
view: "moderator",
icon: "M", level: 3 },
{ label: "Admin Panel",
view: "admin",
icon: "A", level: 4 },
{ label: "God Panel",
view: "god-panel",
icon: "G", level: 5 },
{ label: "Super God",
view: "supergod",
icon: "S", level: 6 }
]
return items.filter(function(item) {
return item.level <= root.currentLevel
})
}
delegate: CListItem {
Layout.fillWidth: true
activeFocusOnTab: true
title: modelData.label
leadingIcon: modelData.icon
selected: root.currentView
=== modelData.view
Accessible.role: Accessible.MenuItem
Accessible.name: modelData.label
Accessible.description:
selected
? modelData.label + ", current page"
: modelData.label
Keys.onReturnPressed:
root.navigate(modelData.view)
Keys.onSpacePressed:
root.navigate(modelData.view)
onClicked: {
root.navigate(modelData.view)
}
}
}
// Dynamic package nav items (from PackageLoader)
Repeater {
model: {
var navPkgs = PackageLoader.navigablePackages()
return navPkgs.filter(function(pkg) {
var lvl = pkg.level ? pkg.level : 2
return lvl <= root.currentLevel
})
}
delegate: CListItem {
Layout.fillWidth: true
activeFocusOnTab: true
title: modelData.navLabel
? modelData.navLabel
: modelData.name
leadingIcon: modelData.icon
? modelData.icon
: modelData.name.charAt(0)
selected: root.currentView
=== root.packageViewName(modelData)
Accessible.role: Accessible.MenuItem
Accessible.name: modelData.navLabel
|| modelData.name
Accessible.description:
selected
? (modelData.navLabel
|| modelData.name)
+ ", current page"
: (modelData.navLabel
|| modelData.name)
Keys.onReturnPressed: root.navigate(
root.packageViewName(modelData))
Keys.onSpacePressed: root.navigate(
root.packageViewName(modelData))
onClicked: root.navigate(
root.packageViewName(modelData))
}
}
Item { Layout.fillHeight: true }
CDivider { Layout.fillWidth: true }
CListItem {
Layout.fillWidth: true
activeFocusOnTab: true
title: "Settings"
leadingIcon: "S"
selected: root.currentView === "settings"
Accessible.role: Accessible.MenuItem
Accessible.name: "Settings"
Keys.onReturnPressed: root.navigate("settings")
Keys.onSpacePressed: root.navigate("settings")
onClicked: root.navigate("settings")
}
}
}