ToolButton.qml 1.6 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.Templates as T
  6. import QtQuick.Controls.impl
  7. import QtQuick.Controls.Universal
  8. T.ToolButton {
  9. id: control
  10. implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
  11. implicitContentWidth + leftPadding + rightPadding)
  12. implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
  13. implicitContentHeight + topPadding + bottomPadding)
  14. padding: 6
  15. spacing: 8
  16. icon.width: 20
  17. icon.height: 20
  18. icon.color: Color.transparent(Universal.foreground, enabled ? 1.0 : 0.2)
  19. property bool useSystemFocusVisuals: true
  20. contentItem: IconLabel {
  21. spacing: control.spacing
  22. mirrored: control.mirrored
  23. display: control.display
  24. icon: control.icon
  25. text: control.text
  26. font: control.font
  27. color: Color.transparent(control.Universal.foreground, enabled ? 1.0 : 0.2)
  28. }
  29. background: Rectangle {
  30. implicitWidth: 68
  31. implicitHeight: 48 // AppBarThemeCompactHeight
  32. color: control.enabled && (control.highlighted || control.checked) ? control.Universal.accent : "transparent"
  33. Rectangle {
  34. width: parent.width
  35. height: parent.height
  36. visible: enabled && (control.down || control.hovered)
  37. color: control.down ? control.Universal.listMediumColor : control.Universal.listLowColor
  38. }
  39. }
  40. }