DelayButton.qml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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.Universal
  7. T.DelayButton {
  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. padding: 8
  14. verticalPadding: padding - 4
  15. property bool useSystemFocusVisuals: true
  16. transition: Transition {
  17. NumberAnimation {
  18. duration: control.delay * (control.pressed ? 1.0 - control.progress : 0.3 * control.progress)
  19. }
  20. }
  21. contentItem: Text {
  22. text: control.text
  23. font: control.font
  24. elide: Text.ElideRight
  25. horizontalAlignment: Text.AlignHCenter
  26. verticalAlignment: Text.AlignVCenter
  27. opacity: enabled ? 1.0 : 0.2
  28. color: control.Universal.foreground
  29. }
  30. background: Rectangle {
  31. implicitWidth: 32
  32. implicitHeight: 32
  33. color: control.down ? control.Universal.baseMediumLowColor :
  34. control.enabled && control.checked ? control.Universal.accent : control.Universal.baseLowColor
  35. Rectangle {
  36. visible: !control.checked
  37. width: parent.width * control.progress
  38. height: parent.height
  39. color: control.Universal.accent
  40. }
  41. Rectangle {
  42. width: parent.width
  43. height: parent.height
  44. color: "transparent"
  45. visible: enabled && control.hovered
  46. border.width: 2 // ButtonBorderThemeThickness
  47. border.color: control.Universal.baseMediumLowColor
  48. }
  49. }
  50. }