1
0

ConnectionStatus.qml 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import QtQuick 2.15
  2. Rectangle {
  3. id: connectionDot
  4. property var backend: null
  5. width: 12
  6. height: 12
  7. radius: 6
  8. // Direct property binding to backend.serialConnected
  9. color: {
  10. if (!backend) {
  11. return "#FF5722" // Red if no backend
  12. }
  13. var connected = backend.serialConnected
  14. if (connected === true) {
  15. return "#4CAF50" // Green if connected
  16. } else {
  17. return "#FF5722" // Red if not connected
  18. }
  19. }
  20. // Listen for changes to trigger color update
  21. Connections {
  22. target: backend
  23. function onSerialConnectionChanged(connected) {
  24. // The color binding will automatically update
  25. }
  26. }
  27. // Debug logging
  28. Component.onCompleted: {
  29. if (backend) {
  30. }
  31. }
  32. onBackendChanged: {
  33. if (backend) {
  34. }
  35. }
  36. // Animate color changes
  37. Behavior on color {
  38. ColorAnimation {
  39. duration: 300
  40. easing.type: Easing.OutQuart
  41. }
  42. }
  43. }