docs: qt6,frontends,qml (2 files)

This commit is contained in:
2025-12-26 06:42:44 +00:00
parent 0792883f20
commit a3913a1c23
2 changed files with 25 additions and 7 deletions

View File

@@ -26,4 +26,5 @@ You can also embed `main.qml` into a Qt Quick Application project and expose C++
- Use `Material.MaterialSurface` and `Material.MaterialDivider` to group controls with Material elevation, spacing, and dividers.
- `Material.MaterialButton` now supports icon sources and a built-in ripple animation so interactions feel tactile.
- Material badges live in `Material.MaterialBadge` for lightweight status chips (accented, dense, or outlined).
- `Material.MaterialBadge` also accepts `iconSource` so you can anchor a micro icon beside the label.
- Preview the Material view with `qmlscene frontends/qt6/MaterialLanding.qml` or embed it into your Qt Quick application to reuse the tokens and components across other screens.

View File

@@ -6,22 +6,39 @@ import "MaterialPalette.qml" as MaterialPalette
Rectangle {
id: badge
property string text: ""
property url iconSource: ""
property bool accent: false
property bool outlined: false
property bool dense: false
height: dense ? 24 : 28
radius: height / 2
implicitWidth: label.width + 20
implicitWidth: label.width + (iconSource.length > 0 ? 32 : 20)
color: outlined ? "transparent" : (accent ? MaterialPalette.secondaryContainer : MaterialPalette.surfaceVariant)
border.color: outlined ? MaterialPalette.secondary : "transparent"
border.width: outlined ? 1 : 0
Text {
id: label
anchors.centerIn: parent
text: badge.text
font.pixelSize: dense ? 12 : 14
color: accent ? MaterialPalette.secondary : MaterialPalette.onSurface
RowLayout {
id: wrapper
anchors.fill: parent
anchors.margins: 6
spacing: iconSource.length > 0 ? 6 : 0
Layout.alignment: Qt.AlignCenter
Image {
source: iconSource
visible: iconSource.length > 0
width: 16
height: 16
fillMode: Image.PreserveAspectFit
opacity: 0.85
}
Text {
id: label
text: badge.text
font.pixelSize: dense ? 12 : 14
color: accent ? MaterialPalette.secondary : MaterialPalette.onSurface
}
}
}