SyncState.qml 3.5 KB

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