FluRadioButton.qml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. Keys.onSpacePressed: control.visualFocus&&clicked()
  19. contentItem: RowLayout{
  20. Rectangle{
  21. id:rect_check
  22. width: 20
  23. height: 20
  24. radius: 10
  25. border.width: {
  26. if(selected&&disabled){
  27. return 3
  28. }
  29. if(pressed){
  30. if(selected){
  31. return 5
  32. }
  33. return 1
  34. }
  35. if(hovered){
  36. if(selected){
  37. return 3
  38. }
  39. return 1
  40. }
  41. return selected ? 5 : 1
  42. }
  43. Behavior on border.width {
  44. NumberAnimation{
  45. duration: 167
  46. easing.type: Easing.BezierSpline
  47. easing.bezierCurve: [ 0, 0, 0, 1 ]
  48. }
  49. }
  50. border.color: {
  51. if(disabled){
  52. if(FluTheme.dark){
  53. return Qt.rgba(82/255,82/255,82/255,1)
  54. }else{
  55. return Qt.rgba(198/255,198/255,198/255,1)
  56. }
  57. }
  58. if(selected){
  59. if(FluTheme.dark){
  60. return FluTheme.primaryColor.lighter
  61. }else{
  62. return FluTheme.primaryColor.dark
  63. }
  64. }else{
  65. if(FluTheme.dark){
  66. return Qt.rgba(161/255,161/255,161/255,1)
  67. }else{
  68. return Qt.rgba(141/255,141/255,141/255,1)
  69. }
  70. }
  71. }
  72. color:{
  73. if(disabled&&selected){
  74. return Qt.rgba(159/255,159/255,159/255,1)
  75. }
  76. if(FluTheme.dark){
  77. if(hovered){
  78. return Qt.rgba(43/255,43/255,43/255,1)
  79. }
  80. return Qt.rgba(50/255,50/255,50/255,1)
  81. }else{
  82. if(hovered){
  83. if(selected){
  84. return Qt.rgba(1,1,1,1)
  85. }
  86. return Qt.rgba(222/255,222/255,222/255,1)
  87. }
  88. return Qt.rgba(1,1,1,1)
  89. }
  90. }
  91. }
  92. FluText{
  93. text: control.text
  94. Layout.alignment: Qt.AlignVCenter
  95. }
  96. }
  97. }