Dial.qml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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.Material
  7. import QtQuick.Controls.Material.impl
  8. T.Dial {
  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. background: Rectangle {
  15. implicitWidth: 100
  16. implicitHeight: 100
  17. x: control.width / 2 - width / 2
  18. y: control.height / 2 - height / 2
  19. width: Math.max(64, Math.min(control.width, control.height))
  20. height: width
  21. color: "transparent"
  22. radius: width / 2
  23. border.color: control.enabled ? control.Material.accentColor : control.Material.hintTextColor
  24. }
  25. handle: SliderHandle {
  26. x: control.background.x + control.background.width / 2 - width / 2
  27. y: control.background.y + control.background.height / 2 - height / 2
  28. transform: [
  29. Translate {
  30. y: -control.background.height * 0.4
  31. + (control.handle ? control.handle.height / 2 : 0)
  32. },
  33. Rotation {
  34. angle: control.angle
  35. origin.x: control.handle ? control.handle.width / 2 : 0
  36. origin.y: control.handle ? control.handle.height / 2 : 0
  37. }
  38. ]
  39. implicitWidth: 10
  40. implicitHeight: 10
  41. value: control.value
  42. handleHasFocus: control.visualFocus
  43. handlePressed: control.pressed
  44. handleHovered: control.hovered
  45. }
  46. }