Button.qml 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright (C) 2020 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.NativeStyle as NativeStyle
  7. NativeStyle.DefaultButton {
  8. id: control
  9. background: NativeStyle.Button {
  10. control: control
  11. contentWidth: contentItem.implicitWidth
  12. contentHeight: contentItem.implicitHeight
  13. useNinePatchImage: false
  14. overrideState: NativeStyle.StyleItem.NeverHovered
  15. readonly property bool __ignoreNotCustomizable: true
  16. }
  17. NativeStyle.Button {
  18. id: hoverButton
  19. control: control
  20. x: background.x
  21. y: background.y
  22. width: background.width
  23. height: background.height
  24. useNinePatchImage: false
  25. overrideState: NativeStyle.StyleItem.AlwaysHovered
  26. opacity: control.hovered ? 1 : 0
  27. visible: opacity !== 0
  28. Behavior on opacity { NumberAnimation { duration: hoverButton.transitionDuration } }
  29. }
  30. contentItem: IconLabel {
  31. spacing: control.spacing
  32. mirrored: control.mirrored
  33. display: control.display
  34. icon: control.icon
  35. text: control.text
  36. font: control.font
  37. color: control.flat && !control.down ? (control.visualFocus ? control.palette.highlight : control.palette.windowText) : control.palette.buttonText
  38. readonly property bool __ignoreNotCustomizable: true
  39. }
  40. }