RunStatusIcon.qml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import QtQuick
  2. import QtQuick.Controls
  3. import FluentUI
  4. import "../Global"
  5. Item {
  6. id: root
  7. width: 40
  8. height: 40
  9. clip: true
  10. property int runStatus: MainEvent.runStatus
  11. property real radius: width / 2
  12. property color color: FluTheme.dark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
  13. property real animationDuration: 600 // in ms
  14. property real maxRadius: width / 4
  15. Rectangle {
  16. id: runError
  17. anchors.centerIn: parent
  18. width: radius * 2
  19. height: radius * 2
  20. visible: runStatus
  21. color: root.color
  22. radius: radius
  23. // Behavior on radius {
  24. // enabled: false
  25. // NumberAnimation {
  26. // duration: root.animationDuration
  27. // easing.type: Easing.OutQuad
  28. // }
  29. // }
  30. // SequentialAnimation on radius {
  31. // enabled: false
  32. // loops: Animation.Infinite
  33. // PropertyAnimation { to: root.maxRadius; duration: root.animationDuration }
  34. // }
  35. }
  36. FluProgressRing{
  37. id: runProgress
  38. anchors.centerIn: parent
  39. indeterminate: false
  40. width: parent.width/2
  41. height: parent.height/2
  42. }
  43. onRunStatusChanged: {
  44. if(runStatus === MainEvent.RunStatus.Empty){
  45. runError.visible = false
  46. runProgress.visible = false
  47. }else if(runStatus === MainEvent.RunStatus.Free){
  48. runError.visible = false
  49. runProgress.visible = true
  50. runProgress.progress = 0
  51. }else if(runStatus === MainEvent.RunStatus.Run){
  52. runError.visible = false
  53. runProgress.visible = true
  54. runProgress.progress = 0.25
  55. }else if(runStatus === MainEvent.RunStatus.Error){
  56. runError.visible = true
  57. runProgress.visible = false
  58. runProgress.progress = 0
  59. }else if(runStatus === MainEvent.RunStatus.Init){
  60. runError.visible = false
  61. runProgress.visible = true
  62. runProgress.progress = 0.25
  63. }
  64. }
  65. }