SwipeDelegate.qml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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.SwipeDelegate {
  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: 12
  16. icon.width: 24
  17. icon.height: 24
  18. icon.color: control.palette.text
  19. swipe.transition: Transition { SmoothedAnimation { velocity: 3; easing.type: Easing.InOutCubic } }
  20. contentItem: IconLabel {
  21. spacing: control.spacing
  22. mirrored: control.mirrored
  23. display: control.display
  24. alignment: control.display === IconLabel.IconOnly || control.display === IconLabel.TextUnderIcon ? Qt.AlignCenter : Qt.AlignLeft
  25. icon: control.icon
  26. text: control.text
  27. font: control.font
  28. color: control.palette.text
  29. }
  30. background: Rectangle {
  31. implicitWidth: 100
  32. implicitHeight: 40
  33. color: Color.blend(control.down ? control.palette.midlight : control.palette.light,
  34. control.palette.highlight, control.visualFocus ? 0.15 : 0.0)
  35. // The condition of (control.down || control.highlighted || control.visualFocus)
  36. // came from the ItemDelegate.qml
  37. border.width: Qt.styleHints.accessibility.contrastPreference === Qt.HighContrast &&
  38. (control.down || control.highlighted || control.visualFocus) ? 1 : 0
  39. border.color: control.down || control.highlighted || control.visualFocus ?
  40. control.palette.highlightedText : control.palette.text
  41. }
  42. }