RadioButton.qml 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. radius: (width / 2) | 0
  24. border.width: UM.Theme.getSize("default_lining").width
  25. border.color: radioButton.hovered ? UM.Theme.getColor("small_button_text") : UM.Theme.getColor("small_button_text_hover")
  26. Rectangle
  27. {
  28. width: (parent.width / 2) | 0
  29. height: width
  30. anchors.centerIn: parent
  31. radius: (width / 2) | 0
  32. color: radioButton.hovered ? UM.Theme.getColor("primary_button_hover") : UM.Theme.getColor("primary_button")
  33. visible: radioButton.checked
  34. }
  35. }
  36. contentItem: Label
  37. {
  38. verticalAlignment: Text.AlignVCenter
  39. leftPadding: radioButton.indicator.width + radioButton.spacing
  40. text: radioButton.text
  41. font: radioButton.font
  42. renderType: Text.NativeRendering
  43. }
  44. }