FluProgressBar.qml 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import QtQuick
  2. import QtQuick.Controls
  3. import FluentUI
  4. FluRectangle {
  5. property real progress: 0.5
  6. property bool indeterminate: true
  7. id: control
  8. width: 150
  9. height: 5
  10. radius: [3,3,3,3]
  11. clip: true
  12. color: FluTheme.dark ? Qt.rgba(99/255,99/255,99/255,1) : Qt.rgba(214/255,214/255,214/255,1)
  13. Component.onCompleted: {
  14. if(indeterminate){
  15. bar.x = -control.width*0.5
  16. behavior.enabled = true
  17. bar.x = control.width
  18. }else{
  19. bar.x = 0
  20. }
  21. }
  22. Rectangle{
  23. id:bar
  24. radius: 3
  25. width: control.width*progress
  26. height: control.height
  27. color:FluTheme.dark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
  28. Behavior on x{
  29. id:behavior
  30. enabled: false
  31. NumberAnimation{
  32. duration: 1000
  33. onRunningChanged: {
  34. if(!running){
  35. behavior.enabled = false
  36. bar.x = -control.width*0.5
  37. behavior.enabled = true
  38. bar.x = control.width
  39. }
  40. }
  41. }
  42. }
  43. }
  44. }