6import QtQuick.Templates as T
8import "../internal/MotionAnimation.js" as MotionAnimation
9import "../core/UiMetrics.js" as UiMetrics
50 property string overline:
""
58 property string supportingText:
""
66 property Component leading: null
74 property Component trailing: null
85 property bool segmented:
false
99 readonly
property bool _first: ListView.view !== null && index === 0
113 readonly
property bool _last: ListView.view !== null && index === ListView.view.count - 1
120 readonly
property int lineCount: 1 + (overline.length > 0 ? 1 : 0) + (supportingText.length > 0 ? 1 : 0)
123 implicitWidth: Math.max(parent ? parent.width : 0, implicitBackgroundWidth + leftInset + rightInset, implicitContentWidth + leftPadding + rightPadding)
124 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, implicitContentHeight + topPadding + bottomPadding)
126 topPadding: MD.
Tokens.listItem.topSpace
127 bottomPadding: MD.
Tokens.listItem.bottomSpace
128 leftPadding: MD.
Tokens.listItem.leadingSpace
129 rightPadding: MD.
Tokens.listItem.trailingSpace
130 spacing: MD.
Tokens.listItem.betweenSpace
132 topInset: control.segmented && !control._first ? MD.
Tokens.listItem.segmentedGap : 0
133 bottomInset: control.segmented && !control._last ? MD.
Tokens.listItem.segmentedGap : 0
136 focusPolicy: Qt.StrongFocus
137 Accessible.name: text
138 Accessible.description: supportingText
147 property color containerColor: control.segmented ? control.MD.Style.surfaceContainerColor : control.MD.Style.surfaceColor
148 property color labelColor: control.MD.Style.onSurfaceColor
149 property color overlineColor: control.MD.Style.onSurfaceVariantColor
150 property color supportingTextColor: control.MD.Style.onSurfaceVariantColor
151 property color stateLayerColor:
"transparent"
152 property real stateLayerOpacity: 0.0
153 property real contentOpacity: 1.0
159 when: !control.enabled
163 labelColor: control.MD.Style.onSurfaceColor
164 overlineColor: control.MD.Style.onSurfaceColor
165 supportingTextColor: control.MD.Style.onSurfaceColor
166 contentOpacity: MD.
Tokens.listItem.disabledContentOpacity
172 when: control.hovered && control.enabled
176 stateLayerColor: control.MD.Style.onSurfaceColor
177 stateLayerOpacity: MD.
Tokens.listItem.hoverStateLayerOpacity
183 when: control.visualFocus && control.enabled
187 stateLayerColor: control.MD.Style.onSurfaceColor
188 stateLayerOpacity: MD.
Tokens.listItem.focusStateLayerOpacity
194 when: control.down && control.enabled
198 stateLayerColor: control.MD.Style.onSurfaceColor
199 stateLayerOpacity: MD.
Tokens.listItem.pressedStateLayerOpacity
214 implicitWidth: _row.implicitWidth
215 implicitHeight: _row.implicitHeight
223 sourceComponent: control.leading
224 active: control.leading !== null
225 opacity: _state.contentOpacity
231 sourceComponent: control.trailing
232 active: control.trailing !== null
233 opacity: _state.contentOpacity
240 spacing: control.spacing
245 target: _leadingLoader.item
246 visible: _leadingLoader.item !== null
250 Layout.alignment: internal.lineCount >= 3 ? (Qt.AlignTop | Qt.AlignLeft) : Qt.AlignVCenter
251 Layout.topMargin: internal.lineCount >= 3 ? 4 : 0
256 Layout.fillWidth: true
257 Layout.alignment: Qt.AlignVCenter
262 Layout.fillWidth: true
264 typescale: MD.
Tokens.typescale.labelSmall
265 text: control.overline
266 color: _state.overlineColor
267 opacity: _state.contentOpacity
271 elide: Text.ElideRight
272 visible: control.overline.length > 0
273 Accessible.ignored: true
278 Layout.fillWidth: true
280 typescale: MD.
Tokens.typescale.bodyLarge
282 Accessible.ignored: true
283 color: _state.labelColor
284 opacity: _state.contentOpacity
288 elide: Text.ElideRight
293 Layout.fillWidth: true
295 typescale: MD.
Tokens.typescale.bodyMedium
296 text: control.supportingText
297 color: _state.supportingTextColor
298 opacity: _state.contentOpacity
303 wrapMode: Text.WordWrap
304 elide: Text.ElideRight
305 visible: control.supportingText.length > 0
306 Accessible.ignored: true
313 target: _trailingLoader.item
314 visible: _trailingLoader.item !== null
315 Layout.alignment: internal.lineCount >= 3 ? (Qt.AlignTop | Qt.AlignRight) : Qt.AlignVCenter
316 Layout.topMargin: internal.lineCount >= 3 ? 4 : 0
325 background: Rectangle {
328 if (internal.lineCount >= 3)
329 return MD.
Tokens.listItem.threeLineContainerHeight;
330 if (internal.lineCount === 2)
331 return MD.Tokens.listItem.twoLineContainerHeight;
332 return MD.Tokens.listItem.oneLineContainerHeight;
335 topLeftRadius: control.segmented && control._first
336 ? UiMetrics.resolveShapeRadius(
337 MD.Tokens.listItem.selectedContainerExpressiveShape.topLeft,
339 topRightRadius: control.segmented && control._first
340 ? UiMetrics.resolveShapeRadius(
341 MD.Tokens.listItem.selectedContainerExpressiveShape.topRight,
343 bottomLeftRadius: control.segmented && control._last
344 ? UiMetrics.resolveShapeRadius(
345 MD.Tokens.listItem.selectedContainerExpressiveShape.bottomLeft,
347 bottomRightRadius: control.segmented && control._last
348 ? UiMetrics.resolveShapeRadius(
349 MD.Tokens.listItem.selectedContainerExpressiveShape.bottomRight,
352 color: _state.containerColor
354 Behavior on topLeftRadius {
356 easing.type: Easing.BezierSpline
357 easing.bezierCurve: MotionAnimation.expressiveFastSpatialCurve
358 duration: MotionAnimation.expressiveFastSpatialDuration
361 Behavior on topRightRadius {
363 easing.type: Easing.BezierSpline
364 easing.bezierCurve: MotionAnimation.expressiveFastSpatialCurve
365 duration: MotionAnimation.expressiveFastSpatialDuration
368 Behavior on bottomLeftRadius {
370 easing.type: Easing.BezierSpline
371 easing.bezierCurve: MotionAnimation.expressiveFastSpatialCurve
372 duration: MotionAnimation.expressiveFastSpatialDuration
375 Behavior on bottomRightRadius {
377 easing.type: Easing.BezierSpline
378 easing.bezierCurve: MotionAnimation.expressiveFastSpatialCurve
379 duration: MotionAnimation.expressiveFastSpatialDuration
385 duration: MD.Tokens.motion.duration.short2
391 topLeftRadius: parent.topLeftRadius
392 topRightRadius: parent.topRightRadius
393 bottomLeftRadius: parent.bottomLeftRadius
394 bottomRightRadius: parent.bottomRightRadius
395 color: _state.stateLayerColor
396 pressed: control.down
397 pressX: control.pressX
398 pressY: control.pressY
399 stateOpacity: _state.stateLayerOpacity
Material Design 3 design tokens.
Tokens(QObject *parent=nullptr)
Displays text using a selectable Material 3 type scale.