Files
metabuilder/qml/components/core/CFab.qml
johndoe6345789 5456f7eb4c feat(a11y): add Accessible roles, names, objectNames to all core QML components
Core: CButton, CIconButton, CFab, CChip, CListItem — Button roles, activeFocusOnTab
Forms: CTextField, CSelect, CCheckbox, CSwitch, CRadio, CRating — EditableText, CheckBox, ComboBox, Slider
Feedback: CAlert, CDialog, CSnackbar — AlertMessage, Dialog roles
Navigation: CTabBar — PageTabList + PageTab on delegates
Data: CAvatar, CBadge, CTable, CStatBadge, CStatusBadge — Graphic, StaticText, Table, Row
Surfaces: CCard (Pane), CAccordionItem (Button + expanded), CAppBar (ToolBar)
Progress: CProgress (ProgressBar + value), CSpinner (Animation)
Divider: CDivider (Separator)

28 files, 157 lines of a11y properties added. Zero to full coverage on core library.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 16:00:55 +00:00

66 lines
1.6 KiB
QML

import QtQuick
import QtQuick.Controls
import QmlComponents 1.0
/**
* CFab.qml - Material Design 3 Floating Action Button
*
* MD3 FAB: 56px, rounded corner (radius 16), tonal surface with primary icon.
* Hover adds 8% state layer, press adds 12% state layer.
*/
Rectangle {
id: root
Accessible.role: Accessible.Button
Accessible.name: icon || "Button"
Accessible.description: ""
activeFocusOnTab: true
objectName: "btn_" + (icon || "fab")
.toLowerCase().replace(/ /g, "_")
property alias icon: iconLabel.text
property int size: 56
signal clicked()
width: size
height: size
radius: 16
anchors.margins: StyleVariables.spacingMd
// MD3 tonal surface: primary at 12% opacity over surface
color: Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12)
Behavior on color { ColorAnimation { duration: Theme.transitionShortest } }
// State layer overlay for hover/press
Rectangle {
id: stateLayer
anchors.fill: parent
radius: parent.radius
color: Theme.primary
opacity: mouseArea.pressed ? 0.12 : (mouseArea.containsMouse ? 0.08 : 0)
visible: opacity > 0
Behavior on opacity {
NumberAnimation { duration: Theme.transitionShortest } }
}
Text {
id: iconLabel
anchors.centerIn: parent
text: "+"
color: Theme.primary
font.pixelSize: root.size * 0.43
font.weight: Font.DemiBold
}
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: root.clicked()
}
}