DelayButton.qml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Copyright (C) 2023 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. import QtQuick.NativeStyle as NativeStyle
  8. T.DelayButton {
  9. id: control
  10. readonly property bool __nativeBackground: background instanceof NativeStyle.StyleItem
  11. readonly property bool __notCustomizable: true
  12. readonly property Item __focusFrameTarget: control
  13. implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
  14. implicitContentWidth + leftPadding + rightPadding)
  15. implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
  16. implicitContentHeight + topPadding + bottomPadding)
  17. leftPadding: __nativeBackground ? background.contentPadding.left : 5
  18. rightPadding: __nativeBackground ? background.contentPadding.right : 5
  19. topPadding: __nativeBackground ? background.contentPadding.top : 5
  20. bottomPadding: __nativeBackground ? background.contentPadding.bottom : 5
  21. icon.width: 24
  22. icon.height: 24
  23. icon.color: control.palette.buttonText
  24. transition: Transition {
  25. NumberAnimation {
  26. duration: control.delay * (control.pressed ? 1.0 - control.progress : 0.3 * control.progress)
  27. }
  28. }
  29. background: NativeStyle.DelayButton {
  30. control: control
  31. contentWidth: contentItem.implicitWidth
  32. contentHeight: contentItem.implicitHeight
  33. useNinePatchImage: false
  34. overrideState: NativeStyle.StyleItem.NeverHovered
  35. readonly property bool __ignoreNotCustomizable: true
  36. }
  37. NativeStyle.DelayButton {
  38. id: hoverButton
  39. control: control
  40. x: background.x
  41. y: background.y
  42. width: background.width
  43. height: background.height
  44. useNinePatchImage: false
  45. overrideState: NativeStyle.StyleItem.AlwaysHovered
  46. opacity: control.hovered ? 1 : 0
  47. visible: opacity !== 0
  48. Behavior on opacity { NumberAnimation { duration: hoverButton.transitionDuration } }
  49. }
  50. contentItem: IconLabel {
  51. spacing: control.spacing
  52. mirrored: control.mirrored
  53. display: control.display
  54. icon: control.icon
  55. text: control.text
  56. font: control.font
  57. color: control.palette.buttonText
  58. readonly property bool __ignoreNotCustomizable: true
  59. // Delay progress bar.
  60. Rectangle {
  61. x: (parent.width - parent.implicitWidth) / 2
  62. y: parent.height + 1
  63. width: control.progress * parent.implicitWidth
  64. height: 1
  65. color: control.palette.accent
  66. scale: control.mirrored ? -1 : 1
  67. }
  68. }
  69. }