CheckDelegate.qml 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. import QtQuick.Controls.Universal.impl
  9. T.CheckDelegate {
  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. padding: 12
  18. topPadding: padding - 1
  19. bottomPadding: padding + 1
  20. icon.width: 20
  21. icon.height: 20
  22. icon.color: Color.transparent(Universal.foreground, enabled ? 1.0 : 0.2)
  23. indicator: CheckIndicator {
  24. x: control.text ? (control.mirrored ? control.leftPadding : control.width - width - control.rightPadding) : control.leftPadding + (control.availableWidth - width) / 2
  25. y: control.topPadding + (control.availableHeight - height) / 2
  26. control: control
  27. }
  28. contentItem: IconLabel {
  29. leftPadding: !control.mirrored ? 0 : control.indicator.width + control.spacing
  30. rightPadding: control.mirrored ? 0 : control.indicator.width + control.spacing
  31. spacing: control.spacing
  32. mirrored: control.mirrored
  33. display: control.display
  34. alignment: control.display === IconLabel.IconOnly || control.display === IconLabel.TextUnderIcon ? Qt.AlignCenter : Qt.AlignLeft
  35. icon: control.icon
  36. text: control.text
  37. font: control.font
  38. color: Color.transparent(control.Universal.foreground, enabled ? 1.0 : 0.2)
  39. }
  40. background: Rectangle {
  41. visible: enabled && (control.down || control.highlighted || control.visualFocus || control.hovered)
  42. color: control.down ? control.Universal.listMediumColor :
  43. control.hovered ? control.Universal.listLowColor : control.Universal.altMediumLowColor
  44. Rectangle {
  45. width: parent.width
  46. height: parent.height
  47. visible: control.visualFocus || control.highlighted
  48. color: control.Universal.accent
  49. opacity: control.Universal.theme === Universal.Light ? 0.4 : 0.6
  50. }
  51. }
  52. }