From a3913a1c230cded1d425e58a2973e8fbd0971ff3 Mon Sep 17 00:00:00 2001 From: JohnDoe6345789 Date: Fri, 26 Dec 2025 06:42:44 +0000 Subject: [PATCH] docs: qt6,frontends,qml (2 files) --- frontends/qt6/README.md | 1 + .../qt6/qmllib/Material/MaterialBadge.qml | 31 ++++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/frontends/qt6/README.md b/frontends/qt6/README.md index b9a6953fc..cf4acac84 100644 --- a/frontends/qt6/README.md +++ b/frontends/qt6/README.md @@ -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. diff --git a/frontends/qt6/qmllib/Material/MaterialBadge.qml b/frontends/qt6/qmllib/Material/MaterialBadge.qml index 670bdf3ae..0182b1d90 100644 --- a/frontends/qt6/qmllib/Material/MaterialBadge.qml +++ b/frontends/qt6/qmllib/Material/MaterialBadge.qml @@ -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 + } } }