RadioButton.qml 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright (c) 2019 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.10
  4. import QtQuick.Controls 2.3
  5. import UM 1.3 as UM
  6. import Cura 1.0 as Cura
  7. //
  8. // Cura-style RadioButton.
  9. //
  10. RadioButton
  11. {
  12. id: radioButton
  13. font: UM.Theme.getFont("default")
  14. background: Item
  15. {
  16. anchors.fill: parent
  17. }
  18. indicator: Rectangle
  19. {
  20. implicitWidth: UM.Theme.getSize("radio_button").width
  21. implicitHeight: UM.Theme.getSize("radio_button").height
  22. anchors.verticalCenter: parent.verticalCenter
  23. anchors.alignWhenCentered: false
  24. radius: width / 2
  25. border.width: UM.Theme.getSize("default_lining").width
  26. border.color: radioButton.hovered ? UM.Theme.getColor("small_button_text") : UM.Theme.getColor("small_button_text_hover")
  27. Rectangle
  28. {
  29. width: (parent.width / 2) | 0
  30. height: width
  31. anchors.centerIn: parent
  32. radius: width / 2
  33. color: radioButton.hovered ? UM.Theme.getColor("primary_button_hover") : UM.Theme.getColor("primary_button")
  34. visible: radioButton.checked
  35. }
  36. }
  37. contentItem: Label
  38. {
  39. verticalAlignment: Text.AlignVCenter
  40. leftPadding: radioButton.indicator.width + radioButton.spacing
  41. text: radioButton.text
  42. font: radioButton.font
  43. color: UM.Theme.getColor("text")
  44. renderType: Text.NativeRendering
  45. }
  46. }