FluFilledButton.qml 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import QtQuick
  2. import QtQuick.Controls
  3. import QtQuick.Controls.Basic
  4. import FluentUI
  5. Button {
  6. property bool disabled: false
  7. property color normalColor: FluTheme.dark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
  8. property color hoverColor: FluTheme.dark ? Qt.darker(normalColor,1.1) : Qt.lighter(normalColor,1.1)
  9. property color disableColor: FluTheme.dark ? Qt.rgba(82/255,82/255,82/255,1) : Qt.rgba(199/255,199/255,199/255,1)
  10. property color pressedColor: FluTheme.dark ? Qt.darker(normalColor,1.2) : Qt.lighter(normalColor,1.2)
  11. id: control
  12. enabled: !disabled
  13. topPadding:5
  14. bottomPadding:5
  15. leftPadding:15
  16. rightPadding:15
  17. Keys.onSpacePressed: control.visualFocus&&clicked()
  18. focusPolicy:Qt.TabFocus
  19. background: Rectangle{
  20. radius: 4
  21. FluFocusRectangle{
  22. visible: control.visualFocus
  23. radius:8
  24. }
  25. color:{
  26. if(disabled){
  27. return disableColor
  28. }
  29. if(pressed){
  30. return pressedColor
  31. }
  32. return hovered ? hoverColor :normalColor
  33. }
  34. }
  35. contentItem: FluText {
  36. text: control.text
  37. horizontalAlignment: Text.AlignHCenter
  38. verticalAlignment: Text.AlignVCenter
  39. color: {
  40. if(FluTheme.dark){
  41. if(disabled){
  42. return Qt.rgba(173/255,173/255,173/255,1)
  43. }
  44. return Qt.rgba(0,0,0,1)
  45. }else{
  46. return Qt.rgba(1,1,1,1)
  47. }
  48. }
  49. }
  50. }