ItemDelegate.qml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright (C) 2017 The Qt Company Ltd.
  2. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
  3. // Qt-Security score:significant reason:default
  4. import QtQuick
  5. import QtQuick.Templates as T
  6. import QtQuick.Controls.impl
  7. import QtQuick.Controls.Material
  8. import QtQuick.Controls.Material.impl
  9. T.ItemDelegate {
  10. id: control
  11. implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
  12. implicitContentWidth + leftPadding + rightPadding)
  13. implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
  14. implicitContentHeight + topPadding + bottomPadding,
  15. implicitIndicatorHeight + topPadding + bottomPadding)
  16. padding: 16
  17. verticalPadding: 8
  18. spacing: 16
  19. icon.width: 24
  20. icon.height: 24
  21. icon.color: enabled ? Material.foreground : Material.hintTextColor
  22. contentItem: IconLabel {
  23. spacing: control.spacing
  24. mirrored: control.mirrored
  25. display: control.display
  26. alignment: control.display === IconLabel.IconOnly || control.display === IconLabel.TextUnderIcon ? Qt.AlignCenter : Qt.AlignLeft
  27. icon: control.icon
  28. text: control.text
  29. font: control.font
  30. color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
  31. }
  32. background: Rectangle {
  33. implicitHeight: control.Material.delegateHeight
  34. color: control.highlighted ? control.Material.listHighlightColor : "transparent"
  35. Ripple {
  36. width: parent.width
  37. height: parent.height
  38. clip: visible
  39. pressed: control.pressed
  40. anchor: control
  41. active: enabled && (control.down || control.visualFocus || control.hovered)
  42. color: control.Material.rippleColor
  43. }
  44. }
  45. }