SwipeDelegate.qml 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright (C) 2024 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. 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. spacing: __config.spacing || 0
  15. topPadding: __config.topPadding || 0
  16. leftPadding: __config.leftPadding || 0
  17. rightPadding: __config.rightPadding || 0
  18. bottomPadding: __config.bottomPadding || 0
  19. icon.width: 16
  20. icon.height: 16
  21. icon.color: control.down ? __pressedText : control.palette.buttonText
  22. readonly property color __pressedText: Application.styleHints.colorScheme === Qt.Light
  23. ? Color.transparent(control.palette.buttonText, 0.62)
  24. : Color.transparent(control.palette.buttonText, 0.7725)
  25. readonly property string __currentState: [
  26. !control.enabled && "disabled",
  27. control.highlighted && "highlighted",
  28. control.enabled && !control.down && control.hovered && "hovered",
  29. control.down && "pressed"
  30. ].filter(Boolean).join("_") || "normal"
  31. readonly property var __config: Config.controls.itemdelegate[__currentState] || {}
  32. readonly property Item __focusFrameTarget: control
  33. swipe.transition: Transition { SmoothedAnimation { duration: 167; easing.type: Easing.OutCubic } }
  34. contentItem: IconLabel {
  35. spacing: control.spacing
  36. mirrored: control.mirrored
  37. display: control.display
  38. alignment: control.display === IconLabel.IconOnly || control.display === IconLabel.TextUnderIcon ? Qt.AlignCenter : Qt.AlignLeft
  39. icon: control.icon
  40. text: control.text
  41. font: control.font
  42. color: control.icon.color
  43. }
  44. background: Rectangle {
  45. implicitWidth: control.__config.background.width
  46. implicitHeight: control.__config.background.height
  47. readonly property bool lightScheme: Application.styleHints.colorScheme === Qt.Light
  48. readonly property color bakcgroundColorTint: control.down
  49. ? lightScheme ? Color.transparent("black", 0.02) : Color.transparent("white", 0.04)
  50. : control.hovered || control.highlighted
  51. ? lightScheme ? Color.transparent("black", 0.04) : Color.transparent("white", 0.06)
  52. : "transparent"
  53. color: Qt.tint(control.palette.window, bakcgroundColorTint)
  54. }
  55. }