SwipeDelegate.qml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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.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. 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. swipe.transition: Transition { SmoothedAnimation { velocity: 3; easing.type: Easing.InOutCubic } }
  29. contentItem: IconLabel {
  30. spacing: control.spacing
  31. mirrored: control.mirrored
  32. display: control.display
  33. alignment: control.display === IconLabel.IconOnly || control.display === IconLabel.TextUnderIcon ? Qt.AlignCenter : Qt.AlignLeft
  34. icon: control.icon
  35. text: control.text
  36. font: control.font
  37. color: control.palette.text
  38. }
  39. background: NinePatchImage {
  40. source: Imagine.url + "swipedelegate-background"
  41. NinePatchImageSelector on source {
  42. states: [
  43. {"disabled": !control.enabled},
  44. {"pressed": control.down},
  45. {"focused": control.visualFocus},
  46. {"highlighted": control.highlighted},
  47. {"mirrored": control.mirrored},
  48. {"hovered": control.enabled && control.hovered}
  49. ]
  50. }
  51. }
  52. }