7import QtQuick.Templates as T
9import "../internal/MotionAnimation.js" as MotionAnimation
10import "../core/UiMetrics.js" as UiMetrics
51 property string overline:
""
59 property string supportingText:
""
67 property Component leading: null
75 property Component trailing: null
86 property bool segmented:
false
100 readonly
property bool _first: ListView.view !== null && DelegateModel.itemsIndex === 0
114 readonly
property bool _last: ListView.view !== null && DelegateModel.itemsIndex === ListView.view.count - 1
121 readonly
property int lineCount: 1 + (control.overline.length > 0 ? 1 : 0) + (control.supportingText.length > 0 ? 1 : 0)
124 implicitWidth: Math.max(parent ? parent.width : 0, implicitBackgroundWidth + leftInset + rightInset, implicitContentWidth + leftPadding + rightPadding)
125 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, implicitContentHeight + topPadding + bottomPadding)
127 topPadding: MD.
Tokens.listItem.topSpace
128 bottomPadding: MD.
Tokens.listItem.bottomSpace
129 leftPadding: MD.
Tokens.listItem.leadingSpace
130 rightPadding: MD.
Tokens.listItem.trailingSpace
131 spacing: MD.
Tokens.listItem.betweenSpace
133 topInset: control.segmented && !control._first ? MD.
Tokens.listItem.segmentedGap : 0
134 bottomInset: control.segmented && !control._last ? MD.
Tokens.listItem.segmentedGap : 0
137 focusPolicy: Qt.StrongFocus
138 Accessible.name: text
139 Accessible.description: supportingText
148 property color containerColor: control.segmented ? control.MD.Style.surfaceContainerColor : control.MD.Style.surfaceColor
149 property color labelColor: control.MD.Style.onSurfaceColor
150 property color overlineColor: control.MD.Style.onSurfaceVariantColor
151 property color supportingTextColor: control.MD.Style.onSurfaceVariantColor
152 property color stateLayerColor:
"transparent"
153 property real stateLayerOpacity: 0.0
154 property real contentOpacity: 1.0
160 when: !control.enabled
164 labelColor: control.MD.Style.onSurfaceColor
165 overlineColor: control.MD.Style.onSurfaceColor
166 supportingTextColor: control.MD.Style.onSurfaceColor
167 contentOpacity: MD.
Tokens.listItem.disabledContentOpacity
173 when: control.hovered && control.enabled
177 stateLayerColor: control.MD.Style.onSurfaceColor
178 stateLayerOpacity: MD.
Tokens.listItem.hoverStateLayerOpacity
184 when: control.visualFocus && control.enabled
188 stateLayerColor: control.MD.Style.onSurfaceColor
189 stateLayerOpacity: MD.
Tokens.listItem.focusStateLayerOpacity
195 when: control.down && control.enabled
199 stateLayerColor: control.MD.Style.onSurfaceColor
200 stateLayerOpacity: MD.
Tokens.listItem.pressedStateLayerOpacity
215 implicitWidth: _row.implicitWidth
216 implicitHeight: _row.implicitHeight
224 sourceComponent: control.leading
225 active: control.leading !== null
226 opacity: _state.contentOpacity
232 sourceComponent: control.trailing
233 active: control.trailing !== null
234 opacity: _state.contentOpacity
241 spacing: control.spacing
246 target: _leadingLoader.item as Item
247 visible: _leadingLoader.item !== null
251 Layout.alignment: internal.lineCount >= 3 ? (Qt.AlignTop | Qt.AlignLeft) : Qt.AlignVCenter
252 Layout.topMargin: internal.lineCount >= 3 ? 4 : 0
257 Layout.fillWidth: true
258 Layout.alignment: Qt.AlignVCenter
263 Layout.fillWidth: true
265 typescale: MD.
Tokens.typescale.labelSmall
266 text: control.overline
267 color: _state.overlineColor
268 opacity: _state.contentOpacity
272 elide: Text.ElideRight
273 visible: control.overline.length > 0
274 Accessible.ignored: true
279 Layout.fillWidth: true
281 typescale: MD.
Tokens.typescale.bodyLarge
283 Accessible.ignored: true
284 color: _state.labelColor
285 opacity: _state.contentOpacity
289 elide: Text.ElideRight
294 Layout.fillWidth: true
296 typescale: MD.
Tokens.typescale.bodyMedium
297 text: control.supportingText
298 color: _state.supportingTextColor
299 opacity: _state.contentOpacity
304 wrapMode: Text.WordWrap
305 elide: Text.ElideRight
306 visible: control.supportingText.length > 0
307 Accessible.ignored: true
314 target: _trailingLoader.item as Item
315 visible: _trailingLoader.item !== null
316 Layout.alignment: internal.lineCount >= 3 ? (Qt.AlignTop | Qt.AlignRight) : Qt.AlignVCenter
317 Layout.topMargin: internal.lineCount >= 3 ? 4 : 0
326 background: Rectangle {
329 if (internal.lineCount >= 3)
330 return MD.
Tokens.listItem.threeLineContainerHeight;
331 if (internal.lineCount === 2)
332 return MD.Tokens.listItem.twoLineContainerHeight;
333 return MD.Tokens.listItem.oneLineContainerHeight;
336 topLeftRadius: control.segmented && control._first
337 ? UiMetrics.resolveShapeRadius(
338 MD.Tokens.listItem.selectedContainerExpressiveShape.topLeft,
340 topRightRadius: control.segmented && control._first
341 ? UiMetrics.resolveShapeRadius(
342 MD.Tokens.listItem.selectedContainerExpressiveShape.topRight,
344 bottomLeftRadius: control.segmented && control._last
345 ? UiMetrics.resolveShapeRadius(
346 MD.Tokens.listItem.selectedContainerExpressiveShape.bottomLeft,
348 bottomRightRadius: control.segmented && control._last
349 ? UiMetrics.resolveShapeRadius(
350 MD.Tokens.listItem.selectedContainerExpressiveShape.bottomRight,
353 color: _state.containerColor
355 Behavior on topLeftRadius {
357 easing.type: Easing.BezierSpline
358 easing.bezierCurve: MotionAnimation.expressiveFastSpatialCurve
359 duration: MotionAnimation.expressiveFastSpatialDuration
362 Behavior on topRightRadius {
364 easing.type: Easing.BezierSpline
365 easing.bezierCurve: MotionAnimation.expressiveFastSpatialCurve
366 duration: MotionAnimation.expressiveFastSpatialDuration
369 Behavior on bottomLeftRadius {
371 easing.type: Easing.BezierSpline
372 easing.bezierCurve: MotionAnimation.expressiveFastSpatialCurve
373 duration: MotionAnimation.expressiveFastSpatialDuration
376 Behavior on bottomRightRadius {
378 easing.type: Easing.BezierSpline
379 easing.bezierCurve: MotionAnimation.expressiveFastSpatialCurve
380 duration: MotionAnimation.expressiveFastSpatialDuration
386 duration: MD.Tokens.motion.duration.short2
392 topLeftRadius: parent.topLeftRadius
393 topRightRadius: parent.topRightRadius
394 bottomLeftRadius: parent.bottomLeftRadius
395 bottomRightRadius: parent.bottomRightRadius
396 color: _state.stateLayerColor
397 pressed: control.down
398 pressX: control.pressX
399 pressY: control.pressY
400 stateOpacity: _state.stateLayerOpacity
Material Design 3 design tokens.
Tokens(QObject *parent=nullptr)
Displays text using a selectable Material 3 type scale.