ItemDelegate.qml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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.Imagine
  8. import QtQuick.Controls.Imagine.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. spacing: 12 // ###
  17. topPadding: background ? background.topPadding : 0
  18. leftPadding: background ? background.leftPadding : 0
  19. rightPadding: background ? background.rightPadding : 0
  20. bottomPadding: background ? background.bottomPadding : 0
  21. topInset: background ? -background.topInset || 0 : 0
  22. leftInset: background ? -background.leftInset || 0 : 0
  23. rightInset: background ? -background.rightInset || 0 : 0
  24. bottomInset: background ? -background.bottomInset || 0 : 0
  25. icon.width: 24
  26. icon.height: 24
  27. icon.color: control.palette.text
  28. contentItem: IconLabel {
  29. spacing: control.spacing
  30. mirrored: control.mirrored
  31. display: control.display
  32. alignment: control.display === IconLabel.IconOnly || control.display === IconLabel.TextUnderIcon ? Qt.AlignCenter : Qt.AlignLeft
  33. icon: control.icon
  34. text: control.text
  35. font: control.font
  36. color: control.palette.text
  37. }
  38. background: NinePatchImage {
  39. source: Imagine.url + "itemdelegate-background"
  40. NinePatchImageSelector on source {
  41. states: [
  42. {"disabled": !control.enabled},
  43. {"pressed": control.down},
  44. {"focused": control.visualFocus},
  45. {"highlighted": control.highlighted},
  46. {"mirrored": control.mirrored},
  47. {"hovered": control.enabled && control.hovered}
  48. ]
  49. }
  50. }
  51. }