FluRadioButton.qml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import QtQuick
  2. import QtQuick.Controls
  3. import QtQuick.Controls.Basic
  4. import QtQuick.Layouts
  5. import FluentUI
  6. Button {
  7. property bool selected: false
  8. property bool disabled: false
  9. id:control
  10. enabled: !disabled
  11. focusPolicy:Qt.TabFocus
  12. padding:0
  13. background: Item{
  14. FluFocusRectangle{
  15. visible: control.visualFocus
  16. }
  17. }
  18. font:FluTextStyle.Body
  19. Keys.onSpacePressed: control.visualFocus&&clicked()
  20. contentItem: RowLayout{
  21. Rectangle{
  22. id:rect_check
  23. width: 20
  24. height: 20
  25. radius: 10
  26. border.width: {
  27. if(selected&&disabled){
  28. return 3
  29. }
  30. if(pressed){
  31. if(selected){
  32. return 5
  33. }
  34. return 1
  35. }
  36. if(hovered){
  37. if(selected){
  38. return 3
  39. }
  40. return 1
  41. }
  42. return selected ? 5 : 1
  43. }
  44. Behavior on border.width {
  45. NumberAnimation{
  46. duration: 167
  47. easing.type: Easing.BezierSpline
  48. easing.bezierCurve: [ 0, 0, 0, 1 ]
  49. }
  50. }
  51. border.color: {
  52. if(disabled){
  53. if(FluTheme.dark){
  54. return Qt.rgba(82/255,82/255,82/255,1)
  55. }else{
  56. return Qt.rgba(198/255,198/255,198/255,1)
  57. }
  58. }
  59. if(selected){
  60. if(FluTheme.dark){
  61. return FluTheme.primaryColor.lighter
  62. }else{
  63. return FluTheme.primaryColor.dark
  64. }
  65. }else{
  66. if(FluTheme.dark){
  67. return Qt.rgba(161/255,161/255,161/255,1)
  68. }else{
  69. return Qt.rgba(141/255,141/255,141/255,1)
  70. }
  71. }
  72. }
  73. color:{
  74. if(disabled&&selected){
  75. return Qt.rgba(159/255,159/255,159/255,1)
  76. }
  77. if(FluTheme.dark){
  78. if(hovered){
  79. return Qt.rgba(43/255,43/255,43/255,1)
  80. }
  81. return Qt.rgba(50/255,50/255,50/255,1)
  82. }else{
  83. if(hovered){
  84. if(selected){
  85. return Qt.rgba(1,1,1,1)
  86. }
  87. return Qt.rgba(222/255,222/255,222/255,1)
  88. }
  89. return Qt.rgba(1,1,1,1)
  90. }
  91. }
  92. }
  93. FluText{
  94. text: control.text
  95. Layout.alignment: Qt.AlignVCenter
  96. font: control.font
  97. }
  98. }
  99. }