CustomRadioButton.qml 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import Felgo 4.0
  2. import QtQuick 2.5
  3. import QtQuick.Controls 2.0 as Quick2
  4. Quick2.RadioButton {
  5. id: radioButton
  6. implicitWidth: leftPadding + indicator.implicitWidth + spacing + contentItem.implicitWidth + rightPadding
  7. implicitHeight: topPadding + indicator.implicitHeight + bottomPadding
  8. topPadding: 0
  9. bottomPadding: 0
  10. leftPadding: 0
  11. rightPadding: 0
  12. // overwrite style for density-independent sizes
  13. contentItem: AppText {
  14. text: parent.text
  15. font.pixelSize: sp(12)
  16. anchors.left: parent.left
  17. anchors.leftMargin: parent.indicator.width + parent.indicator.x + parent.spacing
  18. }
  19. indicator: Item {
  20. implicitWidth: dp(36)
  21. implicitHeight: implicitWidth
  22. x: parent.leftPadding
  23. y: parent.height / 2 - height / 2
  24. Rectangle {
  25. anchors.centerIn: parent
  26. implicitWidth: dp(20)
  27. implicitHeight: implicitWidth
  28. radius: width * 0.5
  29. border.color: radioButton.checked ? Theme.tintColor : Theme.secondaryTextColor
  30. border.width: 2
  31. Rectangle {
  32. width: parent.width * 0.5
  33. height: width
  34. anchors.centerIn: parent
  35. radius: width * 0.5
  36. color: Theme.tintColor
  37. visible: radioButton.checked
  38. }
  39. }
  40. }
  41. }