ItemDelegate.qml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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.Universal
  8. T.ItemDelegate {
  9. id: control
  10. implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
  11. implicitContentWidth + leftPadding + rightPadding)
  12. implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
  13. implicitContentHeight + topPadding + bottomPadding,
  14. implicitIndicatorHeight + topPadding + bottomPadding)
  15. spacing: 12
  16. padding: 12
  17. topPadding: padding - 1
  18. bottomPadding: padding + 1
  19. icon.width: 20
  20. icon.height: 20
  21. icon.color: Color.transparent(Universal.foreground, enabled ? 1.0 : 0.2)
  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: Color.transparent(control.Universal.foreground, enabled ? 1.0 : 0.2)
  31. }
  32. background: Rectangle {
  33. visible: enabled && (control.down || control.highlighted || control.visualFocus || control.hovered)
  34. color: control.down ? control.Universal.listMediumColor :
  35. control.hovered ? control.Universal.listLowColor : control.Universal.altMediumLowColor
  36. Rectangle {
  37. width: parent.width
  38. height: parent.height
  39. visible: control.visualFocus || control.highlighted
  40. color: control.Universal.accent
  41. opacity: control.Universal.theme === Universal.Light ? 0.4 : 0.6
  42. }
  43. }
  44. }