ItemDelegate.qml 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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.Controls.impl
  6. import QtQuick.Templates as T
  7. T.ItemDelegate {
  8. id: control
  9. implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
  10. implicitContentWidth + leftPadding + rightPadding)
  11. implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
  12. implicitContentHeight + topPadding + bottomPadding,
  13. implicitIndicatorHeight + topPadding + bottomPadding)
  14. padding: 12
  15. spacing: 8
  16. icon.width: 24
  17. icon.height: 24
  18. icon.color: control.palette.text
  19. contentItem: IconLabel {
  20. spacing: control.spacing
  21. mirrored: control.mirrored
  22. display: control.display
  23. alignment: control.display === IconLabel.IconOnly || control.display === IconLabel.TextUnderIcon ? Qt.AlignCenter : Qt.AlignLeft
  24. icon: control.icon
  25. text: control.text
  26. font: control.font
  27. color: control.highlighted ? control.palette.highlightedText : control.palette.text
  28. }
  29. background: Rectangle {
  30. implicitWidth: 100
  31. implicitHeight: 40
  32. visible: control.down || control.highlighted || control.visualFocus
  33. color: Color.blend(control.down ? control.palette.midlight : control.palette.light,
  34. control.palette.highlight, control.visualFocus ? 0.15 : 0.0)
  35. border.width: Qt.styleHints.accessibility.contrastPreference === Qt.HighContrast ? 1 : 0
  36. border.color: control.highlighted ? control.palette.highlight : control.palette.text
  37. }
  38. }