Dial.qml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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.Dial {
  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. background: Rectangle {
  14. implicitWidth: 100
  15. implicitHeight: 100
  16. x: control.width / 2 - width / 2
  17. y: control.height / 2 - height / 2
  18. width: Math.max(64, Math.min(control.width, control.height))
  19. height: width
  20. radius: width / 2
  21. color: "transparent"
  22. border.color: !control.enabled ? control.Universal.baseLowColor : control.Universal.baseMediumColor
  23. border.width: 2
  24. }
  25. handle: Rectangle {
  26. implicitWidth: 14
  27. implicitHeight: 14
  28. x: control.background.x + control.background.width / 2 - width / 2
  29. y: control.background.y + control.background.height / 2 - height / 2
  30. radius: width / 2
  31. color: !control.enabled ? control.Universal.baseLowColor :
  32. control.pressed ? control.Universal.baseMediumColor :
  33. control.hovered ? control.Universal.baseHighColor : control.Universal.baseMediumHighColor
  34. transform: [
  35. Translate {
  36. y: -control.background.height * 0.4
  37. + (control.handle ? control.handle.height / 2 : 0)
  38. },
  39. Rotation {
  40. angle: control.angle
  41. origin.x: control.handle ? control.handle.width / 2 : 0
  42. origin.y: control.handle ? control.handle.height / 2 : 0
  43. }
  44. ]
  45. }
  46. }