SwipeDelegate.qml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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.SwipeDelegate {
  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. swipe.transition: Transition { SmoothedAnimation { velocity: 3; easing.type: Easing.InOutCubic } }
  23. contentItem: IconLabel {
  24. spacing: control.spacing
  25. mirrored: control.mirrored
  26. display: control.display
  27. alignment: control.display === IconLabel.IconOnly || control.display === IconLabel.TextUnderIcon ? Qt.AlignCenter : Qt.AlignLeft
  28. icon: control.icon
  29. text: control.text
  30. font: control.font
  31. color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
  32. }
  33. background: Rectangle {
  34. implicitHeight: control.Material.delegateHeight
  35. color: control.Material.backgroundColor
  36. Rectangle {
  37. width: parent.width
  38. height: parent.height
  39. visible: control.highlighted
  40. color: control.Material.listHighlightColor
  41. }
  42. Ripple {
  43. width: parent.width
  44. height: parent.height
  45. clip: visible
  46. pressed: control.pressed
  47. anchor: control
  48. active: enabled && (control.down || control.visualFocus || control.hovered)
  49. color: control.Material.rippleColor
  50. enabled: control.swipe.position === 0
  51. }
  52. }
  53. }