SyncState.qml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import QtQuick 2.10
  2. import QtQuick.Controls 2.3
  3. import UM 1.4 as UM
  4. import Cura 1.1 as Cura
  5. Row // Sync state icon + message
  6. {
  7. property var syncState: Cura.API.account.syncState
  8. id: syncRow
  9. width: childrenRect.width
  10. height: childrenRect.height
  11. spacing: UM.Theme.getSize("narrow_margin").height
  12. states: [
  13. State
  14. {
  15. name: "idle"
  16. when: syncState == Cura.AccountSyncState.IDLE
  17. PropertyChanges { target: icon; source: UM.Theme.getIcon("update")}
  18. },
  19. State
  20. {
  21. name: "syncing"
  22. when: syncState == Cura.AccountSyncState.SYNCING
  23. PropertyChanges { target: icon; source: UM.Theme.getIcon("update") }
  24. PropertyChanges { target: stateLabel; text: catalog.i18nc("@label", "Checking...")}
  25. },
  26. State
  27. {
  28. name: "up_to_date"
  29. when: syncState == Cura.AccountSyncState.SUCCESS
  30. PropertyChanges { target: icon; source: UM.Theme.getIcon("checked") }
  31. PropertyChanges { target: stateLabel; text: catalog.i18nc("@label", "Account synced")}
  32. },
  33. State
  34. {
  35. name: "error"
  36. when: syncState == Cura.AccountSyncState.ERROR
  37. PropertyChanges { target: icon; source: UM.Theme.getIcon("warning_light") }
  38. PropertyChanges { target: stateLabel; text: catalog.i18nc("@label", "Something went wrong...")}
  39. }
  40. ]
  41. UM.RecolorImage
  42. {
  43. id: icon
  44. width: 20 * screenScaleFactor
  45. height: width
  46. source: Cura.API.account.manualSyncEnabled ? UM.Theme.getIcon("update") : UM.Theme.getIcon("checked")
  47. color: UM.Theme.getColor("account_sync_state_icon")
  48. RotationAnimator
  49. {
  50. id: updateAnimator
  51. target: icon
  52. from: 0
  53. to: 360
  54. duration: 1000
  55. loops: Animation.Infinite
  56. running: syncState == Cura.AccountSyncState.SYNCING
  57. // reset rotation when stopped
  58. onRunningChanged: {
  59. if(!running)
  60. {
  61. icon.rotation = 0
  62. }
  63. }
  64. }
  65. }
  66. Column
  67. {
  68. width: childrenRect.width
  69. height: childrenRect.height
  70. Label
  71. {
  72. id: stateLabel
  73. text: catalog.i18nc("@state", catalog.i18nc("@label", "Account synced"))
  74. color: UM.Theme.getColor("text")
  75. font: UM.Theme.getFont("medium")
  76. renderType: Text.NativeRendering
  77. width: contentWidth + UM.Theme.getSize("default_margin").height
  78. height: contentHeight
  79. verticalAlignment: Text.AlignVCenter
  80. visible: !Cura.API.account.manualSyncEnabled
  81. }
  82. Label
  83. {
  84. id: accountSyncButton
  85. text: catalog.i18nc("@button", "Check for account updates")
  86. color: UM.Theme.getColor("secondary_button_text")
  87. font: UM.Theme.getFont("medium")
  88. renderType: Text.NativeRendering
  89. verticalAlignment: Text.AlignVCenter
  90. height: contentHeight
  91. width: contentWidth + UM.Theme.getSize("default_margin").height
  92. visible: Cura.API.account.manualSyncEnabled
  93. MouseArea
  94. {
  95. anchors.fill: parent
  96. onClicked: Cura.API.account.sync(true)
  97. hoverEnabled: true
  98. onEntered: accountSyncButton.font.underline = true
  99. onExited: accountSyncButton.font.underline = false
  100. }
  101. }
  102. }
  103. }